优化功能
This commit is contained in:
@ -80,6 +80,8 @@
|
||||
import {mobile as testMobile} from '@/utils/test'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { router } from '@/utils/tools'
|
||||
import { getVerificationCode } from '@/api/user'
|
||||
import { SMS_ENUM } from '@/enum/sms'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
const toast = useToast()
|
||||
@ -129,7 +131,7 @@
|
||||
},
|
||||
|
||||
// 发送验证码
|
||||
handleCountDown: () => {
|
||||
handleCountDown: async () => {
|
||||
if (disabled.value) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
@ -139,6 +141,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
await getVerificationCode({ scene: SMS_ENUM.BANK, mobile: String(model.mobile) })
|
||||
startCountDown.value = true
|
||||
nextTick(() => {
|
||||
countDown.value?.start()
|
||||
@ -174,7 +177,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
router.navigateTo('/pages/login/set-password')
|
||||
router.navigateTo(`/pages/login/set-password?mobile=${model.mobile}&code=${model.code}`)
|
||||
},
|
||||
|
||||
// 获取手机号
|
||||
|
||||
@ -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]" @click="SetPassword.handleToConfirm">确定</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.switchTab('/pages/my/my')">好的</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
@ -71,134 +69,92 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {mobile as testMobile} from '@/utils/test'
|
||||
import { resetPassword } from '@/api/user'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { useUserStore } from '@/store'
|
||||
import { router } from '@/utils/tools'
|
||||
|
||||
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 countDownTime = ref<number>(1 * 60 * 1000) // 60s倒计时
|
||||
const startCountDown = ref<boolean>(false) // 是否开始倒计时
|
||||
const countDown = ref<any>(null) // 倒计时组件
|
||||
|
||||
/** 表单相关 **/
|
||||
// 表单相关
|
||||
const model = reactive<{
|
||||
mobile: string
|
||||
code: string
|
||||
password: string
|
||||
password_confirm: string
|
||||
}>({
|
||||
mobile: '',
|
||||
code: ''
|
||||
password: '',
|
||||
password_confirm: ''
|
||||
})
|
||||
/** 结束 **/
|
||||
|
||||
/** 服务协议和隐私政策 **/
|
||||
const agree = ref<boolean>(false)
|
||||
/** 结束 **/
|
||||
// 手机和验证码
|
||||
const mobile = ref<string>('')
|
||||
const code = ref<string>('')
|
||||
|
||||
onLoad((args) => {
|
||||
// 从个人登录页面进入
|
||||
if (args.type === 'edit') {
|
||||
userId.value = Number(args.userId) || 0 // userId仅做测试使用,实际请传真实用户ID
|
||||
|
||||
page.value.title = '修改手机号'
|
||||
page.value.desc = '手机号一年内可修改2次'
|
||||
pageType = 'edit'
|
||||
}
|
||||
mobile.value = args.mobile || ''
|
||||
code.value = args.code || ''
|
||||
})
|
||||
|
||||
const mobile = {
|
||||
// 验证手机号
|
||||
handleInputMobile: (e: {value: string}) => {
|
||||
model.mobile = e.value
|
||||
disabled.value = !testMobile(model.mobile)
|
||||
},
|
||||
|
||||
// 发送验证码
|
||||
handleCountDown: () => {
|
||||
if (disabled.value) {
|
||||
const SetPassword = {
|
||||
/**
|
||||
* 确认密码
|
||||
*/
|
||||
handleToConfirm: async () => {
|
||||
if (!mobile) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '手机号码错误请重新输入',
|
||||
msg: '手机号异常,请重新操作',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
startCountDown.value = true
|
||||
nextTick(() => {
|
||||
countDown.value?.start()
|
||||
if (!code) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '验证码异常,请重新操作',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 发送验证码请求
|
||||
if (!model.password) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '请输入密码',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (model.password !== model.password_confirm) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '两次输入的密码不一致',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await resetPassword({
|
||||
mobile: mobile.value,
|
||||
code: code.value,
|
||||
password: model.password,
|
||||
password_confirm: model.password_confirm
|
||||
})
|
||||
},
|
||||
|
||||
// 验证码倒计时结束
|
||||
handleFinishCountDown: () => {
|
||||
startCountDown.value = false
|
||||
},
|
||||
|
||||
// 登录
|
||||
handleToLogin: () => {
|
||||
// TODO 如果是edit的话就是修改手机号
|
||||
showEditSuccessPopup.value = true
|
||||
|
||||
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: () => {
|
||||
|
||||
},
|
||||
|
||||
// 修改手机成功后返回
|
||||
handleToBack: () => {
|
||||
uni.navigateBack()
|
||||
// const userStore = useUserStore()
|
||||
// await userStore.logout()
|
||||
// if (!userStore.isLoggedIn) {
|
||||
// toast.info('退出成功')
|
||||
// router.redirectTo('/pages/login/login')
|
||||
// }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -162,7 +162,19 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<wd-input v-model="form.people_number" no-border placeholder="推荐人数1-5人" :maxlength="10"
|
||||
<wd-input v-model="form.people_number" no-border placeholder="推荐人数1-5人"
|
||||
custom-class="!bg-[#F6F7F8] !rounded-16rpx !px-28rpx !py-20rpx" />
|
||||
</view>
|
||||
|
||||
<!-- 销量设置 -->
|
||||
<view class="mt-28rpx add-textarea">
|
||||
<view class="flex items-center justify-between mb-20rpx">
|
||||
<view class="mr-10rpx text-32rpx text-[#303133] font-bold leading-44rpx">
|
||||
销量设置
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<wd-input v-model="form.sold" no-border placeholder="请输入销量"
|
||||
custom-class="!bg-[#F6F7F8] !rounded-16rpx !px-28rpx !py-20rpx" />
|
||||
</view>
|
||||
</view>
|
||||
@ -422,7 +434,6 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { getRoomDetails, getRoomLabelList, handleCreateTag, handleDeleteTag, editRoom } from '@/api/store'
|
||||
import { updateUserInfo } from '@/api/user'
|
||||
@ -468,7 +479,8 @@
|
||||
video: null as any,
|
||||
other_describe: '',
|
||||
weight: 0,
|
||||
people_number: ''
|
||||
people_number: '',
|
||||
sold: ''
|
||||
})
|
||||
const tags = ref<Array<{ id: number, label_name: string, index: number }>>([])
|
||||
const roomLabelId = ref<string>('')
|
||||
@ -500,6 +512,7 @@
|
||||
form.other_describe = res.details.room.other_describe || ''
|
||||
form.weight = res.details.room.weight || 0
|
||||
form.people_number = res.details.room.people_number || ''
|
||||
form.sold = res.details.room.sold || ''
|
||||
},
|
||||
|
||||
/**
|
||||
@ -755,7 +768,8 @@
|
||||
hours: Number(form.hours),
|
||||
other_describe: form.other_describe,
|
||||
weight: Number(form.weight),
|
||||
people_number: form.people_number
|
||||
people_number: form.people_number,
|
||||
sold: form.sold
|
||||
}
|
||||
|
||||
uni.showLoading({
|
||||
|
||||
Reference in New Issue
Block a user