diff --git a/src/pages.json b/src/pages.json
index 7c1cdd4..b32a510 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -217,6 +217,13 @@
"style": {
"navigationBarTitleText": "推荐列表"
}
+ },
+ {
+ "path": "pages/user/change-password",
+ "type": "page",
+ "style": {
+ "navigationBarTitleText": "修改密码"
+ }
}
],
"subPackages": []
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 919c5b1..3bec0ff 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -197,7 +197,7 @@ const closeUserMenu = () => {
const handleModifyPassword = () => {
showUserMenu.value = false
uni.navigateTo({
- url: '/pages/user/modify-password',
+ url: '/pages/user/change-password',
})
}
diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue
index ed72aaa..e873b8f 100644
--- a/src/pages/login/index.vue
+++ b/src/pages/login/index.vue
@@ -64,12 +64,16 @@ const handleLogin = async () => {
}
try {
const res = await loginAPI({ username: account.value, password: password.value })
- uni.setStorageSync('loginData', res.data)
- uni.setStorageSync('x-token', res.data.token)
- useStore.setUserInfo()
- uni.reLaunch({ url: '/pages/index/index' })
- } catch (error) {
- uni.showToast({ title: '登录失败', icon: 'none' })
+ if (res.code === 0) {
+ uni.setStorageSync('loginData', res.data)
+ uni.setStorageSync('x-token', res.data.token)
+ useStore.setUserInfo()
+ uni.reLaunch({ url: '/pages/index/index' })
+ } else {
+ uni.showModal({ title: '登录失败', content: res.msg || '登录失败', showCancel: false })
+ }
+ } catch (error: any) {
+ uni.showModal({ title: '登录失败', content: error?.msg || '登录失败', showCancel: false })
}
}
diff --git a/src/pages/user/change-password.vue b/src/pages/user/change-password.vue
new file mode 100644
index 0000000..03af71a
--- /dev/null
+++ b/src/pages/user/change-password.vue
@@ -0,0 +1,74 @@
+
+
+{
+ style: {
+ navigationBarTitleText: '修改密码',
+ },
+}
+
+
+
+
+
+ 修改密码
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/service/user/index.ts b/src/service/user/index.ts
new file mode 100644
index 0000000..001fe80
--- /dev/null
+++ b/src/service/user/index.ts
@@ -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>('/user/updatePassword', data)
diff --git a/src/types/uni-pages.d.ts b/src/types/uni-pages.d.ts
index b4b5f09..bb95c93 100644
--- a/src/types/uni-pages.d.ts
+++ b/src/types/uni-pages.d.ts
@@ -28,7 +28,8 @@ interface NavigateToOptions {
"/pages/my/spend" |
"/pages/my/subordinate" |
"/pages/my/user-info" |
- "/pages/recommend/index";
+ "/pages/recommend/index" |
+ "/pages/user/change-password";
}
interface RedirectToOptions extends NavigateToOptions {}