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:
hansu 2020-07-03 11:07:40 +08:00
commit 5308f50e4e

View File

@ -4,7 +4,7 @@
<view class="old-phone">
<view class="phone-number">
<view class="title">原手机号</view>
<input type="text" v-model="oldNumber" placeholder="请输入手机号码" />
<input type="text" v-model="oldMobile" placeholder="请输入手机号码" />
</view>
<view class="code">
<view class="title">验证码</view>
@ -16,7 +16,7 @@
<view class="new-phone">
<view class="phone-number">
<view class="title">新手机号</view>
<input type="text" v-model="newNumber" placeholder="请输入手机号码" />
<input type="text" v-model="newMobile" placeholder="请输入手机号码" />
</view>
<view class="code">
<view class="title">验证码</view>
@ -27,51 +27,53 @@
<u-toast ref="uToast" />
</view>
</view>
<view class="tips">注意修改手机号需要原手机号获取验证码无原手机验证码请联系后台</view>
<view class="btn">保存</view>
<view class="tips">注意修改手机号需要原手机号获取验证码无原手机验证码请联系客服</view>
<view class="btn" @click="changeMemberPhone">保存</view>
</view>
</template>
<script>
export default {
data() {
return {
oldNumber: '',
oldMobile: '',
oldCode: '',
newNumber: '',
newMobile: '',
newCode: '',
btnText: ['获取验证码', '获取验证码'],
seconds: 60, //
}
},
methods: {
verifyValue(type) {
const phone = type == 0 ? this.oldNumber : this.newNumber;
return this.$u.test.mobile(phone);
},
// @param Number type 0: 1:
getSmsCode (type) {
if(!this.verifyValue(type)) {
let tips = type == 0 ? '请填写正确的原手机号' : '请填写正确的新手机号';
//
verifySendCode(type) {
const [phone, tips] = type == 0
? [this.oldMobile, '请填写正确的原手机号']
: [this.newMobile, '请填写正确的新手机号'];
if (!this.$u.test.mobile(phone)) {
this.$u.toast(tips);
return false;
}
if(this.seconds > 0) {
this.$u.toast('倒计时结束后再发送');
return true;
},
//
verifyChangeMobile() {
if(!this.$u.test.mobile(oldMobile)) {
this.$u.toast('请填写正确的原手机号');
return false;
}
uni.showLoading({
title: '正在获取验证码'
})
this.$u.api.sendSmsCode({
member_mobile: type == 0 ? this.oldNumber: this.newNumber,
smslog_type: 4 // [1:,2:,3:,4:]
}).then(res => {
uni.hideLoading();
if(res.errCode == 0) {
} else {
this.$u.toast(res.message);
}
})
if(this.$u.test.isEmpty(oldCode)) {
this.$u.toast('验证码为空');
return false;
}
if(!this.$u.test.mobile(newMobile)) {
this.$u.toast('请填写正确的新手机号');
return false;
}
if(this.$u.test.isEmpty(newCode)) {
this.$u.toast('验证码为空');
return false;
}
return true;
},
oldCodeChange(text) {
this.$set(this.btnText, 0, text);
@ -79,39 +81,54 @@ export default {
newCodeChange(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) {
const refs = type == 0 ? this.$refs.uOldCode : this.$refs.uNewCode;
if(refs.canGetCode) {
//
uni.showLoading({
title: '正在获取验证码'
})
setTimeout(() => {
this.getSmsCode(type).then(res => {
uni.hideLoading();
// this.start()
this.$u.toast('验证码已发送');
//
refs.start();
}, 2000);
if(res.errCode == 0) {
// this.start()
this.$u.toast(res.message);
//
refs.start();
}
}).catch(() => {
uni.hideLoading();
this.$u.toast('验证码发送错误');
})
} else {
this.$u.toast('倒计时结束后再发送');
}
},
changeMemberPhone() {
if(!this.verifyChangeMobile) return false;
this.$u.api.changeMemberPhone({
old_mobile: this.oldNumber,
old_mobile: this.oldMobile,
old_code: this.oldCode,
new_mobile: this.newNumber,
new_mobile: this.newMobile,
new_code: this.newCode,
}).then(res => {
if(res.errCode == 0) {
}
})
},
end() {
this.$u.toast('倒计时结束');
// this.$u.toast('');
},
start() {
this.$u.toast('倒计时开始');
// this.$u.toast('');
}
},
};