163 lines
4.0 KiB
Vue
163 lines
4.0 KiB
Vue
<template>
|
|
<s-pages title="修改密码">
|
|
<view class="pages flex-column ju-between">
|
|
<card_list class="cardList bg24" :arr="listArr">
|
|
<template #footer-2>
|
|
<view class="flex-center">
|
|
<uni-easyinput
|
|
style="width: 200rpx"
|
|
v-if="num > 0 && num < 60"
|
|
:inputBorder="false"
|
|
v-model="formData.code"
|
|
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.password"
|
|
type="password"
|
|
placeholder="请输入密码"
|
|
></uni-easyinput>
|
|
</template>
|
|
<template #footer-4>
|
|
<uni-easyinput
|
|
:inputBorder="false"
|
|
v-model="formData.password1"
|
|
type="password"
|
|
placeholder="请再次输入密码"
|
|
></uni-easyinput>
|
|
</template>
|
|
</card_list>
|
|
<view class="submit-btn m-t-20" @click="sub">确定</view>
|
|
</view>
|
|
</s-pages>
|
|
</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 { proxy } = getCurrentInstance();
|
|
let listArr = ref([
|
|
{
|
|
id: '1',
|
|
title: '手机号',
|
|
rightText: '',
|
|
},
|
|
{
|
|
id: '2',
|
|
title: '验证码',
|
|
rightText: '',
|
|
type: 'config',
|
|
},
|
|
{
|
|
id: '3',
|
|
title: '新密码',
|
|
rightText: '',
|
|
type: 'input',
|
|
typeObj: {
|
|
type: 'password',
|
|
placeholder: '请输入密码',
|
|
},
|
|
},
|
|
{
|
|
id: '4',
|
|
title: '确认密码',
|
|
rightText: '',
|
|
type: 'input',
|
|
typeObj: {
|
|
type: 'password',
|
|
placeholder: '请再次输入密码',
|
|
},
|
|
},
|
|
]);
|
|
let formData = ref({});
|
|
let num = ref(0);
|
|
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);
|
|
}
|
|
});
|
|
};
|
|
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) {
|
|
uni.showToast({
|
|
title: '请输入验证码',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
}
|
|
if (formData.value.password != formData.value.password1) {
|
|
uni.showToast({
|
|
title: '两次密码不一致',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
}
|
|
UserApi.updateUserPassword(formData.value).then((res) => {
|
|
if (res.code === 0) {
|
|
setTimeout(() => {
|
|
uni.reLaunch({ url: '/pages/public/login' });
|
|
}, 1000);
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
:deep(input) {
|
|
text-align: right;
|
|
}
|
|
.pages {
|
|
padding: 30rpx 40rpx;
|
|
padding-bottom: 64rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
:deep(.uni-list-item__content-title) {
|
|
white-space: nowrap;
|
|
word-break: keep-all;
|
|
}
|
|
.cardList {
|
|
border-radius: 8rpx;
|
|
overflow: hidden;
|
|
}
|
|
:deep(.uni-list-item__container) {
|
|
align-items: center !important;
|
|
}
|
|
.submit-btn {
|
|
}
|
|
</style>
|