2024-08-20 19:54:37 +08:00
|
|
|
|
<template>
|
2025-02-06 11:37:41 +08:00
|
|
|
|
<view v-if="buttonInfo">
|
2024-08-21 16:20:11 +08:00
|
|
|
|
<view v-if="isLogin">
|
|
|
|
|
|
<view class="view">
|
|
|
|
|
|
<view class="view-button" @click="toUsereInfo">
|
|
|
|
|
|
<view>个人信息</view>
|
|
|
|
|
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="view-line"></view>
|
|
|
|
|
|
<label for="contact">
|
|
|
|
|
|
<view class="view-button">
|
|
|
|
|
|
<view>客服</view>
|
|
|
|
|
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<view class="view-line"></view>
|
|
|
|
|
|
<view class="view-button" @click="toWebview()">
|
|
|
|
|
|
<view>公司介绍</view>
|
|
|
|
|
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="view-line"></view>
|
|
|
|
|
|
<view class="view-button" @click="toWebview('userAgreement')">
|
|
|
|
|
|
<view>用户协议</view>
|
|
|
|
|
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="view-line"></view>
|
|
|
|
|
|
<view class="view-button" @click="toWebview('privacy')">
|
|
|
|
|
|
<view>隐私政策</view>
|
2024-08-20 19:54:37 +08:00
|
|
|
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2024-09-19 11:50:23 +08:00
|
|
|
|
<view class="env" v-if="env">
|
2025-02-06 11:37:41 +08:00
|
|
|
|
<view class="env-text">{{ env.name }} {{ env.version }}+{{ env.buildNumber }}</view>
|
2024-09-19 11:50:23 +08:00
|
|
|
|
<view>{{ env.baseUrl.split('/').slice(0, 3).join('/') }}</view>
|
2025-02-06 11:37:41 +08:00
|
|
|
|
<view v-if="envVersion !== 'release' && env" class="env-button" @click="show = true"
|
|
|
|
|
|
>切换环境</view
|
|
|
|
|
|
>
|
2024-09-02 13:41:35 +08:00
|
|
|
|
</view>
|
2024-08-26 17:33:53 +08:00
|
|
|
|
<label for="changePhone">
|
|
|
|
|
|
<view class="switch-account">切换账号</view>
|
|
|
|
|
|
</label>
|
2024-08-21 16:20:11 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view v-else>
|
2024-08-30 10:48:30 +08:00
|
|
|
|
<view class="tips">因智能门锁与账号绑定,登录为手机号登录</view>
|
2024-08-26 17:33:53 +08:00
|
|
|
|
<label for="phone">
|
|
|
|
|
|
<view class="button-login">登录</view>
|
|
|
|
|
|
</label>
|
2024-09-19 11:50:23 +08:00
|
|
|
|
<view class="env" v-if="env">
|
2025-02-06 11:37:41 +08:00
|
|
|
|
<view class="env-text">{{ env.name }} {{ env.version }}+{{ env.buildNumber }}</view>
|
2024-09-19 17:46:06 +08:00
|
|
|
|
<view>{{ env.baseUrl.split('/').slice(0, 3).join('/') }}</view>
|
2025-02-06 11:37:41 +08:00
|
|
|
|
<view v-if="envVersion !== 'release' && env" class="env-button" @click="show = true"
|
|
|
|
|
|
>切换环境</view
|
|
|
|
|
|
>
|
2024-09-02 13:41:35 +08:00
|
|
|
|
</view>
|
2024-08-20 19:54:37 +08:00
|
|
|
|
</view>
|
2025-02-06 11:37:41 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<button open-type="contact" style="display: none" id="contact"></button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
open-type="getPhoneNumber"
|
|
|
|
|
|
style="display: none"
|
|
|
|
|
|
id="phone"
|
|
|
|
|
|
@getphonenumber="getphonenumber"
|
|
|
|
|
|
></button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
open-type="getPhoneNumber"
|
|
|
|
|
|
style="display: none"
|
|
|
|
|
|
id="changePhone"
|
|
|
|
|
|
@getphonenumber="changePhone"
|
|
|
|
|
|
></button>
|
|
|
|
|
|
<up-action-sheet
|
|
|
|
|
|
:actions="envList"
|
|
|
|
|
|
:closeOnClickOverlay="true"
|
|
|
|
|
|
title="切换环境"
|
|
|
|
|
|
cancelText="取消"
|
|
|
|
|
|
:closeOnClickAction="true"
|
|
|
|
|
|
:show="show"
|
|
|
|
|
|
:safeAreaInsetBottom="true"
|
|
|
|
|
|
@close="show = false"
|
|
|
|
|
|
@select="selectEnv"
|
|
|
|
|
|
></up-action-sheet>
|
2024-08-20 19:54:37 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-02-06 11:37:41 +08:00
|
|
|
|
import { mapState, mapActions } from 'pinia'
|
2024-08-20 19:54:37 +08:00
|
|
|
|
import { useBasicStore } from '@/stores/basic'
|
2024-08-21 16:20:11 +08:00
|
|
|
|
import { useUserStore } from '@/stores/user'
|
2024-08-26 17:33:53 +08:00
|
|
|
|
import { useLockStore } from '@/stores/lock'
|
2024-08-29 17:40:41 +08:00
|
|
|
|
import { phoneLoginRequest } from '@/api/user'
|
2024-09-02 13:41:35 +08:00
|
|
|
|
import env from '@/config/env'
|
2024-09-19 11:50:23 +08:00
|
|
|
|
import { setStorage, getStorage, removeStorage } from '@/utils/storage'
|
2025-02-06 11:37:41 +08:00
|
|
|
|
import { useNotificationStore } from '@/stores/notification'
|
2024-08-20 19:54:37 +08:00
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2024-09-02 13:41:35 +08:00
|
|
|
|
buttonInfo: null,
|
|
|
|
|
|
env: null,
|
|
|
|
|
|
envVersion: '',
|
|
|
|
|
|
envList: [],
|
|
|
|
|
|
show: false
|
2025-02-06 11:37:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-08-21 16:20:11 +08:00
|
|
|
|
computed: {
|
2024-08-29 14:42:16 +08:00
|
|
|
|
...mapState(useUserStore, ['isLogin']),
|
2024-09-30 15:18:05 +08:00
|
|
|
|
...mapState(useLockStore, ['lockSearch']),
|
|
|
|
|
|
...mapState(useNotificationStore, ['notificationSearch'])
|
2024-08-21 16:20:11 +08:00
|
|
|
|
},
|
2024-08-20 19:54:37 +08:00
|
|
|
|
async onLoad() {
|
|
|
|
|
|
this.buttonInfo = await this.getButtonInfo()
|
2024-09-19 11:50:23 +08:00
|
|
|
|
this.env = await env[await getApp().globalData.getEnvConfig()]
|
2024-09-02 13:41:35 +08:00
|
|
|
|
this.envVersion = getApp().globalData.envVersion
|
2025-02-06 11:37:41 +08:00
|
|
|
|
// eslint-disable-next-line guard-for-in,no-restricted-syntax
|
2024-09-02 13:41:35 +08:00
|
|
|
|
for (let key in env) {
|
|
|
|
|
|
this.envList.push({
|
|
|
|
|
|
...env[key],
|
2025-02-06 11:37:41 +08:00
|
|
|
|
key
|
2024-09-02 13:41:35 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log(this.envList)
|
2024-08-20 19:54:37 +08:00
|
|
|
|
},
|
2025-02-06 11:37:41 +08:00
|
|
|
|
methods: {
|
2024-08-21 16:20:11 +08:00
|
|
|
|
...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']),
|
2024-08-29 14:42:16 +08:00
|
|
|
|
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
|
2024-09-30 15:18:05 +08:00
|
|
|
|
...mapActions(useNotificationStore, ['getNotificationList', 'updateNotificationSearch']),
|
2025-02-06 11:37:41 +08:00
|
|
|
|
...mapActions(useUserStore, [
|
|
|
|
|
|
'updateLoginStatus',
|
|
|
|
|
|
'phoneLogin',
|
|
|
|
|
|
'updateUserInfo',
|
|
|
|
|
|
'getUserInfo',
|
|
|
|
|
|
'checkSession'
|
|
|
|
|
|
]),
|
2024-09-02 13:41:35 +08:00
|
|
|
|
selectEnv(env) {
|
2024-09-19 11:50:23 +08:00
|
|
|
|
setStorage('envVersion', env.key)
|
|
|
|
|
|
removeStorage('token')
|
|
|
|
|
|
removeStorage('openid')
|
|
|
|
|
|
removeStorage('userInfo')
|
|
|
|
|
|
removeStorage('lockList')
|
2024-09-02 13:41:35 +08:00
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: '/pages/home/home'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-08-26 17:33:53 +08:00
|
|
|
|
async changePhone(res) {
|
2025-02-06 11:37:41 +08:00
|
|
|
|
if (res.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
2024-08-26 17:33:53 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2024-08-27 10:12:56 +08:00
|
|
|
|
const result = await this.checkSession()
|
2025-02-06 11:37:41 +08:00
|
|
|
|
if (!result) {
|
2024-08-27 10:12:56 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '登录失败,请重试',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2024-09-19 11:50:23 +08:00
|
|
|
|
const openid = getStorage('openid')
|
2024-08-26 17:33:53 +08:00
|
|
|
|
const { code, data, message } = await phoneLoginRequest({
|
|
|
|
|
|
encryptedData: res.detail.encryptedData,
|
|
|
|
|
|
iv: res.detail.iv,
|
|
|
|
|
|
rebind: true,
|
|
|
|
|
|
openid
|
|
|
|
|
|
})
|
2025-02-06 11:37:41 +08:00
|
|
|
|
if (code === 0) {
|
2024-09-19 11:50:23 +08:00
|
|
|
|
removeStorage('userInfo')
|
|
|
|
|
|
removeStorage('lockList')
|
|
|
|
|
|
setStorage('token', data.accessToken)
|
2024-08-29 14:42:16 +08:00
|
|
|
|
this.updateLockSearch({
|
2024-08-29 17:40:41 +08:00
|
|
|
|
...this.lockSearch,
|
2024-08-29 14:42:16 +08:00
|
|
|
|
pageNo: 1
|
2024-08-26 17:33:53 +08:00
|
|
|
|
})
|
2024-08-29 17:40:41 +08:00
|
|
|
|
this.getUserInfo()
|
2024-08-29 14:42:16 +08:00
|
|
|
|
this.getLockList(this.lockSearch)
|
2024-09-30 15:18:05 +08:00
|
|
|
|
this.updateNotificationSearch({
|
|
|
|
|
|
pageNo: 1
|
|
|
|
|
|
})
|
|
|
|
|
|
this.getNotificationList(this.notificationSearch)
|
2024-08-26 17:33:53 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '账号切换成功',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
2025-02-06 11:37:41 +08:00
|
|
|
|
} else if (code === 438) {
|
|
|
|
|
|
/* empty */
|
2024-08-26 17:33:53 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: message,
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
async getphonenumber(data) {
|
2025-02-06 11:37:41 +08:00
|
|
|
|
if (data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
2024-08-26 17:33:53 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2024-08-27 10:12:56 +08:00
|
|
|
|
const result = await this.phoneLogin({
|
2024-08-26 17:33:53 +08:00
|
|
|
|
encryptedData: data.detail.encryptedData,
|
|
|
|
|
|
iv: data.detail.iv
|
|
|
|
|
|
})
|
2025-02-06 11:37:41 +08:00
|
|
|
|
if (!result) {
|
2024-08-26 17:33:53 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '登录失败,请重试',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-08-20 19:54:37 +08:00
|
|
|
|
toUsereInfo() {
|
|
|
|
|
|
this.routeJump({
|
|
|
|
|
|
name: 'userInfo'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-08-21 16:20:11 +08:00
|
|
|
|
toWebview(type) {
|
2024-08-20 19:54:37 +08:00
|
|
|
|
this.routeJump({
|
|
|
|
|
|
name: 'webview',
|
|
|
|
|
|
params: {
|
2024-08-21 16:20:11 +08:00
|
|
|
|
type
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-08-20 19:54:37 +08:00
|
|
|
|
}
|
2024-09-02 09:31:55 +08:00
|
|
|
|
}
|
2025-02-06 11:37:41 +08:00
|
|
|
|
}
|
2024-08-20 19:54:37 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2025-02-06 11:37:41 +08:00
|
|
|
|
page {
|
|
|
|
|
|
background-color: $uni-bg-color-grey;
|
|
|
|
|
|
}
|
2024-08-20 19:54:37 +08:00
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.background-image {
|
|
|
|
|
|
margin-top: 32rpx;
|
|
|
|
|
|
margin-left: 20rpx;
|
|
|
|
|
|
width: 710rpx;
|
|
|
|
|
|
height: 156rpx;
|
|
|
|
|
|
border-radius: 32rpx;
|
|
|
|
|
|
}
|
2024-08-20 19:54:37 +08:00
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.view {
|
|
|
|
|
|
margin-top: 32rpx;
|
|
|
|
|
|
border-radius: 32rpx;
|
|
|
|
|
|
width: 710rpx;
|
|
|
|
|
|
margin-left: 20rpx;
|
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
|
}
|
2024-08-20 19:54:37 +08:00
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.view-button {
|
|
|
|
|
|
padding: 0 20rpx 0 40rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
color: #292826;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
line-height: 80rpx;
|
|
|
|
|
|
}
|
2024-08-20 19:54:37 +08:00
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.icon-arrow {
|
|
|
|
|
|
width: 40rpx;
|
|
|
|
|
|
height: 40rpx;
|
|
|
|
|
|
}
|
2024-08-26 17:33:53 +08:00
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.view-line {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 3rpx;
|
|
|
|
|
|
background: #ebebeb;
|
|
|
|
|
|
}
|
2024-09-02 13:41:35 +08:00
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.switch-account {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
border-radius: 46rpx;
|
|
|
|
|
|
bottom: 60rpx;
|
|
|
|
|
|
width: 600rpx;
|
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
|
line-height: 80rpx;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
margin-left: 75rpx;
|
|
|
|
|
|
background: #63b8af;
|
|
|
|
|
|
color: #ffffff;
|
|
|
|
|
|
font-size: 40rpx;
|
2024-09-03 15:11:35 +08:00
|
|
|
|
font-weight: bold;
|
2024-09-02 13:41:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.env {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: 180rpx;
|
|
|
|
|
|
width: 600rpx;
|
|
|
|
|
|
line-height: 80rpx;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
margin-left: 75rpx;
|
|
|
|
|
|
|
|
|
|
|
|
.env-text {
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.env-button {
|
|
|
|
|
|
background: inherit;
|
|
|
|
|
|
color: #022b7c;
|
|
|
|
|
|
font-size: 0.8rem;
|
|
|
|
|
|
text-align: right;
|
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
|
}
|
2024-09-02 13:41:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.button-login {
|
|
|
|
|
|
border-radius: 46rpx;
|
|
|
|
|
|
width: 650rpx;
|
|
|
|
|
|
height: 120rpx;
|
|
|
|
|
|
line-height: 120rpx;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
margin-left: 50rpx;
|
|
|
|
|
|
background: #63b8af;
|
|
|
|
|
|
color: #ffffff;
|
|
|
|
|
|
font-size: 48rpx;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
2024-08-30 10:48:30 +08:00
|
|
|
|
|
2025-02-06 11:37:41 +08:00
|
|
|
|
.tips {
|
|
|
|
|
|
margin-top: 25vh;
|
|
|
|
|
|
padding: 32rpx 0;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
}
|
2024-08-20 19:54:37 +08:00
|
|
|
|
</style>
|