初始化提交
This commit is contained in:
250
src/bundle/profile/change-mobile.vue
Normal file
250
src/bundle/profile/change-mobile.vue
Normal file
@ -0,0 +1,250 @@
|
||||
<route lang="jsonc" type="page">{
|
||||
"needLogin": true,
|
||||
"layout": "default",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}</route>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<view>
|
||||
<navbar :title="page.title" custom-class='!bg-[#fff]'></navbar>
|
||||
</view>
|
||||
|
||||
<view class="mx-60rpx mt-20rpx">
|
||||
<view class="text-[#303133] text-48rpx leading-80rpx font-600">
|
||||
{{ page.title }}
|
||||
</view>
|
||||
<view class="font-400 text-28rpx leading-44rpx text-[#6B7280] mt-12rpx">{{ page.desc }}</view>
|
||||
</view>
|
||||
<view class="mt-106rpx mx-48rpx">
|
||||
<wd-form ref="form" :model="model">
|
||||
<view>
|
||||
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">手机号</view>
|
||||
<view class="mt-20rpx">
|
||||
<wd-input
|
||||
v-model="model.mobile"
|
||||
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="ChangeMobile.handleInputMobile"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mt-40rpx" v-if="pageType == 'edit'">
|
||||
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">验证码</view>
|
||||
<view class="mt-20rpx">
|
||||
<wd-input type="text" placeholder="请输入验证码" v-model="model.code" inputmode="numeric" no-border custom-class="!bg-[#F6F7F8] !border !border-solid !border-[#EAECF0] !rounded-16rpx" custom-input-class="!px-32rpx !h-104rpx">
|
||||
<template #suffix>
|
||||
<view class="flex items-center mr-34rpx">
|
||||
<view class="flex items-center">
|
||||
<wd-divider color="#C9C9C9" vertical />
|
||||
</view>
|
||||
|
||||
<view class="flex items-center">
|
||||
<view class="text-[#4C9F44] text-32rpx font-400 leading-44rpx" v-if="!startCountDown" @click="ChangeMobile.handleCountDown">发送验证码</view>
|
||||
<view class="!text-[#C9C9C9] text-32rpx font-400 leading-44rpx flex items-center" v-if="startCountDown">
|
||||
<wd-count-down ref="countDown" :time="countDownTime" millisecond :auto-start="false" format="ss" custom-class="!text-[#C9C9C9] !text-32rpx" @finish="ChangeMobile.handleFinishCountDown"></wd-count-down>
|
||||
<view> S后重发</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</wd-input>
|
||||
</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="ChangeMobile.handleConfirm">确定</view>
|
||||
|
||||
<!-- 手机号修改成功 -->
|
||||
<wd-popup v-model="showEditSuccessPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
|
||||
<view class="relative pt-64rpx pb-74rpx">
|
||||
<view class="flex justify-center items-center">
|
||||
<view class="bg-[#4C9F44] w-280rpx rounded-280rpx">
|
||||
<wd-img width="280rpx" height="280rpx" :src="`${OSS}images/reserve_room/reserve_room_image7.png`"/>
|
||||
</view>
|
||||
</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">{{ page.desc }}</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>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {mobile as testMobile} from '@/utils/test'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { router } from '@/utils/tools'
|
||||
import { SMS_ENUM } from '@/enum/sms'
|
||||
import { getVerificationCode, updateUserInfo } from '@/api/user'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
const toast = useToast()
|
||||
const disabled = ref<boolean>(true)
|
||||
|
||||
// 页面
|
||||
const pageType = ref<string>('') // 页面类型 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
|
||||
}>({
|
||||
mobile: '',
|
||||
code: ''
|
||||
})
|
||||
|
||||
|
||||
onLoad((args) => {
|
||||
// 从个人登录页面进入
|
||||
pageType.value = args.type
|
||||
userId.value = Number(args.userId) || 0 // userId仅做测试使用,实际请传真实用户ID
|
||||
|
||||
if (args.type === 'edit') {
|
||||
page.value.title = '修改手机号'
|
||||
page.value.desc = '手机号一年内可修改2次'
|
||||
} else if (args.type === 'change') {
|
||||
page.value.title = '修改绑定用户'
|
||||
page.value.desc = '请输入新的手机号进行绑定'
|
||||
}
|
||||
})
|
||||
|
||||
const ChangeMobile = {
|
||||
/**
|
||||
* 验证手机号
|
||||
* @param e
|
||||
*/
|
||||
handleInputMobile: (e: {value: string}) => {
|
||||
model.mobile = e.value
|
||||
disabled.value = !testMobile(model.mobile)
|
||||
},
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
handleCountDown: async () => {
|
||||
if (disabled.value) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '手机号码错误请重新输入',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await getVerificationCode({ scene: SMS_ENUM.BGSJHM, mobile: String(model.mobile)})
|
||||
|
||||
startCountDown.value = true
|
||||
nextTick(() => {
|
||||
countDown.value?.start()
|
||||
|
||||
// 发送验证码请求
|
||||
})
|
||||
},
|
||||
|
||||
// 验证码倒计时结束
|
||||
handleFinishCountDown: () => {
|
||||
startCountDown.value = false
|
||||
},
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
handleConfirm: async() => {
|
||||
if (!testMobile(model.mobile)) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '手机号码错误请重新输入',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (pageType.value == 'edit') {
|
||||
// TODO 如果是edit的话就是修改手机号
|
||||
if (!model.code) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '验证码错误',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await updateUserInfo({
|
||||
mobile: Number(model.mobile),
|
||||
code: model.code
|
||||
})
|
||||
|
||||
showEditSuccessPopup.value = true
|
||||
} else if (pageType.value == 'change') {
|
||||
await updateUserInfo({
|
||||
band_mobile: model.mobile,
|
||||
})
|
||||
toast.success('绑定手机号修改成功')
|
||||
router.switchTab('/pages/my/my', 500)
|
||||
}
|
||||
},
|
||||
|
||||
// 获取手机号
|
||||
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()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.service {
|
||||
:deep() {
|
||||
.wd-checkbox {
|
||||
display: flex;
|
||||
align-content: flex-start;
|
||||
}
|
||||
|
||||
.wd-checkbox__label {
|
||||
margin-left: 6rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
211
src/bundle/profile/change-password.vue
Normal file
211
src/bundle/profile/change-password.vue
Normal file
@ -0,0 +1,211 @@
|
||||
<route lang="jsonc" type="page">{
|
||||
"needLogin": true,
|
||||
"layout": "default",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}</route>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<view>
|
||||
<navbar title="修改密码" custom-class='!bg-[#fff]'></navbar>
|
||||
</view>
|
||||
|
||||
<view class="mx-60rpx mt-20rpx">
|
||||
<view class="text-[#303133] text-48rpx leading-80rpx font-600">
|
||||
修改密码
|
||||
</view>
|
||||
<view class="font-400 text-28rpx leading-44rpx text-[#6B7280] mt-12rpx">需要验证绑定手机</view>
|
||||
</view>
|
||||
<view class="mt-106rpx mx-48rpx">
|
||||
<wd-form ref="form" :model="model">
|
||||
<view>
|
||||
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">手机号</view>
|
||||
<view class="mt-20rpx">
|
||||
<wd-input
|
||||
v-model="model.mobile"
|
||||
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 class="mt-40rpx">
|
||||
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">验证码</view>
|
||||
<view class="mt-20rpx">
|
||||
<wd-input type="text" placeholder="请输入验证码" v-model="model.code" inputmode="numeric" no-border custom-class="!bg-[#F6F7F8] !border !border-solid !border-[#EAECF0] !rounded-16rpx" custom-input-class="!px-32rpx !h-104rpx">
|
||||
<template #suffix>
|
||||
<view class="flex items-center mr-34rpx">
|
||||
<view class="flex items-center">
|
||||
<wd-divider color="#C9C9C9" vertical />
|
||||
</view>
|
||||
|
||||
<view class="flex items-center">
|
||||
<view class="text-[#4C9F44] text-32rpx font-400 leading-44rpx" v-if="!startCountDown" @click="Mobile.handleCountDown">发送验证码</view>
|
||||
<view class="!text-[#C9C9C9] text-32rpx font-400 leading-44rpx flex items-center" v-if="startCountDown">
|
||||
<wd-count-down ref="countDown" :time="countDownTime" millisecond :auto-start="false" format="ss" custom-class="!text-[#C9C9C9] !text-32rpx" @finish="Mobile.handleFinishCountDown"></wd-count-down>
|
||||
<view> S后重发</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</wd-input>
|
||||
</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.handleNext">下一步</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { mobile as testMobile } from '@/utils/test'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { getVerificationCode } from '@/api/user'
|
||||
import { SMS_ENUM } from '@/enum/sms'
|
||||
import { router } from '@/utils/tools'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
const toast = useToast()
|
||||
const disabled = ref<boolean>(true)
|
||||
|
||||
/** 页面 **/
|
||||
const page = ref<{title: string, desc: string}>({title: '其他手机号登录', desc: '请输入你要登录的手机号'})
|
||||
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
|
||||
}>({
|
||||
mobile: '',
|
||||
code: ''
|
||||
})
|
||||
|
||||
onLoad((args) => {
|
||||
|
||||
})
|
||||
|
||||
const Mobile = {
|
||||
/**
|
||||
* 验证手机号码
|
||||
* @param e 手机号
|
||||
*/
|
||||
handleInputMobile: (e: {value: string}) => {
|
||||
model.mobile = e.value
|
||||
disabled.value = !testMobile(model.mobile)
|
||||
},
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
handleCountDown: async () => {
|
||||
if (disabled.value) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '手机号码错误请重新输入',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await getVerificationCode({ scene: SMS_ENUM.ZHDLMM, mobile: String(model.mobile)})
|
||||
|
||||
startCountDown.value = true
|
||||
nextTick(() => {
|
||||
countDown.value?.start()
|
||||
|
||||
// 发送验证码请求
|
||||
})
|
||||
},
|
||||
|
||||
// 验证码倒计时结束
|
||||
handleFinishCountDown: () => {
|
||||
startCountDown.value = false
|
||||
},
|
||||
|
||||
// 登录
|
||||
handleToLogin: () => {
|
||||
// TODO 如果是edit的话就是修改手机号
|
||||
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)
|
||||
},
|
||||
|
||||
/**
|
||||
* 下一步
|
||||
*/
|
||||
handleNext: () => {
|
||||
if (disabled.value) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '手机号码错误请重新输入',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!model.code) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '请输入验证码',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
router.navigateTo(`/bundle/profile/set-password?mobile=${model.mobile}&code=${model.code}`)
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.service {
|
||||
:deep() {
|
||||
.wd-checkbox {
|
||||
display: flex;
|
||||
align-content: flex-start;
|
||||
}
|
||||
|
||||
.wd-checkbox__label {
|
||||
margin-left: 6rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
272
src/bundle/profile/profile.vue
Normal file
272
src/bundle/profile/profile.vue
Normal file
@ -0,0 +1,272 @@
|
||||
<route lang="jsonc" type="page">
|
||||
{
|
||||
"needLogin": true,
|
||||
"layout": "default",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>
|
||||
<view class="">
|
||||
<!-- 修改昵称 -->
|
||||
<wd-popup v-model="showEditNicknamePopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
|
||||
<view class="relative pb-56rpx">
|
||||
<view class="absolute top-18rpx right-30rpx" @click="showEditNicknamePopup = false">
|
||||
<wd-img width="60rpx" height='60rpx' :src="`${OSS}icon/icon_close.png`"></wd-img>
|
||||
</view>
|
||||
|
||||
<view class="text-36rpx text-[#121212] leading-50rpx text-center pt-50rpx pb-40rpx">修改昵称</view>
|
||||
|
||||
<view class="mt-70rpx mx-48rpx">
|
||||
<wd-input
|
||||
clearable
|
||||
type="text"
|
||||
placeholder="请输入昵称"
|
||||
v-model="nickname"
|
||||
no-border
|
||||
custom-class="!bg-[#F6F7F8] !rounded-16rpx !text-30rpx !leading-48rpx"
|
||||
custom-input-class="!h-104rpx !pl-60rpx">
|
||||
<template #prefix>
|
||||
<view class="ml-30rpx font-bold text-30rpx leading-48rpx text-[#303133]">
|
||||
昵称
|
||||
</view>
|
||||
</template>
|
||||
</wd-input>
|
||||
</view>
|
||||
|
||||
<view class="mt-22rpx text-26rpx leading-36rpx text-[#909399] mx-48rpx">昵称限制1-10字符,一个汉字为一个字符</view>
|
||||
|
||||
<view class="mx-48rpx h-90rpx leading-90rpx rounded-8rpx text-center mt-112rpx text-[#fff]" :class="nickname ? 'bg-[#4C9F44]' : 'bg-[#A5CFA1]'" @click="Profile.handleSaveNickname">保存</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 退出登录 -->
|
||||
<wd-popup v-model="showLogoutPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
|
||||
<view class="relative pt-54rpx pb-74rpx">
|
||||
<view class="text-[#303133] text-36rpx leading-46rpx text-center">您确定要退出该账号吗?</view>
|
||||
<view class="mt-76rpx">
|
||||
<view class="bg-[#4C9F44] h-90rpx leading-90rpx mx-60rpx rounded-8rpx text-center text-[#fff]" @click="Profile.handleLogout">
|
||||
退出登录
|
||||
</view>
|
||||
|
||||
<view class="bg-[#fff] border-2rpx border-solid border-[#9CA3AF] h-90rpx leading-90rpx mx-60rpx rounded-8rpx text-center text-[#303133] mt-40rpx"
|
||||
@click="showLogoutPopup = false">
|
||||
取消
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<view>
|
||||
<navbar title="个人信息" custom-class='!bg-[#F6F7F8]'></navbar>
|
||||
</view>
|
||||
|
||||
<view class="bg-white rounded-16rpx mt-20rpx mx-30rpx px-30rpx py-32rpx">
|
||||
<!-- 头像 -->
|
||||
<view class="flex justify-between items-center mb-54rpx">
|
||||
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">头像</view>
|
||||
<view class="flex justify-end">
|
||||
<view class="flex items-center">
|
||||
<view class="mr-10rpx">
|
||||
<wd-upload
|
||||
:header="{'token': token}"
|
||||
:file-list="fileList"
|
||||
:limit="1"
|
||||
image-mode="scaleToFill"
|
||||
:action="action"
|
||||
@success="Profile.handleUploadSuccess">
|
||||
<wd-img width="64rpx" height="64rpx" :src="user.avatar || `${OSS}images/store/my/image1.png`" mode="aspectFill" round />
|
||||
</wd-upload>
|
||||
</view>
|
||||
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 昵称 -->
|
||||
<view class="flex justify-between items-center mb-54rpx" @click="showEditNicknamePopup = true">
|
||||
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">昵称</view>
|
||||
<view class="flex justify-end">
|
||||
<view class="flex items-center">
|
||||
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">
|
||||
{{ user.nickname }}
|
||||
</view>
|
||||
<view>
|
||||
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 修改手机号 -->
|
||||
<view class="flex justify-between items-center mb-54rpx" @click="router.navigateTo('/bundle/profile/change-mobile?type=edit')">
|
||||
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">修改手机号</view>
|
||||
<view class="flex justify-end">
|
||||
<view class="flex items-center">
|
||||
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">
|
||||
+86 {{ maskedMobile }}
|
||||
</view>
|
||||
<view>
|
||||
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 修改手机号 -->
|
||||
<view class="flex justify-between items-center mb-54rpx" @click="router.navigateTo('/bundle/profile/change-password')">
|
||||
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">修改密码</view>
|
||||
<view>
|
||||
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 修改绑定用户 -->
|
||||
<view class="flex justify-between items-center" @click="router.navigateTo('/bundle/profile/change-mobile?type=change')">
|
||||
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">修改绑定用户</view>
|
||||
<view>
|
||||
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bg-white rounded-16rpx mt-144rpx mx-30rpx px-30rpx py-32rpx text-center font-400 text-[#303133] text-30rpx leading-42rpx" @click="showLogoutPopup = true">
|
||||
退出登录
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { toast } from '@/utils/toast'
|
||||
import { getUserInfo, updateUserInfo } from '@/api/user'
|
||||
import type { IUserResult } from '@/api/types/user'
|
||||
import { router } from '@/utils/tools'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
const showLogoutPopup = ref<boolean>(false) // 是否显示退出登录弹出框
|
||||
|
||||
// 上传文件
|
||||
const fileList = ref<any[]>([])
|
||||
const action = import.meta.env.VITE_UPLOAD_BASEURL
|
||||
|
||||
// 修改昵称
|
||||
const showEditNicknamePopup = ref<boolean>(false) // 是否显示退款详情弹出框
|
||||
const nickname = ref<string>('') // 昵称
|
||||
|
||||
// 用户信息相关
|
||||
const user = ref<IUserResult>({
|
||||
id: 0,
|
||||
sn: 0,
|
||||
sex: "未知",
|
||||
account: "",
|
||||
nickname: "",
|
||||
real_name: "",
|
||||
avatar: "",
|
||||
collect_count: 0,
|
||||
coupon_count: 0,
|
||||
create_time: "",
|
||||
has_auth: false,
|
||||
has_password: false,
|
||||
member: 0,
|
||||
mobile: "",
|
||||
user_money: "0.00",
|
||||
version: ""
|
||||
})
|
||||
|
||||
const token = ref<string>('') // 用户token
|
||||
|
||||
onLoad(() => {
|
||||
token.value = uni.getStorageSync('token')
|
||||
|
||||
Profile.handleInit()
|
||||
})
|
||||
|
||||
const Profile = {
|
||||
/**
|
||||
* 初始化用户信息
|
||||
*/
|
||||
handleInit: async () => {
|
||||
const res = await getUserInfo()
|
||||
user.value = res
|
||||
},
|
||||
|
||||
/**
|
||||
* 图片选择/删除
|
||||
* @param e
|
||||
*/
|
||||
handleChange: (e: any) => {
|
||||
console.log("🚀 ~ e:", e)
|
||||
},
|
||||
|
||||
handleUploadSuccess: async (e: any) => {
|
||||
try {
|
||||
const response = JSON.parse(e.file.response)
|
||||
if (response.code) {
|
||||
const avatarUrl = response.data.url
|
||||
await updateUserInfo({ avatar: avatarUrl })
|
||||
user.value.avatar = avatarUrl
|
||||
toast.info('头像上传成功')
|
||||
} else {
|
||||
throw new Error('上传失败')
|
||||
}
|
||||
} catch (error) {
|
||||
toast.info('上传失败')
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存昵称
|
||||
*/
|
||||
handleSaveNickname: async () => {
|
||||
if (!nickname.value) {
|
||||
toast.info('请输入昵称')
|
||||
return
|
||||
}
|
||||
|
||||
await updateUserInfo({ nickname: nickname.value })
|
||||
showEditNicknamePopup.value = false
|
||||
user.value.nickname = nickname.value
|
||||
toast.info('昵称修改成功')
|
||||
},
|
||||
|
||||
/**
|
||||
* 修改手机号
|
||||
*/
|
||||
handleToEditMobile: () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/mobile?type=edit&userId=123' // userId仅做测试使用,实际请传真实用户ID
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
handleLogout: async () => {
|
||||
const userStore = useUserStore()
|
||||
await userStore.logout()
|
||||
if (!userStore.isLoggedIn) {
|
||||
toast.info('退出成功')
|
||||
router.reLaunch('/pages/my/my')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 掩码处理手机号
|
||||
*/
|
||||
const maskedMobile = computed(() => {
|
||||
if (!user.value.mobile) return ''
|
||||
// 只处理11位手机号
|
||||
return user.value.mobile.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2')
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background: $cz-page-background;
|
||||
}
|
||||
</style>
|
||||
179
src/bundle/profile/set-password.vue
Normal file
179
src/bundle/profile/set-password.vue
Normal file
@ -0,0 +1,179 @@
|
||||
<route lang="jsonc" type="page">{
|
||||
"layout": "default",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationBarBackgroundColor": "#fff"
|
||||
}
|
||||
}</route>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<view class="mx-60rpx mt-20rpx">
|
||||
<view class="text-[#303133] text-48rpx leading-80rpx font-600">
|
||||
设置新密码
|
||||
</view>
|
||||
<view class="font-400 text-28rpx leading-44rpx text-[#6B7280] mt-12rpx">请设置你得新密码</view>
|
||||
</view>
|
||||
<view class="mt-106rpx mx-48rpx">
|
||||
<wd-form ref="form" :model="model">
|
||||
<view>
|
||||
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">密码</view>
|
||||
<view class="mt-20rpx">
|
||||
<wd-input
|
||||
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"
|
||||
/>
|
||||
</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.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"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</wd-form>
|
||||
</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">
|
||||
<view class="relative pt-64rpx pb-74rpx">
|
||||
<view class="flex justify-center items-center">
|
||||
<view class="bg-[#4C9F44] w-280rpx rounded-280rpx">
|
||||
<wd-img width="280rpx" height="280rpx" :src="`${OSS}images/reserve_room/reserve_room_image7.png`"/>
|
||||
</view>
|
||||
</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="router.switchTab('/pages/my/my')">好的</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
<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)
|
||||
|
||||
// 弹窗
|
||||
const showEditSuccessPopup = ref<boolean>(false) // 显示手机号修改成功弹窗
|
||||
|
||||
// 表单相关
|
||||
const model = reactive<{
|
||||
password: string
|
||||
password_confirm: string
|
||||
}>({
|
||||
password: '',
|
||||
password_confirm: ''
|
||||
})
|
||||
|
||||
// 手机和验证码
|
||||
const mobile = ref<string>('')
|
||||
const code = ref<string>('')
|
||||
|
||||
onLoad((args) => {
|
||||
mobile.value = args.mobile || ''
|
||||
code.value = args.code || ''
|
||||
})
|
||||
|
||||
const SetPassword = {
|
||||
/**
|
||||
* 确认密码
|
||||
*/
|
||||
handleToConfirm: async () => {
|
||||
if (!mobile) {
|
||||
toast.show({
|
||||
iconClass: 'info-circle',
|
||||
msg: '手机号异常,请重新操作',
|
||||
direction: 'vertical'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
showEditSuccessPopup.value = true
|
||||
|
||||
// const userStore = useUserStore()
|
||||
// await userStore.logout()
|
||||
// if (!userStore.isLoggedIn) {
|
||||
// toast.info('退出成功')
|
||||
// router.redirectTo('/pages/login/login')
|
||||
// }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.service {
|
||||
:deep() {
|
||||
.wd-checkbox {
|
||||
display: flex;
|
||||
align-content: flex-start;
|
||||
}
|
||||
|
||||
.wd-checkbox__label {
|
||||
margin-left: 6rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user