校验函数
This commit is contained in:
@@ -39,11 +39,18 @@
|
|||||||
<view class="scroll-content">
|
<view class="scroll-content">
|
||||||
<!-- banner -->
|
<!-- banner -->
|
||||||
<view class="bannarClass" v-if="bannerList && bannerList.length > 0">
|
<view class="bannarClass" v-if="bannerList && bannerList.length > 0">
|
||||||
<up-swiper :list="bannerList" indicator indicatorMode="dot" radius="15" height="180" keyName="url">
|
<up-swiper
|
||||||
<template #default="{ item, index }">
|
:list="bannerList"
|
||||||
<image :src="item.url || item" mode="aspectFill" class="banner-img"></image>
|
indicator
|
||||||
</template>
|
indicatorMode="dot"
|
||||||
</up-swiper>
|
radius="15"
|
||||||
|
height="180"
|
||||||
|
keyName="url"
|
||||||
|
>
|
||||||
|
<template #default="{ item, index }">
|
||||||
|
<image :src="item.url || item" mode="aspectFill" class="banner-img"></image>
|
||||||
|
</template>
|
||||||
|
</up-swiper>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 巡检 -->
|
<!-- 巡检 -->
|
||||||
@@ -94,7 +101,7 @@
|
|||||||
<view class="function-container">
|
<view class="function-container">
|
||||||
<!-- 第一行功能:故障上报、一键开门、工单大厅、我的工单 -->
|
<!-- 第一行功能:故障上报、一键开门、工单大厅、我的工单 -->
|
||||||
<view class="function-row">
|
<view class="function-row">
|
||||||
<view class="function-item" @click="goToReport">
|
<view class="function-item" @click="goToReport" v-if="hasPermi('butler:fault:report')">
|
||||||
<image
|
<image
|
||||||
class="item-icon"
|
class="item-icon"
|
||||||
src="https://wuyeadmin.bugtc.com/images/imgs/fault-report.png"
|
src="https://wuyeadmin.bugtc.com/images/imgs/fault-report.png"
|
||||||
@@ -102,7 +109,11 @@
|
|||||||
></image>
|
></image>
|
||||||
<text class="item-text">故障上报</text>
|
<text class="item-text">故障上报</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="function-item" @click="goToOneOpenDoor">
|
<view
|
||||||
|
class="function-item"
|
||||||
|
@click="goToOneOpenDoor"
|
||||||
|
v-if="hasPermi('butler:door:open')"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="item-icon"
|
class="item-icon"
|
||||||
src="https://wuyeadmin.bugtc.com/images/imgs/open.png"
|
src="https://wuyeadmin.bugtc.com/images/imgs/open.png"
|
||||||
@@ -110,7 +121,11 @@
|
|||||||
></image>
|
></image>
|
||||||
<text class="item-text">一键开门</text>
|
<text class="item-text">一键开门</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="function-item" @tap="goToTicketHall">
|
<view
|
||||||
|
class="function-item"
|
||||||
|
@tap="goToTicketHall"
|
||||||
|
v-if="hasPermi('butler:workOrder:hall')"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="item-icon"
|
class="item-icon"
|
||||||
src="https://wuyeadmin.bugtc.com/images/imgs/work-order.png"
|
src="https://wuyeadmin.bugtc.com/images/imgs/work-order.png"
|
||||||
@@ -118,7 +133,11 @@
|
|||||||
></image>
|
></image>
|
||||||
<text class="item-text">工单大厅</text>
|
<text class="item-text">工单大厅</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="function-item" @tap="goToMyTicket">
|
<view
|
||||||
|
class="function-item"
|
||||||
|
@tap="goToMyTicket"
|
||||||
|
v-if="hasPermi('butler:workOrder:mine')"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="item-icon"
|
class="item-icon"
|
||||||
src="https://wuyeadmin.bugtc.com/images/imgs/my-work.png"
|
src="https://wuyeadmin.bugtc.com/images/imgs/my-work.png"
|
||||||
@@ -129,7 +148,11 @@
|
|||||||
</view>
|
</view>
|
||||||
<!-- 第二行 -->
|
<!-- 第二行 -->
|
||||||
<view class="function-row" style="margin-top: 2px">
|
<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
|
<image
|
||||||
class="item-icon"
|
class="item-icon"
|
||||||
src="https://wuyeadmin.bugtc.com/images/imgs/complaint.png"
|
src="https://wuyeadmin.bugtc.com/images/imgs/complaint.png"
|
||||||
@@ -137,7 +160,11 @@
|
|||||||
></image>
|
></image>
|
||||||
<text class="item-text">投诉处理</text>
|
<text class="item-text">投诉处理</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="function-item" @tap="goToReplacement_record">
|
<view
|
||||||
|
class="function-item"
|
||||||
|
@tap="goToReplacement_record"
|
||||||
|
v-if="hasPermi('butler:,meter:replace')"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="item-icon"
|
class="item-icon"
|
||||||
src="https://wuye.ckdzkj.com/images/home/updateDevice.png"
|
src="https://wuye.ckdzkj.com/images/home/updateDevice.png"
|
||||||
@@ -161,7 +188,7 @@ import {
|
|||||||
getNewNoticeData,
|
getNewNoticeData,
|
||||||
getBannarList
|
getBannarList
|
||||||
} from '../../api/api.js'
|
} from '../../api/api.js'
|
||||||
|
import { hasPermi } from '../../utils/permissions.js'
|
||||||
// 列表数据状态
|
// 列表数据状态
|
||||||
const currentCommunity = ref('请先绑定房屋')
|
const currentCommunity = ref('请先绑定房屋')
|
||||||
const bannerList = ref([])
|
const bannerList = ref([])
|
||||||
@@ -171,7 +198,6 @@ const pendingCount = ref(0) //待巡检
|
|||||||
const InspectedCount = ref(0) //已巡检
|
const InspectedCount = ref(0) //已巡检
|
||||||
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
|
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
|
||||||
|
|
||||||
|
|
||||||
// =======方法=======
|
// =======方法=======
|
||||||
// 跳转小区
|
// 跳转小区
|
||||||
const navigateToPage = () => {
|
const navigateToPage = () => {
|
||||||
@@ -235,7 +261,7 @@ const goToReport = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 跳转到仪表换新
|
// 跳转到仪表换新
|
||||||
const goToReplacement_record = () =>{
|
const goToReplacement_record = () => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pageSubPack/instrument/replacement_record'
|
url: '/pageSubPack/instrument/replacement_record'
|
||||||
})
|
})
|
||||||
@@ -291,7 +317,8 @@ const getNoticeData = () => {
|
|||||||
}
|
}
|
||||||
// 获取bannar图
|
// 获取bannar图
|
||||||
function getbannarData() {
|
function getbannarData() {
|
||||||
getBannarList().then(res => {
|
getBannarList()
|
||||||
|
.then(res => {
|
||||||
if (res.code === 200 && res.data) {
|
if (res.code === 200 && res.data) {
|
||||||
// 只有数据真正变化时才更新,避免 swiper 重新渲染导致闪动
|
// 只有数据真正变化时才更新,避免 swiper 重新渲染导致闪动
|
||||||
const newData = res.data
|
const newData = res.data
|
||||||
@@ -332,7 +359,6 @@ onLoad(() => {
|
|||||||
onUnload(() => {
|
onUnload(() => {
|
||||||
uni.$off('confirm', slelctHomeData)
|
uni.$off('confirm', slelctHomeData)
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -452,7 +478,6 @@ onUnload(() => {
|
|||||||
border-radius: 15rpx;
|
border-radius: 15rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.inspectionClass {
|
.inspectionClass {
|
||||||
background: linear-gradient(to right, #7b87fa, #4d5dfa);
|
background: linear-gradient(to right, #7b87fa, #4d5dfa);
|
||||||
border-radius: 16rpx;
|
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