校验函数
This commit is contained in:
@@ -39,7 +39,14 @@
|
||||
<view class="scroll-content">
|
||||
<!-- banner -->
|
||||
<view class="bannarClass" v-if="bannerList && bannerList.length > 0">
|
||||
<up-swiper :list="bannerList" indicator indicatorMode="dot" radius="15" height="180" keyName="url">
|
||||
<up-swiper
|
||||
:list="bannerList"
|
||||
indicator
|
||||
indicatorMode="dot"
|
||||
radius="15"
|
||||
height="180"
|
||||
keyName="url"
|
||||
>
|
||||
<template #default="{ item, index }">
|
||||
<image :src="item.url || item" mode="aspectFill" class="banner-img"></image>
|
||||
</template>
|
||||
@@ -94,7 +101,7 @@
|
||||
<view class="function-container">
|
||||
<!-- 第一行功能:故障上报、一键开门、工单大厅、我的工单 -->
|
||||
<view class="function-row">
|
||||
<view class="function-item" @click="goToReport">
|
||||
<view class="function-item" @click="goToReport" v-if="hasPermi('butler:fault:report')">
|
||||
<image
|
||||
class="item-icon"
|
||||
src="https://wuyeadmin.bugtc.com/images/imgs/fault-report.png"
|
||||
@@ -102,7 +109,11 @@
|
||||
></image>
|
||||
<text class="item-text">故障上报</text>
|
||||
</view>
|
||||
<view class="function-item" @click="goToOneOpenDoor">
|
||||
<view
|
||||
class="function-item"
|
||||
@click="goToOneOpenDoor"
|
||||
v-if="hasPermi('butler:door:open')"
|
||||
>
|
||||
<image
|
||||
class="item-icon"
|
||||
src="https://wuyeadmin.bugtc.com/images/imgs/open.png"
|
||||
@@ -110,7 +121,11 @@
|
||||
></image>
|
||||
<text class="item-text">一键开门</text>
|
||||
</view>
|
||||
<view class="function-item" @tap="goToTicketHall">
|
||||
<view
|
||||
class="function-item"
|
||||
@tap="goToTicketHall"
|
||||
v-if="hasPermi('butler:workOrder:hall')"
|
||||
>
|
||||
<image
|
||||
class="item-icon"
|
||||
src="https://wuyeadmin.bugtc.com/images/imgs/work-order.png"
|
||||
@@ -118,7 +133,11 @@
|
||||
></image>
|
||||
<text class="item-text">工单大厅</text>
|
||||
</view>
|
||||
<view class="function-item" @tap="goToMyTicket">
|
||||
<view
|
||||
class="function-item"
|
||||
@tap="goToMyTicket"
|
||||
v-if="hasPermi('butler:workOrder:mine')"
|
||||
>
|
||||
<image
|
||||
class="item-icon"
|
||||
src="https://wuyeadmin.bugtc.com/images/imgs/my-work.png"
|
||||
@@ -129,7 +148,11 @@
|
||||
</view>
|
||||
<!-- 第二行 -->
|
||||
<view class="function-row" style="margin-top: 2px">
|
||||
<view class="function-item" @tap="goToComplaint">
|
||||
<view
|
||||
class="function-item"
|
||||
@tap="goToComplaint"
|
||||
v-if="hasPermi('butler:complaint:handle')"
|
||||
>
|
||||
<image
|
||||
class="item-icon"
|
||||
src="https://wuyeadmin.bugtc.com/images/imgs/complaint.png"
|
||||
@@ -137,7 +160,11 @@
|
||||
></image>
|
||||
<text class="item-text">投诉处理</text>
|
||||
</view>
|
||||
<view class="function-item" @tap="goToReplacement_record">
|
||||
<view
|
||||
class="function-item"
|
||||
@tap="goToReplacement_record"
|
||||
v-if="hasPermi('butler:,meter:replace')"
|
||||
>
|
||||
<image
|
||||
class="item-icon"
|
||||
src="https://wuye.ckdzkj.com/images/home/updateDevice.png"
|
||||
@@ -161,7 +188,7 @@ import {
|
||||
getNewNoticeData,
|
||||
getBannarList
|
||||
} from '../../api/api.js'
|
||||
|
||||
import { hasPermi } from '../../utils/permissions.js'
|
||||
// 列表数据状态
|
||||
const currentCommunity = ref('请先绑定房屋')
|
||||
const bannerList = ref([])
|
||||
@@ -171,7 +198,6 @@ const pendingCount = ref(0) //待巡检
|
||||
const InspectedCount = ref(0) //已巡检
|
||||
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
|
||||
|
||||
|
||||
// =======方法=======
|
||||
// 跳转小区
|
||||
const navigateToPage = () => {
|
||||
@@ -291,7 +317,8 @@ const getNoticeData = () => {
|
||||
}
|
||||
// 获取bannar图
|
||||
function getbannarData() {
|
||||
getBannarList().then(res => {
|
||||
getBannarList()
|
||||
.then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
// 只有数据真正变化时才更新,避免 swiper 重新渲染导致闪动
|
||||
const newData = res.data
|
||||
@@ -332,7 +359,6 @@ onLoad(() => {
|
||||
onUnload(() => {
|
||||
uni.$off('confirm', slelctHomeData)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -452,7 +478,6 @@ onUnload(() => {
|
||||
border-radius: 15rpx;
|
||||
}
|
||||
|
||||
|
||||
.inspectionClass {
|
||||
background: linear-gradient(to right, #7b87fa, #4d5dfa);
|
||||
border-radius: 16rpx;
|
||||
|
||||
36
wuye-manager-uniapp/utils/permissions.js
Normal file
36
wuye-manager-uniapp/utils/permissions.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 获取本地存储的用户权限标识数组
|
||||
*/
|
||||
export function getPermList() {
|
||||
const perms = uni.getStorageSync('userPermission')
|
||||
return Array.isArray(perms) ? perms : []
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限校验函数
|
||||
* @param perm 单个权限字符串 / 多个权限数组
|
||||
* @param mode or满足任一 / and全部满足,默认or
|
||||
* @returns 是否拥有权限
|
||||
*/
|
||||
export function hasPermi(perm, mode = 'or') {
|
||||
const permList = getPermList()
|
||||
// 超级管理员通配符
|
||||
if (permList.includes('*')) return true
|
||||
|
||||
const checkArr = Array.isArray(perm) ? perm : [perm]
|
||||
|
||||
if (mode === 'and') {
|
||||
// 所有权限都要有
|
||||
return checkArr.every(item => permList.includes(item))
|
||||
} else {
|
||||
// 有一个即可
|
||||
return checkArr.some(item => permList.includes(item))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录清空权限
|
||||
*/
|
||||
export function clearPermList() {
|
||||
uni.removeStorageSync('userPermission')
|
||||
}
|
||||
Reference in New Issue
Block a user