登录优化

main
xuechunyuan 2 years ago
parent 73a2c0d5b7
commit 46aa094e47
  1. 20
      App.vue
  2. 33
      pages/pages_zhentou/homePage/homePage.vue

@ -47,6 +47,7 @@
this.wxLogin();
} else {
this.globalData.openId = openid;
this.getUserInfo();
}
// #endif
},
@ -63,6 +64,25 @@
},
methods: {
...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin']),
//
getUserInfo() {
uni.request({
url: this.globalData.baseUrl + '/weChatUser/getWeChatUser?openId=' + this.globalData.openId,
method: 'GET',
success: (res) => {
console.log(res)
if (res.data.code == 200) {
uni.setStorageSync('userInfo', JSON.stringify(res.data.data));
uni.setStorageSync('phone', res.data.data.phone);
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
}
})
},
//
wxLogin() {
uni.login({

@ -6,8 +6,8 @@
</view>
<view class="bottom_box">
<button class="btn" @click="addForm">填写报名单其他渠道已购买</button>
<button class="btn" v-if="!hasUserInfo &&canIUseGetUserProfile" @click="getUserProfile">定制</button>
<button v-else-if="!hasPhone" class="btn" @getphonenumber="getphonenumber">定制</button>
<button class="btn" v-if="!hasUserInfo && canIUseGetUserProfile" @click="getUserProfile">定制</button>
<button v-else-if="!hasPhone" class="btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">定制</button>
<button v-else class="btn" @click="clickCustom">定制</button>
</view>
</view>
@ -42,7 +42,8 @@
methods: {
//
clickCustom() {
console.log('点击定制')
console.log('点击定制');
// this.doSave();
},
//
addForm() {
@ -56,7 +57,6 @@
},
//
getUserProfile() {
console.log('getuserinfo')
uni.getUserProfile({
lang: 'zh_CN',
desc: '获取微信用户的昵称和头像',
@ -85,6 +85,30 @@
this.phone = res.data.data;
this.hasPhone = true;
uni.setStorageSync('phone', res.data.data);
this.doSave();
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
}
})
},
//
doSave() {
uni.request({
url: getApp().globalData.baseUrl + '/weChatUser/save',
method: 'POST',
data: {
openId: getApp().globalData.openId,
username: this.userInfo.nickName,
phone: this.phone,
avatar: this.userInfo.avatarUrl
},
success: (res) => {
if (res.data.code == 200) {
uni.setStorageSync('userInfo', JSON.stringify(res.data.data));
} else {
uni.showToast({
title: res.data.msg,
@ -94,7 +118,6 @@
}
})
},
}
}
</script>

Loading…
Cancel
Save