Commit 1bf2a333 authored by linwenqing's avatar linwenqing

fix:弱网授权手机号修复

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