5 Commits

  1. 70
      package.json
  2. 2905
      pnpm-lock.yaml
  3. 167
      src/subpackage/device/pages/switch_manage/switch_manage.vue

70
package.json

@ -42,28 +42,30 @@
"test:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin jest -i"
},
"dependencies": {
"@dcloudio/uni-app-plus": "2.0.1-36520221121002",
"@dcloudio/uni-h5": "2.0.1-36520221121002",
"@dcloudio/uni-app": "2.0.2-4050720250324001",
"@dcloudio/uni-app-plus": "2.0.2-4050720250324001",
"@dcloudio/uni-h5": "2.0.2-4050720250324001",
"@dcloudio/uni-helper-json": "*",
"@dcloudio/uni-i18n": "2.0.1-36520221121002",
"@dcloudio/uni-mp-360": "2.0.1-36520221121002",
"@dcloudio/uni-mp-alipay": "2.0.1-36520221121002",
"@dcloudio/uni-mp-baidu": "2.0.1-36520221121002",
"@dcloudio/uni-mp-jd": "2.0.1-36520221121002",
"@dcloudio/uni-mp-kuaishou": "2.0.1-36520221121002",
"@dcloudio/uni-mp-lark": "2.0.1-36520221121002",
"@dcloudio/uni-mp-qq": "2.0.1-36520221121002",
"@dcloudio/uni-mp-toutiao": "2.0.1-36520221121002",
"@dcloudio/uni-mp-vue": "2.0.1-36520221121002",
"@dcloudio/uni-mp-weixin": "2.0.1-36520221121002",
"@dcloudio/uni-mp-xhs": "2.0.1-36520221121002",
"@dcloudio/uni-quickapp-native": "2.0.1-36520221121002",
"@dcloudio/uni-quickapp-webview": "2.0.1-36520221121002",
"@dcloudio/uni-stacktracey": "2.0.1-36520221121002",
"@dcloudio/uni-stat": "2.0.1-36520221121002",
"@vue/shared": "^3.0.0",
"@dcloudio/uni-i18n": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-360": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-alipay": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-baidu": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-harmony": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-jd": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-kuaishou": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-lark": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-qq": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-toutiao": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-vue": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-weixin": "2.0.2-4050720250324001",
"@dcloudio/uni-mp-xhs": "2.0.2-4050720250324001",
"@dcloudio/uni-quickapp-native": "2.0.2-4050720250324001",
"@dcloudio/uni-quickapp-webview": "2.0.2-4050720250324001",
"@dcloudio/uni-stacktracey": "2.0.2-4050720250324001",
"@dcloudio/uni-stat": "2.0.2-4050720250324001",
"@vue/shared": "^3.5.13",
"core-js": "^3.6.5",
"flyio": "^0.6.2",
"flyio": "^0.6.14",
"pinyin-engine": "^1.2.2",
"regenerator-runtime": "^0.12.1",
"sass": "1.63.3",
@ -71,27 +73,27 @@
},
"devDependencies": {
"@dcloudio/types": "*",
"@dcloudio/uni-automator": "2.0.1-36520221121002",
"@dcloudio/uni-cli-i18n": "2.0.1-36520221121002",
"@dcloudio/uni-cli-shared": "2.0.1-36520221121002",
"@dcloudio/uni-migration": "2.0.1-36520221121002",
"@dcloudio/uni-template-compiler": "2.0.1-36520221121002",
"@dcloudio/vue-cli-plugin-hbuilderx": "2.0.1-36520221121002",
"@dcloudio/vue-cli-plugin-uni": "2.0.1-36520221121002",
"@dcloudio/vue-cli-plugin-uni-optimize": "2.0.1-36520221121002",
"@dcloudio/webpack-uni-mp-loader": "2.0.1-36520221121002",
"@dcloudio/webpack-uni-pages-loader": "2.0.1-36520221121002",
"@dcloudio/uni-automator": "2.0.2-4050720250324001",
"@dcloudio/uni-cli-i18n": "2.0.2-4050720250324001",
"@dcloudio/uni-cli-shared": "2.0.2-4050720250324001",
"@dcloudio/uni-migration": "2.0.2-4050720250324001",
"@dcloudio/uni-template-compiler": "2.0.2-4050720250324001",
"@dcloudio/vue-cli-plugin-hbuilderx": "2.0.2-4050720250324001",
"@dcloudio/vue-cli-plugin-uni": "2.0.2-4050720250324001",
"@dcloudio/vue-cli-plugin-uni-optimize": "2.0.2-4050720250324001",
"@dcloudio/webpack-uni-mp-loader": "2.0.2-4050720250324001",
"@dcloudio/webpack-uni-pages-loader": "2.0.2-4050720250324001",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-plugin-import": "^1.11.0",
"cross-env": "^7.0.2",
"jest": "^25.4.0",
"babel-plugin-import": "^1.13.8",
"cross-env": "^7.0.3",
"jest": "^25.5.4",
"mini-types": "*",
"miniprogram-api-typings": "*",
"numeral": "^2.0.6",
"postcss-comment": "^2.0.0",
"vue-template-compiler": "^2.6.11",
"vuex": "^3.2.0"
"vuex": "^3.6.2"
},
"browserslist": [
"Android >= 4",

2905
pnpm-lock.yaml
File diff suppressed because it is too large
View File

167
src/subpackage/device/pages/switch_manage/switch_manage.vue

@ -3,6 +3,7 @@
<store-name></store-name>
<view class="sm-tit">{{pageInfo.name || '-'}}</view>
<view class="sm-tip" v-if="pageInfo.longOpenName"><text>*</text>长开表示不再被系统智能控制只有手动关闭后才会被智能控制请谨慎操作</view>
<view class="sm-tip" v-if="['Light', 'Air'].includes(pageInfo.hardware_type)">现场电源断开则无法获取到开关状态状态是通过硬件发送通知给服务器则状态获取可能存在延时</view>
<view class="sm-list">
<view v-for="(e, i) in deviceList" :key="i" :class="[ 'sl-item', pageInfo.iconNum<=2?'sl-limit':'' ]">
@ -16,10 +17,16 @@
sim状态: <text>{{getLotStatus(e)}}</text>
</view>
<view class="sr-bot" v-else-if="pageInfo.id !=5">
<view :class="[e.defineStatusCode == 1?'active':'']">
<text>{{ e.defineStatusCode == 1 ? '设备在线' : e.defineStatusCode == 0?'设备离线' : '-' }}</text>
<view class="sb-online-status">
<view :class="[e.defineStatusCode == 1?'active':'']">
<text>{{ e.defineStatusCode == 1 ? '设备在线' : e.defineStatusCode == 0?'设备离线' : '-' }}</text>
</view>
<image mode="aspectFit" src="/subpackage/device/static/images/refresh.png" @click="refreshStatusBtn({switchInfo:e, index:i})"></image>
</view>
<view class="sb-open-status" v-if="['Light', 'Air'].includes(e.hardware_type)">
当前开关状态{{ (e.extension&&e.extension.hardware_status_info&&e.extension.hardware_status_info.switch_status) || '-' }}
<image mode="aspectFit" src="/subpackage/device/static/images/refresh.png" @click="refreshOpenStatusBtn(e, i)"></image>
</view>
<image mode="aspectFit" src="/subpackage/device/static/images/refresh.png" @click="refreshStatusBtn({switchInfo:e, index:i})"></image>
</view>
</view>
</view>
@ -72,7 +79,7 @@ import deviceServer from '../../js/device_server';
import deviceApi from '../../js/device_api';
import { mapState } from 'vuex';
import util from '../../../../utils/util';
import util, { debounce, showLoad, hideLoad } from '../../../../utils/util';
import DEVICE_FUN from '../../js/device_fun.js';
export default {
@ -111,6 +118,7 @@ export default {
return {
pageInfo: {},
deviceList: [],
stadium_id: '',
}
},
/**
@ -121,24 +129,29 @@ export default {
*/
onLoad(options){
let _pageInfo = getShowArr(`s${options.sid}`) || {};
let _stadiumId = options?.stadium_id ?? '';
this.pageInfo = _pageInfo;
this.stadium_id = _stadiumId
uni.setNavigationBarTitle({ title: _pageInfo.name });
this.getDeviceList({
stadium_id: options.stadium_id || this.curStoreInfo.id,
stadium_id: _stadiumId || this.curStoreInfo.id,
hardware_type: _pageInfo.hardware_type
})
setTimeout(_=>{
this.$nextTick(_=>{
uni.createSelectorQuery().selectAll(".si-bottom > view")
.boundingClientRect(data => {
console.warn('createSelectorQuery', data)
}).exec();
})
}, 1000)
},
methods: {
refreshOpenStatusBtn: debounce(async function(e, i){
let _devices = await this.getDevices({
stadium_id: e?.stadium_id ?? '',
hardware_type: e?.hardware_type ?? '',
"filter[id]": e?.id ?? ''
});
let _deviceInfo = _devices?.[0] ?? {};
if(_deviceInfo?.id === e.id){
this.deviceList[i].extension.hardware_status_info = _deviceInfo?.extension?.hardware_status_info ?? null
}
}, 300, true),
isDetailBtn(e){
if(e&&e.toString() === "[object Object]"){
return e.hardware_model == 'XiaoHuiXiong' && e.hardware_type === 'Air';
@ -152,39 +165,48 @@ export default {
let _qrStr = util.jsonStr(_queryObj);
if(e.hardware_type == "Air")return util.routeTo(`/subpackage/device/pages/air_conditioner/detail/detail?qrstr=${_qrStr}&name=${e.hardware_name || '-'}`, 'nT');
},
getDeviceList({
stadium_id,
hardware_type,
limit = 100,
page = 1
}){
util.showLoad();
let reqListData = {
getDevices({ stadium_id, hardware_type = '', id = '', limit = 1000, page = 1, ...agrs }){
showLoad();
return deviceServer.get({
url: deviceApi.hardwareList,
data: {
'filter[hardware_type]': hardware_type,
'filter[stadium_id]': stadium_id,
'limit': limit,
'page': page,
}
if(hardware_type=="WaterValve") reqListData.operating_status = 1; //0723
deviceServer.get({
url: deviceApi.hardwareList,
data: reqListData,
limit,
page,
...agrs
},
failMsg: '加载失败!'
})
.then(res=>{
util.hideLoad();
let _list = res.list || [];
if(hardware_type=="Router4G"){ //线
_list = _list.map((e,i)=>{
hideLoad();
return res?.list ?? []
})
.catch(err=>{
hideLoad();
console.warn('subpackage device pages switch mange getSingleDevice err', err);
})
},
async getDeviceList({
stadium_id,
hardware_type,
limit = 1000,
page = 1
}){
let _query = {
stadium_id, hardware_type, limit, page
}
if(hardware_type=="WaterValve") _query['operating_status'] = 1; //0723
let _devices = await this.getDevices(_query);
if(_devices?.length){
if(hardware_type=="Router4G"){ //线
_devices = _devices.map((e,i)=>{
e['defineStatusCode'] = e.extension.online? 1 : 0;
return e
})
}
this.deviceList = _list;
console.log(res)
})
.catch(util.hideLoad)
}
this.deviceList = _devices;
},
controlDevice(e){
util.routeTo(`/subpackage/device/pages/index/lot_manage?mac=${switchInfo.hardware_standard}`, 'nT');
@ -229,7 +251,6 @@ export default {
}
this.operateReq({ data: _data });
}, 300, 300),
//
@ -652,6 +673,17 @@ function getShowArr(key){
&.sl-limit{
flex-grow: 0;
width: 328upx !important;
.si-top>.st-right>.sr-bot{
flex-wrap: wrap;
.sb-open-status{
margin-left: 0;
font-size: 20upx;
}
image{
width: 26upx;
height: 26upx;
}
}
}
.si-top{
padding: 20upx 20upx 30upx;
@ -683,36 +715,45 @@ function getShowArr(key){
}
.sr-bot{
display: flex;
align-items: center;
>view{
margin-right: 8upx;
padding: 0 12upx;
font-size: 20upx;
line-height: 28upx;
border-radius: 28upx;
border: 2upx solid #9A9A9D;
color: #9A9A9D;
&::before{
content: '';
margin-right: 12upx;
margin-top: -4upx;
display: inline-block;
vertical-align: middle;
width: 8upx;
height: 8upx;
border-radius: 50%;
background-color: #9A9A9D;
}
&.active{
color: #333333;
.sb-online-status{
@include ctf;
>view{
padding: 0 12upx;
border-radius: 28upx;
border: 2upx solid #9A9A9D;
@include flcw(20upx, 28upx, #9A9A9D);
&::before{
background-color: $themeColor;
content: '';
margin-right: 12upx;
margin-top: -4upx;
display: inline-block;
vertical-align: middle;
width: 8upx;
height: 8upx;
border-radius: 50%;
background-color: #9A9A9D;
}
&.active{
color: #333333;
&::before{
background-color: $themeColor;
}
}
}
}
.sb-open-status{
margin-left: auto;
margin-right: 0;
@include flcw(28upx, 40upx, #333);
image{
vertical-align: middle;
}
}
>image{
image{
flex-shrink: 0;
flex-grow: 0;
margin-left: 8upx;
width: 32upx;
height: 32upx;
}

Loading…
Cancel
Save