userinfo.uvue 5.5 KB
Newer Older
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
1
<template>
crlfe's avatar
crlfe 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  <view class="uni-content">
    <view class="list">
      <view class="item">
        <text class="title">头像</text>
        <uni-id-pages-x-avatar ref="avatar" width="60px" height="60px" :border="false"></uni-id-pages-x-avatar>
      </view>
      <view class="item">
        <text class="title">昵称</text>
        <view @click="setNickname" class="content">
          <text class="unset" v-if="!isLogin">未登录</text>
          <text class="value"
                v-else-if="userInfo['nickname'] != null && userInfo['nickname'] != ''">{{userInfo['nickname']}}
          </text>
          <text class="unset" v-else>未设置</text>
          <uni-id-pages-x-icons v-if="isLogin" :size="16" type="right-arrow"
                                class="link-icon"></uni-id-pages-x-icons>
        </view>
      </view>
      <view class="item">
        <text class="title">手机号码</text>
        <view @click="bindmobile" class="content">
          <text class="value" v-if="userInfo['mobile'] != null">{{userInfo['mobile']}}</text>
          <text class="unset" v-else>未绑定</text>
          <uni-id-pages-x-icons :size="16" type="right-arrow" class="link-icon"></uni-id-pages-x-icons>
        </view>
      </view>
    </view>
A
Anne_LXM 已提交
29
    <!-- #ifdef APP -->
crlfe's avatar
crlfe 已提交
30 31 32 33 34 35 36 37 38 39 40
    <view class="list">
      <!-- 如未开通实人认证服务,可以将实名认证入口注释 -->
      <view @click="realNameVerify" class="item">
        <text class="title">实名认证</text>
        <view class="content">
            <text class="value" v-if="realNameStatus == 2">已认证</text>
            <text class="unset" v-else>未认证</text>
          <uni-id-pages-x-icons :size="16" type="right-arrow" class="link-icon"></uni-id-pages-x-icons>
        </view>
      </view>
    </view>
A
Anne_LXM 已提交
41
    <!-- #endif -->
crlfe's avatar
crlfe 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    <view class="list">
      <view @click="deactivate" class="item">
        <text class="title">注销账号</text>
        <uni-id-pages-x-icons :size="16" type="right-arrow" class="link-icon"></uni-id-pages-x-icons>
      </view>
      <view class="item" v-if="isLogin && showLoginManage" @click="logout">
        <text class="title">退出登录</text>
        <uni-id-pages-x-icons :size="16" type="right-arrow" class="link-icon"></uni-id-pages-x-icons>
      </view>
      <view class="mask" v-if="!isLogin" @click="login"></view>
    </view>
    <view class="btn-list" v-if="showLoginManage">
      <!-- <button v-if="isLogin" @click="logout" class="logout">退出登录</button> -->
      <button v-if="!isLogin" @click="login" type="primary" class="login">去登录</button>
    </view>
    <!-- 弹出对话框组件 -->
    <uni-id-pages-x-popup-dialog ref="popup-dialog"/>
  </view>
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
60 61 62
</template>

<script>
A
Anne_LXM 已提交
63
  import {state} from '@/uni_modules/uni-id-pages-x/store.uts';
crlfe's avatar
crlfe 已提交
64 65 66
  import {logout} from '@/uni_modules/uni-id-pages-x/common/common.uts';
  export default {
    data() {
A
Anne_LXM 已提交
67 68 69
      return {
        showLoginManage: true
      }
crlfe's avatar
crlfe 已提交
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    },
    computed: {
      userInfo(): UTSJSONObject {
        return state.userInfo
      },
      isLogin(): boolean {
        return state.isLogin
      },
      realNameStatus (): number {
        const realNameAuth = this.userInfo.getJSON('realNameInfo')
        const authStatus = realNameAuth?.getNumber('authStatus')
        if (realNameAuth == null || authStatus == null) {
          return 0
        }
        return authStatus as number
      }
    },
A
Anne_LXM 已提交
87 88
    onLoad(options){
      this.showLoginManage = options['showLoginManage'] == 'true'
crlfe's avatar
crlfe 已提交
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
    },
    methods: {
      setNickname() {
        uni.navigateTo({
          "url": "/uni_modules/uni-id-pages-x/pages/userinfo/setNickname/setNickname"
        })
      },
      bindmobile() {
        uni.navigateTo({
          url: "/uni_modules/uni-id-pages-x/pages/userinfo/bindMobile/bindMobile",
          complete(_) {
            // console.log('e', e);
          }
        })
      },
      deactivate() {
        uni.navigateTo({
          url: "/uni_modules/uni-id-pages-x/pages/userinfo/deactivate/deactivate",
          complete(_) {
            // console.log('e', e);
          }
        })
      },
      logout() {
        logout()
      },
      login() {
        uni.navigateTo({
          url: "/uni_modules/uni-id-pages-x/pages/login/login",
          // complete(e){
          //   console.log('e',e);
          // }
        })
      },
      realNameVerify() {
        uni.navigateTo({
          "url": "/uni_modules/uni-id-pages-x/pages/userinfo/realnameAuth/realnameAuth"
        })
      }
    }
  }
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
130 131
</script>
<style>
crlfe's avatar
crlfe 已提交
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
  .uni-content {
    width: 750rpx;
    background-color: #f5f5f5;
    flex: 1;
  }

  .avatar {
    border: 1px solid #000;
    align-items: center;
  }

  .list {
    position: relative;
    background-color: #fff;
    margin-top: 15px;
  }

  .mask {
DCloud_JSON's avatar
DCloud_JSON 已提交
150
    position: fixed;
crlfe's avatar
crlfe 已提交
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
    width: 750rpx;
    height: 100%;
  }

  .list .item {
      border-bottom: 1px solid #f5f5f5;
      flex-direction: row;
      align-items: center;
      padding: 15px 15px;
  }

  .list .item.deactivate {
    margin-top: 20px;
    border-top: 0.1px solid #EEE;
  }

  .list .item .title {
    font-size: 14px;
    flex: 1;
    color: #333;
  }

  .list .item .content {
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }

  .list .item .content .value {
    color: #999;
    font-size: 12px;
  }

  .list .item .content .unset {
    color: #aaa;
    font-size: 12px;
  }

  .link-icon {
    margin-left: 5px;
    width: 13px;
  }

  .btn-list {
    margin-top: 30px;
    padding: 30px 150rpx;
  }

  .logout {
    color: #888;
    border-style: none;
  }
</style>