fix: 修复通知列表页面无登录功能的bug
This commit is contained in:
parent
c340a52c35
commit
6d3274c183
@ -77,7 +77,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="getphonenumber"></button>
|
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="getphonenumber"></button>
|
||||||
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal"
|
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal"
|
||||||
@confirm="confirmModal">
|
@confirm="confirmModal">
|
||||||
<view class="slot-content" @click="changeRadio">
|
<view class="slot-content" @click="changeRadio">
|
||||||
<view style="display: flex;align-items: center;">
|
<view style="display: flex;align-items: center;">
|
||||||
@ -622,7 +622,7 @@ page {
|
|||||||
.button-add-big {
|
.button-add-big {
|
||||||
width: 400rpx;
|
width: 400rpx;
|
||||||
height: 400rpx;
|
height: 400rpx;
|
||||||
margin-top: 250rpx;
|
margin-top: 300rpx;
|
||||||
margin-left: 136rpx;
|
margin-left: 136rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<scroll-view v-if="deviceInfo" scroll-y="true" :style="{ height: deviceInfo.windowHeight + 'px' }"
|
||||||
<scroll-view v-if="deviceInfo" scroll-y="true" :style="{ height: deviceInfo.windowHeight + 'px' }"
|
lower-threshold="100" @refresherrefresh="refresherList" :refresher-enabled="true" @scrolltolower="nextPage"
|
||||||
lower-threshold="100" @refresherrefresh="refresherList" :refresher-enabled="true" @scrolltolower="nextPage"
|
:refresher-triggered="refresherTriggered" @scroll="scroll">
|
||||||
:refresher-triggered="refresherTriggered" @scroll="scroll">
|
<view v-if="isLogin">
|
||||||
<view class="list" v-if="requestFinished">
|
<view class="list" v-if="requestFinished">
|
||||||
<view v-if="notificationList.length === 0">
|
<view v-if="notificationList.length === 0">
|
||||||
<image class="empty-list" src="/static/images/background_empty_list.png" mode="aspectFill"></image>
|
<image class="empty-list" src="/static/images/background_empty_list.png" mode="aspectFill"></image>
|
||||||
@ -28,19 +28,28 @@
|
|||||||
</up-swipe-action-item>
|
</up-swipe-action-item>
|
||||||
</up-swipe-action>
|
</up-swipe-action>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
|
||||||
<view class="delete" @click="deleteAllNotification">
|
|
||||||
<image class="delete-image" src="/static/images/icon_delete.png" mode="aspectFill"></image>
|
|
||||||
</view>
|
</view>
|
||||||
|
<view v-else>
|
||||||
|
<view class="tips">因智能门锁与账号绑定,登录为手机号登录</view>
|
||||||
|
<label for="phone">
|
||||||
|
<view class="button-login">登录</view>
|
||||||
|
</label>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
<view class="delete" @click="deleteAllNotification" v-if="isLogin && requestFinished && notificationList.length !==
|
||||||
|
0">
|
||||||
|
<image class="delete-image" src="/static/images/icon_delete.png" mode="aspectFill"></image>
|
||||||
</view>
|
</view>
|
||||||
|
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="getphonenumber"></button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions, mapState } from 'pinia'
|
import { mapActions, mapState } from 'pinia'
|
||||||
import { useNotificationStore } from '../../stores/notification'
|
import { useNotificationStore } from '@/stores/notification'
|
||||||
import { useBasicStore } from '../../stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
import { timeFormat } from 'uview-plus'
|
import { timeFormat } from 'uview-plus'
|
||||||
import { deleteAllNotification, deleteNotification, markAsReadNotification } from '../../api/notification'
|
import { deleteAllNotification, deleteNotification, markAsReadNotification } from '@/api/notification'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
@ -58,28 +67,50 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useNotificationStore, ['notificationTotal', 'notificationList', 'notificationSearch']),
|
...mapState(useNotificationStore, ['notificationTotal', 'notificationList', 'notificationSearch']),
|
||||||
|
...mapState(useUserStore, ['isLogin']),
|
||||||
},
|
},
|
||||||
async onLoad () {
|
async onLoad () {
|
||||||
uni.showLoading({
|
|
||||||
title: '加载中',
|
|
||||||
mask: true
|
|
||||||
})
|
|
||||||
this.deviceInfo = await this.getDeviceInfo()
|
this.deviceInfo = await this.getDeviceInfo()
|
||||||
const { code, message } = await this.getNotificationList(this.notificationSearch)
|
if(this.isLogin) {
|
||||||
uni.hideLoading()
|
await this.getList()
|
||||||
this.requestFinished = true
|
|
||||||
if (code !== 0) {
|
|
||||||
uni.showToast({
|
|
||||||
title: message,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
this.requestFinished = true
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
timeFormat,
|
timeFormat,
|
||||||
...mapActions(useNotificationStore, ['getNotificationList', 'updateNotificationSearch', 'updateNotificationItem','deleteNotificationItem']),
|
...mapActions(useNotificationStore, ['getNotificationList', 'updateNotificationSearch', 'updateNotificationItem','deleteNotificationItem']),
|
||||||
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']),
|
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']),
|
||||||
scroll(e) {
|
...mapActions(useUserStore, ['phoneLogin']),
|
||||||
|
async getList() {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '加载中',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
const { code, message } = await this.getNotificationList(this.notificationSearch)
|
||||||
|
uni.hideLoading()
|
||||||
|
if (code !== 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getphonenumber(data) {
|
||||||
|
if(data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const result = await this.phoneLogin({
|
||||||
|
encryptedData: data.detail.encryptedData,
|
||||||
|
iv: data.detail.iv
|
||||||
|
})
|
||||||
|
if(!result) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '登录失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scroll() {
|
||||||
this.$refs.swipeItem.forEach(item => {
|
this.$refs.swipeItem.forEach(item => {
|
||||||
if(item.show) {
|
if(item.show) {
|
||||||
item.closeHandler()
|
item.closeHandler()
|
||||||
@ -316,4 +347,25 @@ page {
|
|||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tips {
|
||||||
|
margin-top: 40vh;
|
||||||
|
padding: 32rpx 0;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { defineStore } from 'pinia'
|
|||||||
import { getUserInfoRequest, loginRequest, phoneLoginRequest } from '@/api/user'
|
import { getUserInfoRequest, loginRequest, phoneLoginRequest } from '@/api/user'
|
||||||
import { useLockStore } from '@/stores/lock'
|
import { useLockStore } from '@/stores/lock'
|
||||||
import { setStorage, getStorage } from '@/utils/storage'
|
import { setStorage, getStorage } from '@/utils/storage'
|
||||||
|
import { useNotificationStore } from '@/stores/notification'
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', {
|
export const useUserStore = defineStore('user', {
|
||||||
state() {
|
state() {
|
||||||
@ -35,7 +36,7 @@ export const useUserStore = defineStore('user', {
|
|||||||
async phoneLogin(params) {
|
async phoneLogin(params) {
|
||||||
const { iv, encryptedData } = params
|
const { iv, encryptedData } = params
|
||||||
const openid = getStorage('openid')
|
const openid = getStorage('openid')
|
||||||
const { code, data, message } = await phoneLoginRequest({ iv, encryptedData, openid })
|
const { code, data } = await phoneLoginRequest({ iv, encryptedData, openid })
|
||||||
if(code === 0) {
|
if(code === 0) {
|
||||||
setStorage('token', data.accessToken)
|
setStorage('token', data.accessToken)
|
||||||
this.getUserInfo()
|
this.getUserInfo()
|
||||||
@ -44,6 +45,11 @@ export const useUserStore = defineStore('user', {
|
|||||||
pageNo: 1
|
pageNo: 1
|
||||||
})
|
})
|
||||||
useLockStore().getLockList(useLockStore().lockSearch)
|
useLockStore().getLockList(useLockStore().lockSearch)
|
||||||
|
useNotificationStore().updateNotificationSearch({
|
||||||
|
...useNotificationStore().notificationSearch,
|
||||||
|
pageNo: 1
|
||||||
|
})
|
||||||
|
useNotificationStore().getNotificationList(useNotificationStore().notificationSearch)
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user