调试接口

This commit is contained in:
wangxiaowei
2025-12-30 01:05:27 +08:00
parent 338a99a54a
commit f69536a7e4
9 changed files with 430 additions and 478 deletions

View File

@ -20,37 +20,35 @@
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">密码</view>
<view class="mt-20rpx">
<wd-input
v-model="model.mobile"
v-model="model.password"
type="text"
placeholder="请输入密码"
inputmode="numeric"
no-border
custom-class="!bg-[#F6F7F8] !border !border-solid !border-[#EAECF0] !rounded-16rpx"
custom-input-class="!px-32rpx !h-104rpx"
@input="mobile.handleInputMobile"
/>
</view>
</view>
<view>
<view class="mt-40rpx">
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">再次确认</view>
<view class="mt-20rpx">
<wd-input
v-model="model.mobile"
v-model="model.password_confirm"
type="text"
placeholder="再次确认新的密码"
inputmode="numeric"
no-border
custom-class="!bg-[#F6F7F8] !border !border-solid !border-[#EAECF0] !rounded-16rpx"
custom-input-class="!px-32rpx !h-104rpx"
@input="mobile.handleInputMobile"
/>
</view>
</view>
</wd-form>
</view>
<view class="h-90rpx leading-90rpx mx-60rpx rounded-8rpx text-center mt-112rpx bg-[#4C9F44] text-[#fff]" :class="disabled ? 'opacity-40' : ''" @click="mobile.handleToLogin">确定</view>
<view class="h-90rpx leading-90rpx mx-60rpx rounded-8rpx text-center mt-112rpx bg-[#4C9F44] text-[#fff]" :class="disabled ? 'opacity-40' : ''" @click="Mobile.handleToLogin">确定</view>
<!-- 手机号修改成功 -->
<wd-popup v-model="showEditSuccessPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
@ -62,7 +60,7 @@
</view>
<view class="text-[#303133] text-36rpx leading-46rpx text-center mt-48rpx">密码修改成功</view>
<view class="text-[#9CA3AF] text-28rpx leading-44rpx mt-16rpx text-center">请记住你的登录密码</view>
<view class="w-630rpx h-90rpx leading-90rpx text-center bg-[#4C9F44] rounded-8rpx text-[#fff] mt-174rpx mx-auto" @click="mobile.handleToBack">好的</view>
<view class="w-630rpx h-90rpx leading-90rpx text-center bg-[#4C9F44] rounded-8rpx text-[#fff] mt-174rpx mx-auto" @click="router.reLaunch('/pages/login/login')">好的</view>
</view>
</wd-popup>
</view>
@ -70,59 +68,34 @@
<script lang="ts" setup>
import {mobile as testMobile} from '@/utils/test'
import { mobile } from '@/utils/test'
import { useToast } from 'wot-design-uni'
import { router } from '@/utils/tools'
import { resetPassword } from '@/api/user'
const OSS = inject('OSS')
const toast = useToast()
const disabled = ref<boolean>(true)
/** 页面 **/
let pageType = 'login' // 页面类型 login:登录 edit:修改手机号
const page = ref<{title: string, desc: string}>({title: '其他手机号登录', desc: '请输入你要登录的手机号'})
const showEditSuccessPopup = ref<boolean>(false) // 显示手机号修改成功弹窗
const userId = ref<number>(0) // 用户ID修改手机号时需要传
// 手机号修改成功弹窗
const showEditSuccessPopup = ref<boolean>(false)
/** 验证码倒计时 **/
const countDownTime = ref<number>(1 * 60 * 1000) // 60s倒计时
const startCountDown = ref<boolean>(false) // 是否开始倒计时
const countDown = ref<any>(null) // 倒计时组件
/** 表单相关 **/
const model = reactive<{
mobile: string
code: string
}>({
const model = ref({
mobile: '',
code: ''
code: '',
password: '',
password_confirm: ''
})
/** 结束 **/
/** 服务协议和隐私政策 **/
const agree = ref<boolean>(false)
/** 结束 **/
onLoad((args) => {
// 从个人登录页面进入
if (args.type === 'edit') {
userId.value = Number(args.userId) || 0 // userId仅做测试使用实际请传真实用户ID
page.value.title = '修改手机号'
page.value.desc = '手机号一年内可修改2次'
pageType = 'edit'
}
})
const mobile = {
// 验证手机号
handleInputMobile: (e: {value: string}) => {
model.mobile = e.value
disabled.value = !testMobile(model.mobile)
},
// 发送验证码
handleCountDown: () => {
if (disabled.value) {
const Mobile = {
// 重置密码
handleToLogin: async () => {
if (!mobile(model.value.mobile)) {
toast.show({
iconClass: 'info-circle',
msg: '手机号码错误请重新输入',
@ -131,74 +104,46 @@
return
}
startCountDown.value = true
nextTick(() => {
countDown.value?.start()
if (!model.value.code) {
toast.show({
iconClass: 'info-circle',
msg: '验证码不存在',
direction: 'vertical'
})
return
}
// 发送验证码请求
if (!model.value.password) {
toast.show({
iconClass: 'info-circle',
msg: '请输入新密码',
direction: 'vertical'
})
return
}
if (model.value.password !== model.value.password_confirm) {
toast.show({
iconClass: 'info-circle',
msg: '两次输入密码不一致',
direction: 'vertical'
})
return
}
const res = await resetPassword({
mobile: model.value.mobile,
code: model.value.code,
password: model.value.password,
password_confirm: model.value.password_confirm
})
},
// 验证码倒计时结束
handleFinishCountDown: () => {
startCountDown.value = false
},
// 登录
handleToLogin: () => {
// TODO 如果是edit的话就是修改手机号
if (pageType === 'login' && !agree.value) {
toast.show({
iconClass: 'info-circle',
msg: '请同意服务协议和隐私政策',
direction: 'vertical'
})
return
}
if (!testMobile(model.mobile)) {
toast.show({
iconClass: 'info-circle',
msg: '手机号码错误请重新输入',
direction: 'vertical'
})
return
}
if (!model.code) {
toast.show({
iconClass: 'info-circle',
msg: '验证码错误',
direction: 'vertical'
})
return
}
},
// 获取手机号
handleGetPhoneNumber: (e: object) => {
console.log("🚀 ~ e:", e)
},
handleAgree: (e: any) => {
console.log('e', e)
},
// 跳转到服务协议页面
handleToService: () => {
disabled.value = !disabled.value
console.log("🚀 ~ disabled:", disabled)
},
// 跳转到隐私政策页面
handleToPrivacy: () => {
showEditSuccessPopup.value = true
},
// 修改手机成功后返回
handleToBack: () => {
uni.navigateBack()
router.navigateBack()
}
}
</script>