|
@@ -15,7 +15,7 @@
|
|
</view>
|
|
</view>
|
|
<!-- #ifdef MP-ALIPAY -->
|
|
<!-- #ifdef MP-ALIPAY -->
|
|
<view class="login-btn">
|
|
<view class="login-btn">
|
|
- <button if="canIUseAuthButton" open-type="getAuthorize" @getAuthorize="onGetAuthorize" @error="onAuthError" scope='phoneNumber'>支付宝登录</button>
|
|
|
|
|
|
+ <button open-type="getAuthorize" @getAuthorize="onGetAuthorize" @error="onAuthError" scope='phoneNumber'>支付宝登录</button>
|
|
<button @click="onCode">获取code</button>
|
|
<button @click="onCode">获取code</button>
|
|
</view>
|
|
</view>
|
|
<!-- #endif -->
|
|
<!-- #endif -->
|
|
@@ -59,7 +59,6 @@
|
|
authShow: false,
|
|
authShow: false,
|
|
token: '',
|
|
token: '',
|
|
checked: true,
|
|
checked: true,
|
|
- canIUseAuthButton: my.canIUse('button.open-type.getAuthorize')
|
|
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -168,6 +167,7 @@
|
|
$http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
|
|
$http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
if (res.code == 0) {
|
|
if (res.code == 0) {
|
|
|
|
+ console.log(res);
|
|
uni.setStorageSync('userInfo', res.data)
|
|
uni.setStorageSync('userInfo', res.data)
|
|
if (res.data.openId) {
|
|
if (res.data.openId) {
|
|
uni.$u.toast('登录成功');
|
|
uni.$u.toast('登录成功');
|
|
@@ -184,19 +184,51 @@
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ getBaseInfoAli(){
|
|
|
|
+ $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
+ console.log(res);
|
|
|
|
+ uni.setStorageSync('userInfo', res.data)
|
|
|
|
+ if (res.data.aliUserId) {
|
|
|
|
+ uni.$u.toast('登录成功');
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ uni.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ })
|
|
|
|
+ }, 500)
|
|
|
|
+ } else {
|
|
|
|
+ this.authShow = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ })
|
|
|
|
+ },
|
|
onAuthError(e) {
|
|
onAuthError(e) {
|
|
console.log("err",e);
|
|
console.log("err",e);
|
|
},
|
|
},
|
|
onGetAuthorize(e){
|
|
onGetAuthorize(e){
|
|
|
|
+ let _this = this
|
|
|
|
+ if (!_this.checked) {
|
|
|
|
+ uni.$u.toast('请阅读并勾选底部协议');
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
my.getPhoneNumber({
|
|
my.getPhoneNumber({
|
|
success: (res) => {
|
|
success: (res) => {
|
|
- let encryptedData = res.response;
|
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: '登录中'
|
|
|
|
+ });
|
|
$http.post('/api/v1/mp/user/aliAuth/mobile', {
|
|
$http.post('/api/v1/mp/user/aliAuth/mobile', {
|
|
- encryptedData,
|
|
|
|
|
|
+ encryptedData: res.response,
|
|
identity: 1,
|
|
identity: 1,
|
|
noToken: true
|
|
noToken: true
|
|
}).then(res=>{
|
|
}).then(res=>{
|
|
- console.log("successres",res);
|
|
|
|
|
|
+ if(res.code == 0){
|
|
|
|
+ uni.setStorageSync('token', res.token)
|
|
|
|
+ _this.getBaseInfoAli()
|
|
|
|
+ }
|
|
})
|
|
})
|
|
},
|
|
},
|
|
fail: (res) => {
|
|
fail: (res) => {
|