|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="settings">
|
|
|
- <el-tabs tab-position="left">
|
|
|
- <el-tab-pane label="密码设置">
|
|
|
+ <el-tabs v-model="activeName" tab-position="left">
|
|
|
+ <el-tab-pane name="first" label="密码设置">
|
|
|
<div class="form-wrapper">
|
|
|
<el-form
|
|
|
ref="ruleFormRef"
|
|
|
@@ -28,7 +28,7 @@
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</el-tab-pane>
|
|
|
- <el-tab-pane label="用户名设置">
|
|
|
+ <el-tab-pane name="second" label="用户名设置">
|
|
|
<div class="form-wrapper">
|
|
|
<el-form
|
|
|
ref="ruleFormRef2"
|
|
|
@@ -49,7 +49,7 @@
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</el-tab-pane>
|
|
|
- <el-tab-pane label="手机号设置">
|
|
|
+ <el-tab-pane name="third" label="手机号绑定" v-if="!user.profile.mobile">
|
|
|
<div class="form-wrapper">
|
|
|
<el-form
|
|
|
ref="ruleFormRef3"
|
|
|
@@ -81,6 +81,9 @@
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</el-tab-pane>
|
|
|
+ <el-tab-pane name="forth" label="手机号换绑" v-else>
|
|
|
+ <switch-moble v-if="activeName === 'forth'"/>
|
|
|
+ </el-tab-pane>
|
|
|
</el-tabs>
|
|
|
|
|
|
</div>
|
|
|
@@ -101,7 +104,7 @@
|
|
|
<van-tabs v-model:active="active" animated color="#BD5B8F" background="transparent" title-inactive-color="#2F4858" title-active-color="">
|
|
|
<van-tab title="密码设置" name="a"/>
|
|
|
<van-tab title="用户名设置" name="b"/>
|
|
|
- <van-tab title="手机号设置" name="c"/>
|
|
|
+ <van-tab :title="!user.profile.mobile?'手机号绑定':'手机号换绑'" name="c"/>
|
|
|
</van-tabs>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -158,7 +161,7 @@
|
|
|
</van-form>
|
|
|
</div>
|
|
|
<div v-else-if="active === 'c'" class="form-wrapper">
|
|
|
- <van-form>
|
|
|
+ <van-form v-if="!user.profile.mobile" @submit="onSubmit4">
|
|
|
<van-field
|
|
|
v-model="ruleForm3.mobile"
|
|
|
type="text"
|
|
|
@@ -181,14 +184,15 @@
|
|
|
</template>
|
|
|
</van-field>
|
|
|
<div style="margin: 16px;">
|
|
|
- <van-button v-if="!!user.profile.mobile" style="width: 100%;padding: 10px;" round block type="primary" @click="onSubmit3">
|
|
|
+ <!-- <van-button v-if="!!user.profile.mobile" style="width: 100%;padding: 10px;" round block type="primary" @click="onSubmit3">
|
|
|
解绑
|
|
|
- </van-button>
|
|
|
- <van-button v-else round block type="primary" style="width: 100%;padding: 10px;" @click="onSubmit4">
|
|
|
+ </van-button> -->
|
|
|
+ <van-button round block type="primary" style="width: 100%;padding: 10px;" native-type="submit">
|
|
|
绑定
|
|
|
</van-button>
|
|
|
</div>
|
|
|
</van-form>
|
|
|
+ <mob-switch-mobile v-else/>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -200,7 +204,8 @@ import { resetPassword, setPassword, userAccount, unbindCaptcha, clearMobile, bi
|
|
|
import Message from '@/utils/Message'
|
|
|
import { useStore } from '@/store/index'
|
|
|
import { showSuccessToast, showFailToast } from 'vant'
|
|
|
-
|
|
|
+import switchMoble from './pane/switchMoble.vue'
|
|
|
+import mobSwitchMobile from './pane/mobSwitchMobile.vue'
|
|
|
const { user } = useStore()
|
|
|
const img:any = inject('img')
|
|
|
const active = ref('a')
|
|
|
@@ -362,6 +367,7 @@ const submitForm4 = async(formEl: FormInstance | undefined) => {
|
|
|
clearInterval(interval)
|
|
|
smsMessage.value = '获取验证码'
|
|
|
can_send.value = true
|
|
|
+ activeName.value = 'forth'
|
|
|
}).catch((error) => {
|
|
|
console.log(error)
|
|
|
Message.error(error.data.msg)
|
|
|
@@ -389,6 +395,12 @@ const getCaptcha = async() => {
|
|
|
})
|
|
|
}
|
|
|
const getCaptcha2 = async() => {
|
|
|
+ if (!ruleForm3.mobile) {
|
|
|
+ return showFailToast('请输入手机号')
|
|
|
+ }
|
|
|
+ if (ruleForm3.mobile.length !== 11) {
|
|
|
+ return showFailToast('请输入正确的手机号')
|
|
|
+ }
|
|
|
await bindCaptcha({ mobile: ruleForm3.mobile }).then((res) => {
|
|
|
console.log(res)
|
|
|
can_send.value = false
|
|
|
@@ -456,21 +468,21 @@ const onSubmit2 = async() => {
|
|
|
showFailToast(error.data.msg)
|
|
|
})
|
|
|
}
|
|
|
-const onSubmit3 = async() => {
|
|
|
- await clearMobile({ captcha: ruleForm3.captcha }).then(async(res) => {
|
|
|
- console.log(res)
|
|
|
- showSuccessToast(res.data.msg)
|
|
|
- await user.getUserProfile()
|
|
|
- ruleForm3.mobile = user.profile.mobile
|
|
|
- ruleForm3.captcha = ''
|
|
|
- clearInterval(interval)
|
|
|
- smsMessage.value = '获取验证码'
|
|
|
- can_send.value = true
|
|
|
- }).catch((error) => {
|
|
|
- console.log(error)
|
|
|
- showFailToast(error.data.msg)
|
|
|
- })
|
|
|
-}
|
|
|
+// const onSubmit3 = async() => {
|
|
|
+// await clearMobile({ captcha: ruleForm3.captcha }).then(async(res) => {
|
|
|
+// console.log(res)
|
|
|
+// showSuccessToast(res.data.msg)
|
|
|
+// await user.getUserProfile()
|
|
|
+// ruleForm3.mobile = user.profile.mobile
|
|
|
+// ruleForm3.captcha = ''
|
|
|
+// clearInterval(interval)
|
|
|
+// smsMessage.value = '获取验证码'
|
|
|
+// can_send.value = true
|
|
|
+// }).catch((error) => {
|
|
|
+// console.log(error)
|
|
|
+// showFailToast(error.data.msg)
|
|
|
+// })
|
|
|
+// }
|
|
|
const onSubmit4 = async() => {
|
|
|
await bindMobile({ mobile: ruleForm3.mobile, captcha: ruleForm3.captcha }).then(async(res) => {
|
|
|
console.log(res)
|
|
|
@@ -481,6 +493,7 @@ const onSubmit4 = async() => {
|
|
|
clearInterval(interval)
|
|
|
smsMessage.value = '获取验证码'
|
|
|
can_send.value = true
|
|
|
+ activeName.value = 'first'
|
|
|
}).catch((error) => {
|
|
|
console.log(error)
|
|
|
showFailToast(error.data.msg)
|
|
|
@@ -489,6 +502,7 @@ const onSubmit4 = async() => {
|
|
|
const pattern = ref<RegExp>(/^[a-zA-Z][a-zA-Z0-9]{5,19}$/)
|
|
|
const pattern2 = ref<RegExp>(/^(?:(?:\+|00)86)?1[3-9]\d{9}$/)
|
|
|
const account = ref<string>('')
|
|
|
+const activeName = ref<'first'|'second'|'third'|'forth'>('first')
|
|
|
onMounted(async() => {
|
|
|
from.value = parseInt(localStorage.getItem('from') as string)as 1 | 2
|
|
|
console.log(from.value)
|