feat(custom):

This commit is contained in:
2024-05-20 19:59:36 +08:00
parent 4245ae6c80
commit 09840d72ed
11 changed files with 268 additions and 46 deletions

View File

@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '交易密码',
});

View File

@@ -0,0 +1,29 @@
.form {
background-color: #fff;
margin-top: 20px;
padding: 25px 0;
.form-item {
display: flex;
padding: 20px 30px;
align-items: center;
.form-item-label {
font-size: 28px;
width: 150px;
}
.form-item-content {
flex: 1;
border-bottom: rgba(232, 232, 232, 1) 1px solid;
padding: 10px 0;
display: flex;
justify-content: space-between;
align-items: center;
}
}
}
.nut-button {
border-radius: 20px;
}

View File

@@ -0,0 +1,146 @@
<template>
<view>
<view class="form">
<view class="form-item">
<view class="form-item-label">
<text>设置密码:</text>
</view>
<view class="form-item-content">
<input
type="password"
maxLength="6"
placeholder="请输入6位数交易密码"
v-model="formVal.password"
placeholder-style="color:rgba(176, 176, 176, 1);font-size: 20px;" />
</view>
</view>
<view class="form-item">
<view class="form-item-label">
<text>确认密码:</text>
</view>
<view class="form-item-content">
<input
type="password"
maxLength="6"
v-model="formVal.confirmPassword"
placeholder="请再次输入6位数密码"
placeholder-style="color:rgba(176, 176, 176, 1);font-size: 20px;" />
</view>
</view>
<view class="form-item">
<view class="form-item-label">
<text>手机号码:</text>
</view>
<view class="form-item-content">
<input
type="text"
placeholder="请输入手机号码"
:disabled="true"
:value="userinfo.data?.phone"
placeholder-style="color:rgba(176, 176, 176, 1);font-size: 20px;" />
</view>
</view>
<view class="form-item">
<view class="form-item-label">
<text>验证码:</text>
</view>
<view class="form-item-content">
<input
type="text"
placeholder="请输入验证码"
maxLength="6"
v-model="formVal.code"
placeholder-style="color:rgba(176, 176, 176, 1);font-size: 20px;" />
<text
:style="{
color: !isT ? '#F83D3D' : 'rgba(176, 176, 176, 1)',
}"
@tap="getCode"
>{{ codeText }}
</text>
</view>
</view>
</view>
<view class="w-[90%] mt-[80px] mx-auto">
<nut-button shape="square" type="primary" block @click="formSubmit"
>确认修改
</nut-button>
</view>
</view>
</template>
<script setup lang="ts">
import {ref} from 'vue';
import Taro from '@tarojs/taro';
import {editTradePwd, getVerifyCode} from '@/api/user';
const userinfo = ref<any>({});
const codeText = ref('获取验证码');
const isT = ref(false);
const formVal = ref({
password: '',
confirmPassword: '',
code: '',
});
const xFormVal = ref({
oldPassword: '',
password: '',
confirmPassword: '',
code: '',
});
Taro.useLoad(() => {
userinfo.value = Taro.getStorageSync('userInfo');
});
const formSubmit = async () => {
try {
if (!formVal.value.password)
return Taro.showToast({title: '请输入交易密码', icon: 'none'});
if (!formVal.value.confirmPassword)
return Taro.showToast({title: '请再次输入交易密码', icon: 'none'});
if (formVal.value.password !== formVal.value.confirmPassword)
return Taro.showToast({title: '两次密码不一致', icon: 'none'});
if (!formVal.value.code)
return Taro.showToast({title: '请输入验证码', icon: 'none'});
const res = await editTradePwd({
pay_password: formVal.value.password,
code: formVal.value.code,
});
Taro.showToast({title: res.msg, icon: 'none'});
Taro.navigateBack({
delta: 1,
});
} catch (err) {
Taro.showToast({title: err.msg, icon: 'none'});
}
};
const getCode = async () => {
if (isT.value) return;
isT.value = true;
await getVerifyCode({
phone: userinfo.value.data?.phone,
});
// 倒计时60s
let time = 60;
const timer = setInterval(() => {
if (time === 0) {
clearInterval(timer);
isT.value = false;
codeText.value = '获取验证码';
} else {
codeText.value = `${time}s后重新获取`;
time--;
}
}, 1000);
};
</script>
<style lang="scss">
@import './index.scss';
</style>

View File

@@ -41,12 +41,22 @@ const clickText = (type: number, text: string) => {
title="个人信息"
is-link
@click="toPage('/pages/users/user_setting/index')"></nut-cell>
<nut-cell title="服务协议" is-link @click="clickText(1, '用户协议')"></nut-cell>
<nut-cell title="隐私政策协议" is-link @click="clickText(2, '隐私政策')"></nut-cell>
<nut-cell
title="服务协议"
is-link
@click="clickText(1, '用户协议')"></nut-cell>
<nut-cell
title="隐私政策协议"
is-link
@click="clickText(2, '隐私政策')"></nut-cell>
<nut-cell
title="平台积分使用规则"
is-link
@click="clickText(3, '积分使用规则')"></nut-cell>
<nut-cell
title="修改交易密码"
is-link
@click="toPage('/pages/users/pwd/index')"></nut-cell>
</nut-cell-group>
<view class="w-[90%] m-auto">
<nut-button

View File

@@ -94,7 +94,7 @@ const subUser = async () => {
placeholder="修改登录密码" />
</template>
</nut-cell> -->
<nut-cell title="交易密码" desc="创建/修改交易密码" is-link> </nut-cell>
<!-- <nut-cell title="交易密码" desc="创建/修改交易密码" is-link> </nut-cell> -->
<!-- <nut-cell title="注销账号" desc="账号注销后不能恢复" is-link> </nut-cell> -->
</nut-cell-group>
<view class="btn">