修改密码

This commit is contained in:
Jason 2022-09-09 17:58:18 +08:00
parent 33e4cd45f3
commit 43b9a54b6a
7 changed files with 499 additions and 450 deletions

View File

@ -23,4 +23,6 @@ export function userBindMobile(data: any) {
export function userMnpMobile(data: any) { export function userMnpMobile(data: any) {
return request.post({ url: '/user/mnpMobile', data: data }) return request.post({ url: '/user/mnpMobile', data: data })
} }
export function userChangePwd(data: any) {
return request.post({ url: '/user/changePwd', data: data })
}

View File

@ -1,37 +1,67 @@
<template> <template>
<view class=""> <view
<u-parse :html="agreementContent"></u-parse> class="register bg-white min-h-full flex flex-col items-center px-[40rpx] pt-[100rpx] box-border"
</view> >
</template> <view class="w-full">
<view class="text-2xl font-medium mb-[60rpx]">修改登录密码</view>
<u-form borderBottom :label-width="150">
<u-form-item label="原密码" borderBottom>
<u-input
class="flex-1"
v-model="formData.oldPassword"
:border="false"
placeholder="请输入原来的密码"
/>
</u-form-item>
<u-form-item label="新密码" borderBottom>
<u-input
class="flex-1"
type="password"
v-model="formData.password"
placeholder="6-20位数字+字母或符号组合"
:border="false"
/>
</u-form-item>
<u-form-item label="确认密码" borderBottom>
<u-input
class="flex-1"
type="password"
v-model="formData.password2"
placeholder="再次输入新密码"
:border="false"
/>
</u-form-item>
</u-form>
<view class="mt-[100rpx]">
<u-button type="primary" shape="circle" @click="handleConfirm"> 确定 </u-button>
</view>
</view>
</view>
</template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from 'vue' import { userChangePwd } from '@/api/user'
import { onLoad } from "@dcloudio/uni-app"; import { reactive } from 'vue'
import { AgreementEnum } from '@/enums/agreementEnums'
import { getPolicy } from '@/api/app' const formData = reactive({
oldPassword: '',
let agreementType = ref('') // password: '',
let agreementContent = ref('') // password2: ''
// let agreementName = ref('') // })
const getData = async (type) => { const handleConfirm = async () => {
let res = await getPolicy({ type }) if (!formData.oldPassword) return uni.$u.toast('请输入原来的密码')
console.log(res, 'res') if (!formData.password) return uni.$u.toast('请输入密码')
if (!formData.password2) return uni.$u.toast('请输入确认密码')
agreementContent.value = res.content if (formData.password != formData.password2) return uni.$u.toast('两次输入的密码不一致')
await userChangePwd(formData)
uni.setNavigationBarTitle({ uni.$u.toast('操作成功')
title: res.name uni.navigateBack()
}) }
} </script>
onLoad((options: any) => { <style lang="scss">
if(options.type) { page {
agreementType.value = options.type height: 100%;
getData(agreementType) }
}
})
</script>
<style lang="scss" scoped>
</style> </style>

View File

@ -3,7 +3,7 @@
class="register bg-white min-h-full flex flex-col items-center px-[40rpx] pt-[100rpx] box-border" class="register bg-white min-h-full flex flex-col items-center px-[40rpx] pt-[100rpx] box-border"
> >
<view class="w-full"> <view class="w-full">
<view class="text-2xl font-medium mb-[100rpx]">忘记登录密码</view> <view class="text-2xl font-medium mb-[60rpx]">忘记登录密码</view>
<u-form borderBottom :label-width="150"> <u-form borderBottom :label-width="150">
<u-form-item label="手机号" borderBottom> <u-form-item label="手机号" borderBottom>
<u-input <u-input

View File

@ -42,6 +42,7 @@ const getData = async () => {
state.pages = JSON.parse(data.pages) state.pages = JSON.parse(data.pages)
state.article = data.article state.article = data.article
} }
getData() getData()
</script> </script>

View File

@ -137,6 +137,7 @@ import { SMSEnum } from '@/enums/appEnums'
import { useLockFn } from '@/hooks/useLockFn' import { useLockFn } from '@/hooks/useLockFn'
import { useAppStore } from '@/stores/app' import { useAppStore } from '@/stores/app'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { currentPage } from '@/utils/util'
import { reactive, ref, shallowRef } from 'vue' import { reactive, ref, shallowRef } from 'vue'
enum LoginTypeEnum { enum LoginTypeEnum {
MOBILE = 'mobile', MOBILE = 'mobile',
@ -197,7 +198,14 @@ const loginFun = async (scene: LoginTypeEnum, code?: string) => {
await userStore.getUser() await userStore.getUser()
uni.$u.toast('登录成功') uni.$u.toast('登录成功')
uni.hideLoading() uni.hideLoading()
uni.navigateBack() uni.navigateBack({
success: () => {
// @ts-ignore
const { onLoad, options } = currentPage()
//
onLoad && onLoad(options)
}
})
} catch (error: any) { } catch (error: any) {
uni.hideLoading() uni.hideLoading()
throw new Error(error) throw new Error(error)

View File

@ -1,353 +1,350 @@
<template> <template>
<!-- Main Start --> <!-- Main Start -->
<!-- 头部修改头像 --> <!-- 头部修改头像 -->
<view class="header bg-white pt-[30rpx]"> <view class="header bg-white pt-[30rpx]">
<view class="flex justify-center"> <view class="flex justify-center">
<image @click="uploaderAvatar" :src="userInfo?.avatar"></image> <image @click="uploaderAvatar" :src="userInfo?.avatar"></image>
</view> </view>
<view class="mt-[20rpx] text-center text-muted text-xs" @click="uploaderAvatar">点击修改头像</view> <view class="mt-[20rpx] text-center text-muted text-xs" @click="uploaderAvatar"
</view> >点击修改头像</view
>
</view>
<!-- 用户ID --> <!-- 用户ID -->
<view class="item text-nr flex justify-between" @click="(showUserName = true), (newUsername = userInfo?.username)"> <view
<view class="label">账号</view> class="item text-nr flex justify-between"
<view class="content">{{ userInfo?.username }}</view> @click=";(showUserName = true), (newUsername = userInfo?.username)"
<u-icon name="arrow-right" size="22"></u-icon> >
</view> <view class="label">账号</view>
<view class="content">{{ userInfo?.username }}</view>
<u-icon name="arrow-right" size="22"></u-icon>
</view>
<!-- 昵称 --> <!-- 昵称 -->
<view class="item text-nr flex justify-between" @click="(showNickName = true), (newNickname = userInfo?.nickname)"> <view
<view class="label">昵称</view> class="item text-nr flex justify-between"
<view class="content">{{ userInfo?.nickname }}</view> @click=";(showNickName = true), (newNickname = userInfo?.nickname)"
<u-icon name="arrow-right" size="22"></u-icon> >
</view> <view class="label">昵称</view>
<view class="content">{{ userInfo?.nickname }}</view>
<u-icon name="arrow-right" size="22"></u-icon>
</view>
<!-- 性别 --> <!-- 性别 -->
<view class="item text-nr flex justify-between" @click="changeSex"> <view class="item text-nr flex justify-between" @click="changeSex">
<view class="label">性别</view> <view class="label">性别</view>
<view class="content">{{ userInfo?.sex }}</view> <view class="content">{{ userInfo?.sex }}</view>
<u-icon name="arrow-right" size="22"></u-icon> <u-icon name="arrow-right" size="22"></u-icon>
</view> </view>
<!-- 手机号 --> <!-- 手机号 -->
<view class="item text-nr flex justify-between"> <view class="item text-nr flex justify-between">
<view class="label">手机号</view> <view class="label">手机号</view>
<view class="content">{{ userInfo?.mobile == '' ? '未绑定手机号' : userInfo?.mobile }}</view> <view class="content">{{
userInfo?.mobile == '' ? '未绑定手机号' : userInfo?.mobile
}}</view>
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<u-button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" size="mini" type="primary" shape="circle" :plain="true"> <u-button
{{ userInfo?.mobile == '' ? '绑定手机号' : '更换手机号' }} open-type="getPhoneNumber"
</u-button> @getphonenumber="getPhoneNumber"
<!-- #endif --> size="mini"
<!-- #ifndef MP-WEIXIN --> type="primary"
<u-button @click="" size="mini" type="primary" shape="circle" :plain="true"> shape="circle"
{{ userInfo?.mobile == '' ? '绑定手机号' : '更换手机号' }} :plain="true"
</u-button> >
<!-- #endif --> {{ userInfo?.mobile == '' ? '绑定手机号' : '更换手机号' }}
</view> </u-button>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<u-button @click="" size="mini" type="primary" shape="circle" :plain="true">
{{ userInfo?.mobile == '' ? '绑定手机号' : '更换手机号' }}
</u-button>
<!-- #endif -->
</view>
<!-- 注册时间 --> <!-- 注册时间 -->
<view class="item text-nr flex justify-between"> <view class="item text-nr flex justify-between">
<view class="label">注册时间</view> <view class="label">注册时间</view>
<view class="content">{{ userInfo?.createTime }}</view> <view class="content">{{ userInfo?.createTime }}</view>
</view> </view>
<!-- 昵称修改组件 --> <!-- 昵称修改组件 -->
<u-popup v-model="showNickName" :closeable="true" mode="center" border-radius="20"> <u-popup v-model="showNickName" :closeable="true" mode="center" border-radius="20">
<view class="px-[50rpx] py-[40rpx] bg-white" style="width: 85vw"> <view class="px-[50rpx] py-[40rpx] bg-white" style="width: 85vw">
<view class="mb-[70rpx] text-xl text-center">修改昵称</view> <view class="mb-[70rpx] text-xl text-center">修改昵称</view>
<u-field v-model="newNickname" label="新昵称" placeholder="请输入新的昵称"> </u-field> <u-field v-model="newNickname" label="新昵称" placeholder="请输入新的昵称"> </u-field>
<view class="mt-[80rpx]"> <view class="mt-[80rpx]">
<u-button @click="changeNameConfirm" type="primary" shape="circle"> <u-button @click="changeNameConfirm" type="primary" shape="circle"> 确定 </u-button>
确定 </view>
</u-button> </view>
</view> </u-popup>
</view>
</u-popup>
<!-- 账号修改组件 -->
<u-popup v-model="showUserName" :closeable="true" mode="center" border-radius="20">
<view class="px-[50rpx] py-[40rpx] bg-white" style="width: 85vw">
<view class="mb-[70rpx] text-xl text-center">修改账号</view>
<u-field v-model="newUsername" label="新账号" placeholder="请输入新的账号"> </u-field>
<view class="mt-[80rpx]">
<u-button @click="changeUserNameConfirm" type="primary" shape="circle">
确定
</u-button>
</view>
</view>
</u-popup>
<!-- 性别修改组件 --> <!-- 账号修改组件 -->
<u-picker mode="selector" v-model="showPicker" confirm-color="#4173FF" :default-selector="[0]" :range="sexList" <u-popup v-model="showUserName" :closeable="true" mode="center" border-radius="20">
@confirm="changeSexConfirm" /> <view class="px-[50rpx] py-[40rpx] bg-white" style="width: 85vw">
<view class="mb-[70rpx] text-xl text-center">修改账号</view>
<!-- 账号修改组件 --> <u-field v-model="newUsername" label="新账号" placeholder="请输入新的账号"> </u-field>
<u-popup v-model="showMobilePop" :closeable="true" mode="center" border-radius="20"> <view class="mt-[80rpx]">
<view class="px-[50rpx] py-[40rpx] bg-white" style="width: 85vw"> <u-button @click="changeUserNameConfirm" type="primary" shape="circle">
<view class="mb-[70rpx] text-xl text-center">修改手机号码</view> 确定
<u-form-item borderBottom> </u-button>
<u-input </view>
class="flex-1" </view>
v-model="newMobile" </u-popup>
placeholder="请输入新的手机号码"
:border="false" <!-- 性别修改组件 -->
/> <u-picker
</u-form-item> mode="selector"
<u-form-item borderBottom> v-model="showPicker"
<u-input confirm-color="#4173FF"
class="flex-1" :default-selector="[0]"
v-model="mobileCode" :range="sexList"
placeholder="请输入验证码" @confirm="changeSexConfirm"
:border="false" />
/>
<view <!-- 账号修改组件 -->
class="border-l border-solid border-0 border-light pl-3 text-muted leading-4 ml-3 w-[180rpx]" <u-popup v-model="showMobilePop" :closeable="true" mode="center" border-radius="20">
@click="sendSms" <view class="px-[50rpx] py-[40rpx] bg-white" style="width: 85vw">
> <view class="mb-[70rpx] text-xl text-center">修改手机号码</view>
<u-verification-code <u-form-item borderBottom>
ref="uCodeRef" <u-input
:seconds="60" class="flex-1"
@change="codeChange" v-model="newMobile"
change-text="x秒" placeholder="请输入新的手机号码"
/> :border="false"
{{ codeTips }} />
</view> </u-form-item>
</u-form-item> <u-form-item borderBottom>
<view class="mt-[80rpx]"> <u-input
<u-button @click="changeCodeMobile" type="primary" shape="circle"> class="flex-1"
确定 v-model="mobileCode"
</u-button> placeholder="请输入验证码"
</view> :border="false"
</view> />
</u-popup> <view
class="border-l border-solid border-0 border-light pl-3 text-muted leading-4 ml-3 w-[180rpx]"
@click="sendSms"
>
<u-verification-code
ref="uCodeRef"
:seconds="60"
@change="codeChange"
change-text="x秒"
/>
{{ codeTips }}
</view>
</u-form-item>
<view class="mt-[80rpx]">
<u-button @click="changeCodeMobile" type="primary" shape="circle"> 确定 </u-button>
</view>
</view>
</u-popup>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { import { ref, shallowRef } from 'vue'
ref, import { onShow, onUnload } from '@dcloudio/uni-app'
shallowRef, import { getUserInfo, userEdit, userBindMobile, userMnpMobile } from '@/api/user.ts'
} from 'vue' import { smsSend } from '@/api/app'
import { import { FieldType, SMSEnum } from '@/enums/appEnums'
onShow, import { uploadFile } from '@/utils/util.ts'
onUnload
} from '@dcloudio/uni-app'
import {
getUserInfo,
userEdit,
userBindMobile,
userMnpMobile,
} from '@/api/user.ts'
import { smsSend } from '@/api/app'
import {
FieldType,
SMSEnum,
} from '@/enums/appEnums'
import {
uploadFile
} from '@/utils/util.ts'
// //
let userInfo = ref < any | null > (null) const userInfo = ref<any | null>(null)
// //
const fieldType = ref(FieldType.NONE) const fieldType = ref(FieldType.NONE)
// //
const sexList = ref < Array < string > | null > (['男', '女']) const sexList = ref<Array<string> | null>(['男', '女'])
//
const showNickName = ref < boolean | null >(false)
//
const showUserName = ref < boolean | null >(false)
//
const showPicker = ref < boolean | null >(false)
//
const showMobilePop = ref < boolean | null > (false)
//
const newNickname = ref < string > ('')
//
const newUsername = ref < string > ('')
//
const newMobile = ref < string > ('')
//
const mobileCode = ref <string > ('')
const codeTips = ref('')
const uCodeRef = shallowRef()
//
const getUser = async (): Promise < void > => {
userInfo.value = await getUserInfo()
}
//
const codeChange = (text: string) => {
codeTips.value = text
}
//
const sendSms = async () => {
if (!newMobile.value) return uni.$u.toast('请输入新的手机号码')
if (uCodeRef.value?.canGetCode) {
await smsSend({
scene: userInfo.mobile ? SMSEnum.CHANGE_MOBILE : SMSEnum.BIND_MOBILE,
mobile: newMobile.value
})
uni.$u.toast('发送成功')
uCodeRef.value?.start()
}
}
// -
const changeCodeMobile = async () => {
await userBindMobile({
type: userInfo.mobile ? 'change' : 'bind',
mobile: newMobile.value,
code: mobileCode.value,
})
getUser()
}
//
const setUserInfoFun = async (value: string): Promise < void > => {
await userEdit({
field: fieldType.value,
value: value,
})
getUser()
}
//
const uploaderAvatar = () => {
fieldType.value = FieldType.AVATAR
uni.navigateTo({
url: '/uni_modules/vk-uview-ui/components/u-avatar-cropper/u-avatar-cropper?destWidth=300&rectWidth=200&fileType=jpg',
})
}
//
const changeSex = () => {
showPicker.value = true
fieldType.value = FieldType.SEX
}
//
const changeSexConfirm = (value) => {
setUserInfoFun(value[0] + 1)
showPicker.value = false
}
//
const changeUserNameConfirm = () => {
if (newUsername.value == '') return uni.$u.toast('账号不能为空')
if (newUsername.value.length > 10) return uni.$u.toast('账号长度不得超过十位数')
fieldType.value = FieldType.USERNAME
setUserInfoFun(newUsername.value)
showUserName.value = false
}
//
const changeNameConfirm = () => {
if (newNickname.value == '') return uni.$u.toast('昵称不能为空')
if (newNickname.value.length > 10) return uni.$u.toast('昵称长度不得超过十位数')
showNickName.value = false
fieldType.value = FieldType.NICKNAME
setUserInfoFun(newNickname.value)
}
//
const getPhoneNumber = async (e): Promise < void > => {
fieldType.value = FieldType.MOBILE
const {
encryptedData,
iv,
code,
} = e.detail
let data = {
code,
encrypted_data: encryptedData,
iv,
}
if (encryptedData) {
await userMnpMobile({
...data
})
getUser()
}
}
const goPage = (url: string) => { //
uni.navigateTo({ const showNickName = ref<boolean | null>(false)
url: url, //
}) const showUserName = ref<boolean | null>(false)
} //
const showPicker = ref<boolean | null>(false)
//
const showMobilePop = ref<boolean | null>(false)
// //
uni.$on('uAvatarCropper', (path) => { const newNickname = ref<string>('')
uni.showLoading({ //
title: '正在上传中...', const newUsername = ref<string>('')
mask: true, //
}) const newMobile = ref<string>('')
uploadFile(path)
.then((res) => {
uni.hideLoading()
setUserInfoFun(res.url)
})
.catch(() => {
uni.hideLoading()
uni.$u.toast('上传失败')
})
})
onShow(async () => { //
getUser() const mobileCode = ref<string>('')
}) const codeTips = ref('')
const uCodeRef = shallowRef()
onUnload(() => {
uni.$off('uAvatarCropper') //
}) const getUser = async (): Promise<void> => {
userInfo.value = await getUserInfo()
}
//
const codeChange = (text: string) => {
codeTips.value = text
}
//
const sendSms = async () => {
if (!newMobile.value) return uni.$u.toast('请输入新的手机号码')
if (uCodeRef.value?.canGetCode) {
await smsSend({
scene: userInfo.value.mobile ? SMSEnum.CHANGE_MOBILE : SMSEnum.BIND_MOBILE,
mobile: newMobile.value
})
uni.$u.toast('发送成功')
uCodeRef.value?.start()
}
}
// -
const changeCodeMobile = async () => {
await userBindMobile({
type: userInfo.value.mobile ? 'change' : 'bind',
mobile: newMobile.value,
code: mobileCode.value
})
getUser()
}
//
const setUserInfoFun = async (value: string): Promise<void> => {
await userEdit({
field: fieldType.value,
value: value
})
getUser()
}
//
const uploaderAvatar = () => {
fieldType.value = FieldType.AVATAR
uni.navigateTo({
url: '/uni_modules/vk-uview-ui/components/u-avatar-cropper/u-avatar-cropper?destWidth=300&rectWidth=200&fileType=jpg'
})
}
//
const changeSex = () => {
showPicker.value = true
fieldType.value = FieldType.SEX
}
//
const changeSexConfirm = (value) => {
setUserInfoFun(value[0] + 1)
showPicker.value = false
}
//
const changeUserNameConfirm = () => {
if (newUsername.value == '') return uni.$u.toast('账号不能为空')
if (newUsername.value.length > 10) return uni.$u.toast('账号长度不得超过十位数')
fieldType.value = FieldType.USERNAME
setUserInfoFun(newUsername.value)
showUserName.value = false
}
//
const changeNameConfirm = () => {
if (newNickname.value == '') return uni.$u.toast('昵称不能为空')
if (newNickname.value.length > 10) return uni.$u.toast('昵称长度不得超过十位数')
showNickName.value = false
fieldType.value = FieldType.NICKNAME
setUserInfoFun(newNickname.value)
}
//
const getPhoneNumber = async (e): Promise<void> => {
fieldType.value = FieldType.MOBILE
const { encryptedData, iv, code } = e.detail
const data = {
code,
encrypted_data: encryptedData,
iv
}
if (encryptedData) {
await userMnpMobile({
...data
})
getUser()
}
}
const goPage = (url: string) => {
uni.navigateTo({
url: url
})
}
//
uni.$on('uAvatarCropper', (path) => {
uni.showLoading({
title: '正在上传中...',
mask: true
})
uploadFile(path)
.then((res) => {
uni.hideLoading()
setUserInfoFun(res.url)
})
.catch(() => {
uni.hideLoading()
uni.$u.toast('上传失败')
})
})
onShow(async () => {
getUser()
})
onUnload(() => {
uni.$off('uAvatarCropper')
})
</script> </script>
<style lang="scss"> <style lang="scss">
.header { .header {
width: 100%; width: 100%;
height: 240rpx; height: 240rpx;
// border-radius: 14rpx; // border-radius: 14rpx;
image { image {
width: 120rpx; width: 120rpx;
height: 120rpx; height: 120rpx;
border-radius: 50%; border-radius: 50%;
} }
} }
.item { .item {
margin-top: 2rpx; margin-top: 2rpx;
padding: 30rpx 20rpx; padding: 30rpx 20rpx;
// border-radius: 14rpx; // border-radius: 14rpx;
background-color: #ffffff; background-color: #ffffff;
.label { .label {
width: 150rpx; width: 150rpx;
} }
.content { .content {
flex: 1; flex: 1;
width: 80%; width: 80%;
} }
.bind { .bind {
height: 56rpx; height: 56rpx;
border-width: 1rpx; border-width: 1rpx;
border-style: solid; border-style: solid;
} }
} }
.license { .license {
margin-top: 80rpx; margin-top: 80rpx;
color: #a7a7a7; color: #a7a7a7;
} }
</style> </style>

View File

@ -1,97 +1,108 @@
<template> <template>
<view class="user-set"> <view class="user-set">
<navigator :url="`/pages/user_data/user_data`"> <navigator :url="`/pages/user_data/user_data`">
<view class="item flex bg-white mt-[20rpx]"> <view class="item flex bg-white mt-[20rpx]">
<u-avatar :src="userInfo.avatar" shape="square"></u-avatar> <u-avatar :src="userInfo.avatar" shape="square"></u-avatar>
<view class="ml-[20rpx] flex flex-1 justify-between"> <view class="ml-[20rpx] flex flex-1 justify-between">
<view> <view>
<view class="mb-[15rpx] text-xl font-medium">{{ userInfo.nickname }}</view> <view class="mb-[15rpx] text-xl font-medium">{{ userInfo.nickname }}</view>
<view class="text-content text-xs">账号{{ userInfo.username }}</view> <view class="text-content text-xs">账号{{ userInfo.username }}</view>
</view> </view>
<u-icon name="arrow-right" color="#666"></u-icon> <u-icon name="arrow-right" color="#666"></u-icon>
</view> </view>
</view> </view>
</navigator> </navigator>
<view class="item bg-white mt-[20rpx] btn-border flex flex-1 justify-between"> <view
<view class="text-xl">登录密码</view> class="item bg-white mt-[20rpx] btn-border flex flex-1 justify-between"
<u-icon name="arrow-right" color="#666"></u-icon> @click="show = true"
</view> >
<view class="item bg-white btn-border flex flex-1 justify-between"> <view class="text-xl">登录密码</view>
<view class="text-xl">绑定微信</view> <u-icon name="arrow-right" color="#666"></u-icon>
<view class=" flex justify-between"> </view>
<view class="text-muted mr-[20rpx]"> <view class="item bg-white btn-border flex flex-1 justify-between">
{{ userInfo.isBindMnp ? '已绑定' : '未绑定' }} <view class="text-xl">绑定微信</view>
</view> <view class="flex justify-between">
<u-icon name="arrow-right" color="#666"></u-icon> <view class="text-muted mr-[20rpx]">
</view> {{ userInfo.isBindMnp ? '已绑定' : '未绑定' }}
</view> </view>
<u-icon name="arrow-right" color="#666"></u-icon>
</view>
</view>
<navigator :url="`/pages/agreement/agreement?type=${ AgreementEnum.PRIVACY }`"> <navigator :url="`/pages/agreement/agreement?type=${AgreementEnum.PRIVACY}`">
<view class="item bg-white mt-[20rpx] btn-border flex flex-1 justify-between"> <view class="item bg-white mt-[20rpx] btn-border flex flex-1 justify-between">
<view class="text-xl">隐私政策</view> <view class="text-xl">隐私政策</view>
<u-icon name="arrow-right" color="#666"></u-icon> <u-icon name="arrow-right" color="#666"></u-icon>
</view> </view>
</navigator> </navigator>
<navigator :url="`/pages/agreement/agreement?type=${ AgreementEnum.SERVICE }`"> <navigator :url="`/pages/agreement/agreement?type=${AgreementEnum.SERVICE}`">
<view class="item bg-white btn-border flex flex-1 justify-between"> <view class="item bg-white btn-border flex flex-1 justify-between">
<view class="text-xl">服务协议</view> <view class="text-xl">服务协议</view>
<u-icon name="arrow-right" color="#666"></u-icon> <u-icon name="arrow-right" color="#666"></u-icon>
</view> </view>
</navigator> </navigator>
<view class="item bg-white btn-border flex flex-1 justify-between"> <view class="item bg-white btn-border flex flex-1 justify-between">
<view class="text-xl">关于我们</view> <view class="text-xl">关于我们</view>
<view class="flex justify-between"> <view class="flex justify-between">
<view class="text-muted mr-[20rpx]"> <view class="text-muted mr-[20rpx]">
{{ appStore.config.version }} {{ appStore.config.version }}
</view> </view>
<u-icon name="arrow-right" color="#666"></u-icon> <u-icon name="arrow-right" color="#666"></u-icon>
</view> </view>
</view> </view>
</view> <u-action-sheet :list="list" v-model="show" @click="handleClick"></u-action-sheet>
</view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { import { getUserInfo } from '@/api/user'
getUserInfo import { onShow } from '@dcloudio/uni-app'
} from '@/api/user' import { reactive, ref } from 'vue'
import { import { useAppStore } from '@/stores/app'
onShow import { AgreementEnum } from '@/enums/agreementEnums'
} from '@dcloudio/uni-app'
import {
reactive,
ref,
} from 'vue'
import {
useAppStore
} from '@/stores/app'
import {
AgreementEnum
} from '@/enums/agreementEnums'
const appStore = useAppStore() const appStore = useAppStore()
let userInfo = ref({}) const userInfo = ref({})
const list = ref([
{
text: '修改密码'
},
{
text: '忘记密码'
}
])
const show = ref(false)
const getUser = async () => {
const res = await getUserInfo()
console.log(res, 'res')
const getUser = async () => { userInfo.value = res
let res = await getUserInfo() }
console.log(res, 'res')
userInfo.value = res const handleClick = (index: number) => {
switch (index) {
case 0:
uni.navigateTo({ url: '/pages/change_password/change_password' })
break
case 1:
uni.navigateTo({ url: '/pages/forget_pwd/forget_pwd' })
break
}
}
} onShow(() => {
getUser()
onShow(() => { })
getUser()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.user-set { .user-set {
.item { .item {
padding: 30rpx; padding: 30rpx;
} }
.btn-border { .btn-border {
border-bottom: 1rpx solid $u-form-item-border-color; border-bottom: 1rpx solid $u-form-item-border-color;
} }
} }
</style> </style>