From 056ccd463e47600c7be3e6914ea1101846285fad Mon Sep 17 00:00:00 2001
From: fanpeng <438123081@qq.com>
Date: Mon, 9 Jun 2025 14:37:37 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=80=80=E5=87=BA?=
=?UTF-8?q?=E7=99=BB=E5=BD=95=E4=B8=8E=E4=B8=8A=E4=BC=A0=E5=A4=B4=E5=83=8F?=
=?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/user.js | 9 +++
pages/main/mine.vue | 26 ++++++-
pages/user/updateEmail.vue | 51 +++++++------
pages/user/updateName.vue | 24 +++----
pages/user/updatePassword.vue | 53 +++++++-------
pages/user/userInfo.vue | 132 ++++++++++++++++++++++------------
pages/user/verifyEmail.vue | 39 +++++-----
7 files changed, 204 insertions(+), 130 deletions(-)
diff --git a/api/user.js b/api/user.js
index c927885..a160ff4 100644
--- a/api/user.js
+++ b/api/user.js
@@ -136,3 +136,12 @@ export function getWebUrlRequest(data) {
data
})
}
+
+// 退出登录
+export function logoutRequest(data) {
+ return request({
+ url: '/v3/user/logout',
+ method: 'POST',
+ data
+ })
+}
diff --git a/pages/main/mine.vue b/pages/main/mine.vue
index 67085e5..5af3ffe 100644
--- a/pages/main/mine.vue
+++ b/pages/main/mine.vue
@@ -56,9 +56,14 @@
>切换环境
+
+
+
+ 退出
+
因智能门锁与账号绑定,登录为手机号登录
@@ -105,7 +110,7 @@
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { useLockStore } from '@/stores/lock'
- import { phoneLoginRequest } from '@/api/user'
+ import { phoneLoginRequest, logoutRequest } from '@/api/user'
import env from '@/config/env'
import { setStorage, getStorage, removeStorage } from '@/utils/storage'
import { useNotificationStore } from '@/stores/notification'
@@ -260,6 +265,25 @@
type
}
})
+ },
+ logout() {
+ uni.showModal({
+ title: '提示',
+ content: '确定退出登录吗?',
+ success: async res => {
+ if (res.confirm) {
+ await logoutRequest()
+ removeStorage('token')
+ removeStorage('openid')
+ removeStorage('userInfo')
+ removeStorage('lockList')
+ this.routeJump({
+ name: 'login',
+ type: 'reLaunch'
+ })
+ }
+ }
+ })
}
}
}
diff --git a/pages/user/updateEmail.vue b/pages/user/updateEmail.vue
index 1999c9a..441b380 100644
--- a/pages/user/updateEmail.vue
+++ b/pages/user/updateEmail.vue
@@ -168,28 +168,27 @@
}
.input-email {
- border-radius: 16rpx;
- background: #ffffff;
- margin-left: 35rpx;
- margin-top: 48rpx;
- height: 108rpx;
width: 616rpx;
- padding-left: 32rpx;
+ height: 108rpx;
padding-right: 32rpx;
+ padding-left: 32rpx;
+ margin-top: 48rpx;
+ margin-left: 35rpx;
+ background: #ffffff;
+ border-radius: 16rpx;
}
.button-verify {
- margin-top: 48rpx;
- height: 108rpx;
width: 265rpx;
- line-height: 108rpx;
- border-radius: 16rpx;
- text-align: center;
- font-size: 32rpx;
+ height: 108rpx;
+ margin-top: 48rpx;
margin-left: 35rpx;
-
- background: #63b8af;
+ font-size: 32rpx;
+ line-height: 108rpx;
color: #ffffff;
+ text-align: center;
+ background: #63b8af;
+ border-radius: 16rpx;
}
.view-top {
@@ -198,14 +197,14 @@
}
.input-verify {
- border-radius: 16rpx;
- background: #ffffff;
- margin-left: 35rpx;
- margin-top: 48rpx;
- height: 108rpx;
width: 316rpx;
- padding-left: 32rpx;
+ height: 108rpx;
padding-right: 32rpx;
+ padding-left: 32rpx;
+ margin-top: 48rpx;
+ margin-left: 35rpx;
+ background: #ffffff;
+ border-radius: 16rpx;
}
.input-placeholder {
@@ -216,15 +215,15 @@
}
.button {
- margin-top: 32rpx;
- margin-left: 35rpx;
width: 680rpx;
height: 96rpx;
+ margin-top: 32rpx;
+ margin-left: 35rpx;
+ font-size: 32rpx;
+ line-height: 96rpx;
+ color: #ffffff;
+ text-align: center;
background: #63b8af;
border-radius: 16rpx;
- line-height: 96rpx;
- text-align: center;
- font-size: 32rpx;
- color: #ffffff;
}
diff --git a/pages/user/updateName.vue b/pages/user/updateName.vue
index 229b3b5..ca237d2 100644
--- a/pages/user/updateName.vue
+++ b/pages/user/updateName.vue
@@ -84,14 +84,14 @@
diff --git a/pages/user/updatePassword.vue b/pages/user/updatePassword.vue
index 031d61b..ba2acca 100644
--- a/pages/user/updatePassword.vue
+++ b/pages/user/updatePassword.vue
@@ -145,14 +145,14 @@
diff --git a/pages/user/userInfo.vue b/pages/user/userInfo.vue
index d69cfe3..c6f907b 100644
--- a/pages/user/userInfo.vue
+++ b/pages/user/userInfo.vue
@@ -1,6 +1,7 @@
+
+
+
+
+
+ 头像
+
+
+
+
+
+
+
昵称
@@ -146,13 +163,33 @@
}
this.pending = false
},
+ chooseImage() {
+ const that = this
+ uni.chooseImage({
+ count: 1,
+ sourceType: ['camera', 'album'],
+ crop: {
+ quality: 60,
+ width: 108,
+ height: 108
+ },
+ success: res => {
+ const data = res.tempFiles[0]
+ const list = data.path.split('/')
+ const filename = list[list.length - 1]
+ that.uploadRequest({
+ ...data,
+ filename
+ })
+ }
+ })
+ },
chooseAvatar(e) {
const that = this
if (that.pending) {
return
}
that.pending = true
-
const path = e.detail.avatarUrl
const list = path.split('/')
const filename = list[list.length - 1]
@@ -160,58 +197,65 @@
filePath: path,
async success(res) {
const size = res.size
- const { code, data } = await getUploadParamsRequest({
+ that.uploadRequest({
size,
- module: 'avatar',
- userId: that.userInfo.userId,
- filename
+ filename,
+ path
})
- if (code === 0) {
- uni.uploadFile({
- url: data.uploadUrl,
- filePath: path,
- name: 'file',
- formData: data.formData,
- async success() {
- const { code: updateCode } = await updateUserInfoRequest({
- headUrl: data.fileUrl
- })
- if (updateCode === 0) {
- that.updateUserInfo({
- ...that.userInfo,
- headUrl: data.fileUrl
- })
- uni.showToast({
- title: '头像更新成功',
- icon: 'none'
- })
- } else {
- uni.showToast({
- title: '头像更新失败',
- icon: 'none'
- })
- }
- that.pending = false
- },
- fail(res) {
- console.log('上传失败', res)
- console.log(data.uploadUrl, path, data.formData)
- uni.showToast({
- title: '头像更新失败',
- icon: 'none'
- })
- that.pending = false
- }
+ }
+ })
+ },
+ async uploadRequest(params) {
+ const that = this
+ const { code, data } = await getUploadParamsRequest({
+ size: params.size,
+ module: 'avatar',
+ userId: that.userInfo.userId,
+ filename: params.filename
+ })
+ if (code === 0) {
+ uni.uploadFile({
+ url: data.uploadUrl,
+ filePath: params.path,
+ name: 'file',
+ formData: data.formData,
+ async success() {
+ const { code: updateCode } = await updateUserInfoRequest({
+ headUrl: data.fileUrl
})
- } else {
+ if (updateCode === 0) {
+ that.updateUserInfo({
+ ...that.userInfo,
+ headUrl: data.fileUrl
+ })
+ uni.showToast({
+ title: '头像更新成功',
+ icon: 'none'
+ })
+ } else {
+ uni.showToast({
+ title: '头像更新失败',
+ icon: 'none'
+ })
+ }
+ that.pending = false
+ },
+ fail(res) {
+ console.log('上传失败', res)
uni.showToast({
title: '头像更新失败',
icon: 'none'
})
that.pending = false
}
- }
- })
+ })
+ } else {
+ uni.showToast({
+ title: '头像更新失败',
+ icon: 'none'
+ })
+ that.pending = false
+ }
},
toUpdateName() {
this.routeJump({
diff --git a/pages/user/verifyEmail.vue b/pages/user/verifyEmail.vue
index 17b5209..5b1343f 100644
--- a/pages/user/verifyEmail.vue
+++ b/pages/user/verifyEmail.vue
@@ -122,17 +122,16 @@
}
.button-verify {
- margin-top: 48rpx;
- height: 108rpx;
width: 265rpx;
- line-height: 108rpx;
- border-radius: 16rpx;
- text-align: center;
- font-size: 32rpx;
+ height: 108rpx;
+ margin-top: 48rpx;
margin-left: 35rpx;
-
- background: #63b8af;
+ font-size: 32rpx;
+ line-height: 108rpx;
color: #ffffff;
+ text-align: center;
+ background: #63b8af;
+ border-radius: 16rpx;
}
.view-top {
@@ -141,14 +140,14 @@
}
.input {
- border-radius: 16rpx;
- background: #ffffff;
- margin-left: 35rpx;
- margin-top: 48rpx;
- height: 108rpx;
width: 316rpx;
- padding-left: 32rpx;
+ height: 108rpx;
padding-right: 32rpx;
+ padding-left: 32rpx;
+ margin-top: 48rpx;
+ margin-left: 35rpx;
+ background: #ffffff;
+ border-radius: 16rpx;
}
.input-placeholder {
@@ -159,15 +158,15 @@
}
.button {
- margin-top: 32rpx;
- margin-left: 35rpx;
width: 680rpx;
height: 96rpx;
+ margin-top: 32rpx;
+ margin-left: 35rpx;
+ font-size: 32rpx;
+ line-height: 96rpx;
+ color: #ffffff;
+ text-align: center;
background: #63b8af;
border-radius: 16rpx;
- line-height: 96rpx;
- text-align: center;
- font-size: 32rpx;
- color: #ffffff;
}