From 43b401e211c115e8fce77e965e5192e025955f30 Mon Sep 17 00:00:00 2001 From: "liujw155@outlook.com" Date: Mon, 16 May 2022 16:18:14 +0800 Subject: [PATCH] add device tab author --- src/subpackage/device/js/device_api.js | 4 ++ src/subpackage/device/pages/index/index.vue | 57 +++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/subpackage/device/js/device_api.js b/src/subpackage/device/js/device_api.js index 80c9df3..ff6be99 100644 --- a/src/subpackage/device/js/device_api.js +++ b/src/subpackage/device/js/device_api.js @@ -58,6 +58,10 @@ export const DEVICE_API = { // 20211015 orderRefund:`${ORIGIN}/admin/stadium/order/refund`, // 订场/次卡退款 + + // 【ID1000841】 20220516 小程序-商家助手菜单入口权限优化 + hardwareTypeList:`${ORIGIN}/admin/stadium/hardwareType/list`, // 设备权限列表 + } diff --git a/src/subpackage/device/pages/index/index.vue b/src/subpackage/device/pages/index/index.vue index b020bf3..7163596 100644 --- a/src/subpackage/device/pages/index/index.vue +++ b/src/subpackage/device/pages/index/index.vue @@ -20,10 +20,13 @@ - - - {{e.name || ''}} - + + + + {{e.name || ''}} + + + @@ -37,7 +40,6 @@ import deviceApi from '../../js/device_api'; const rootPage = '/subpackage/device' const tabArr = [ - {id: 1, name: '照明', path: `/pages/switch_manage/switch_manage`}, {id: 2, name: '空调', path: `/pages/switch_manage/switch_manage`}, {id: 3, name: '风扇', path: `/pages/switch_manage/switch_manage`}, @@ -57,7 +59,6 @@ const tabArr = [ // {id: 17, name: '窗帘', path: `/pages/switch_manage/switch_manage`}, {id: 18, name: '路由器', path: `/pages/switch_manage/switch_manage`}, {id: 19, name: '物联卡', path: `/pages/switch_manage/switch_manage`}, - ]; import { mapState } from 'vuex' export default { @@ -69,7 +70,6 @@ export default { storeList: state => state.device.storeList, curStoreInfo: state => state.device.curStoreInfo, }), - getTop(){ return (lineHeight)=>{ // #ifdef MP-WEIXIN @@ -80,12 +80,27 @@ export default { return top } }, + // + showHardwareIdLs(){ + let { hardwareTypeList } = this; + let _ls = hardwareTypeList || []; + let _fls = _ls.filter(ele=>ele.stadium_has); + let _idLs = _fls.map(el => el.mini_local_menu_id); + return _idLs || []; + }, + }, + watch: { + curStoreInfo(nw, od){ + console.warn(od.id, nw.id); + this.getHardwareTypeList(); + } }, data(){ return { - tabArr, - deviceInfo:"" - } + tabArr: [], + deviceInfo:"", + hardwareTypeList: [], + } }, async onLoad(){ try{ @@ -93,6 +108,7 @@ export default { let _brandInfo = await this.$store.dispatch('getBrandInfo'); await this.$store.dispatch('getStoreList'); this.updateAC(); + await this.getHardwareTypeList(); util.hideLoad(); }catch(err){ util.hideLoad(); @@ -100,9 +116,28 @@ export default { }, onShow() { - this.updateAC()//更新中控信息 + this.updateAC() // 更新中控信息 }, methods: { + isShowHardwareTab(e){ + let { showHardwareIdLs } = this; + if(!showHardwareIdLs || !showHardwareIdLs.length)return false; + return showHardwareIdLs.includes(e.id); + }, + getHardwareTypeList(){ + let { curStoreInfo } = this; + this.tabArr = []; + return deviceServer.get({ + url: deviceApi.hardwareTypeList, + data: { stadium_id: curStoreInfo.id }, + failMsg: '加载设备类型列表失败!' + }) + .then(res=>{ + let _ls = res || []; + if(_ls&&_ls.length)this.tabArr = tabArr; + return this.hardwareTypeList = _ls || []; + }) + }, copyDeviceID(){ let that = this uni.setClipboardData({