Commit 1bf2a333 authored by linwenqing's avatar linwenqing

fix:弱网授权手机号修复

parent 3842edcf
......@@ -21,13 +21,18 @@
<view class="bind-tips">{{ bindTips }}</view>
</view>
<u-gap height="480"></u-gap>
<button class="loginBtn" v-if="needAuth" lang="zh_CN" @tap="getUserProfile">
<text class="u-font-32 white">{{ loginTitle }}</text>
</button>
<button class="loginBtn" v-else open-type="getPhoneNumber" throttle-time="1000"
@getphonenumber="signupLogin">
<text class="u-font-32 white">{{ bindTitle }}</text>
</button>
<view v-if="needAuth">
<button class="loginBtn" lang="zh_CN" @tap="getUserProfile">
<text class="u-font-32 white">{{ loginTitle }}</text>
</button>
</view>
<view @click.capture="getCode" v-else>
<button class="loginBtn" :class="{disable:isClickGetPhone}"
open-type="getPhoneNumber" throttle-time="1000"
@getphonenumber="signupLogin" :disabled="isClickGetPhone">
<text class="u-font-32 white">{{ bindTitle }}</text>
</button>
</view>
</view>
</view>
</template>
......@@ -46,6 +51,7 @@ export default {
bindPhone: '绑定手机',
bindTips: '首次登录的用户需绑定手机才可接单',
code: '',
isClickGetPhone: false,
}
},
computed: {
......@@ -64,13 +70,17 @@ export default {
if (this.vuex_auth_user && Object.keys(this.vuex_auth_user).length) {
this.needAuth = false
}
this.getCode()
},
methods: {
qnFile(src) {
return process.uniEnv.qn_base_url + src
},
async getCode() {
this.isClickGetPhone = true
uni.showLoading({
title: '授权中..',
mask: true
});
login.appLogin().then(res => {
this.code = res.code
})
......@@ -90,6 +100,7 @@ export default {
mask: true
});
if (getApp().globalData.logout) {
console.log('隐藏loading 5')
uni.hideLoading()
that.setLoginStatus()
} else {
......@@ -138,8 +149,14 @@ export default {
that.setLoginStatus()
})
},
inGetAuth() {
uni.showLoading({
title: '授权中..',
mask: true
});
},
signupLogin(e) {
this.inGetAuth()
var that = this
if(e && e.detail) {
if(e.detail.errMsg.indexOf('user deny') > -1) {
......@@ -160,16 +177,20 @@ export default {
success () {
//session_key 未过期,并且在本生命周期一直有效
params.code = that.code
that.inGetAuth()
login.signup(params).then(res => {
uni.hideLoading()
that.inGetAuth()
that.isClickGetPhone = false
if (res) {
login.setUserData(res.data, that)
app.track('signup_login', {mobile: res.data.mobile});
app.profileSet(that)
app.profileAppend(that)
app.getBaseInfo(that)
uni.hideLoading()
that.goBackPage()
} else {
uni.hideLoading()
uni.showToast({
title: '授权失败,请重新授权',
icon: 'none'
......@@ -177,6 +198,7 @@ export default {
that.setLoginStatus(false)
}
}).catch(res => {
that.isClickGetPhone = false
uni.hideLoading()
that.setLoginStatus(false)
})
......@@ -193,7 +215,7 @@ export default {
uni.showModal({
title: '提示',
showCancel: false,
content: e.detail.errMsg
content: '用户取消授权'
});
}
} else {
......@@ -209,7 +231,6 @@ export default {
params.code = res.code
return login.signup(params);
}).then(res => {
uni.hideLoading()
if (res) {
login.setUserData(res.data, this)
app.track('signup_login', {mobile: res.data.mobile});
......@@ -218,6 +239,8 @@ export default {
app.getBaseInfo(this)
this.goBackPage()
} else {
console.log('隐藏loading 3-2')
uni.hideLoading()
uni.showToast({
title: '授权失败,请重新授权',
icon: 'none'
......@@ -225,6 +248,7 @@ export default {
this.setLoginStatus(false)
}
}).catch(res => {
console.log('隐藏loading 4')
uni.hideLoading()
this.setLoginStatus(false)
})
......@@ -361,6 +385,20 @@ export default {
justify-content: center;
}
.disable {
background-color: #2272FF !important;
font-size: 32rpx;
font-weight: 600;
color: #FFFFFF !important;
line-height: 104px;
width: 600rpx;
height: 104rpx;
border-radius: 52rpx;
display: flex;
align-items: center;
justify-content: center;
}
.cancelView {
width: 100%;
margin-top: 30rpx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment