|
|
@@ -8,6 +8,7 @@ var url = '' // 分享或模板落地页
|
|
|
var invite = 0 //邀请id
|
|
|
var poster = []
|
|
|
var project = []
|
|
|
+const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0';
|
|
|
Page({
|
|
|
data: {
|
|
|
userInfo: {},
|
|
|
@@ -24,7 +25,9 @@ Page({
|
|
|
bindTelfirst:0,
|
|
|
cashbalance:0,
|
|
|
kfqr:'',//客服二维码
|
|
|
- showqr:false
|
|
|
+ showqr:false,
|
|
|
+ avatarUrl: defaultAvatarUrl,
|
|
|
+ nickname:''
|
|
|
},
|
|
|
onLoad: function () {
|
|
|
//// console.log(options)
|
|
|
@@ -94,6 +97,7 @@ Page({
|
|
|
wx.setStorageSync('lbt_session_time', Date.now())
|
|
|
wx.setStorageSync('lbt_token_key', res.data.token)
|
|
|
console.log('nowtoken',res.data.token);
|
|
|
+
|
|
|
if(res.data.wx_user && res.data.wx_user.head != ''){
|
|
|
var userInfo = res.data.wx_user;
|
|
|
|
|
|
@@ -110,10 +114,18 @@ Page({
|
|
|
// }
|
|
|
//checkwxhead---start
|
|
|
// console.log('that.data.checkhead',that.data.checkhead);
|
|
|
+
|
|
|
+
|
|
|
if(res.data.wx_user.head == '' ){
|
|
|
that.setData({
|
|
|
checkhead: false
|
|
|
})
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ userInfo: 'nologin'
|
|
|
+ })
|
|
|
+
|
|
|
+ /*
|
|
|
wx.getSetting({
|
|
|
success: res => {
|
|
|
var auth = res.authSetting
|
|
|
@@ -156,7 +168,10 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ */
|
|
|
}
|
|
|
+
|
|
|
//checkwxhead---end
|
|
|
}else{
|
|
|
that.setData({
|
|
|
@@ -232,7 +247,29 @@ Page({
|
|
|
getUserProfile:function(){
|
|
|
console.log('tap')
|
|
|
var that = this
|
|
|
-
|
|
|
+console.log('getUserProfile')
|
|
|
+ const app = this
|
|
|
+
|
|
|
+ //增加判断昵称和头像是否设置
|
|
|
+ if(app.data.avatarUrl == defaultAvatarUrl){
|
|
|
+ wx.showToast({
|
|
|
+ title: '请设置头像',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(app.data.nickname == ''){
|
|
|
+ wx.showToast({
|
|
|
+ title: '请设置昵称',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('用户同意了授权');
|
|
|
// wx.getUserProfile({
|
|
|
// desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
|
|
// success: (res) => {
|
|
|
@@ -264,7 +301,10 @@ Page({
|
|
|
wx.getUserProfile({
|
|
|
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
|
|
success: function(res3) {
|
|
|
- console.log('userinfo',res3)
|
|
|
+
|
|
|
+ res3.userInfo.avatarUrl = that.data.avatarUrl;
|
|
|
+ res3.userInfo.nickName = that.data.nickname;
|
|
|
+ console.log('userinfo',res3)
|
|
|
var url = 'xcx/save_wx_user/info'
|
|
|
var params = {
|
|
|
userinfo: JSON.stringify(res3.userInfo)
|
|
|
@@ -615,5 +655,71 @@ Page({
|
|
|
},
|
|
|
catchtapQR:function(){
|
|
|
console.log('catchtapQR');
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户头像设置
|
|
|
+ */
|
|
|
+ onChooseAvatar(e) {
|
|
|
+ const { avatarUrl } = e.detail
|
|
|
+ this.setData({
|
|
|
+ avatarUrl,
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户昵称设置
|
|
|
+ */
|
|
|
+ changeNickName(e) {
|
|
|
+ console.log(e.detail);
|
|
|
+ this.setData({
|
|
|
+ nickname: e.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ savebtn(){
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ //增加判断昵称和头像是否设置
|
|
|
+ if(that.data.avatarUrl == defaultAvatarUrl){
|
|
|
+ wx.showToast({
|
|
|
+ title: '请设置头像',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(that.data.nickname == ''){
|
|
|
+ wx.showToast({
|
|
|
+ title: '请设置昵称',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var url = 'v1/user/update/info'
|
|
|
+ var params = {
|
|
|
+ nickname:that.data.nickname,
|
|
|
+ birthday:'',
|
|
|
+ sex:0,
|
|
|
+ }
|
|
|
+ var success = function (res) {
|
|
|
+ console.log(res);
|
|
|
+ wx.showToast({
|
|
|
+ title: '更新成功',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ var fail = function (res) {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ _request.$uploadFile(url,'head',that.data.avatarUrl, params, success,fail)
|
|
|
+ that.onLoad()
|
|
|
+
|
|
|
+ },
|
|
|
})
|