init
This commit is contained in:
@@ -0,0 +1,199 @@
|
||||
<template>
|
||||
<s-layout :bgStyle="{ color: 'var(--color1)' }" title="修改手机号">
|
||||
<view class="pages flex-column ju-between">
|
||||
<card_list class="cardList" :arr="listArr">
|
||||
<template #footer-2>
|
||||
<view class="flex-center">
|
||||
<uni-easyinput
|
||||
v-if="num > 0 && num < 60"
|
||||
:inputBorder="false"
|
||||
v-model="formData.oldCode"
|
||||
type="number"
|
||||
placeholder="请输入验证码"
|
||||
></uni-easyinput>
|
||||
<view class="c_primary size28" @click="getCode">{{
|
||||
num > 0 && num < 60 ? num + 's后重新获取' : '获取验证码'
|
||||
}}</view>
|
||||
</view>
|
||||
</template>
|
||||
<template #footer-3>
|
||||
<uni-easyinput
|
||||
:inputBorder="false"
|
||||
v-model="formData.mobile1"
|
||||
type="number"
|
||||
placeholder="请输入手机号"
|
||||
maxlength="11"
|
||||
minlength="11"
|
||||
></uni-easyinput>
|
||||
</template>
|
||||
<template #footer-4>
|
||||
<view class="flex-center">
|
||||
<uni-easyinput
|
||||
style="width: 200rpx"
|
||||
v-if="num1 > 0 && num1 < 60"
|
||||
:inputBorder="false"
|
||||
v-model="formData.code"
|
||||
type="number"
|
||||
placeholder="请输入验证码"
|
||||
maxlength="4"
|
||||
minlength="4"
|
||||
></uni-easyinput>
|
||||
<view class="c_primary size28" @click="getCode1">{{
|
||||
num1 > 0 && num1 < 60 ? num1 + 's后重新获取' : '获取验证码'
|
||||
}}</view>
|
||||
</view>
|
||||
</template>
|
||||
</card_list>
|
||||
<view class="absolute b130 l0 w100 p-x-40">
|
||||
<view class="submit-btn m-b-20" @click="sub">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</s-layout>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import sheep from '@/sheep';
|
||||
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
|
||||
import card_list from '@/components/card_list/card_list.vue';
|
||||
import UserApi from '@/sheep/api/member/user';
|
||||
import AuthUtil from '@/sheep/api/member/auth';
|
||||
let timer = ref(null);
|
||||
let timer1 = ref(null);
|
||||
let { proxy } = getCurrentInstance();
|
||||
let listArr = ref([
|
||||
{
|
||||
id: '1',
|
||||
title: '原手机号',
|
||||
rightText: '',
|
||||
},
|
||||
// {
|
||||
// id: '2',
|
||||
// title: '原手机验证码',
|
||||
// rightText: '',
|
||||
// type: 'config',
|
||||
// },
|
||||
{
|
||||
id: '3',
|
||||
title: '新手机号',
|
||||
rightText: '',
|
||||
type: 'input',
|
||||
typeObj: {
|
||||
type: 'number',
|
||||
placeholder: '请输入手机号',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
title: '新手机验证码',
|
||||
rightText: '',
|
||||
type: 'config',
|
||||
},
|
||||
]);
|
||||
let formData = ref({});
|
||||
let num = ref(0);
|
||||
let num1 = ref(0);
|
||||
const getCode1 = () => {
|
||||
if (num1.value > 0) {
|
||||
return;
|
||||
}
|
||||
if (!formData.value.mobile1) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
sendCode1();
|
||||
};
|
||||
const getCode = () => {
|
||||
if (num.value > 0) {
|
||||
return;
|
||||
}
|
||||
sendCode();
|
||||
};
|
||||
const sendCode = async () => {
|
||||
AuthUtil.sendSmsCode(formData.value.mobile, 3).then((res) => {
|
||||
if (res.code === 0) {
|
||||
num.value = 60;
|
||||
timer.value = setInterval(() => {
|
||||
num.value--;
|
||||
if (num.value <= 0) {
|
||||
clearInterval(timer.value);
|
||||
num.value = 60;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
const sendCode1 = async () => {
|
||||
AuthUtil.sendSmsCode(formData.value.mobile1, 3).then((res) => {
|
||||
if (res.code === 0) {
|
||||
num1.value = 60;
|
||||
timer1.value = setInterval(() => {
|
||||
num1.value--;
|
||||
if (num1.value <= 0) {
|
||||
clearInterval(timer1.value);
|
||||
num1.value = 60;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
let dataInfo = ref({});
|
||||
const getData = () => {
|
||||
sheep
|
||||
.$store('user')
|
||||
.getInfo()
|
||||
.then((res) => {
|
||||
dataInfo.value = res;
|
||||
formData.value.mobile = res.mobile;
|
||||
listArr.value[0].rightText = res.mobile;
|
||||
});
|
||||
};
|
||||
getData();
|
||||
const sub = () => {
|
||||
if (!formData.value.code || formData.value.oldCode === '') {
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!formData.value.mobile1) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
UserApi.updateUserMobile({
|
||||
oldCode: formData.value.oldCode,
|
||||
mobile: formData.value.mobile1,
|
||||
code: formData.value.code,
|
||||
}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
getData();
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(input) {
|
||||
text-align: right;
|
||||
}
|
||||
.pages {
|
||||
padding: 30rpx 40rpx;
|
||||
padding-bottom: 64rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.cardList {
|
||||
background-color: var(--color24);
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
:deep(.uni-list-item__container) {
|
||||
align-items: center !important;
|
||||
}
|
||||
:deep(.uni-input-input) {
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user