1. 添加全局登录状态
2. 完成修改安全问题 3. 优化请求处理
This commit is contained in:
parent
c9a7c24672
commit
0b595ed01c
12
App.vue
12
App.vue
@ -1,11 +1,20 @@
|
|||||||
<script>
|
<script>
|
||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
import { mapState, mapActions } from 'pinia'
|
import { mapState, mapActions } from 'pinia'
|
||||||
|
import { getUserInfoRequest } from '@/api/user'
|
||||||
|
let vm
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
globalData: {
|
||||||
|
// 更新登录状态
|
||||||
|
updateIsLogin(isLogin) {
|
||||||
|
useUserStore().updateLoginStatus(isLogin)
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useBluetoothStore, ['bluetoothStatus'])
|
...mapState(useBluetoothStore, ['bluetoothStatus']),
|
||||||
},
|
},
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
// 检查强制升级
|
// 检查强制升级
|
||||||
@ -29,6 +38,7 @@
|
|||||||
...mapActions(useBluetoothStore, ['initBluetooth', 'onBluetoothState', 'updateBluetoothStatus', 'checkSetting',
|
...mapActions(useBluetoothStore, ['initBluetooth', 'onBluetoothState', 'updateBluetoothStatus', 'checkSetting',
|
||||||
'onBluetoothConnectStatus', 'onBluetoothCharacteristicValueChange']),
|
'onBluetoothConnectStatus', 'onBluetoothCharacteristicValueChange']),
|
||||||
...mapActions(useBasicStore, ['getDeviceInfo', 'getButtonInfo']),
|
...mapActions(useBasicStore, ['getDeviceInfo', 'getButtonInfo']),
|
||||||
|
...mapActions(useUserStore, ['updateLoginStatus']),
|
||||||
// 强制升级
|
// 强制升级
|
||||||
updateMiniProgram() {
|
updateMiniProgram() {
|
||||||
const updateManager = uni.getUpdateManager()
|
const updateManager = uni.getUpdateManager()
|
||||||
|
|||||||
@ -22,4 +22,4 @@ const PROD = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更换环境的时候 切换导出就行
|
// 更换环境的时候 切换导出就行
|
||||||
export default PRE
|
export default DEV
|
||||||
|
|||||||
@ -71,6 +71,15 @@
|
|||||||
"navigationStyle": "default"
|
"navigationStyle": "default"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/updateSafeQuestion/updateSafeQuestion",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "修改安全问题",
|
||||||
|
"navigationBarTextStyle": "white",
|
||||||
|
"navigationBarBackgroundColor": "#63b8af",
|
||||||
|
"navigationStyle": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/webview/webview",
|
"path": "pages/webview/webview",
|
||||||
"style": {
|
"style": {
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
home
|
<view v-if="isLogin">111111</view>
|
||||||
|
<view v-else>
|
||||||
|
<view class="button-login" @click="login">登录</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -8,7 +11,6 @@
|
|||||||
import { getUserInfoRequest } from '@/api/user'
|
import { getUserInfoRequest } from '@/api/user'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { mapState, mapActions } from 'pinia'
|
import { mapState, mapActions } from 'pinia'
|
||||||
import { getCompanyRequest } from '@/api/app'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -17,14 +19,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useUserStore, ['userInfo'])
|
...mapState(useUserStore, ['userInfo', 'isLogin'])
|
||||||
},
|
},
|
||||||
async onLoad() {
|
async onLoad() {
|
||||||
uni.setStorageSync('token', '3016|NQth8ud3JRGLDKO3Gsmg7gEgv9yBjowrZNijlBCp975d2a97')
|
uni.showLoading({
|
||||||
this.getUserInfo()
|
title: '加载中'
|
||||||
|
})
|
||||||
|
const token = uni.getStorageSync('token')
|
||||||
|
if(token) {
|
||||||
|
this.updateLoginStatus(true)
|
||||||
|
await this.getUserInfo()
|
||||||
|
}
|
||||||
|
uni.hideLoading()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useUserStore, ['updateUserInfo']),
|
...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'login']),
|
||||||
async getUserInfo() {
|
async getUserInfo() {
|
||||||
const { code, data } = await getUserInfoRequest()
|
const { code, data } = await getUserInfoRequest()
|
||||||
if(code === 0) {
|
if(code === 0) {
|
||||||
@ -43,5 +52,17 @@ page {
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
.button-login {
|
||||||
|
margin-top: 40vh;
|
||||||
|
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;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -2,58 +2,87 @@
|
|||||||
<view v-if="buttonInfo">
|
<view v-if="buttonInfo">
|
||||||
<image :style="{marginTop: buttonInfo.bottom + 10 + 'px'}" src="/static/images/background_mine.png"
|
<image :style="{marginTop: buttonInfo.bottom + 10 + 'px'}" src="/static/images/background_mine.png"
|
||||||
class="background-image"></image>
|
class="background-image"></image>
|
||||||
<view class="view">
|
<view v-if="isLogin">
|
||||||
<view class="view-button" @click="toUsereInfo">
|
<view class="view">
|
||||||
<view>个人信息</view>
|
<view class="view-button" @click="toUsereInfo">
|
||||||
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
<view>个人信息</view>
|
||||||
</view>
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
||||||
<view class="view-line"></view>
|
</view>
|
||||||
<label for="contact">
|
<view class="view-line"></view>
|
||||||
<view class="view-button">
|
<label for="contact">
|
||||||
<view>客服</view>
|
<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>
|
||||||
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
||||||
</view>
|
</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>
|
||||||
|
<view class="button-logout" @click="logout">退出</view>
|
||||||
|
</view>
|
||||||
|
<view v-else>
|
||||||
|
<view class="button-login" @click="login">登录</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="button-logout">退出</view>
|
|
||||||
</view>
|
</view>
|
||||||
<button open-type="contact" id="contact"></button>
|
<button open-type="contact" id="contact"></button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
import { mapState, mapActions } from 'pinia'
|
import { mapState, mapActions } from 'pinia'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
buttonInfo: null,
|
buttonInfo: null
|
||||||
deviceInfo: null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState(useUserStore, ['isLogin'])
|
||||||
|
},
|
||||||
async onLoad() {
|
async onLoad() {
|
||||||
this.deviceInfo = await this.getDeviceInfo()
|
|
||||||
this.buttonInfo = await this.getButtonInfo()
|
this.buttonInfo = await this.getButtonInfo()
|
||||||
console.log(this.deviceInfo)
|
|
||||||
console.log(this.buttonInfo.top)
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useBasicStore, ['getDeviceInfo', 'getButtonInfo', 'routeJump']),
|
...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']),
|
||||||
|
...mapActions(useUserStore, ['updateLoginStatus', 'login']),
|
||||||
toUsereInfo() {
|
toUsereInfo() {
|
||||||
this.routeJump({
|
this.routeJump({
|
||||||
name: 'userInfo'
|
name: 'userInfo'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toWebview() {
|
toWebview(type) {
|
||||||
this.routeJump({
|
this.routeJump({
|
||||||
name: 'webview',
|
name: 'webview',
|
||||||
params: {
|
params: {
|
||||||
type: 'default'
|
type
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
logout() {
|
||||||
|
const that = this
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定退出登录吗?',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
uni.removeStorageSync('token')
|
||||||
|
that.updateLoginStatus(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -109,7 +138,7 @@ page {
|
|||||||
.button-logout {
|
.button-logout {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
border-radius: 46rpx;
|
border-radius: 46rpx;
|
||||||
bottom: 40rpx;
|
bottom: 60rpx;
|
||||||
width: 710rpx;
|
width: 710rpx;
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
line-height: 80rpx;
|
line-height: 80rpx;
|
||||||
@ -120,4 +149,18 @@ page {
|
|||||||
font-size: 40rpx;
|
font-size: 40rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button-login {
|
||||||
|
margin-top: 40vh;
|
||||||
|
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;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,22 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
|
<view class="text">如果手机丢了,可以通过回答设置的安全问题来登录新设备</view>
|
||||||
|
<view class="safe-question" v-for="item in questionAnswer" :key="item.questionId">
|
||||||
|
<view class="question">
|
||||||
|
<view>{{item.question}}</view>
|
||||||
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
||||||
|
</view>
|
||||||
|
<view class="line"></view>
|
||||||
|
<input class="input" :value="item.answer" maxlength="16" placeholder="请输入答案"
|
||||||
|
placeholder-class="input-placeholder" :disabled="true"></input>
|
||||||
|
</view>
|
||||||
|
<view class="button" @click="updateAnswer">修改</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getQuestionAnswerRequest, getQuestionListRequest } from '@/api/safeAnswer'
|
import { getQuestionAnswerRequest, getQuestionListRequest, updateQuestionAnswerRequest } from '@/api/safeAnswer'
|
||||||
|
import { mapActions } from 'pinia'
|
||||||
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
questionAnswer: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.getQuestionList()
|
|
||||||
this.getQuestionAnswer()
|
this.getQuestionAnswer()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async getQuestionList() {
|
...mapActions(useBasicStore, ['routeJump']),
|
||||||
const { code, data, message } = await getQuestionListRequest()
|
async getQuestionAnswer() {
|
||||||
|
const { code, data, message } = await getQuestionAnswerRequest()
|
||||||
if(code === 0) {
|
if(code === 0) {
|
||||||
console.log(1, data)
|
this.questionAnswer = data
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: message,
|
title: message,
|
||||||
@ -24,23 +41,97 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getQuestionAnswer() {
|
updateAnswer() {
|
||||||
const { code, data, message } = await getQuestionAnswerRequest()
|
this.routeJump({
|
||||||
if(code === 0) {
|
type: 'redirectTo',
|
||||||
console.log(2, data)
|
name: 'updateSafeQuestion'
|
||||||
} else {
|
})
|
||||||
uni.showToast({
|
|
||||||
title: message,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
<style scoped lang="scss">
|
page {
|
||||||
|
background-color: $uni-bg-color-grey;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.text {
|
||||||
|
padding-top: 20rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.safe-question {
|
||||||
|
width: 710rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.question {
|
||||||
|
border-radius: 32rpx 32rpx 0 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 20rpx 32rpx;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-arrow {
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input {
|
||||||
|
border-radius: 0 0 32rpx 32rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
line-height: 100rpx;
|
||||||
|
background: #FFFFFF;
|
||||||
|
padding: 0 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-placeholder {
|
||||||
|
height: 100rpx;
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 100rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.line {
|
||||||
|
width: 100%;
|
||||||
|
height: 2rpx;
|
||||||
|
background: #EBEBEB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-title {
|
||||||
|
font-size: 32rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 100rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-content {
|
||||||
|
font-size: 32rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
margin-top: 32rpx;
|
||||||
|
margin-left: 35rpx;
|
||||||
|
width: 680rpx;
|
||||||
|
height: 96rpx;
|
||||||
|
background: #63b8af;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
line-height: 96rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -24,7 +24,8 @@ export default {
|
|||||||
text: '获取验证码',
|
text: '获取验证码',
|
||||||
verificationCode: '',
|
verificationCode: '',
|
||||||
token: '',
|
token: '',
|
||||||
email: ''
|
email: '',
|
||||||
|
pending: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -74,7 +75,18 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async toUpdateEmail () {
|
async toUpdateEmail () {
|
||||||
|
if(!test.email(this.email)){
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入正确的邮箱',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.verificationCode.length === 6 && test.digits(this.verificationCode)) {
|
if (this.verificationCode.length === 6 && test.digits(this.verificationCode)) {
|
||||||
|
if(this.pending){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.pending = true
|
||||||
const params = {
|
const params = {
|
||||||
verificationCode: this.verificationCode,
|
verificationCode: this.verificationCode,
|
||||||
email: this.email
|
email: this.email
|
||||||
@ -102,6 +114,7 @@ export default {
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
this.pending = false
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '验证码为6位纯数字',
|
title: '验证码为6位纯数字',
|
||||||
@ -112,10 +125,11 @@ export default {
|
|||||||
updateTime () {
|
updateTime () {
|
||||||
let time = 120
|
let time = 120
|
||||||
this.text = `${time} s`
|
this.text = `${time} s`
|
||||||
|
const now = new Date().getTime()
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
time--
|
const second = parseInt((new Date().getTime() - now) / 1000)
|
||||||
this.text = `${time} s`
|
this.text = `${time - second} s`
|
||||||
if (time === 0) {
|
if (time <= second) {
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
this.text = '获取验证码'
|
this.text = '获取验证码'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,8 @@ import { updateUserInfoRequest } from '@/api/user'
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
nickname: ''
|
nickname: '',
|
||||||
|
pending: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -37,6 +38,10 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if(this.pending) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.pending = true
|
||||||
const { code } = await updateUserInfoRequest({
|
const { code } = await updateUserInfoRequest({
|
||||||
nickname: this.nickname
|
nickname: this.nickname
|
||||||
})
|
})
|
||||||
@ -59,6 +64,7 @@ export default {
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
this.pending = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
oldPassword: '',
|
oldPassword: '',
|
||||||
newPassword: '',
|
newPassword: '',
|
||||||
confirmPassword: ''
|
confirmPassword: '',
|
||||||
|
pending: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -61,6 +62,10 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if(this.pending) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.pending = true
|
||||||
const { code, message } = await updatePasswordRequest({
|
const { code, message } = await updatePasswordRequest({
|
||||||
oldPassword: this.oldPassword,
|
oldPassword: this.oldPassword,
|
||||||
newPassword: this.newPassword,
|
newPassword: this.newPassword,
|
||||||
@ -85,6 +90,7 @@ export default {
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
this.pending = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
252
pages/updateSafeQuestion/updateSafeQuestion.vue
Normal file
252
pages/updateSafeQuestion/updateSafeQuestion.vue
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view class="text">如果手机丢了,可以通过回答设置的安全问题来登录新设备</view>
|
||||||
|
<view class="safe-question">
|
||||||
|
<view class="question" @click="popup('firstList')">
|
||||||
|
<view>{{answer[0].question}}</view>
|
||||||
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
||||||
|
</view>
|
||||||
|
<view class="line"></view>
|
||||||
|
<input class="input" :value="answer[0].answer" maxlength="16" placeholder="请输入答案"
|
||||||
|
placeholder-class="input-placeholder" @input="changeFirstAnswer"></input>
|
||||||
|
</view>
|
||||||
|
<view class="safe-question">
|
||||||
|
<view class="question" @click="popup('secondList')">
|
||||||
|
<view>{{answer[1].question}}</view>
|
||||||
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
||||||
|
</view>
|
||||||
|
<view class="line"></view>
|
||||||
|
<input class="input" :value="answer[1].answer" maxlength="16" placeholder="请输入答案"
|
||||||
|
placeholder-class="input-placeholder" @input="changeSecondAnswer"></input>
|
||||||
|
</view>
|
||||||
|
<view class="safe-question">
|
||||||
|
<view class="question" @click="popup('thirdList')">
|
||||||
|
<view>{{answer[2].question}}</view>
|
||||||
|
<image class="icon-arrow" src="/static/images/icon_arrow.png" mode="aspectFill"></image>
|
||||||
|
</view>
|
||||||
|
<view class="line"></view>
|
||||||
|
<input class="input" :value="answer[2].answer" maxlength="16" placeholder="请输入答案"
|
||||||
|
placeholder-class="input-placeholder" @input="changeThirdAnswer"></input>
|
||||||
|
</view>
|
||||||
|
<view class="button" @click="updateAnswer">保存</view>
|
||||||
|
</view>
|
||||||
|
<up-popup :show="show" mode="bottom" round="16rpx" @close="close">
|
||||||
|
<view class="popup-title">选择问题</view>
|
||||||
|
<view class="line" style="height: 10rpx"></view>
|
||||||
|
<view v-for="item in currentQuestionList" :key="item.questionId" @click="selectQuestion(item)">
|
||||||
|
<view class="popup-content">{{item.question}}</view>
|
||||||
|
<view class="line"></view>
|
||||||
|
</view>
|
||||||
|
<view class="line" style="height: 10rpx"></view>
|
||||||
|
<view class="popup-title" @click="close">取消</view>
|
||||||
|
</up-popup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getQuestionAnswerRequest, getQuestionListRequest, updateQuestionAnswerRequest } from '@/api/safeAnswer'
|
||||||
|
import { mapActions, mapState } from 'pinia'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
questionList: {},
|
||||||
|
currentQuestionList: [],
|
||||||
|
currentIndex: 0,
|
||||||
|
answer:[{
|
||||||
|
question: '问题一',
|
||||||
|
answer: ''
|
||||||
|
}, {
|
||||||
|
question: '问题二',
|
||||||
|
answer: ''
|
||||||
|
}, {
|
||||||
|
question: '问题三',
|
||||||
|
answer: ''
|
||||||
|
}],
|
||||||
|
show: false,
|
||||||
|
pending: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState(useUserStore, ['userInfo'])
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
this.getQuestionList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions(useUserStore, ['updateUserInfo']),
|
||||||
|
async updateAnswer() {
|
||||||
|
console.log('答案', this.answer)
|
||||||
|
for(let i = 0; i < this.answer.length; i++) {
|
||||||
|
if(!this.answer[i].questionId) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '问题不能为空',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(let i = 0; i < this.answer.length; i++) {
|
||||||
|
if(this.answer[i].answer === '') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '答案不能为空',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(this.pending) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.pending = true
|
||||||
|
const { code, message } = await updateQuestionAnswerRequest({
|
||||||
|
questionAndAnswerList: this.answer
|
||||||
|
})
|
||||||
|
if(code === 0) {
|
||||||
|
this.updateUserInfo({
|
||||||
|
...this.userInfo,
|
||||||
|
haveSafeAnswer: 1
|
||||||
|
})
|
||||||
|
uni.navigateBack({
|
||||||
|
complete() {
|
||||||
|
uni.showToast({
|
||||||
|
title: '安全问题设置成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.pending = false
|
||||||
|
},
|
||||||
|
changeFirstAnswer(data) {
|
||||||
|
this.answer[0].answer = data.detail.value
|
||||||
|
},
|
||||||
|
changeSecondAnswer(data) {
|
||||||
|
this.answer[1].answer = data.detail.value
|
||||||
|
},
|
||||||
|
changeThirdAnswer(data) {
|
||||||
|
this.answer[2].answer = data.detail.value
|
||||||
|
},
|
||||||
|
close() {
|
||||||
|
this.show = false
|
||||||
|
},
|
||||||
|
selectQuestion(item) {
|
||||||
|
this.answer[this.currentIndex].question = item.question
|
||||||
|
this.answer[this.currentIndex].questionId = item.questionId
|
||||||
|
this.show = false
|
||||||
|
},
|
||||||
|
popup(type) {
|
||||||
|
if(type === 'secondList') {
|
||||||
|
this.currentIndex = 1
|
||||||
|
} else if(type === 'thirdList') {
|
||||||
|
this.currentIndex = 2
|
||||||
|
} else {
|
||||||
|
this.currentIndex = 0
|
||||||
|
}
|
||||||
|
this.currentQuestionList = this.questionList[type]
|
||||||
|
this.show = true
|
||||||
|
},
|
||||||
|
async getQuestionList() {
|
||||||
|
const { code, data, message } = await getQuestionListRequest()
|
||||||
|
if(code === 0) {
|
||||||
|
this.questionList = data
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-color: $uni-bg-color-grey;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.text {
|
||||||
|
padding-top: 20rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.safe-question {
|
||||||
|
width: 710rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.question {
|
||||||
|
border-radius: 32rpx 32rpx 0 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 20rpx 32rpx;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-arrow {
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input {
|
||||||
|
border-radius: 0 0 32rpx 32rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
line-height: 100rpx;
|
||||||
|
background: #FFFFFF;
|
||||||
|
padding: 0 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-placeholder {
|
||||||
|
height: 100rpx;
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 100rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.line {
|
||||||
|
width: 100%;
|
||||||
|
height: 2rpx;
|
||||||
|
background: #EBEBEB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-title {
|
||||||
|
font-size: 32rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 100rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-content {
|
||||||
|
font-size: 32rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
margin-top: 32rpx;
|
||||||
|
margin-left: 35rpx;
|
||||||
|
width: 680rpx;
|
||||||
|
height: 96rpx;
|
||||||
|
background: #63b8af;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
line-height: 96rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<button open-type="chooseAvatar" style="display: none" id="avatar" @chooseavatar="chooseAvatar"></button>
|
<button open-type="chooseAvatar" style="display:none" id="avatar" @chooseavatar="chooseAvatar"></button>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -69,6 +69,11 @@ import { getUploadParamsRequest } from '@/api/file'
|
|||||||
import { updateUserInfoRequest } from '@/api/user'
|
import { updateUserInfoRequest } from '@/api/user'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
pending: false
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useUserStore, ['userInfo'])
|
...mapState(useUserStore, ['userInfo'])
|
||||||
},
|
},
|
||||||
@ -76,7 +81,14 @@ export default {
|
|||||||
...mapActions(useBasicStore, ['routeJump']),
|
...mapActions(useBasicStore, ['routeJump']),
|
||||||
...mapActions(useUserStore, ['updateUserInfo']),
|
...mapActions(useUserStore, ['updateUserInfo']),
|
||||||
chooseAvatar(e) {
|
chooseAvatar(e) {
|
||||||
|
console.log(e)
|
||||||
const that = this
|
const that = this
|
||||||
|
|
||||||
|
if(that.pending) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
that.pending = true
|
||||||
|
|
||||||
const path = e.detail.avatarUrl
|
const path = e.detail.avatarUrl
|
||||||
const list = path.split('/')
|
const list = path.split('/')
|
||||||
const filename = list[list.length - 1]
|
const filename = list[list.length - 1]
|
||||||
@ -115,13 +127,16 @@ export default {
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
that.pending = false
|
||||||
},
|
},
|
||||||
fail(res) {
|
fail(res) {
|
||||||
console.log(res)
|
console.log('上传失败', res)
|
||||||
|
console.log(data.uploadUrl, path, data.formData)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '头像更新失败',
|
title: '头像更新失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
|
that.pending = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -129,6 +144,7 @@ export default {
|
|||||||
title: '头像更新失败',
|
title: '头像更新失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
|
that.pending = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -155,9 +171,15 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
toSafeQuestion() {
|
toSafeQuestion() {
|
||||||
this.routeJump({
|
if(this.userInfo.haveSafeAnswer) {
|
||||||
name: 'safeQuestion'
|
this.routeJump({
|
||||||
})
|
name: 'safeQuestion'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.routeJump({
|
||||||
|
name: 'updateSafeQuestion'
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,10 +75,11 @@ export default {
|
|||||||
updateTime() {
|
updateTime() {
|
||||||
let time = 120
|
let time = 120
|
||||||
this.text = `${time} s`
|
this.text = `${time} s`
|
||||||
|
const now = new Date().getTime()
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
time--
|
const second = parseInt((new Date().getTime() - now) / 1000)
|
||||||
this.text = `${time} s`
|
this.text = `${time - second} s`
|
||||||
if(time === 0) {
|
if (time <= second) {
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
this.text = '获取验证码'
|
this.text = '获取验证码'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,10 @@ export default {
|
|||||||
userAgreement: {
|
userAgreement: {
|
||||||
url: '/app/userAgreement',
|
url: '/app/userAgreement',
|
||||||
name: '用户协议'
|
name: '用户协议'
|
||||||
|
},
|
||||||
|
privacy: {
|
||||||
|
url: '/app/privacy',
|
||||||
|
name: '隐私政策'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const item = officialAccounts[options?.type] || officialAccounts['default']
|
const item = officialAccounts[options?.type] || officialAccounts['default']
|
||||||
|
|||||||
@ -42,6 +42,11 @@ const pages = [
|
|||||||
path: '/pages/safeQuestion/safeQuestion',
|
path: '/pages/safeQuestion/safeQuestion',
|
||||||
tabBar: false
|
tabBar: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'updateSafeQuestion',
|
||||||
|
path: '/pages/updateSafeQuestion/updateSafeQuestion',
|
||||||
|
tabBar: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'webview',
|
name: 'webview',
|
||||||
path: '/pages/webview/webview',
|
path: '/pages/webview/webview',
|
||||||
@ -64,7 +69,6 @@ export const useBasicStore = defineStore('basic', {
|
|||||||
/* data 入参 name string页面名称 type string跳转方式 params object传递参数 delta number返回页面数
|
/* data 入参 name string页面名称 type string跳转方式 params object传递参数 delta number返回页面数
|
||||||
* 具体入参查看文档 https://www.uviewui.com/js/route.html */
|
* 具体入参查看文档 https://www.uviewui.com/js/route.html */
|
||||||
routeJump(data) {
|
routeJump(data) {
|
||||||
console.log(data)
|
|
||||||
const page = pages.find((page) => {
|
const page = pages.find((page) => {
|
||||||
return page.name === data.name
|
return page.name === data.name
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,16 +2,32 @@
|
|||||||
* @description 用户信息数据持久化
|
* @description 用户信息数据持久化
|
||||||
*/
|
*/
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
import { getUserInfoRequest } from '@/api/user'
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', {
|
export const useUserStore = defineStore('user', {
|
||||||
state() {
|
state() {
|
||||||
return {
|
return {
|
||||||
userInfo: {}
|
// 用户信息
|
||||||
|
userInfo: {},
|
||||||
|
// 登录状态
|
||||||
|
isLogin: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
updateUserInfo(data) {
|
updateUserInfo(data) {
|
||||||
this.userInfo = 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -31,12 +31,29 @@ const request = (config) => {
|
|||||||
async success(res) {
|
async success(res) {
|
||||||
const { statusCode, data } = res
|
const { statusCode, data } = res
|
||||||
if (statusCode === 200) {
|
if (statusCode === 200) {
|
||||||
// 根据情况添加处理代码
|
const code = data.errorCode
|
||||||
resolve({
|
const message = data.errorMsg
|
||||||
code: data.errorCode,
|
if(code === 403) {
|
||||||
data: data.data,
|
uni.removeStorageSync('token')
|
||||||
message: data.errorMsg
|
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 {
|
} else {
|
||||||
resolve({ code: -1, data, message: '网络不太好哦,请稍后再试' })
|
resolve({ code: -1, data, message: '网络不太好哦,请稍后再试' })
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user