Merge pull request 'change mobile' (#46) from zhy into master
Reviewed-on: http://git.luyuan.tk/luyuan/deming/pulls/46
This commit is contained in:
commit
5308f50e4e
@ -4,7 +4,7 @@
|
|||||||
<view class="old-phone">
|
<view class="old-phone">
|
||||||
<view class="phone-number">
|
<view class="phone-number">
|
||||||
<view class="title">原手机号</view>
|
<view class="title">原手机号</view>
|
||||||
<input type="text" v-model="oldNumber" placeholder="请输入手机号码" />
|
<input type="text" v-model="oldMobile" placeholder="请输入手机号码" />
|
||||||
</view>
|
</view>
|
||||||
<view class="code">
|
<view class="code">
|
||||||
<view class="title">验证码</view>
|
<view class="title">验证码</view>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
<view class="new-phone">
|
<view class="new-phone">
|
||||||
<view class="phone-number">
|
<view class="phone-number">
|
||||||
<view class="title">新手机号</view>
|
<view class="title">新手机号</view>
|
||||||
<input type="text" v-model="newNumber" placeholder="请输入手机号码" />
|
<input type="text" v-model="newMobile" placeholder="请输入手机号码" />
|
||||||
</view>
|
</view>
|
||||||
<view class="code">
|
<view class="code">
|
||||||
<view class="title">验证码</view>
|
<view class="title">验证码</view>
|
||||||
@ -27,51 +27,53 @@
|
|||||||
<u-toast ref="uToast" />
|
<u-toast ref="uToast" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="tips">注意:修改手机号需要原手机号获取验证码,无原手机验证码,请联系后台</view>
|
<view class="tips">注意:修改手机号需要原手机号获取验证码,无原手机验证码,请联系客服</view>
|
||||||
<view class="btn">保存</view>
|
<view class="btn" @click="changeMemberPhone">保存</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
oldNumber: '',
|
oldMobile: '',
|
||||||
oldCode: '',
|
oldCode: '',
|
||||||
newNumber: '',
|
newMobile: '',
|
||||||
newCode: '',
|
newCode: '',
|
||||||
btnText: ['获取验证码', '获取验证码'],
|
btnText: ['获取验证码', '获取验证码'],
|
||||||
seconds: 60, // 获取验证码间隔时间
|
seconds: 60, // 获取验证码间隔时间
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
verifyValue(type) {
|
// 验证发送验证码
|
||||||
const phone = type == 0 ? this.oldNumber : this.newNumber;
|
verifySendCode(type) {
|
||||||
return this.$u.test.mobile(phone);
|
const [phone, tips] = type == 0
|
||||||
},
|
? [this.oldMobile, '请填写正确的原手机号']
|
||||||
// @param Number type 0: 原手机号 1: 新手机号
|
: [this.newMobile, '请填写正确的新手机号'];
|
||||||
getSmsCode (type) {
|
if (!this.$u.test.mobile(phone)) {
|
||||||
if(!this.verifyValue(type)) {
|
|
||||||
let tips = type == 0 ? '请填写正确的原手机号' : '请填写正确的新手机号';
|
|
||||||
this.$u.toast(tips);
|
this.$u.toast(tips);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(this.seconds > 0) {
|
return true;
|
||||||
this.$u.toast('倒计时结束后再发送');
|
},
|
||||||
|
// 验证修改绑定手机号
|
||||||
|
verifyChangeMobile() {
|
||||||
|
if(!this.$u.test.mobile(oldMobile)) {
|
||||||
|
this.$u.toast('请填写正确的原手机号');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
uni.showLoading({
|
if(this.$u.test.isEmpty(oldCode)) {
|
||||||
title: '正在获取验证码'
|
this.$u.toast('验证码为空');
|
||||||
})
|
return false;
|
||||||
this.$u.api.sendSmsCode({
|
}
|
||||||
member_mobile: type == 0 ? this.oldNumber: this.newNumber,
|
if(!this.$u.test.mobile(newMobile)) {
|
||||||
smslog_type: 4 // 类型[1:注册,2:登录,3:找回密码,4:绑定手机]
|
this.$u.toast('请填写正确的新手机号');
|
||||||
}).then(res => {
|
return false;
|
||||||
uni.hideLoading();
|
}
|
||||||
if(res.errCode == 0) {
|
if(this.$u.test.isEmpty(newCode)) {
|
||||||
|
this.$u.toast('验证码为空');
|
||||||
} else {
|
return false;
|
||||||
this.$u.toast(res.message);
|
}
|
||||||
}
|
return true;
|
||||||
})
|
|
||||||
},
|
},
|
||||||
oldCodeChange(text) {
|
oldCodeChange(text) {
|
||||||
this.$set(this.btnText, 0, text);
|
this.$set(this.btnText, 0, text);
|
||||||
@ -79,39 +81,54 @@ export default {
|
|||||||
newCodeChange(text) {
|
newCodeChange(text) {
|
||||||
this.$set(this.btnText, 1, text);
|
this.$set(this.btnText, 1, text);
|
||||||
},
|
},
|
||||||
|
// @param Number type 0: 原手机号 1: 新手机号
|
||||||
|
async getSmsCode (type) {
|
||||||
|
if(!this.verifySendCode(type)) return false;
|
||||||
|
return await this.$u.api.sendSmsCode({
|
||||||
|
member_mobile: type == 0 ? this.oldMobile: this.newMobile,
|
||||||
|
smslog_type: 4 // 类型[1:注册,2:登录,3:找回密码,4:绑定手机]
|
||||||
|
})
|
||||||
|
},
|
||||||
getCode(type) {
|
getCode(type) {
|
||||||
const refs = type == 0 ? this.$refs.uOldCode : this.$refs.uNewCode;
|
const refs = type == 0 ? this.$refs.uOldCode : this.$refs.uNewCode;
|
||||||
if(refs.canGetCode) {
|
if(refs.canGetCode) {
|
||||||
// 模拟向后端请求验证码
|
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '正在获取验证码'
|
title: '正在获取验证码'
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
this.getSmsCode(type).then(res => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
// 这里此提示会被this.start()方法中的提示覆盖
|
if(res.errCode == 0) {
|
||||||
this.$u.toast('验证码已发送');
|
// 这里此提示会被this.start()方法中的提示覆盖
|
||||||
// 通知验证码组件内部开始倒计时
|
this.$u.toast(res.message);
|
||||||
refs.start();
|
// 通知验证码组件内部开始倒计时
|
||||||
}, 2000);
|
refs.start();
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
uni.hideLoading();
|
||||||
|
this.$u.toast('验证码发送错误');
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$u.toast('倒计时结束后再发送');
|
this.$u.toast('倒计时结束后再发送');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeMemberPhone() {
|
changeMemberPhone() {
|
||||||
|
if(!this.verifyChangeMobile) return false;
|
||||||
this.$u.api.changeMemberPhone({
|
this.$u.api.changeMemberPhone({
|
||||||
old_mobile: this.oldNumber,
|
old_mobile: this.oldMobile,
|
||||||
old_code: this.oldCode,
|
old_code: this.oldCode,
|
||||||
new_mobile: this.newNumber,
|
new_mobile: this.newMobile,
|
||||||
new_code: this.newCode,
|
new_code: this.newCode,
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
if(res.errCode == 0) {
|
||||||
|
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
end() {
|
end() {
|
||||||
this.$u.toast('倒计时结束');
|
// this.$u.toast('倒计时结束');
|
||||||
},
|
},
|
||||||
start() {
|
start() {
|
||||||
this.$u.toast('倒计时开始');
|
// this.$u.toast('倒计时开始');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user