Commit 33e23bc5 by luyt

feat:授权昵称弹框

1 parent 1fa9c5ee
......@@ -14,16 +14,26 @@ Page({
data: {
IMG_URL,
senceData,
isShare:false, //是否是分享出去的
actNum: 0,
tabAct: 0,
showLeft:false, //更多按钮显示的内容
scrollTop:0
scrollTop:0,
img_version:0.1,
// 是否授权昵称
hasUserInfo: false,
phone: '', //授权手机号
},
// 计算属性
computed: {
showLeftFlag(data) {
return data.showLeft
}
},
// // 授权昵称弹框显示
// authNcknameShow(){
// }
},
/**
* 生命周期函数--监听页面加载
......@@ -188,7 +198,7 @@ Page({
if (confirm) this.init()
})
},
// 获取用户信息
// 获取用户信息(手机号)
getUserInfo({ detail }) {
// console.log(detail);
......@@ -221,6 +231,36 @@ Page({
// this.setBtnLoading(false)
});
},
// 获取用户昵称(昵称头像)
getUserProfile(e) {
this.setData({
hasUserInfo: true
})
let _this = this
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '用于完善资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: res => {
// console.log('res: ', res.userInfo.nickName);
// userInfo.nickName
this.setData({
userInfo: res.userInfo
})
let wx_user_info = wx.$storage.get('wx_user_info')
// console.log('wx_user_info: ', wx_user_info);
let obj = {
...wx_user_info,
nickName: res.userInfo.nickName,
avatarUrl: res.userInfo.avatarUrl
}
// console.log('obj',obj)
wx.$storage.set('wx_user_info', obj)
_this.onLoad(null)
}
})
},
/**
* 生命周期函数--监听页面显示
*/
......
......@@ -183,3 +183,14 @@ page {
}
}
}
/* 用户授权 */
.user-profile {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 3;
background-color: transparent;
}
......@@ -49,4 +49,6 @@
</view>
</view>
<!-- 申请按钮 -->
<apply-button downShow="{{false}}"></apply-button>
\ No newline at end of file
<apply-button downShow="{{false}}"></apply-button>
<!-- 授权昵称 -->
<view wx:if="{{!hasUserInfo}}" class="user-profile" bindtap="getUserProfile"></view>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!