<template>
  <scroll-view scroll-y class="content">
    <div class="user">
      <van-cell  center :value="userInfo.nickName" @click="showVConsole">
        <view slot="title">
         <image class="user-headImg" :src="userInfo.headImage"></image>
        </view>
      </van-cell>
      <van-cell-group class="group">
        <!-- <van-cell title="我要提现" value="" is-link center @click="goCashOut">
        </van-cell> -->
        <!-- <van-cell title="我的下级" value="" is-link center @click="goMyBranch">
				<template #icon>
					<m-icon type="hyyxq" class="cell-icon" />
				</template>
			</van-cell> -->
        <!-- <van-cell
          title="我的推广积分"
          value=""
          is-link
          center
          @click="goMyIntegral"
        >
        </van-cell> -->
        <van-cell
          title="会员有效期"
          :value="expireTime ? expireTime : '开通会员'"
          is-link
          center
          url="/otherPages/buyVip/index"
        >
        </van-cell>
      </van-cell-group>
      <van-cell-group class="group">
        <van-cell
          title="反馈帮助"
          is-link
          center
          url="/pages/webview/webview?src=https://support.qq.com/product/359609"
        >
          <template #icon>
            <m-icon type="fkbz" class="cell-icon" />
          </template>
        </van-cell>
      </van-cell-group>
    </div>

    <!-- <view class="ad-box serviceBox">
			<ad unit-id="adunit-d8c1548cc9663765"></ad>
		</view> -->
  </scroll-view>
</template>

<script>
export default {
  computed: {
    userInfo() {
      return this.$store.state.user.userInfo;
    },
    expireTime(){

      return this.$store.state.user.userInfo.expireTime&&this.$store.getters.isVip?this.$store.state.user.userInfo.expireTime.split(" ")[0]:null
    }
  },
  mounted() {
    this.$store.dispatch("GetInfo");
  },
  methods: {
    async getUserProfile(e) {
      let userInfo = await wx.getUserProfile({
        desc: "业务需要",
      });
      let updateRes = await this.$api.user.updateUserInfo({
        headImage: userInfo.userInfo.avatarUrl,
        nickName: userInfo.userInfo.nickName,
      });
      if (updateRes.code == 200) {
        uni.setStorageSync("userInfo", userInfo.userInfo);
        this.$store.state.user.userInfo.headImage = userInfo.userInfo.avatarUrl;
        this.$store.state.user.userInfo.nickName = userInfo.userInfo.nickName;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.user {
  background-color: #f2f3f5;
  /* height: 100vh; */
  .group {
    margin: 10px 0;
  }
  .user-avatar {
    width: 46px;
    height: 46px;
    margin-right: 10px;
  }
}
.user-headImg{
	width: 90rpx;
	height: 90rpx;
	border-radius: 50%;
}
.cell-icon {
  margin-right: 5px;
}
</style>
