1
This commit is contained in:
parent
cd569f2881
commit
71bdaaeb4c
@ -217,6 +217,13 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "推荐列表"
|
"navigationBarTitleText": "推荐列表"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/user/change-password",
|
||||||
|
"type": "page",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "修改密码"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"subPackages": []
|
"subPackages": []
|
||||||
|
|||||||
@ -197,7 +197,7 @@ const closeUserMenu = () => {
|
|||||||
const handleModifyPassword = () => {
|
const handleModifyPassword = () => {
|
||||||
showUserMenu.value = false
|
showUserMenu.value = false
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/user/modify-password',
|
url: '/pages/user/change-password',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -64,12 +64,16 @@ const handleLogin = async () => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const res = await loginAPI({ username: account.value, password: password.value })
|
const res = await loginAPI({ username: account.value, password: password.value })
|
||||||
uni.setStorageSync('loginData', res.data)
|
if (res.code === 0) {
|
||||||
uni.setStorageSync('x-token', res.data.token)
|
uni.setStorageSync('loginData', res.data)
|
||||||
useStore.setUserInfo()
|
uni.setStorageSync('x-token', res.data.token)
|
||||||
uni.reLaunch({ url: '/pages/index/index' })
|
useStore.setUserInfo()
|
||||||
} catch (error) {
|
uni.reLaunch({ url: '/pages/index/index' })
|
||||||
uni.showToast({ title: '登录失败', icon: 'none' })
|
} else {
|
||||||
|
uni.showModal({ title: '登录失败', content: res.msg || '登录失败', showCancel: false })
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
uni.showModal({ title: '登录失败', content: error?.msg || '登录失败', showCancel: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
74
src/pages/user/change-password.vue
Normal file
74
src/pages/user/change-password.vue
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page;推荐使用json5,更强大,且允许注释 -->
|
||||||
|
<route lang="json5">
|
||||||
|
{
|
||||||
|
style: {
|
||||||
|
navigationBarTitleText: '修改密码',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</route>
|
||||||
|
<template>
|
||||||
|
<view class="min-h-screen flex items-center justify-center bg-gray-200 px-4">
|
||||||
|
<view
|
||||||
|
class="w-full max-w-md mx-auto bg-white rounded-2xl shadow-lg p-8 border border-gray-100 box-border mx-4"
|
||||||
|
>
|
||||||
|
<view class="mb-6 text-center">
|
||||||
|
<text class="text-2xl font-bold text-gray-800">修改密码</text>
|
||||||
|
</view>
|
||||||
|
<view class="mb-4">
|
||||||
|
<input
|
||||||
|
v-model="oldPassword"
|
||||||
|
type="password"
|
||||||
|
placeholder="请输入旧密码"
|
||||||
|
class="w-full h-12 px-4 border-2 border-gray-300 rounded-lg focus:border-pink-400 outline-none bg-gray-50 text-base transition-all duration-200 box-border"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="mb-6">
|
||||||
|
<input
|
||||||
|
v-model="newPassword"
|
||||||
|
type="password"
|
||||||
|
placeholder="请输入新密码"
|
||||||
|
class="w-full h-12 px-4 border-2 border-gray-300 rounded-lg focus:border-pink-400 outline-none bg-gray-50 text-base transition-all duration-200 box-border"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<button
|
||||||
|
class="w-full h-12 bg-black text-white rounded-lg text-base font-semibold flex items-center justify-center"
|
||||||
|
@click="handleChangePassword"
|
||||||
|
>
|
||||||
|
<span class="w-full text-center">确定</span>
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { changePasswordAPI } from '@/service/user'
|
||||||
|
|
||||||
|
const oldPassword = ref('')
|
||||||
|
const newPassword = ref('')
|
||||||
|
|
||||||
|
const handleChangePassword = async () => {
|
||||||
|
if (!oldPassword.value || !newPassword.value) {
|
||||||
|
uni.showToast({ title: '请填写完整', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await changePasswordAPI({
|
||||||
|
oldPassword: oldPassword.value,
|
||||||
|
newPassword: newPassword.value,
|
||||||
|
})
|
||||||
|
console.log(111111111111111111111111)
|
||||||
|
console.log(res)
|
||||||
|
if (res.code === 0) {
|
||||||
|
uni.showToast({ title: '修改成功', icon: 'success' })
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack()
|
||||||
|
}, 1000)
|
||||||
|
} else {
|
||||||
|
uni.showModal({ title: '修改失败', content: res.msg || '修改失败', showCancel: false })
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
uni.showModal({ title: '修改失败', content: e?.msg || '修改失败', showCancel: false })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
5
src/service/user/index.ts
Normal file
5
src/service/user/index.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
import type { BaseResponse } from '../login/type'
|
||||||
|
|
||||||
|
export const changePasswordAPI = (data: { oldPassword: string; newPassword: string }) =>
|
||||||
|
request.post<BaseResponse<any>>('/user/updatePassword', data)
|
||||||
3
src/types/uni-pages.d.ts
vendored
3
src/types/uni-pages.d.ts
vendored
@ -28,7 +28,8 @@ interface NavigateToOptions {
|
|||||||
"/pages/my/spend" |
|
"/pages/my/spend" |
|
||||||
"/pages/my/subordinate" |
|
"/pages/my/subordinate" |
|
||||||
"/pages/my/user-info" |
|
"/pages/my/user-info" |
|
||||||
"/pages/recommend/index";
|
"/pages/recommend/index" |
|
||||||
|
"/pages/user/change-password";
|
||||||
}
|
}
|
||||||
interface RedirectToOptions extends NavigateToOptions {}
|
interface RedirectToOptions extends NavigateToOptions {}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user