|
|
|
|
@ -35,6 +35,7 @@ |
|
|
|
|
let userInfo = uni.getStorageSync('userInfo'); |
|
|
|
|
if (userInfo) { |
|
|
|
|
this.userInfo = JSON.parse(userInfo); |
|
|
|
|
console.log('home',userInfo) |
|
|
|
|
if(this.userInfo.phone) { |
|
|
|
|
this.phone = this.userInfo.phone; |
|
|
|
|
this.hasPhone = true; |
|
|
|
|
@ -81,6 +82,9 @@ |
|
|
|
|
}, |
|
|
|
|
//获取手机号 |
|
|
|
|
getPhoneNumber(e) { |
|
|
|
|
if(e.detail.errMsg == 'getPhoneNumber:fail user deny'){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
console.log(e, '获取手机号授权') |
|
|
|
|
uni.request({ |
|
|
|
|
url: getApp().globalData.baseUrl + '/app/phone', //仅为示例,并非真实接口地址。 |
|
|
|
|
@ -92,7 +96,7 @@ |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
this.phone = res.data.data; |
|
|
|
|
this.hasPhone = true; |
|
|
|
|
uni.setStorageSync('phone', res.data.data); |
|
|
|
|
// uni.setStorageSync('phone', res.data.data); |
|
|
|
|
this.doSave(); |
|
|
|
|
} else { |
|
|
|
|
uni.showToast({ |
|
|
|
|
@ -129,7 +133,7 @@ |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
uni.setStorageSync('userInfo', JSON.stringify(res.data.data)); |
|
|
|
|
//登录 |
|
|
|
|
this.doLogin(); |
|
|
|
|
this.doLogin(1); |
|
|
|
|
} else { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.data.msg, |
|
|
|
|
@ -140,7 +144,7 @@ |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
//登录 |
|
|
|
|
doLogin() { |
|
|
|
|
doLogin(type) { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '登录中', |
|
|
|
|
mask: true |
|
|
|
|
@ -159,6 +163,9 @@ |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
uni.setStorageSync('token', res.data.data.access_token); |
|
|
|
|
if(type == 1) { |
|
|
|
|
this.clickCustom(); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.data.msg, |
|
|
|
|
|