|
|
@@ -12,7 +12,9 @@
|
|
|
<span class="link forgot" @click.stop="forgot">忘记密码</span>
|
|
|
</div>
|
|
|
<div style="padding: 0 16px; margin-top: 40px;">
|
|
|
- <van-button @click="login" :color="$colors.prim" block>立即登录</van-button>
|
|
|
+ <van-button :color="$colors.prim" block open-type="getUserInfo" @getuserinfo="getUserInfo">
|
|
|
+ 立即登录
|
|
|
+ </van-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -27,7 +29,7 @@ export default {
|
|
|
url: '/pages/register'
|
|
|
});
|
|
|
},
|
|
|
- login() {
|
|
|
+ getUserInfo(e) {
|
|
|
if (!/^1\d{10}$/.test(this.mobile)) {
|
|
|
wx.showToast({
|
|
|
icon: 'none',
|
|
|
@@ -46,10 +48,22 @@ export default {
|
|
|
mask: true,
|
|
|
title: ''
|
|
|
});
|
|
|
- this.$http
|
|
|
- .post('/applets/bindaccount', {
|
|
|
- username: this.mobile,
|
|
|
- password: this.password
|
|
|
+ Promise.resolve()
|
|
|
+ .then(() => {
|
|
|
+ if (this.$store.state.loginInfo && this.$store.state.loginInfo.hasUnionId) {
|
|
|
+ return Promise.resolve();
|
|
|
+ } else {
|
|
|
+ return this.$http.post('/applets/dealuserinfo', {
|
|
|
+ ...e.detail,
|
|
|
+ userInfo: JSON.stringify(e.detail.userInfo)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return this.$http.post('/applets/bindaccount', {
|
|
|
+ username: this.mobile,
|
|
|
+ password: this.password
|
|
|
+ });
|
|
|
})
|
|
|
.then(res => {
|
|
|
if (res.code === 200) {
|
|
|
@@ -59,11 +73,17 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
.then(() => {
|
|
|
- wx.hideLoading();
|
|
|
this.$store.commit('setLoginInfo', {
|
|
|
hasUnionId: true,
|
|
|
link: true
|
|
|
});
|
|
|
+ this.$store.dispatch('getUserInfo');
|
|
|
+ wx.hideLoading();
|
|
|
+ wx.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '登录成功'
|
|
|
+ });
|
|
|
+ wx.navigateBack();
|
|
|
})
|
|
|
.catch(e => {
|
|
|
wx.hideLoading();
|