在onLoad生命周期接受传参,未登录的话在获取信息失败(401)方法里通过uni.redirectTo()重定向至登录页
onLoad(options) {
if (options.auth) {
this.auth = options.auth
console.log(this.auth)
}
this.getUserCenter()
}
- 个人用户
显示头像用户名信息,如果已经实名,显示手机号未实名显示绑定手机号,点击绑定手机号,去绑定。(code为小程序专有,用户登录凭证)代码如下:
<button class="gr-but" open-type="getPhoneNumber" @getphonenumber="getPhone">
<!-- <text class="hpPhone"> -->
绑定手机号码
<!-- </text> -->
</button>`
getPhone(res) {
console.log('授权手机号', res)
console.log(res.target.iv)
console.log(res.target.encryptedData)
const iv = res.target.iv
const encryptedData = res.target.encryptedData
// 获取微信code
uni.login({
success: (res) => {
if (res.code) {
console.log('获取微信code', res.code)
const code = res.code
apiGetWechatMobie({
code: code,
encryptedData: encryptedData,
iv: iv
}).then(res => {
//判断是否等录如果已登陆,进入index
console.log('获取微信手机号', res)
if (res[1].data.code === 200) {
this.mobile = res[1].data.data
}else {
uni.showModal({
content: res[1].errMsg
})
}
console.log('手机号', this.mobile)
})
}
}
})
}
- 企业用户
显示企业头像/名字/手机号/是授权签署人还是法人等信息。 - 套餐剩余/购买总数/使用总数
- 个人中心列表
- 显示关联企业信息,关联几家企业,点击判断是否实名认证,是则跳转至关联企业页面(/pages/association/association)
- 帮助中心,点击前往帮助中心
- 联系客服,代码如下
<button class="list-lxkf" open-type="contact" hover-stop-propagation='true'>
<view class="list-glqy-img">
<image src="../../static/icon_grzxlb_lxkf@2x.png"></image>
</view>
<view class="list-glqy-qy">{{userList[5].name}}</view>
<view class="list-glqy-jt">
<image src="../../static/jiantou-2@2x.png"></image>
</view>
</button>
- 企业中心列表
- 合同模板,点击跳转至合同模板页面(/pages/contTemplate/contTemplate)
- 企业授权,携带role参数前往授权页(/pages/author/author?role=)
- 帮助中心,点击前往帮助中心
- 联系客服,代码如下
- 退出登录
uni.removeStorageSync()删除本地token,重定向到登录页