Remotecontrol.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. <template>
  2. <view>
  3. <!-- <view class="position">
  4. <picker mode="multiSelector" @columnchange="bindMultiPickerColumnChange"
  5. @change="(val)=>confirmHandle(val,'position')" :range="positionList" style="width:100%;height: 100%;"
  6. range-key="orgName">
  7. <u-icon name="map-fill" color="#fff" class="inline"></u-icon>
  8. <view class="uni-input inline positionName">{{name}}</view>
  9. <u-icon name="arrow-rightward" class="inline" color="#fff"></u-icon>
  10. </picker>
  11. </view> -->
  12. <u-cell-group class="toptemplate">
  13. <u-cell :title="mytitle" @click="floorchange">
  14. <u-icon slot="icon" size="40" color="#fff" name="map"></u-icon>
  15. <u-icon slot="right-icon" size="40" color="#fff" name="search"></u-icon>
  16. </u-cell>
  17. </u-cell-group>
  18. <view class="form">
  19. <view class="drawdownMenu">
  20. <picker @change="(val)=>confirmHandle(val,'deviceType')" :value="deviceTypeIndex"
  21. :range="deviceTypeList" style="width:100%;height: 100%;" range-key="dictLabel">
  22. <view class="uni-input">{{deviceTypeList[deviceTypeIndex].dictLabel}}</view>
  23. <u-icon name="arrow-down-fill" color="#666" size="16" class="inline"></u-icon>
  24. </picker>
  25. </view>
  26. <view class="drawdownMenu">
  27. <picker @change="(val)=>confirmHandle(val,'deviceStatus')" :value="deviceStatusIndex"
  28. :range="deviceStatusList" style="width:100%;height: 100%;" range-key="text">
  29. <view class="uni-input">{{deviceStatusList[deviceStatusIndex].text}}</view>
  30. <u-icon name="arrow-down-fill" color="#666" size="16" class="inline"></u-icon>
  31. </picker>
  32. </view>
  33. </view>
  34. <view class="total">
  35. 共有<text style="color: #f44;">{{total}}</text>条记录
  36. </view>
  37. <!-- 列表 -->
  38. <view class="list">
  39. <template v-if="deviceType == 'AirConditioner'">
  40. <view class="each c" v-for="(item,index) in dataList" :class="'bg'+(item.attributeList.length==0?'':item.attributeList[2].value)">
  41. <div class="top1">
  42. <template v-if="item.attributeList.length!=0">
  43. <image v-if="item.attributeList[2].value == '1'"
  44. src="../../../static/management/taiyang.png"></image>
  45. <image v-if="item.attributeList[2].value == '2'||item.attributeList[2].value == '0'"
  46. src="../../../static/management/zl.png"></image>
  47. <image v-if="item.attributeList[2].value == '4'"
  48. src="../../../static/management/auto.png"</image>
  49. <image v-if="item.attributeList[2].value == '8'"
  50. src="../../../static/management/cs.png"</image>
  51. </template>
  52. <view class="l1">{{item.airConditionerName}}</view>
  53. <view class="l2">{{ item.installSite }}{{ item.roomNumbers }}</view>
  54. <view class="l3">{{item.attributeList.length==0?'--':item.attributeList[5].value}}℃</view>
  55. <view class="l4">室温:{{ item.attributeList.length==0?'--':item.attributeList[4].value }}℃</view>
  56. </div>
  57. </div>
  58. <view class="operation" v-if="item.attributeList&&item.attributeList.length!=0">
  59. <picker
  60. @change="(val)=>confirmHandle(val,'modeType',item.deviceId,item.attributeList[2].sensorAddress)"
  61. :value="item.attributeList[2].value|findInd(modeTypeList)" :range="modeTypeList"
  62. style="width:100%;height: 100%;" range-key="dictLabel">
  63. <view class="uni-input">{{findInd2(item.attributeList[2].value,modeTypeList)}}</view>
  64. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  65. </picker>
  66. <picker
  67. @change="(val)=>confirmHandle(val,'temp',item.deviceId,item.attributeList[5].sensorAddress)"
  68. :value="item.attributeList[5].value|findInd(temperatureList)" :range="temperatureList"
  69. style="width:100%;height: 100%;">
  70. <view class="uni-input">{{item.attributeList[5].value}}</view>
  71. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  72. </picker>
  73. <picker
  74. @change="(val)=>confirmHandle(val,'speedType',item.deviceId,item.attributeList[0].sensorAddress)"
  75. :value="item.attributeList[0].value|findInd(speedTypeList)" :range="speedTypeList"
  76. style="width:100%;height: 100%;" range-key="dictLabel">
  77. <view class="uni-input">{{findInd2(item.attributeList[0].value,speedTypeList)}}</view>
  78. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  79. </picker>
  80. </view>
  81. <view class="operation" v-else>
  82. <picker style="width:100%;height: 100%;">
  83. <view class="uni-input">--</view>
  84. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  85. </picker>
  86. <picker style="width:100%;height: 100%;">
  87. <view class="uni-input">--</view>
  88. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  89. </picker>
  90. <picker style="width:100%;height: 100%;">
  91. <view class="uni-input">--</view>
  92. <u-icon name="arrow-down" color="#999" size="16" class="inline"></u-icon>
  93. </picker>
  94. </view>
  95. <switch :checked="item.attributeList[3].value==1?true:false" v-if="item.attributeList.length!=0"
  96. @change="(val)=>changeSwitch('AirConditioner', val, item.deviceId, index,item.attributeList[3].sensorAddress)"
  97. style="transform:scale(0.7)" class="switch" />
  98. </view>
  99. </template>
  100. <template v-if="deviceType == 'Relay'">
  101. <view :class="item.status==0?'each':'each on2'" v-for="(item,index) in dataList">
  102. <div class="top">
  103. <view class="l1">{{item.controlName}}</view>
  104. <view class="l2">空间信息:{{ item.installSite }}</view>
  105. <div class="open">
  106. <image src="../../../static/management/kg.png" @click="control(item.deviceId, item.status)">
  107. </image>
  108. <p>{{ item | delStatus }}</p>
  109. </div>
  110. </div>
  111. <div class="operation2" v-if="item.attributeList && item.attributeList.length > 0">
  112. <div v-for="(ope, index2) in item.relayNames" :key="index2" class="s">
  113. <p>{{ ope.name }}</p>
  114. <u-switch :value="item.attributeList[index2].value | delTimestamp" active-value="a"
  115. inactive-value="b" @change="handleChange(
  116. 'switch',
  117. $event,
  118. index,
  119. item.attributeList[index2].sensorAddress
  120. )
  121. " style="margin: 0 auto;height: 16px;"></u-switch>
  122. </div>
  123. </div>
  124. </view>
  125. </template>
  126. </view>
  127. <u-picker :show="showfloor" ref="uPicker" @confirm="confirmfloor" @cancel='cancelfloor' :columns="columns"
  128. keyName="orgName" @change="changeHandler" visibleItemCount="7" itemHeight="70"></u-picker>
  129. </view>
  130. </template>
  131. <script>
  132. import {
  133. isEmpty,
  134. getDictDataList,
  135. getUrlKey
  136. } from "@/utils/index";
  137. import Api from "./@/http/Api.js";
  138. export default {
  139. data() {
  140. return {
  141. showfloor: false,
  142. showtype: false,
  143. modeTypeList: [],
  144. modeTypeIndex: 0,
  145. temperatureList: [],
  146. tempIndex: 0,
  147. columns: [],
  148. speedTypeList: [],
  149. speedTypeIndex: 0,
  150. dataForm: {
  151. page: 1,
  152. limit: 10,
  153. buildingId: "",
  154. storeyId: "",
  155. status: "",
  156. controlCategory: "CommonLighting",
  157. },
  158. airIcon:{
  159. 2:'',
  160. 4:'',
  161. 8:''
  162. },
  163. mytitle: '',
  164. total: 0,
  165. refreshing: false,
  166. finished: false,
  167. deviceTypeIndex: 0,
  168. deviceStatusIndex: 0,
  169. name: '跨境电商',
  170. projectName: '',
  171. p1: 0,
  172. p2: 0,
  173. positionList: [
  174. [],
  175. []
  176. ],
  177. columnData: [],
  178. deviceType: "AirConditioner",
  179. deviceStatus: '',
  180. deviceTypeList: [],
  181. dataList: [],
  182. deviceStatusList: [{
  183. text: "全部",
  184. value: ""
  185. },
  186. {
  187. text: "开启",
  188. value: 1
  189. },
  190. {
  191. text: "关闭",
  192. value: 0
  193. },
  194. ],
  195. }
  196. },
  197. onReachBottom() {
  198. if (!this.finished) {
  199. this.dataForm.page++;
  200. this.getDataList();
  201. }
  202. },
  203. onLoad() {
  204. let getDictDataList = uni.getStorageSync('getDictDataList');
  205. for (let i = 0; i < getDictDataList.length; i++) {
  206. if (getDictDataList[i].dictType == 'ModeType') {
  207. this.modeTypeList = getDictDataList[i].dataList
  208. this.modeTypeList.push({dictLabel: "制冷",dictTypeId: "1610183082852225025",dictValue: "0"})
  209. }
  210. if (getDictDataList[i].dictType == 'SpeedType') {
  211. this.speedTypeList = getDictDataList[i].dataList
  212. }
  213. if (getDictDataList[i].dictType == 'DeviceCategory') {
  214. this.deviceTypeList = getDictDataList[i].dataList;
  215. // console.log('7777',this.deviceTypeList)
  216. this.deviceTypeList.forEach((item) => {
  217. item.text = item.dictLabel;
  218. item.value = item.dictValue;
  219. });
  220. this.deviceTypeList = this.deviceTypeList.filter(
  221. (item) => item.value != "WaterMeter" && item.value != "Ammeter"
  222. );
  223. }
  224. }
  225. this.getBuildList();
  226. // this.getDeviceTypeList();
  227. this.setTemperatureList();
  228. this.getDataList()
  229. },
  230. watch: {
  231. "dataForm.buildingId"(newval, oldval) {
  232. if (newval != oldval) {
  233. this.onRefresh();
  234. }
  235. },
  236. "dataForm.storeyId"(newval, oldval) {
  237. if (newval != oldval) {
  238. this.onRefresh();
  239. }
  240. },
  241. },
  242. filters: {
  243. delTimestamp(val) {
  244. if (!val) return "b";
  245. if (val.indexOf("n") > -1) {
  246. return 'a'; //开a
  247. } else {
  248. return 'b'; //关b
  249. }
  250. },
  251. delStatus(item) {
  252. let status = 0;
  253. if (item.attributeList && item.attributeList.length > 0) {
  254. for (let i = 0; i < item.relayNames.length; i++) {
  255. if (
  256. item.attributeList[i].value &&
  257. item.attributeList[i].value.indexOf("n") > -1
  258. ) {
  259. status++;
  260. } else {
  261. status--;
  262. }
  263. }
  264. if (status == item.relayNames.length) {
  265. item.status = 1;
  266. return "全关";
  267. }
  268. if (status == 0 - item.relayNames.length) {
  269. item.status = 0;
  270. return "全开";
  271. }
  272. return "全关";
  273. } else {
  274. return "全关";
  275. }
  276. },
  277. findInd(val, list) {
  278. if (isEmpty(val)) {
  279. return 0;
  280. }
  281. if (list.length > 5) {
  282. return list.findIndex((item) => item == val);
  283. } else {
  284. return list.findIndex((item) => parseFloat(item.dictValue) == val);
  285. }
  286. }
  287. },
  288. methods: {
  289. handleChange(type, val, index, identifier) {
  290. let that = this;
  291. if (type == "switch") {
  292. let msg = "";
  293. let deviceId = this.dataList[index].deviceId;
  294. let params = {
  295. // keyword: "setRelay",
  296. value: val,
  297. deviceId: deviceId,
  298. identifier: identifier,
  299. action: 0,
  300. };
  301. if (val == "a") {
  302. msg = "开启";
  303. }
  304. if (val == "b") {
  305. msg = "关闭";
  306. }
  307. uni.showModal({
  308. title: '提示',
  309. content: `确定执行${msg}操作`,
  310. success(res) {
  311. if (res.confirm) {
  312. that.switchLighting(type, params, index, msg, identifier);
  313. } else {
  314. uni.showToast({
  315. icon: 'none',
  316. title: '已取消'
  317. })
  318. }
  319. },
  320. })
  321. }
  322. },
  323. switchLighting(type, val, index, msg, identifier) {
  324. uni.showLoading({
  325. title: `正在${msg},请稍后`
  326. });
  327. if (type == "switch") {
  328. Api.setControlElec(val).then((res) => {
  329. uni.hideLoading()
  330. if (res.data.code == 0) {
  331. this.getDataList();
  332. uni.showToast({
  333. title: '操作成功'
  334. })
  335. }
  336. });
  337. }
  338. },
  339. findInd2(val, list) {
  340. if (isEmpty(val)) {
  341. return 0;
  342. }
  343. if (list.find((item) => parseFloat(item.dictValue) == val)) {
  344. return list.find((item) => parseFloat(item.dictValue) == val).dictLabel;
  345. } else {
  346. return list[0].dictLabel
  347. }
  348. },
  349. floorchange() {
  350. this.showfloor = true;
  351. },
  352. confirmfloor(e) {
  353. console.log(e)
  354. this.mytitle = (e.value[0].orgName=='全部'?'跨境电商':e.value[0].orgName) + (e.value[1].orgName=='全部'?'':e.value[1].orgName);
  355. this.dataForm.buildingId = e.value[0].orgId;
  356. this.dataForm.storeyId = e.value[1].orgId;
  357. this.showfloor = false;
  358. this.dataList = []; // 清空数组
  359. this.dataForm.page = 1;
  360. this.getDataList()
  361. },
  362. cancelfloor() {
  363. this.showfloor = false;
  364. },
  365. changeHandler(e) {
  366. const {
  367. columnIndex,
  368. index,
  369. // 微信小程序无法将picker实例传出来,只能通过ref操作
  370. picker = this.$refs.uPicker
  371. } = e
  372. if (columnIndex === 0) {
  373. this.loading = true
  374. picker.setColumnValues(1, this.columnData[index])
  375. this.loading = false
  376. }
  377. // this.dataList = []; // 清空数组
  378. // this.dataForm.page = 1;
  379. // this.getDataList()
  380. },
  381. //获取楼栋
  382. getBuildList2() {
  383. Api.getBuildInfo().then((res) => {
  384. if (res.data.code == 0) {
  385. this.name = this.projectName = res.data.data[0].orgName;
  386. this.positionList[0]=[];
  387. let positionList = res.data.data[0].childrenList;
  388. if (positionList) {
  389. let json = {
  390. category: "s",
  391. childrenList: null,
  392. orgId: "",
  393. orgName: "全部",
  394. };
  395. for (let i = 0; i <positionList.length; i++) {
  396. positionList[i].childrenList.unshift(json);
  397. this.positionList[0].push(positionList[i]);
  398. }
  399. this.positionList[0].unshift(json);
  400. //this.positionList[1]=this.positionList[0][0].childrenList;
  401. console.log(this.positionList)
  402. }
  403. }
  404. });
  405. },
  406. //获取楼栋
  407. getBuildList() {
  408. this.$api.get('/control/getOrgStructureTree/', {})
  409. .then(res => {
  410. if (res.data.code == 0) {
  411. let json = [{
  412. category: "s",
  413. childrenList: null,
  414. orgId: "",
  415. orgName: "全部",
  416. }];
  417. this.dataForm.projectId = res.data.data[0].orgId;
  418. this.mytitle = res.data.data[0].orgName;
  419. this.alldata = res.data.data[0].childrenList;
  420. //console.log('111111111111111111', res.data.data[0].childrenList)
  421. this.columns = [
  422. json.concat(res.data.data[0].childrenList),
  423. res.data.data[0].childrenList[0].childrenList
  424. ]
  425. let allfloor = [];
  426. for (let i = 0; i < res.data.data[0].childrenList.length; i++) {
  427. allfloor.push(json.concat(res.data.data[0].childrenList[i].childrenList));
  428. }
  429. this.columnData = allfloor;
  430. this.dataList = []; // 清空数组
  431. this.dataForm.page = 1;
  432. this.getDataList()
  433. } else {
  434. this.showdct = true
  435. }
  436. })
  437. },
  438. control(deviceId, status) {
  439. let msg = status == 0 ? '全开' : '全关';
  440. let that = this;
  441. uni.showModal({
  442. title: '提示',
  443. content: `确定执行${msg}操作`,
  444. success(res) {
  445. if (res.confirm) {
  446. uni.showLoading({
  447. title: "正在操作,请稍后。。。",
  448. })
  449. Api.setControlElec({
  450. action: 0,
  451. identifier: "",
  452. deviceId: deviceId,
  453. value: status == 0 ? "qk" : "qg",
  454. }).then((res) => {
  455. uni.hideLoading()
  456. if (res.data.code == 0) {
  457. that.getDataList();
  458. uni.showLoading({
  459. title: "操作成功",
  460. })
  461. }
  462. });
  463. } else {
  464. uni.showToast({
  465. icon: 'none',
  466. title: '已取消'
  467. })
  468. }
  469. },
  470. })
  471. },
  472. setTemperatureList() {
  473. this.temperatureList = [];
  474. for (let i = 16; i < 33; i++) {
  475. this.temperatureList.push(i);
  476. }
  477. },
  478. confirmHandle(e, type, deviceId, identifier) {
  479. this.dataForm.page = 1;
  480. if (type == 'position') {
  481. // this.p1 = e.detail.value[0];
  482. // this.p2 = e.detail.value[1];
  483. // this.dataForm.buildingId = this.p1 == 0 ? '' : this.positionList[0][this.p1].orgId;
  484. // this.dataForm.storeyId = this.p2 == 0 ? "" : this.positionList[1][this.p2].orgId;
  485. // let buildName = this.p1 == 0 ? "" : '-' + this.positionList[0][this.p1].orgName;
  486. // let storeyName = this.p2 == 0 ? "" : '-' + this.positionList[1][this.p2].orgName;
  487. // this.name = this.projectName + buildName + storeyName;
  488. } else {
  489. let index = type + "Index";
  490. this[index] = e.detail.value;
  491. if (type == "deviceType") {
  492. this.deviceType = this.deviceTypeList[e.detail.value].value;
  493. this.onRefresh();
  494. }
  495. if (type == "deviceStatus") {
  496. this.deviceStatus = this.deviceStatusList[e.detail.value].value;
  497. this.dataForm.status = this.deviceStatus;
  498. this.onRefresh();
  499. }
  500. if (type == "modeType" || type == "speedType" || type == "temp") {
  501. let data = this.modeTypeList[e.detail.value].dictValue;
  502. this.onConfirmMode(data, 'modeTypeList', deviceId, identifier);
  503. }
  504. }
  505. },
  506. //刷新
  507. onRefresh() {
  508. this.finished = false;
  509. // 重新加载数据
  510. this.dataList = [];
  511. // 将 loading 设置为 true,表示处于加载状态
  512. this.total = 0;
  513. this.loading = true;
  514. this.dataForm.page = 1; // 分页数赋值为1
  515. this.loadData();
  516. },
  517. //加载数据
  518. loadData() {
  519. setTimeout(async () => {
  520. if (this.refreshing) {
  521. this.dataList = [];
  522. this.refreshing = false;
  523. }
  524. await this.getDataList();
  525. //this.dataForm.page++; // 分页数加一
  526. }, 100);
  527. },
  528. getDataList() {
  529. if (this.deviceType == "AirConditioner") {
  530. this.getAircond();
  531. }
  532. if (this.deviceType == "Relay") {
  533. this.getElec();
  534. }
  535. },
  536. // getDeviceTypeList() {
  537. // this.deviceTypeList = JSON.parse(
  538. // JSON.stringify(getDictDataList("DeviceCategory"))
  539. // );
  540. // this.deviceTypeList.forEach((item) => {
  541. // item.text = item.dictLabel;
  542. // item.value = item.dictValue;
  543. // });
  544. // this.deviceTypeList = this.deviceTypeList.filter(
  545. // (item) => item.value != "WaterMeter" && item.value != "Ammeter"
  546. // );
  547. // },
  548. getAircond() {
  549. this.dataForm.status = "";
  550. Api.airconditioner(this.dataForm).then((res) => {
  551. if (res.data.code == 0) {
  552. console.log(res.data.data)
  553. if (res.data.data) {
  554. if (res.data.data.list.length == 0) {
  555. // 判断获取数据条数若等于0
  556. this.dataList = []; // 清空数组
  557. this.finished = true; // 停止加载
  558. }
  559. console.log(this.dataList)
  560. // 若数据条数不等于0
  561. if (this.dataForm.page == 1) {
  562. this.dataList = res.data.data.list;
  563. } else {
  564. this.dataList.push(...res.data.data.list); // 将数据放入list中
  565. }
  566. this.loading = false; // 加载状态结束
  567. this.total = res.data.data.total;
  568. // 如果list长度大于等于总数据条数,数据全部加载完成
  569. if (this.dataList.length >= res.data.data.total) {
  570. this.finished = true; // 结束加载状态
  571. }
  572. console.log(this.dataList)
  573. } else {
  574. // 判断获取数据条数若等于0
  575. this.dataList = []; // 清空数组
  576. this.finished = true; // 停止加载
  577. }
  578. } else {
  579. this.loading = false; // 加载状态结束
  580. this.finished = true; // 停止加载
  581. }
  582. });
  583. },
  584. getElec() {
  585. Api.getElec(this.dataForm).then((res) => {
  586. if (res.data.code == 0) {
  587. if (res.data.data) {
  588. if (res.data.data.list.length == 0) {
  589. // 判断获取数据条数若等于0
  590. this.dataList = []; // 清空数组
  591. this.finished = true; // 停止加载
  592. }
  593. // 若数据条数不等于0
  594. if (this.dataForm.page == 1) {
  595. this.dataList = res.data.data.list;
  596. } else {
  597. this.dataList.push(...res.data.data.list); // 将数据放入list中
  598. }
  599. this.loading = false; // 加载状态结束
  600. this.total = res.data.data.total;
  601. // 如果list长度大于等于总数据条数,数据全部加载完成
  602. if (this.dataList.length >= res.data.data.total) {
  603. this.finished = true; // 结束加载状态
  604. }
  605. } else {
  606. // 判断获取数据条数若等于0
  607. this.dataList = []; // 清空数组
  608. this.finished = true; // 停止加载
  609. }
  610. } else {
  611. this.loading = false; // 加载状态结束
  612. this.finished = true; // 停止加载
  613. }
  614. });
  615. },
  616. //下发指令开关
  617. changeSwitch(type, val, deviceId, index, identifier) {
  618. let msg = "";
  619. if (val.detail.value) {
  620. msg = "开启";
  621. } else {
  622. msg = "关闭";
  623. }
  624. uni.showModal({
  625. title: '提示',
  626. content: `请确认是否【${msg}】此设备`,
  627. success: function(res) {
  628. if (res.confirm) {
  629. if (type == "AirConditioner") {
  630. Api.setControl({
  631. identifier: identifier,
  632. action: 0,
  633. value: val.detail.value ? 1 : 0,
  634. deviceId: deviceId,
  635. }).then((res) => {
  636. if (res.data.code == 0) {
  637. this.dataList[index].attributeList[3].value = val;
  638. uni.showToast({
  639. title: '操作成功',
  640. duration: 2000
  641. });
  642. } else {
  643. uni.showToast({
  644. title: '操作失败',
  645. duration: 2000
  646. });
  647. }
  648. });
  649. }
  650. if (type == "Relay") {
  651. Api.setControlElec({
  652. identifier: identifier,
  653. action: 0,
  654. value: val.detail.value ? 1 : 0,
  655. deviceId: deviceId,
  656. }).then((res) => {
  657. if (res.data.code == 0) {
  658. this.dataList[index].status = val;
  659. uni.showToast({
  660. title: '操作成功',
  661. duration: 2000
  662. });
  663. } else {
  664. uni.showToast({
  665. title: '操作失败',
  666. duration: 2000
  667. });
  668. }
  669. });
  670. }
  671. } else if (res.cancel) {
  672. console.log('用户点击取消');
  673. }
  674. }
  675. });
  676. },
  677. onConfirmMode(data, module, deviceId, identifier) {
  678. let deviceCommandDTO = {
  679. action: 0,
  680. identifier: identifier,
  681. value: data,
  682. deviceId: deviceId,
  683. };
  684. // switch (module) {
  685. // case "modeTypeList":
  686. // deviceCommandDTO = {
  687. // action: 0,
  688. // identifier:identifier,
  689. // value: data,
  690. // deviceId: deviceId,
  691. // };
  692. // break;
  693. // case "temperatureList":
  694. // deviceCommandDTO = {
  695. // keyword: "setTemp",
  696. // param: data,
  697. // deviceId: deviceId,
  698. // };
  699. // break;
  700. // case "speedTypeList":
  701. // deviceCommandDTO = {
  702. // keyword: "setFan",
  703. // param: data,
  704. // deviceId: deviceId,
  705. // };
  706. // break;
  707. // }
  708. Api.setControl(deviceCommandDTO).then((res) => {
  709. this.$toast.clear();
  710. if (res.data.code == 0) {
  711. uni.showToast({
  712. title: '操作成功',
  713. duration: 2000
  714. });
  715. }
  716. });
  717. },
  718. }
  719. }
  720. </script>
  721. <style lang="scss" scoped>
  722. .uni-input {
  723. margin-right: 4px;
  724. }
  725. .uni-input,
  726. .inline {
  727. display: inline-block;
  728. }
  729. .form {
  730. display: flex;
  731. height: 48px;
  732. align-items: center;
  733. background-color: #fff;
  734. .drawdownMenu {
  735. display: flex;
  736. text-align: center;
  737. width: 50%;
  738. }
  739. }
  740. .header {
  741. background-color: #5c8fff;
  742. height: 25px;
  743. }
  744. .position {
  745. font-size: 16px;
  746. color: #fff;
  747. padding: 10px 16px;
  748. background: #5c8fff;
  749. .positionName {
  750. margin: 0 5px;
  751. }
  752. }
  753. .total {
  754. padding: 0 16px;
  755. margin: 8px 0;
  756. line-height: 15px;
  757. display: flex;
  758. text-align: left;
  759. text {
  760. font-size: 15px;
  761. vertical-align: middle;
  762. }
  763. }
  764. .list {
  765. padding: 0 16px;
  766. .each {
  767. background: #ffffff;
  768. box-shadow: 0px 0px 10px 0px rgba(153, 153, 153, 0.15);
  769. border-radius: 4px;
  770. margin-bottom: 12px;
  771. position: relative;
  772. box-shadow: 0px 0px 2px 4px rgba(87, 134, 238, 0.03);
  773. &.on2 {
  774. background: linear-gradient(to bottom,
  775. rgba(255, 155, 37, 0.25),
  776. rgba(255, 234, 200, 0.13),
  777. rgba(255, 255, 255, 0.04));
  778. }
  779. &.c {
  780. display: flex;
  781. flex-direction: column;
  782. .top1 {
  783. padding: 16px 20px;
  784. border-bottom: 1px solid #E6E7EA;
  785. image{
  786. width: 54px;
  787. height: 56px;
  788. position: absolute;
  789. left: 0;
  790. top: 0;
  791. z-index: 1;
  792. }
  793. }
  794. }
  795. &.bg0,&.bg2{
  796. background: linear-gradient(to bottom,#D2F0FF,#FFFFFF)
  797. }
  798. &.bg1{
  799. background: linear-gradient(to bottom,#FFE2DF,#FFFFFF)
  800. }
  801. &.bg4{
  802. background: linear-gradient(to bottom,#DDF8DC,#FFFFFF)
  803. }
  804. &.bg8{
  805. background: linear-gradient(to bottom,#DEE4FE,#FFFFFF)
  806. }
  807. .top {
  808. padding: 16px 20px;
  809. border-bottom: 1px solid #ddd;
  810. position: relative;
  811. .open {
  812. position: absolute;
  813. right: 0;
  814. top: 0;
  815. height: 100%;
  816. width: 60px;
  817. display: flex;
  818. flex-direction: column;
  819. justify-content: space-between;
  820. align-items: center;
  821. color: #2e69eb;
  822. font-size: 14px;
  823. padding: 12px 0;
  824. border-left: 1px solid #e6e7ea;
  825. box-sizing: border-box;
  826. image {
  827. width: 28px;
  828. height: 26px;
  829. cursor: pointer;
  830. }
  831. }
  832. }
  833. .l1 {
  834. height: 22px;
  835. font-size: 16px;
  836. color: #0c1935;
  837. line-height: 22px;
  838. margin-bottom: 2px;
  839. }
  840. .l2 {
  841. font-size: 12px;
  842. color: #697081;
  843. }
  844. .l3 {
  845. text-align: center;
  846. font-size: 32px;
  847. }
  848. .l4 {
  849. text-align: right;
  850. font-size: 14px;
  851. color: #0C1935;
  852. }
  853. .operation {
  854. display: flex;
  855. width: 100%;
  856. position: relative;
  857. font-size: 14px;
  858. padding: 18px;
  859. text-align: center;
  860. box-sizing:border-box;
  861. .uni-input{
  862. color: #2e69eb;
  863. }
  864. }
  865. .switch {
  866. position: absolute;
  867. right: 10px;
  868. font-size: 18px;
  869. top: auto;
  870. z-index: 1;
  871. }
  872. .operation2 {
  873. width: 100%;
  874. display: flex;
  875. align-items: center;
  876. justify-content: center;
  877. box-sizing: border-box;
  878. .s {
  879. flex: 1;
  880. width: 200px;
  881. text-align: center;
  882. line-height: 26px;
  883. padding: 10px 0;
  884. font-size: 14px;
  885. color: #697081;
  886. border-right: 1px solid #ddd;
  887. &:last-child {
  888. border-right: none;
  889. }
  890. }
  891. }
  892. }
  893. }
  894. </style>