diff --git a/App.vue b/App.vue
index 7143e68..f8e8dce 100644
--- a/App.vue
+++ b/App.vue
@@ -1,11 +1,20 @@
-
-
+
+
diff --git a/pages/updateEmail/updateEmail.vue b/pages/updateEmail/updateEmail.vue
index c9f7cc1..cc45226 100644
--- a/pages/updateEmail/updateEmail.vue
+++ b/pages/updateEmail/updateEmail.vue
@@ -24,7 +24,8 @@ export default {
text: '获取验证码',
verificationCode: '',
token: '',
- email: ''
+ email: '',
+ pending: false
}
},
computed: {
@@ -74,7 +75,18 @@ export default {
}
},
async toUpdateEmail () {
+ if(!test.email(this.email)){
+ uni.showToast({
+ title: '请输入正确的邮箱',
+ icon: 'none'
+ })
+ return
+ }
if (this.verificationCode.length === 6 && test.digits(this.verificationCode)) {
+ if(this.pending){
+ return
+ }
+ this.pending = true
const params = {
verificationCode: this.verificationCode,
email: this.email
@@ -102,6 +114,7 @@ export default {
icon: 'none'
})
}
+ this.pending = false
} else {
uni.showToast({
title: '验证码为6位纯数字',
@@ -112,10 +125,11 @@ export default {
updateTime () {
let time = 120
this.text = `${time} s`
+ const now = new Date().getTime()
const timer = setInterval(() => {
- time--
- this.text = `${time} s`
- if (time === 0) {
+ const second = parseInt((new Date().getTime() - now) / 1000)
+ this.text = `${time - second} s`
+ if (time <= second) {
clearInterval(timer)
this.text = '获取验证码'
}
diff --git a/pages/updateName/updateName.vue b/pages/updateName/updateName.vue
index ede76f0..97f7538 100644
--- a/pages/updateName/updateName.vue
+++ b/pages/updateName/updateName.vue
@@ -14,7 +14,8 @@ import { updateUserInfoRequest } from '@/api/user'
export default {
data() {
return {
- nickname: ''
+ nickname: '',
+ pending: false
}
},
computed: {
@@ -37,6 +38,10 @@ export default {
})
return
}
+ if(this.pending) {
+ return
+ }
+ this.pending = true
const { code } = await updateUserInfoRequest({
nickname: this.nickname
})
@@ -59,6 +64,7 @@ export default {
icon: 'none'
})
}
+ this.pending = false
}
}
}
diff --git a/pages/updatePassword/updatePassword.vue b/pages/updatePassword/updatePassword.vue
index ceb5eea..11462b3 100644
--- a/pages/updatePassword/updatePassword.vue
+++ b/pages/updatePassword/updatePassword.vue
@@ -21,7 +21,8 @@ export default {
return {
oldPassword: '',
newPassword: '',
- confirmPassword: ''
+ confirmPassword: '',
+ pending: false
}
},
computed: {
@@ -61,6 +62,10 @@ export default {
})
return
}
+ if(this.pending) {
+ return
+ }
+ this.pending = true
const { code, message } = await updatePasswordRequest({
oldPassword: this.oldPassword,
newPassword: this.newPassword,
@@ -85,6 +90,7 @@ export default {
icon: 'none'
})
}
+ this.pending = false
}
}
}
diff --git a/pages/updateSafeQuestion/updateSafeQuestion.vue b/pages/updateSafeQuestion/updateSafeQuestion.vue
new file mode 100644
index 0000000..53d323f
--- /dev/null
+++ b/pages/updateSafeQuestion/updateSafeQuestion.vue
@@ -0,0 +1,252 @@
+
+
+ 如果手机丢了,可以通过回答设置的安全问题来登录新设备
+
+
+ {{answer[0].question}}
+
+
+
+
+
+
+
+ {{answer[1].question}}
+
+
+
+
+
+
+
+ {{answer[2].question}}
+
+
+
+
+
+ 保存
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/userInfo/userInfo.vue b/pages/userInfo/userInfo.vue
index c9e3a71..5368d89 100644
--- a/pages/userInfo/userInfo.vue
+++ b/pages/userInfo/userInfo.vue
@@ -57,7 +57,7 @@
-
+
@@ -69,6 +69,11 @@ import { getUploadParamsRequest } from '@/api/file'
import { updateUserInfoRequest } from '@/api/user'
export default {
+ data() {
+ return {
+ pending: false
+ }
+ },
computed: {
...mapState(useUserStore, ['userInfo'])
},
@@ -76,7 +81,14 @@ export default {
...mapActions(useBasicStore, ['routeJump']),
...mapActions(useUserStore, ['updateUserInfo']),
chooseAvatar(e) {
+ console.log(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]
@@ -115,13 +127,16 @@ export default {
icon: 'none'
})
}
+ that.pending = false
},
fail(res) {
- console.log(res)
+ console.log('上传失败', res)
+ console.log(data.uploadUrl, path, data.formData)
uni.showToast({
title: '头像更新失败',
icon: 'none'
})
+ that.pending = false
}
})
} else {
@@ -129,6 +144,7 @@ export default {
title: '头像更新失败',
icon: 'none'
})
+ that.pending = false
}
}
})
@@ -155,9 +171,15 @@ export default {
})
},
toSafeQuestion() {
- this.routeJump({
- name: 'safeQuestion'
- })
+ if(this.userInfo.haveSafeAnswer) {
+ this.routeJump({
+ name: 'safeQuestion'
+ })
+ } else {
+ this.routeJump({
+ name: 'updateSafeQuestion'
+ })
+ }
}
}
}
diff --git a/pages/verifyEmail/verifyEmail.vue b/pages/verifyEmail/verifyEmail.vue
index 2afdd24..d041c40 100644
--- a/pages/verifyEmail/verifyEmail.vue
+++ b/pages/verifyEmail/verifyEmail.vue
@@ -75,10 +75,11 @@ export default {
updateTime() {
let time = 120
this.text = `${time} s`
+ const now = new Date().getTime()
const timer = setInterval(() => {
- time--
- this.text = `${time} s`
- if(time === 0) {
+ const second = parseInt((new Date().getTime() - now) / 1000)
+ this.text = `${time - second} s`
+ if (time <= second) {
clearInterval(timer)
this.text = '获取验证码'
}
diff --git a/pages/webview/webview.vue b/pages/webview/webview.vue
index 32c3aec..29ca69c 100644
--- a/pages/webview/webview.vue
+++ b/pages/webview/webview.vue
@@ -23,6 +23,10 @@ export default {
userAgreement: {
url: '/app/userAgreement',
name: '用户协议'
+ },
+ privacy: {
+ url: '/app/privacy',
+ name: '隐私政策'
}
}
const item = officialAccounts[options?.type] || officialAccounts['default']
diff --git a/stores/basic.js b/stores/basic.js
index 2477917..351e5fd 100644
--- a/stores/basic.js
+++ b/stores/basic.js
@@ -42,6 +42,11 @@ const pages = [
path: '/pages/safeQuestion/safeQuestion',
tabBar: false
},
+ {
+ name: 'updateSafeQuestion',
+ path: '/pages/updateSafeQuestion/updateSafeQuestion',
+ tabBar: false
+ },
{
name: 'webview',
path: '/pages/webview/webview',
@@ -64,7 +69,6 @@ export const useBasicStore = defineStore('basic', {
/* data 入参 name string页面名称 type string跳转方式 params object传递参数 delta number返回页面数
* 具体入参查看文档 https://www.uviewui.com/js/route.html */
routeJump(data) {
- console.log(data)
const page = pages.find((page) => {
return page.name === data.name
})
diff --git a/stores/user.js b/stores/user.js
index a431d0f..145a64d 100644
--- a/stores/user.js
+++ b/stores/user.js
@@ -2,16 +2,32 @@
* @description 用户信息数据持久化
*/
import { defineStore } from 'pinia'
+import { getUserInfoRequest } from '@/api/user'
export const useUserStore = defineStore('user', {
state() {
return {
- userInfo: {}
+ // 用户信息
+ userInfo: {},
+ // 登录状态
+ isLogin: false
}
},
actions: {
updateUserInfo(data) {
this.userInfo = data
+ },
+ updateLoginStatus(status) {
+ this.isLogin = status
+ },
+ async login() {
+ uni.setStorageSync('token', '1041|9UcJSZO3C1uuDnIgG8jXTxNXDIiCrvvIhdj7bFF8c1c07b2d')
+ this.isLogin = true
+ const { code, data } = await getUserInfoRequest()
+ if(code === 0) {
+ this.updateUserInfo(data)
+ }
+ return this.isLogin
}
}
})
diff --git a/utils/request.js b/utils/request.js
index ba417e5..f7567ae 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -31,12 +31,29 @@ const request = (config) => {
async success(res) {
const { statusCode, data } = res
if (statusCode === 200) {
- // 根据情况添加处理代码
- resolve({
- code: data.errorCode,
- data: data.data,
- message: data.errorMsg
- })
+ const code = data.errorCode
+ const message = data.errorMsg
+ if(code === 403) {
+ uni.removeStorageSync('token')
+ getApp().globalData.updateIsLogin(false)
+ resolve({ code: 403, data, message: '登录已过期' })
+ uni.showModal({
+ title: '提示',
+ content: '登录已过期,请重新登录',
+ showCancel: false,
+ success() {
+ uni.reLaunch({
+ url: '/pages/home/home'
+ })
+ }
+ })
+ } else {
+ resolve({
+ code,
+ data: data.data,
+ message
+ })
+ }
} else {
resolve({ code: -1, data, message: '网络不太好哦,请稍后再试' })
}