连接了我的项目,我的抽成

This commit is contained in:
2025-05-29 21:31:35 +08:00
parent 48e92710d6
commit bafd46bf63
12 changed files with 208 additions and 37 deletions

View File

@ -1,3 +1,6 @@
import { baseUrl } from "../../../request";
import { formatPassword } from "../../../utils/util"
// pages/personCenter/resetPwd/resetPwd.js
Page({
@ -5,14 +8,118 @@ Page({
* 页面的初始数据
*/
data: {
phone: '', // 手机号
sending: false, // 是否发送验证码
count: 60,
password: '', // 第一次输入的密码
currentPwd: '', // 再次确认密码
verificationCode: '' // 验证码
},
resetPwd() {
const { phone, verificationCode, password, currentPwd } = this.data;
formatPassword(password,currentPwd);
wx.request({
url: baseUrl + '/userInfo/mini/in/reset/pwd',
method: 'POST',
header: {
Authorization: wx.getStorageSync('token')
},
data: {
phoneNumber: phone,
verificationCode: verificationCode,
userPassword: password,
userConfirmPassword: currentPwd
},
success: res => {
console.log('修改密码--->',res);
if (res.data.code === 1) {
wx.showToast({
title: '更改密码成功',
icon: 'success'
})
wx.reLaunch({
url: '/pages/loginModule/pwdLogin/pwdLogin',
})
} else {
wx.showModal({
title: '提示',
content: res.data.message
})
}
}
})
},
// 获取验证码
getVerificationCode() {
const { phone } = this.data;
wx.request({
url: baseUrl + '/userInfo/code/pwd',
method: 'POST',
header: {
Authorization: wx.getStorageSync('token')
},
data: {
templateString: phone
},
success: res => {
if (res.data.code === 1) {
wx.showToast({ title: '验证码已发送' });
this.startCountdown();
} else {
wx.showToast({
title: '发送失败',
icon: 'error'
})
}
}
})
},
// 验证码开始
startCountdown() {
this.setData({ sending: true, count: 60 });
const timer = setInterval(() => {
let { count } = this.data;
if (count <= 1) {
clearInterval(timer);
this.setData({ sending: false });
} else {
this.setData({ count: count - 1 });
}
}, 1000);
},
// 通用输入事件处理函数
onInput(e) {
const field = e.currentTarget.dataset.field; // 获取字段名
console.log(field);
const value = e.detail.value; // 获取输入容
this.setData({
[field]: value // 动态更新应字段
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 获取用户信息 —— 用于渲染手机号
wx.request({
url: baseUrl + '/userInfo/get/jwt',
method: 'GET',
header: {
Authorization: wx.getStorageSync('token')
},
success: res => {
if (res.data.code === 1) {
this.setData({
phone: res.data.data.phoneNumber
})
}
}
})
},
/**

View File

@ -1,13 +1,33 @@
<view class="flex-col page">
<view class="flex-col section">
<text class="self-start font text">15888610253</text>
<view class="self-start font text">{{ phone }}</view>
<view class="flex-row justify-between self-stretch group">
<input class="font text_2" placeholder="验证码" />
<text class="font text_3">获取验证码</text>
<input
class="font text_2"
placeholder="验证码"
bindinput="onInput"
data-field="verificationCode"
value="{{ verificationCode }}"
/>
<view bind:tap="{{ sending ? '' : 'getVerificationCode' }}">
<text class="font text_3">{{ sending ? count + 's后重发' : '发送验证码' }}</text>
</view>
</view>
<input class="text_1 font" placeholder="密码" />
<input
class="text_1 font"
placeholder="密码"
bindinput="onInput"
data-field="password"
value="{{ password }}"
/>
<view class="self-stretch divider"></view>
<input class="text_8 font text_4" placeholder="再输入密码" />
<input
class="text_8 font text_4"
placeholder="再输入密码"
bindinput="onInput"
data-field="currentPwd"
value="{{ currentPwd }}"
/>
</view>
<view class="flex-col justify-start items-center text-wrapper mt-20"><text class="font text_5">重置密码</text></view>
<view class="flex-col justify-start items-center text-wrapper mt-20" bind:tap="resetPwd"><text class="font text_5">重置密码</text></view>
</view>