diff --git a/App.vue b/App.vue index ab386a2..412bcca 100644 --- a/App.vue +++ b/App.vue @@ -31,7 +31,7 @@ return 'XHJ' } // #endif - return 'PRE' + return 'XHJ' } }, computed: { diff --git a/api/user.js b/api/user.js index a160ff4..2024731 100644 --- a/api/user.js +++ b/api/user.js @@ -38,6 +38,15 @@ export function unbindEmailTokenRequest(data) { }) } +// 获取解绑手机号token +export function unbindPhoneTokenRequest(data) { + return request({ + url: '/user/unbindPhoneToken', + method: 'POST', + data + }) +} + // 修改绑定邮箱 export function updateEmailRequest(data) { return request({ @@ -47,6 +56,15 @@ export function updateEmailRequest(data) { }) } +// 修改绑定手机号 +export function updatePhoneRequest(data) { + return request({ + url: '/user/bindPhone', + method: 'POST', + data + }) +} + // 获取邮箱验证码 export function getEmailCodeRequest(data) { return request({ @@ -137,6 +155,15 @@ export function getWebUrlRequest(data) { }) } +// 删除账号 +export function deleteAccountRequest(data) { + return request({ + url: '/user/delete', + method: 'POST', + data + }) +} + // 退出登录 export function logoutRequest(data) { return request({ diff --git a/manifest.json b/manifest.json index 9e7e280..cbeb16b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,114 +1,114 @@ { - "name" : "星星锁Lite", - "appid" : "__UNI__933D519", - "description" : "", - "versionName" : "1.3.1", - "versionCode" : "39", - "mp-weixin" : { - "appid" : "wx9829a39e65550757", - "setting" : { - "urlCheck" : true, - "minified" : true - }, - "permission" : { - "scope.bluetooth" : { - "desc" : "蓝牙将用于控制和管理您的智能门锁" - } - }, - "usingComponents" : true, - "lazyCodeLoading" : "requiredComponents", - "optimization" : { - "subPackages" : true - }, - "plugins" : { - "wmpf-voip" : { - "version" : "latest", - "provider" : "wxf830863afde621eb", - "genericsImplementation" : { - "call-page-plugin" : { - "custombox" : "pages/main/customBox" - } - } - } - } + "name": "星星锁Lite", + "appid": "__UNI__933D519", + "description": "", + "versionName": "1.3.2", + "versionCode": "40", + "mp-weixin": { + "appid": "wx9829a39e65550757", + "setting": { + "urlCheck": true, + "minified": true }, - "vueVersion" : "3", - "app-plus" : { - "distribute" : { - "icons" : { - "android" : { - "hdpi" : "unpackage/res/icons/72x72.png", - "xhdpi" : "unpackage/res/icons/96x96.png", - "xxhdpi" : "unpackage/res/icons/144x144.png", - "xxxhdpi" : "unpackage/res/icons/192x192.png" - }, - "ios" : { - "appstore" : "unpackage/res/icons/1024x1024.png", - "ipad" : { - "app" : "unpackage/res/icons/76x76.png", - "app@2x" : "unpackage/res/icons/152x152.png", - "notification" : "unpackage/res/icons/20x20.png", - "notification@2x" : "unpackage/res/icons/40x40.png", - "proapp@2x" : "unpackage/res/icons/167x167.png", - "settings" : "unpackage/res/icons/29x29.png", - "settings@2x" : "unpackage/res/icons/58x58.png", - "spotlight" : "unpackage/res/icons/40x40.png", - "spotlight@2x" : "unpackage/res/icons/80x80.png" - }, - "iphone" : { - "app@2x" : "unpackage/res/icons/120x120.png", - "app@3x" : "unpackage/res/icons/180x180.png", - "notification@2x" : "unpackage/res/icons/40x40.png", - "notification@3x" : "unpackage/res/icons/60x60.png", - "settings@2x" : "unpackage/res/icons/58x58.png", - "settings@3x" : "unpackage/res/icons/87x87.png", - "spotlight@2x" : "unpackage/res/icons/80x80.png", - "spotlight@3x" : "unpackage/res/icons/120x120.png" - } - } - }, - "android" : { - "permissions" : [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ], - "targetSdkVersion" : 34, - "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ] - }, - "ios" : { - "dSYMs" : false - } - }, - "modules" : { - "Bluetooth" : {}, - "VideoPlayer" : {}, - "Camera" : {}, - "Record" : {} - }, - "splashscreen" : { - "waiting" : false + "permission": { + "scope.bluetooth": { + "desc": "蓝牙将用于控制和管理您的智能门锁" + } + }, + "usingComponents": true, + "lazyCodeLoading": "requiredComponents", + "optimization": { + "subPackages": true + }, + "plugins": { + "wmpf-voip": { + "version": "latest", + "provider": "wxf830863afde621eb", + "genericsImplementation": { + "call-page-plugin": { + "custombox": "pages/main/customBox" + } } + } } + }, + "vueVersion": "3", + "app-plus": { + "distribute": { + "icons": { + "android": { + "hdpi": "unpackage/res/icons/72x72.png", + "xhdpi": "unpackage/res/icons/96x96.png", + "xxhdpi": "unpackage/res/icons/144x144.png", + "xxxhdpi": "unpackage/res/icons/192x192.png" + }, + "ios": { + "appstore": "unpackage/res/icons/1024x1024.png", + "ipad": { + "app": "unpackage/res/icons/76x76.png", + "app@2x": "unpackage/res/icons/152x152.png", + "notification": "unpackage/res/icons/20x20.png", + "notification@2x": "unpackage/res/icons/40x40.png", + "proapp@2x": "unpackage/res/icons/167x167.png", + "settings": "unpackage/res/icons/29x29.png", + "settings@2x": "unpackage/res/icons/58x58.png", + "spotlight": "unpackage/res/icons/40x40.png", + "spotlight@2x": "unpackage/res/icons/80x80.png" + }, + "iphone": { + "app@2x": "unpackage/res/icons/120x120.png", + "app@3x": "unpackage/res/icons/180x180.png", + "notification@2x": "unpackage/res/icons/40x40.png", + "notification@3x": "unpackage/res/icons/60x60.png", + "settings@2x": "unpackage/res/icons/58x58.png", + "settings@3x": "unpackage/res/icons/87x87.png", + "spotlight@2x": "unpackage/res/icons/80x80.png", + "spotlight@3x": "unpackage/res/icons/120x120.png" + } + } + }, + "android": { + "permissions": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "targetSdkVersion": 34, + "abiFilters": ["armeabi-v7a", "arm64-v8a"] + }, + "ios": { + "dSYMs": false + } + }, + "modules": { + "Bluetooth": {}, + "VideoPlayer": {}, + "Camera": {}, + "Record": {} + }, + "splashscreen": { + "waiting": false + } + } } diff --git a/pages.json b/pages.json index fbf61bb..c35a594 100644 --- a/pages.json +++ b/pages.json @@ -107,13 +107,13 @@ } }, { - "path": "updateEmail", + "path": "updateAccount", "style": { "navigationBarTitleText": "修改邮箱" } }, { - "path": "verifyEmail", + "path": "verifyAccount", "style": { "navigationBarTitleText": "验证邮箱" } @@ -150,6 +150,13 @@ "style": { "navigationBarTitleText": "安全验证" } + }, + { + "path": "deleteAccount", + "style": { + "navigationBarTitleText": "删除账号", + "disableScroll": true + } } ] }, diff --git a/pages/main/mine.vue b/pages/main/mine.vue index 42e9c8e..73f9714 100644 --- a/pages/main/mine.vue +++ b/pages/main/mine.vue @@ -77,6 +77,7 @@ + @@ -175,6 +176,19 @@ 'getUserInfo', 'checkSession' ]), + deleteAccount() { + uni.showModal({ + title: '提示', + content: '删除账号后,你的所有信息及相关记录都会从平台彻底删除,且不可恢复,是否删除?', + success: res => { + if (res.confirm) { + this.routeJump({ + name: 'deleteAccount' + }) + } + } + }) + }, selectEnv(env) { setStorage('envVersion', env.key) removeStorage('token') @@ -364,7 +378,7 @@ .switch-account { position: absolute; - bottom: 60rpx; + bottom: 120rpx; width: 600rpx; height: 80rpx; margin-left: 75rpx; @@ -377,9 +391,17 @@ border-radius: 46rpx; } + .delete-account { + position: absolute; + right: 75rpx; + bottom: 60rpx; + font-size: 28rpx; + color: #666; + } + .env { position: absolute; - bottom: 180rpx; + bottom: 240rpx; width: 600rpx; margin-left: 75rpx; line-height: 80rpx; diff --git a/pages/user/updateEmail.vue b/pages/user/deleteAccount.vue similarity index 59% rename from pages/user/updateEmail.vue rename to pages/user/deleteAccount.vue index daea8a1..c72c235 100644 --- a/pages/user/updateEmail.vue +++ b/pages/user/deleteAccount.vue @@ -1,27 +1,19 @@ @@ -29,107 +21,77 @@ import { mapActions, mapState } from 'pinia' import { test } from 'uview-plus' import { useUserStore } from '@/stores/user' - import { getEmailCodeRequest, updateEmailRequest } from '@/api/user' + import { getEmailCodeRequest, deleteAccountRequest } from '@/api/user' import { useBasicStore } from '@/stores/basic' + import { removeStorage } from '@/utils/storage' export default { data() { return { text: '获取验证码', verificationCode: '', - token: '', - email: '', pending: false } }, computed: { ...mapState(useUserStore, ['userInfo']) }, - onLoad(option) { - if (option.token) { - this.token = option.token - } else { - uni.setNavigationBarTitle({ - title: '绑定邮箱' - }) - } - }, methods: { - ...mapActions(useUserStore, ['updateUserInfo']), - ...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']), - updateInputEmail(data) { - this.email = data.detail.value - }, - updateInputCode(data) { - this.verificationCode = data.detail.value - }, + ...mapActions(useBasicStore, ['routeJump', 'getNetworkType']), async getEmailCode() { if (this.text !== '获取验证码') { return } - if (!test.email(this.email)) { - uni.showToast({ - title: '请输入正确的邮箱', - icon: 'none' - }) - return - } const netWork = await this.getNetworkType() if (!netWork) { return } - const { code } = await getEmailCodeRequest({ - account: this.email, - channel: '2', - codeType: 6 + const { code, message } = await getEmailCodeRequest({ + channel: this.userInfo.mobile !== '' ? '1' : '2', + codeType: 5 }) if (code === 0) { this.updateTime() } else { uni.showToast({ - title: '验证码获取失败', + title: message, icon: 'none' }) } }, - async toUpdateEmail() { - if (!test.email(this.email)) { - uni.showToast({ - title: '请输入正确的邮箱', - icon: 'none' - }) - return - } + async verify() { if (this.verificationCode.length === 6 && test.digits(this.verificationCode)) { const netWork = await this.getNetworkType() if (!netWork) { return } - if (this.pending) { - return - } + this.pending = true - const params = { - verificationCode: this.verificationCode, - email: this.email - } - if (this.token !== '') { - params.unbindToken = this.token - } - const { code, message } = await updateEmailRequest(params) + + const { code, message } = await deleteAccountRequest({ + channel: this.userInfo.mobile !== '' ? 1 : 2, + verificationCode: this.verificationCode + }) + this.pending = false if (code === 0) { - this.updateUserInfo({ - ...this.userInfo, - email: this.email + removeStorage('token') + removeStorage('openid') + removeStorage('userInfo') + removeStorage('lockList') + this.routeJump({ + name: 'login', + type: 'reLaunch' + }) + uni.showToast({ + title: '删除成功', + icon: 'none' }) - this.backAndToast('邮箱绑定成功') } else { uni.showToast({ title: message, icon: 'none' }) } - this.pending = false } else { uni.showToast({ title: '验证码为6位纯数字', @@ -149,6 +111,9 @@ this.text = '获取验证码' } }, 1000) + }, + updateInput(data) { + this.verificationCode = data.detail.value } } } @@ -167,17 +132,6 @@ color: #999999; } - .input-email { - width: 616rpx; - height: 108rpx; - padding-right: 32rpx; - padding-left: 32rpx; - margin-top: 48rpx; - margin-left: 35rpx; - background: #ffffff; - border-radius: 16rpx; - } - .button-verify { width: 265rpx; height: 108rpx; @@ -196,7 +150,7 @@ align-items: center; } - .input-verify { + .input { width: 316rpx; height: 108rpx; padding-right: 32rpx; diff --git a/pages/user/login.vue b/pages/user/login.vue index f218b2e..c58f46b 100644 --- a/pages/user/login.vue +++ b/pages/user/login.vue @@ -94,10 +94,10 @@ abbreviation: 'CN', group: 'Z' }) - const username = ref('18174429647') - const password = ref('..022059') + const username = ref('') + const password = ref('') - const select = ref(true) + const select = ref(false) const pending = ref(false) diff --git a/pages/user/updateAccount.vue b/pages/user/updateAccount.vue new file mode 100644 index 0000000..edd506c --- /dev/null +++ b/pages/user/updateAccount.vue @@ -0,0 +1,302 @@ + + + + + + + diff --git a/pages/user/userInfo.vue b/pages/user/userInfo.vue index c6f907b..fe98e44 100644 --- a/pages/user/userInfo.vue +++ b/pages/user/userInfo.vue @@ -44,6 +44,7 @@ + + + + + 手机号 + + {{ userInfo.mobile }} + + + + + - + 邮箱 {{ userInfo.email }} @@ -262,14 +278,20 @@ name: 'updateName' }) }, - toUpdateEmail() { - if (this.userInfo.email === '') { + toUpdateAccount(type) { + if (this.userInfo[type] === '') { this.routeJump({ - name: 'updateEmail' + name: 'updateAccount', + params: { + type + } }) } else { this.routeJump({ - name: 'verifyEmail' + name: 'verifyAccount', + params: { + type + } }) } }, diff --git a/pages/user/verifyEmail.vue b/pages/user/verifyAccount.vue similarity index 82% rename from pages/user/verifyEmail.vue rename to pages/user/verifyAccount.vue index 5b1343f..f96633e 100644 --- a/pages/user/verifyEmail.vue +++ b/pages/user/verifyAccount.vue @@ -21,19 +21,26 @@ import { mapActions, mapState } from 'pinia' import { test } from 'uview-plus' import { useUserStore } from '@/stores/user' - import { getEmailCodeRequest, unbindEmailTokenRequest } from '@/api/user' + import { getEmailCodeRequest, unbindEmailTokenRequest, unbindPhoneTokenRequest } from '@/api/user' import { useBasicStore } from '@/stores/basic' export default { data() { return { text: '获取验证码', - verificationCode: '' + verificationCode: '', + type: '' } }, computed: { ...mapState(useUserStore, ['userInfo']) }, + onLoad(options) { + this.type = options.type + uni.setNavigationBarTitle({ + title: this.type === 'email' ? '验证邮箱' : '验证手机号' + }) + }, methods: { ...mapActions(useUserStore, ['updateUserInfo']), ...mapActions(useBasicStore, ['routeJump', 'getNetworkType']), @@ -45,15 +52,15 @@ if (!netWork) { return } - const { code } = await getEmailCodeRequest({ - channel: '2', - codeType: 7 + const { code, message } = await getEmailCodeRequest({ + channel: this.type === 'email' ? '2' : '1', + codeType: this.type === 'email' ? 7 : 4 }) if (code === 0) { this.updateTime() } else { uni.showToast({ - title: '验证码获取失败', + title: message, icon: 'none' }) } @@ -64,15 +71,17 @@ if (!netWork) { return } - const { code, data, message } = await unbindEmailTokenRequest({ + const request = this.type === 'email' ? unbindEmailTokenRequest : unbindPhoneTokenRequest + const { code, data, message } = await request({ verificationCode: this.verificationCode }) if (code === 0) { this.routeJump({ type: 'redirectTo', - name: 'updateEmail', + name: 'updateAccount', params: { - token: data.token + token: data.token, + type: this.type } }) } else { diff --git a/stores/basic.js b/stores/basic.js index 91c4afb..519a851 100644 --- a/stores/basic.js +++ b/stores/basic.js @@ -28,13 +28,13 @@ const pages = [ tabBar: false }, { - name: 'updateEmail', - path: '/pages/user/updateEmail', + name: 'updateAccount', + path: '/pages/user/updateAccount', tabBar: false }, { - name: 'verifyEmail', - path: '/pages/user/verifyEmail', + name: 'verifyAccount', + path: '/pages/user/verifyAccount', tabBar: false }, { @@ -431,6 +431,11 @@ const pages = [ name: 'safeVerify', path: '/pages/user/safeVerify', tabBar: false + }, + { + name: 'deleteAccount', + path: '/pages/user/deleteAccount', + tabBar: false } ]