Browse Source

finish tid1641

tid1731
刘嘉炜 4 months ago
parent
commit
d2b0622697
  1. 4
      src/pages.json
  2. 6
      src/subpackage/device/js/device_api.js
  3. 34
      src/subpackage/device/pages/index/index.vue
  4. 180
      src/subpackage/device/pages/lighting_time/list.vue
  5. 66
      src/subpackage/device/pages/lighting_time/setting.vue
  6. 86
      src/subpackage/device/pages/lighting_timie/list.vue
  7. 8
      src/subpackage/device/pages/switch_manage/switch_manage.vue
  8. BIN
      src/subpackage/device/static/images/delete.png
  9. 4
      src/utils/util.js

4
src/pages.json

@ -440,13 +440,13 @@
}
},
{
"path": "pages/lighting_timie/list",
"path": "pages/lighting_time/list",
"style": {
"navigationBarTitleText": "照明管理"
}
},
{
"path": "pages/lighting_timie/setting",
"path": "pages/lighting_time/setting",
"style": {
"navigationBarTitleText": "照明管理"
}

6
src/subpackage/device/js/device_api.js

@ -69,6 +69,12 @@ export const DEVICE_API = {
brandList:`${ORIGIN}/stadium/brand/all`, // 获取品牌列表
brandInfo:`${ORIGIN}/stadium/brand/get`, // 获取品牌信息
// 20240830 tid1641 小程序-商家助手小程序照明定时任务优化
cacScheduledTaskGet:`${ORIGIN}/admin/cacScheduledTask/data`, // 获取YZK照明定时列表接口
cacScheduledTaskSave:`${ORIGIN}/admin/cacScheduledTask/save`, // 设置YZK照明定时
cacScheduledTaskDelete:`${ORIGIN}/admin/cacScheduledTask/delete`, // 删除YZK照明定时
}
export default DEVICE_API;

34
src/subpackage/device/pages/index/index.vue

@ -10,7 +10,8 @@
<store-name :theme="'light'"></store-name>
<view class="ih-container">
<view class="ic-title">欧轩智能中控</view>
<view class="ic-info">
<view class="ic-info" v-if="curStoreInfo.device_name">
<view class="ii-veiw">
<view class="iv-view">
<veiw class="iv-txt">设备id{{ curStoreInfo.device_name || "-" }}</veiw>
@ -32,7 +33,7 @@
</view>
<view class="ic-btn-box">
<view
v-if="oxAcInfo.extension&&oxAcInfo.extension.switch_device_name"
v-if="oxAcInfo.extension&&oxAcInfo.extension.switch_device_name&&curStoreInfo.device_name"
class="ic-btn"
hover-class="hover-active"
@click="restartBtn"
@ -118,13 +119,14 @@ export default {
line-height:${titleBarHeight}px;
`
return _styleStr
},
}
},
watch: {
async curStoreInfo(nw, od){
util.hideLoad();
this.getOuxuanacInfo(nw.device_name);
this.getHardwareTypeList(nw.id);
if(!nw.device_name)return; // tid1641 idid线
this.getOuxuanacInfo(nw.device_name);
this.updateAC(nw.device_name);
},
switchBrandInfo(nw, od){
@ -156,7 +158,7 @@ export default {
await this.$store.dispatch('getStoreList', { stadium_id: +options.stadium_id || '', storeChange: true });
let { curStoreInfo } = this;
this.getHardwareTypeList(curStoreInfo.id);
this.getOuxuanacInfo(curStoreInfo.device_name);
if(curStoreInfo?.device_name)this.getOuxuanacInfo(curStoreInfo.device_name);
this.getBrandSwitch();
util.hideLoad();
}catch(err){
@ -246,14 +248,26 @@ export default {
deviceServer.get({
url: deviceApi.acUpdate,
data: { id: device_name },
failMsg: '加载失败!'
isDefaultGet: false,
// failMsg: ''
})
.then(res=>{
util.hideLoad();
this.deviceInfo = res || {};
uni.setStorageSync("deviceInfo",res)
let _data = res?.data || {}
util.hideLoad();
if(_data.code === 0){
this.deviceInfo = _data?.data || {};
uni.setStorageSync("deviceInfo",res)
}else{
return Promise.reject(_data);
}
})
.catch(err=>{
util.hideLoad();
util.showModal({
title: '提示',
content: err?.message || '中控在线状态查询失败!'
})
})
.catch(util.hideLoad)
},
goBack(){
uni.navigateBack({ delta:1 });

180
src/subpackage/device/pages/lighting_time/list.vue

@ -0,0 +1,180 @@
<template>
<view class="lt-list">
<view class="ll-title">{{ optionsQuery.hardware_name || '-' }}</view>
<view class="ll-list">
<view class="ll-item" v-for="(e, i) in timingLs" :key="i">
<view class="li-line">
<view class="ll-txt">指令{{ getInstructTxt(e.operate) }}</view>
<image class="ll-icon" @click="deleteItem(e)" mode="aspectFit" src="/subpackage/device/static/images/delete.png"></image>
</view>
<view class="li-line">
<view class="ll-txt">时间{{ e.h_m_s || '-'}}</view>
</view>
<view class="li-line">
<view class="ll-txt">日期{{ e.day_of_week || '-' }}</view>
</view>
</view>
</view>
<view class="ll-fixed-space"></view>
<view class="ll-fixed">
<view class="lf-btn" @click="addTask">添加定时任务</view>
</view>
</view>
</template>
<script>
import deviceServer from '../../js/device_server';
import deviceApi from '../../js/device_api';
import { showModal, showNone, showLoad, hideLoad, routeTo, jsonPar, jsonStr } from "@/utils/util";
export default {
data(){
return {
timingLs: [],
optionsQuery: {},
}
},
onLoad(options){
options.hardware_name = jsonPar(options?.hardware_name);
this.optionsQuery = options;
},
onShow(){
let { optionsQuery } = this;
this.getTimingList({
hardware_id: optionsQuery?.hardware_id || ''
})
},
methods: {
addTask(){
let { hardware_id, hardware_name } = this.optionsQuery;
let _qryStr = `hardware_id=${hardware_id || ''}&hardware_name=${jsonStr(hardware_name || '')}`
routeTo(`/subpackage/device/pages/lighting_time/setting?${_qryStr}`, 'nT')
},
deleteItem(e){
showModal({
title: '提示',
content: '是否删除该项?',
showCancel: true,
confirmText: '是',
cancelText: '否',
success: res =>{
if(res?.confirm){
this.cacScheduledTaskDelete(e?.id)
.then(res=>{
if(res === 'SUCCESS')this.getTimingList({ hardware_id: e?.hardware_id })
})
}
}
})
},
cacScheduledTaskDelete(id){
showLoad();
return deviceServer.post({
url: deviceApi.cacScheduledTaskDelete,
data: { id },
isDefaultGet: false,
})
.then(res => {
hideLoad();
let _data = res?.data || {};
if(_data.code === 0){
showModal({
title: '提示',
content: _data.message || '操作成功!'
})
return "SUCCESS"
}else{
return Promise.reject(_data);
}
})
.catch(err => {
hideLoad();
showModal({
title: '提示',
content: err.message || '操作失败!'
})
console.warn('setting cacScheduledTaskSave err', err);
})
},
getInstructTxt(operate){
let _obj = {
'open': '开启',
'close': '关闭'
}
return _obj?.[operate] || operate || '未知'
},
getTimingList({
hardware_id = '',
}){
showLoad();
return deviceServer.get({
url: deviceApi.cacScheduledTaskGet,
data: {
hardware_id,
},
failMsg: '获取定时列表失败'
})
.then(res => {
hideLoad();
let _ls = res || [];
this.timingLs = _ls;
})
.catch(err => {
hideLoad();
console.warn('lighting_time list getTimingList err --->', err);
// return Promise.reject(err);
})
},
}
}
</script>
<style lang="scss">
.ll-title{
padding: 46upx 40upx 60upx;
@include flcw(44upx, 60upx, #1a1a1a, 500);
@include tHide;
}
.ll-list{
.ll-item{
padding: 24upx 30upx;
background: #fff;
&+.ll-item{
margin-top: 24upx;
}
.li-line{
@include ctf(space-between);
align-items: baseline;
&+.li-line{
margin-top: 16upx;
}
.ll-txt{
@include flcw(28upx, 40upx, #1a1a1a);
}
.ll-icon {
flex-shrink: 0;
margin-left: 12upx;
width: 44upx;
height: 44upx;
}
}
}
}
.ll-fixed-space{
padding-bottom: 132upx;
@include isPd(132upx);
}
.ll-fixed{
position: fixed;
bottom: 0;
padding: 10upx 24upx;
width: 100%;
@include isPd(10upx);
.lf-btn{
text-align: center;
border-radius: 10upx;
background: $mColor;
@include flcw(32upx, 112upx, #fff, 500);
}
}
</style>

66
src/subpackage/device/pages/lighting_timie/setting.vue → src/subpackage/device/pages/lighting_time/setting.vue

@ -1,6 +1,6 @@
<template>
<view class="lt-setting">
<view class="ll-title">1号馆照明定时</view>
<view class="ll-title">{{ optionsQuery.hardware_name || '-' }}</view>
<view class="ls-container">
<view class="lc-select">
@ -56,23 +56,31 @@
<view class="ll-fixed-space"></view>
<view class="ll-fixed">
<view class="lf-btn">添加定时任务</view>
<view class="lf-btn" @click="confirmBtn">添加定时任务</view>
</view>
</view>
</template>
<script>
import deviceServer from '../../js/device_server';
import deviceApi from '../../js/device_api';
import { showModal, showNone, showLoad, hideLoad, routeTo, jsonPar } from "@/utils/util";
export default {
data(){
return {
weeks: [ '日', '一', '二', '三', '四', '五', '六' ],
weeks: [ '日', '一', '二', '三', '四', '五', '六' ].map(e=>`星期${e}`),
condition: {
instruct: 'open', // open: , close:
time: '', //
time: '00:00', //
weekLs: [], //
}
},
optionsQuery: {}
}
},
onLoad(options){
options.hardware_name = jsonPar(options?.hardware_name);
this.optionsQuery = options || {}
},
methods: {
switchChange(e){
if(e.detail.value){
@ -88,7 +96,53 @@ export default {
}else{
weekLs.push(e);
}
}
},
confirmBtn(){
let { optionsQuery, condition } = this;
if(!condition?.weekLs?.length)return showNone('请选择日期!');
if(!condition?.time)return showNone('请选时间点!');
this.cacScheduledTaskSave({
hardware_id: optionsQuery?.hardware_id || '',
day_of_week: condition?.weekLs?.join(','),
h_m_s: `${condition?.time}:00`,
operate: condition?.instruct,
})
},
cacScheduledTaskSave({
hardware_id = '',
day_of_week = '',
h_m_s = '',
operate = ''
}){
showLoad();
return deviceServer.post({
url: deviceApi.cacScheduledTaskSave,
data: { hardware_id, day_of_week, h_m_s, operate },
isDefaultGet: false,
})
.then(res => {
hideLoad();
let _data = res?.data || {};
if(_data.code === 0){
showModal({
title: '提示',
content: _data.message || '操作成功!',
})
}else{
return Promise.reject(_data);
}
})
.catch(err => {
hideLoad();
showModal({
title: '提示',
content: err.message || '操作失败!'
})
console.warn('setting cacScheduledTaskSave err', err);
})
},
}
}
</script>

86
src/subpackage/device/pages/lighting_timie/list.vue

@ -1,86 +0,0 @@
<template>
<view class="lt-list">
<view class="ll-title">1号馆照明定时</view>
<view class="ll-list">
<view class="ll-item" v-for="i in 12" :key="i">
<view class="li-line">
<view class="ll-txt">指令关闭</view>
<image class="ll-icon"></image>
</view>
<view class="li-line">
<view class="ll-txt">时间08:00</view>
</view>
<view class="li-line">
<view class="ll-txt">日期周日周一周二周三周四周五周六</view>
</view>
</view>
</view>
<view class="ll-fixed-space"></view>
<view class="ll-fixed">
<view class="lf-btn">添加定时任务</view>
</view>
</view>
</template>
<script>
export default {
data(){
return {
condition: {
}
}
}
}
</script>
<style lang="scss">
.ll-title{
padding: 46upx 40upx 60upx;
@include flcw(44upx, 60upx, #1a1a1a, 500);
@include tHide;
}
.ll-list{
.ll-item{
padding: 24upx 30upx;
background: #fff;
&+.ll-item{
margin-top: 24upx;
}
.li-line{
@include ctf(space-between);
align-items: baseline;
&+.li-line{
margin-top: 16upx;
}
.ll-txt{
@include flcw(28upx, 40upx, #1a1a1a);
}
.ll-icon {
flex-shrink: 0;
margin-left: 12upx;
width: 44upx;
height: 44upx;
background: skyblue;
}
}
}
}
.ll-fixed-space{
padding-bottom: 132upx;
@include isPd(132upx);
}
.ll-fixed{
position: fixed;
bottom: 0;
padding: 10upx 24upx;
width: 100%;
@include isPd(10upx);
.lf-btn{
text-align: center;
border-radius: 10upx;
background: $mColor;
@include flcw(32upx, 112upx, #fff, 500);
}
}
</style>

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

@ -210,7 +210,13 @@ export default {
if(this.pageInfo.hardware_type=='IotSim')return util.routeTo(`/subpackage/device/pages/index/lot_manage?mac=${switchInfo.hardware_standard}`, 'nT');
}
if(status == 3) return (()=>{
//
if(status === 3 && switchInfo?.hardware_type === "Light" && switchInfo?.hardware_connect_method === "YZK" ){
let { hardware_name, id } = switchInfo;
let _qryStr = `hardware_id=${id || ''}&hardware_name=${util.jsonStr(hardware_name || '')}`
return util.routeTo(`/subpackage/device/pages/lighting_time/list?${_qryStr}`, 'nT');
} else if (status == 3) return (()=>{
switchInfo.switchData = _data;//
let timing_setting = `/subpackage/device/pages/timing/timing_setting?switchInfo=${encodeURIComponent(JSON.stringify(switchInfo))}`
util.routeTo(`${timing_setting}`, 'nT');

BIN
src/subpackage/device/static/images/delete.png

After

Width: 36  |  Height: 36  |  Size: 365 B

4
src/utils/util.js

@ -150,10 +150,10 @@ export function debounce(func, wait, immediate) {
}
}
function jsonStr(data){
export function jsonStr(data){
return encodeURIComponent(JSON.stringify(data))
}
function jsonPar(json){
export function jsonPar(json){
return JSON.parse(decodeURIComponent(json))
}

Loading…
Cancel
Save