修复权限缓存问题
This commit is contained in:
@@ -100,7 +100,9 @@
|
||||
import { ref, computed, onUnmounted } from 'vue'
|
||||
import { getLoginBySms, getSendCode } from '../../api/api.js'
|
||||
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
|
||||
import { usePermStore } from '@/stores/usePermStore'
|
||||
|
||||
const permStore = usePermStore()
|
||||
// ========== 响应式数据 ==========
|
||||
// 手机号
|
||||
const phoneNumber = ref('')
|
||||
@@ -246,12 +248,13 @@ const handleLogin = () => {
|
||||
scene: 'butler_login',
|
||||
cid: push_cid
|
||||
}
|
||||
permStore.clearPerm()
|
||||
getLoginBySms(params)
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
if (res.data) {
|
||||
uni.setStorageSync('token', res.data.token)
|
||||
uni.setStorageSync('userPermission', res.data.user.permissions)
|
||||
permStore.setPerm(res.data.user.permissions)
|
||||
// 存用户ID
|
||||
if (res.data.user.userId) {
|
||||
uni.setStorageSync('userId', res.data.user.userId)
|
||||
|
||||
@@ -99,7 +99,9 @@ import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getLoginPassword } from '../../api/api.js'
|
||||
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
|
||||
import { usePermStore } from '@/stores/usePermStore'
|
||||
|
||||
const permStore = usePermStore()
|
||||
// 响应式数据
|
||||
const phoneNumber = ref('')
|
||||
const password = ref('')
|
||||
@@ -201,6 +203,7 @@ const handleLogin = () => {
|
||||
password: password.value,
|
||||
cid: push_cid
|
||||
}
|
||||
permStore.clearPerm()
|
||||
getLoginPassword(params)
|
||||
.then(res => {
|
||||
// console.log('33333',res)
|
||||
@@ -214,7 +217,11 @@ const handleLogin = () => {
|
||||
// // const currentVillageId = res.data.currentVillageId || 0;
|
||||
// // uni.setStorageSync('currentVillageId', currentVillageId);
|
||||
// }
|
||||
uni.setStorageSync('userPermission', res.data.user.permissions)
|
||||
uni.setStorage({
|
||||
key: 'userPermission',
|
||||
data: res.data.user.permissions
|
||||
})
|
||||
permStore.setPerm(res.data.user.permissions)
|
||||
uni.hideLoading()
|
||||
if (rememberPwd.value) {
|
||||
uni.setStorageSync('rememberPhone', phoneNumber.value)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<view class="news-card" v-for="item in noticeList" :key="item.id">
|
||||
<view class="news-header">
|
||||
<text class="news-title">{{ item.item || '暂无标题' }}</text>
|
||||
<view class="unread-dot" v-if="item.isCheckStr === '未读' "></view>
|
||||
<view class="unread-dot" v-if="item.isCheckStr === '未读'"></view>
|
||||
</view>
|
||||
|
||||
<view class="news-meta">
|
||||
@@ -29,9 +29,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 空数据 -->
|
||||
<view class="empty" v-if="noticeList.length === 0 && !loading">
|
||||
暂无通知消息
|
||||
</view>
|
||||
<view class="empty" v-if="noticeList.length === 0 && !loading"> 暂无通知消息 </view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -39,16 +37,18 @@
|
||||
import { ref } from 'vue'
|
||||
import { onShow, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
|
||||
import { getNoticeList } from '../../api/api.js'
|
||||
import { usePermStore } from '@/stores/usePermStore.js'
|
||||
|
||||
const permStore = usePermStore()
|
||||
// 列表数据
|
||||
const noticeList = ref([])
|
||||
|
||||
// 分页相关
|
||||
const pageNum = ref(1) // 当前页
|
||||
const pageSize = ref(10) // 每页条数
|
||||
const total = ref(0) // 总条数
|
||||
const loading = ref(false) // 加载状态
|
||||
const noMore = ref(false) // 是否没有更多
|
||||
const pageNum = ref(1) // 当前页
|
||||
const pageSize = ref(10) // 每页条数
|
||||
const total = ref(0) // 总条数
|
||||
const loading = ref(false) // 加载状态
|
||||
const noMore = ref(false) // 是否没有更多
|
||||
|
||||
// 获取列表数据
|
||||
const getNoticeData = (isRefresh = false) => {
|
||||
@@ -59,29 +59,32 @@ const getNoticeData = (isRefresh = false) => {
|
||||
getNoticeList({
|
||||
pageSize: pageSize.value,
|
||||
pageNum: pageNum.value
|
||||
}).then(res => {
|
||||
if (res.code === 200) {
|
||||
total.value = res.total || 0
|
||||
const data = res.rows || []
|
||||
|
||||
// 第一页:覆盖,分页:追加
|
||||
if (pageNum.value === 1) {
|
||||
noticeList.value = data
|
||||
} else {
|
||||
noticeList.value = [...noticeList.value, ...data]
|
||||
}
|
||||
|
||||
// 判断是否还有更多
|
||||
noMore.value = noticeList.value.length >= total.value
|
||||
}
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
if (isRefresh) {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
total.value = res.total || 0
|
||||
const data = res.rows || []
|
||||
|
||||
// 第一页:覆盖,分页:追加
|
||||
if (pageNum.value === 1) {
|
||||
noticeList.value = data
|
||||
} else {
|
||||
noticeList.value = [...noticeList.value, ...data]
|
||||
}
|
||||
|
||||
// 判断是否还有更多
|
||||
noMore.value = noticeList.value.length >= total.value
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
if (isRefresh) {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 上拉加载更多
|
||||
@@ -99,11 +102,17 @@ onPullDownRefresh(() => {
|
||||
})
|
||||
|
||||
// 跳详情(即时标记已读)
|
||||
const goToDetail = (item) => {
|
||||
item.isCheck = '1'
|
||||
uni.navigateTo({
|
||||
url: `/pageSubPack/ticket/repairMain?id=${item.id}`
|
||||
})
|
||||
const goToDetail = item => {
|
||||
const hasMine = permStore.hasPermi('butler:workOrder:mine')
|
||||
const hasHall = permStore.hasPermi('butler:workOrder:hall')
|
||||
if (hasMine || hasHall) {
|
||||
item.isCheck = '1'
|
||||
uni.navigateTo({
|
||||
url: `/pageSubPack/ticket/repairMain?id=${item.id}`
|
||||
})
|
||||
} else {
|
||||
uni.showToast({ title: '暂无操作权限', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
// 页面显示时刷新(从详情页返回也会触发)
|
||||
@@ -111,6 +120,7 @@ onShow(() => {
|
||||
pageNum.value = 1
|
||||
noMore.value = false
|
||||
getNoticeData()
|
||||
permStore.initPerm()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -149,7 +159,7 @@ onShow(() => {
|
||||
.unread-dot {
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
background-color: #E34D59;
|
||||
background-color: #e34d59;
|
||||
border-radius: 50%;
|
||||
margin-top: 6rpx;
|
||||
}
|
||||
@@ -189,7 +199,7 @@ onShow(() => {
|
||||
justify-content: space-between;
|
||||
.detail-text {
|
||||
font-size: 28rpx;
|
||||
color: #4D5DFA;
|
||||
color: #4d5dfa;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,9 @@
|
||||
import { ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { logout, getSettingInfo } from '../../api/api.js'
|
||||
import { clearPermList } from '../../utils/permissions.js'
|
||||
import { usePermStore } from '@/stores/usePermStore'
|
||||
|
||||
const permStore = usePermStore()
|
||||
|
||||
// 响应式数据
|
||||
const phoneNumber = ref('') // 绑定手机号
|
||||
@@ -118,7 +120,7 @@ const confirmLogout = () => {
|
||||
logout()
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
clearPermList()
|
||||
permStore.clearPerm()
|
||||
uni.clearStorageSync()
|
||||
uni.showToast({ title: '退出登录成功', icon: 'success' })
|
||||
uni.redirectTo({ url: '/pageSubPack/loginSub/pwd-login' })
|
||||
|
||||
Reference in New Issue
Block a user