Browse Source

用户api

master
453530270@qq.com 2 years ago
parent
commit
0ccc6bfe48
  1. 36
      pages/home.vue

36
pages/home.vue

@ -12,7 +12,7 @@
<view class="ubinfo">
<view class="ubi-uname">用户名</view>
<view class="ubi-verify">
<view class="mbtxt">手机号13812345678</view>
<view class="mbtxt">手机号{{userInfo.mobile}}</view>
<view class="mbstatus verify" v-if="hasverify">认证</view>
<view class="mbstatus unverfiy" v-else>未认证</view>
</view>
@ -180,6 +180,9 @@
import store from '@/store'
//
import { checkLogin, showError } from '@/core/app'
import * as UserApi from '@/api/user'
import { userInfo } from 'os'
export default {
data() {
return {
@ -187,16 +190,21 @@
hasverify: false,
//
isLogin: true,
//
userInfo:[]
}
},
mounted() {
this.init()
this.getUserInfo()
},
methods: {
//
init(){
if(checkLogin()==true){
this.isLogin = true
// 0
//this.hasverify = this.userInfo.grade_id>0?true:false;
}else{
this.isLogin= false
setTimeout("",1200)
@ -207,6 +215,30 @@
gotologin(){
this.$navTo("pages/login/loginsms")
},
//
getUserInfo() {
const app = this
return new Promise((resolve, reject) => {
!app.isLogin ? resolve(null) : UserApi.info({}, { load: app.isFirstload })
.then(result => {
app.userInfo = result.data.userInfo
//
console.log(app.userInfo.grade_id)
this.hasverify = app.userInfo.grade_id>0?true:false
resolve(app.userInfo)
})
.catch(err => {
if (err.result && err.result.status == 401) {
app.isLogin = false
resolve(null)
} else {
reject(err)
}
})
})
},
// 退
handleLogout() {
const app = this
@ -379,7 +411,7 @@
.verify_notice{
background: rgba(0,0,0,0.8);
width: 100%;
height: 72vh;
height: 66vh;
max-height: 72vh;
padding-top: 100rpx;
text-align: center;

Loading…
Cancel
Save