From 682182cf67a5aa9fed34335fea22d4673f30f10c Mon Sep 17 00:00:00 2001 From: Mr.Shi <1878285526@qq.com> Date: 星期一, 04 九月 2023 11:59:44 +0800 Subject: [PATCH] 小程序 --- minipro_standard/pages/updatePhone/updatePhone.vue | 41 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 38 insertions(+), 3 deletions(-) diff --git a/minipro_standard/pages/updatePhone/updatePhone.vue b/minipro_standard/pages/updatePhone/updatePhone.vue index b70fb79..46dd2ba 100644 --- a/minipro_standard/pages/updatePhone/updatePhone.vue +++ b/minipro_standard/pages/updatePhone/updatePhone.vue @@ -8,7 +8,7 @@ <view class="password_list_item"> <text>褰撳墠缁戝畾</text> <view class="password_list_item_box"> - <input type="number" disabled v-model="form.currentPhone" maxlength="11"> + <input type="number" disabled v-model="userInfo.companyUser.phone" maxlength="11"> </view> </view> <view class="password_list_item"> @@ -22,7 +22,7 @@ <view class="password_list_item_box"> <input type="text" v-model="form.verificationCode" maxlength="4" placeholder="璇疯緭鍏ユ墜鏈洪獙璇佺爜"> <p @click="getVerificationCode" v-if="!code.isOpen">鑾峰彇楠岃瘉鐮�</p> - <p @click="getVerificationCode" v-else>{{code.num}}</p> + <p v-else>{{code.num}}</p> </view> </view> </view> @@ -35,15 +35,50 @@ </template> <script> + import { mapState } from 'vuex' + import { phoneRegular } from '@/common/config.js' export default { data() { return { form: { - currentPhone: '', newPhone: '', verificationCode: '' + }, + code: { + num: 60, + isOpen: false, + timer: 0 } }; + }, + computed: mapState([ + 'userInfo' + ]), + methods: { + // 鑾峰彇楠岃瘉鐮� + getVerificationCode() { + this.code.isOpen = true + this.code.timer = setInterval(() => { + if (this.code.num === 0) { + clearInterval(this.code.timer) + this.code.isOpen = false + this.code.num = 60 + } + this.code.num = this.code.num - 1 + }, 1000) + }, + // 鎻愪氦淇敼 + submit() { + if (!this.form.newPhone) { + uni.showToast({ title: '鏂版墜鏈哄彿涓嶈兘涓虹┖', icon: 'none', duration: 2000 }); + } else if (!phoneRegular.test(this.form.newPhone)) { + uni.showToast({ title: '鎵嬫満鍙蜂笉鍚堟硶', icon: 'none', duration: 2000 }); + } else if (!this.form.verificationCode) { + uni.showToast({ title: '楠岃瘉鐮佷笉鑳戒负绌�', icon: 'none', duration: 2000 }); + } else { + console.log('鍙互鎻愪氦') + } + } } } </script> -- Gitblit v1.9.3