|
|
@@ -15,7 +15,9 @@
|
|
|
<van-field placeholder="确认密码" password @input="password1 = $event.detail" />
|
|
|
<div class="login" @click="login">已有账号,<span class="link">点击登录</span></div>
|
|
|
<div style="padding: 0 16px; margin-top: 20px;">
|
|
|
- <van-button @click="register" :color="$colors.prim" block>立即注册</van-button>
|
|
|
+ <van-button :color="$colors.prim" block open-type="getUserInfo" @getuserinfo="getUserInfo">
|
|
|
+ 立即注册
|
|
|
+ </van-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -63,7 +65,7 @@ export default {
|
|
|
}, 1000);
|
|
|
});
|
|
|
},
|
|
|
- register() {
|
|
|
+ getUserInfo(e) {
|
|
|
if (!/^1\d{10}$/.test(this.mobile)) {
|
|
|
wx.showToast({
|
|
|
icon: 'none',
|
|
|
@@ -96,11 +98,34 @@ export default {
|
|
|
title: '',
|
|
|
mask: true
|
|
|
});
|
|
|
- this.$http
|
|
|
- .get('/applets/register', {
|
|
|
- mobile: this.mobile,
|
|
|
- password: this.password,
|
|
|
- code: this.code
|
|
|
+ Promise.resolve()
|
|
|
+ .then(() => {
|
|
|
+ if (this.$store.state.loginInfo && this.$store.state.loginInfo.hasUnionId) {
|
|
|
+ return Promise.resolve();
|
|
|
+ } else {
|
|
|
+ this.$http.post('/applets/dealuserinfo', {
|
|
|
+ ...e.detail,
|
|
|
+ userInfo: JSON.stringify(e.detail.userInfo)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ return this.$http.get('/applets/checkmobileexist');
|
|
|
+ } else {
|
|
|
+ return Promise.reject(res.message);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ return this.$http.get('/applets/register', {
|
|
|
+ mobile: this.mobile,
|
|
|
+ password: this.password,
|
|
|
+ code: this.code
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return Promise.reject(res.message);
|
|
|
+ }
|
|
|
})
|
|
|
.then(res => {
|
|
|
console.log(res);
|
|
|
@@ -123,6 +148,9 @@ export default {
|
|
|
return Promise.reject(res.message);
|
|
|
}
|
|
|
})
|
|
|
+ .then(() => {
|
|
|
+ wx.hideLoading();
|
|
|
+ })
|
|
|
.catch(e => {
|
|
|
wx.hideLoading();
|
|
|
wx.showToast({
|