Remotecontrol.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  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. console.log(this.columns)
  426. let allfloor = [];
  427. for (let i = 0; i < res.data.data[0].childrenList.length; i++) {
  428. allfloor.push(json.concat(res.data.data[0].childrenList[i].childrenList));
  429. }
  430. console.log(allfloor)
  431. this.columnData = allfloor;
  432. this.dataList = []; // 清空数组
  433. this.dataForm.page = 1;
  434. this.getDataList()
  435. } else {
  436. this.showdct = true
  437. }
  438. })
  439. },
  440. control(deviceId, status) {
  441. let msg = status == 0 ? '全开' : '全关';
  442. let that = this;
  443. uni.showModal({
  444. title: '提示',
  445. content: `确定执行${msg}操作`,
  446. success(res) {
  447. if (res.confirm) {
  448. uni.showLoading({
  449. title: "正在操作,请稍后。。。",
  450. })
  451. Api.setControlElec({
  452. action: 0,
  453. identifier: "",
  454. deviceId: deviceId,
  455. value: status == 0 ? "qk" : "qg",
  456. }).then((res) => {
  457. uni.hideLoading()
  458. if (res.data.code == 0) {
  459. that.getDataList();
  460. uni.showLoading({
  461. title: "操作成功",
  462. })
  463. }
  464. });
  465. } else {
  466. uni.showToast({
  467. icon: 'none',
  468. title: '已取消'
  469. })
  470. }
  471. },
  472. })
  473. },
  474. setTemperatureList() {
  475. this.temperatureList = [];
  476. for (let i = 16; i < 33; i++) {
  477. this.temperatureList.push(i);
  478. }
  479. },
  480. confirmHandle(e, type, deviceId, identifier) {
  481. this.dataForm.page = 1;
  482. if (type == 'position') {
  483. // this.p1 = e.detail.value[0];
  484. // this.p2 = e.detail.value[1];
  485. // this.dataForm.buildingId = this.p1 == 0 ? '' : this.positionList[0][this.p1].orgId;
  486. // this.dataForm.storeyId = this.p2 == 0 ? "" : this.positionList[1][this.p2].orgId;
  487. // let buildName = this.p1 == 0 ? "" : '-' + this.positionList[0][this.p1].orgName;
  488. // let storeyName = this.p2 == 0 ? "" : '-' + this.positionList[1][this.p2].orgName;
  489. // this.name = this.projectName + buildName + storeyName;
  490. } else {
  491. let index = type + "Index";
  492. this[index] = e.detail.value;
  493. if (type == "deviceType") {
  494. this.deviceType = this.deviceTypeList[e.detail.value].value;
  495. this.onRefresh();
  496. }
  497. if (type == "deviceStatus") {
  498. this.deviceStatus = this.deviceStatusList[e.detail.value].value;
  499. this.dataForm.status = this.deviceStatus;
  500. this.onRefresh();
  501. }
  502. if (type == "modeType" || type == "speedType" || type == "temp") {
  503. let data = this.modeTypeList[e.detail.value].dictValue;
  504. this.onConfirmMode(data, 'modeTypeList', deviceId, identifier);
  505. }
  506. }
  507. },
  508. //刷新
  509. onRefresh() {
  510. this.finished = false;
  511. // 重新加载数据
  512. this.dataList = [];
  513. // 将 loading 设置为 true,表示处于加载状态
  514. this.total = 0;
  515. this.loading = true;
  516. this.dataForm.page = 1; // 分页数赋值为1
  517. this.loadData();
  518. },
  519. //加载数据
  520. loadData() {
  521. setTimeout(async () => {
  522. if (this.refreshing) {
  523. this.dataList = [];
  524. this.refreshing = false;
  525. }
  526. await this.getDataList();
  527. //this.dataForm.page++; // 分页数加一
  528. }, 100);
  529. },
  530. getDataList() {
  531. if (this.deviceType == "AirConditioner") {
  532. this.getAircond();
  533. }
  534. if (this.deviceType == "Relay") {
  535. this.getElec();
  536. }
  537. },
  538. // getDeviceTypeList() {
  539. // this.deviceTypeList = JSON.parse(
  540. // JSON.stringify(getDictDataList("DeviceCategory"))
  541. // );
  542. // this.deviceTypeList.forEach((item) => {
  543. // item.text = item.dictLabel;
  544. // item.value = item.dictValue;
  545. // });
  546. // this.deviceTypeList = this.deviceTypeList.filter(
  547. // (item) => item.value != "WaterMeter" && item.value != "Ammeter"
  548. // );
  549. // },
  550. getAircond() {
  551. this.dataForm.status = "";
  552. Api.airconditioner(this.dataForm).then((res) => {
  553. if (res.data.code == 0) {
  554. console.log(res.data.data)
  555. if (res.data.data) {
  556. if (res.data.data.list.length == 0) {
  557. // 判断获取数据条数若等于0
  558. this.dataList = []; // 清空数组
  559. this.finished = true; // 停止加载
  560. }
  561. // 若数据条数不等于0
  562. this.dataList.push(...res.data.data.list); // 将数据放入list中
  563. this.loading = false; // 加载状态结束
  564. this.total = res.data.data.total;
  565. // 如果list长度大于等于总数据条数,数据全部加载完成
  566. if (this.dataList.length >= res.data.data.total) {
  567. this.finished = true; // 结束加载状态
  568. }
  569. console.log(this.dataList)
  570. } else {
  571. // 判断获取数据条数若等于0
  572. this.dataList = []; // 清空数组
  573. this.finished = true; // 停止加载
  574. }
  575. } else {
  576. this.loading = false; // 加载状态结束
  577. this.finished = true; // 停止加载
  578. }
  579. });
  580. },
  581. getElec() {
  582. Api.getElec(this.dataForm).then((res) => {
  583. if (res.data.code == 0) {
  584. if (res.data.data) {
  585. if (res.data.data.list.length == 0) {
  586. // 判断获取数据条数若等于0
  587. this.dataList = []; // 清空数组
  588. this.finished = true; // 停止加载
  589. }
  590. // 若数据条数不等于0
  591. if (this.dataForm.page == 1) {
  592. this.dataList = res.data.data.list;
  593. } else {
  594. this.dataList.push(...res.data.data.list); // 将数据放入list中
  595. }
  596. this.loading = false; // 加载状态结束
  597. this.total = res.data.data.total;
  598. // 如果list长度大于等于总数据条数,数据全部加载完成
  599. if (this.dataList.length >= res.data.data.total) {
  600. this.finished = true; // 结束加载状态
  601. }
  602. } else {
  603. // 判断获取数据条数若等于0
  604. this.dataList = []; // 清空数组
  605. this.finished = true; // 停止加载
  606. }
  607. } else {
  608. this.loading = false; // 加载状态结束
  609. this.finished = true; // 停止加载
  610. }
  611. });
  612. },
  613. //下发指令开关
  614. changeSwitch(type, val, deviceId, index, identifier) {
  615. let msg = "";
  616. if (val.detail.value) {
  617. msg = "开启";
  618. } else {
  619. msg = "关闭";
  620. }
  621. uni.showModal({
  622. title: '提示',
  623. content: `请确认是否【${msg}】此设备`,
  624. success: function(res) {
  625. if (res.confirm) {
  626. if (type == "AirConditioner") {
  627. Api.setControl({
  628. identifier: identifier,
  629. action: 0,
  630. value: val.detail.value ? 1 : 0,
  631. deviceId: deviceId,
  632. }).then((res) => {
  633. if (res.data.code == 0) {
  634. this.dataList[index].attributeList[3].value = val;
  635. uni.showToast({
  636. title: '操作成功',
  637. duration: 2000
  638. });
  639. } else {
  640. uni.showToast({
  641. title: '操作失败',
  642. duration: 2000
  643. });
  644. }
  645. });
  646. }
  647. if (type == "Relay") {
  648. Api.setControlElec({
  649. identifier: identifier,
  650. action: 0,
  651. value: val.detail.value ? 1 : 0,
  652. deviceId: deviceId,
  653. }).then((res) => {
  654. if (res.data.code == 0) {
  655. this.dataList[index].status = val;
  656. uni.showToast({
  657. title: '操作成功',
  658. duration: 2000
  659. });
  660. } else {
  661. uni.showToast({
  662. title: '操作失败',
  663. duration: 2000
  664. });
  665. }
  666. });
  667. }
  668. } else if (res.cancel) {
  669. console.log('用户点击取消');
  670. }
  671. }
  672. });
  673. },
  674. onConfirmMode(data, module, deviceId, identifier) {
  675. let deviceCommandDTO = {
  676. action: 0,
  677. identifier: identifier,
  678. value: data,
  679. deviceId: deviceId,
  680. };
  681. // switch (module) {
  682. // case "modeTypeList":
  683. // deviceCommandDTO = {
  684. // action: 0,
  685. // identifier:identifier,
  686. // value: data,
  687. // deviceId: deviceId,
  688. // };
  689. // break;
  690. // case "temperatureList":
  691. // deviceCommandDTO = {
  692. // keyword: "setTemp",
  693. // param: data,
  694. // deviceId: deviceId,
  695. // };
  696. // break;
  697. // case "speedTypeList":
  698. // deviceCommandDTO = {
  699. // keyword: "setFan",
  700. // param: data,
  701. // deviceId: deviceId,
  702. // };
  703. // break;
  704. // }
  705. Api.setControl(deviceCommandDTO).then((res) => {
  706. this.$toast.clear();
  707. if (res.data.code == 0) {
  708. uni.showToast({
  709. title: '操作成功',
  710. duration: 2000
  711. });
  712. }
  713. });
  714. },
  715. }
  716. }
  717. </script>
  718. <style lang="scss" scoped>
  719. .uni-input {
  720. margin-right: 4px;
  721. }
  722. .uni-input,
  723. .inline {
  724. display: inline-block;
  725. }
  726. .form {
  727. display: flex;
  728. height: 48px;
  729. align-items: center;
  730. background-color: #fff;
  731. .drawdownMenu {
  732. display: flex;
  733. text-align: center;
  734. width: 50%;
  735. }
  736. }
  737. .header {
  738. background-color: #5c8fff;
  739. height: 25px;
  740. }
  741. .position {
  742. font-size: 16px;
  743. color: #fff;
  744. padding: 10px 16px;
  745. background: #5c8fff;
  746. .positionName {
  747. margin: 0 5px;
  748. }
  749. }
  750. .total {
  751. padding: 0 16px;
  752. margin: 8px 0;
  753. line-height: 15px;
  754. display: flex;
  755. text-align: left;
  756. text {
  757. font-size: 15px;
  758. vertical-align: middle;
  759. }
  760. }
  761. .list {
  762. padding: 0 16px;
  763. .each {
  764. background: #ffffff;
  765. box-shadow: 0px 0px 10px 0px rgba(153, 153, 153, 0.15);
  766. border-radius: 4px;
  767. margin-bottom: 12px;
  768. position: relative;
  769. box-shadow: 0px 0px 2px 4px rgba(87, 134, 238, 0.03);
  770. &.on2 {
  771. background: linear-gradient(to bottom,
  772. rgba(255, 155, 37, 0.25),
  773. rgba(255, 234, 200, 0.13),
  774. rgba(255, 255, 255, 0.04));
  775. }
  776. &.c {
  777. display: flex;
  778. flex-direction: column;
  779. .top1 {
  780. padding: 16px 20px;
  781. border-bottom: 1px solid #E6E7EA;
  782. image{
  783. width: 54px;
  784. height: 56px;
  785. position: absolute;
  786. left: 0;
  787. top: 0;
  788. z-index: 1;
  789. }
  790. }
  791. }
  792. &.bg0,&.bg2{
  793. background: linear-gradient(to bottom,#D2F0FF,#FFFFFF)
  794. }
  795. &.bg1{
  796. background: linear-gradient(to bottom,#FFE2DF,#FFFFFF)
  797. }
  798. &.bg4{
  799. background: linear-gradient(to bottom,#DDF8DC,#FFFFFF)
  800. }
  801. &.bg8{
  802. background: linear-gradient(to bottom,#DEE4FE,#FFFFFF)
  803. }
  804. .top {
  805. padding: 16px 20px;
  806. border-bottom: 1px solid #ddd;
  807. position: relative;
  808. .open {
  809. position: absolute;
  810. right: 0;
  811. top: 0;
  812. height: 100%;
  813. width: 60px;
  814. display: flex;
  815. flex-direction: column;
  816. justify-content: space-between;
  817. align-items: center;
  818. color: #2e69eb;
  819. font-size: 14px;
  820. padding: 12px 0;
  821. border-left: 1px solid #e6e7ea;
  822. box-sizing: border-box;
  823. image {
  824. width: 28px;
  825. height: 26px;
  826. cursor: pointer;
  827. }
  828. }
  829. }
  830. .l1 {
  831. height: 22px;
  832. font-size: 16px;
  833. color: #0c1935;
  834. line-height: 22px;
  835. margin-bottom: 2px;
  836. }
  837. .l2 {
  838. font-size: 12px;
  839. color: #697081;
  840. }
  841. .l3 {
  842. text-align: center;
  843. font-size: 32px;
  844. }
  845. .l4 {
  846. text-align: right;
  847. font-size: 14px;
  848. color: #0C1935;
  849. }
  850. .operation {
  851. display: flex;
  852. width: 100%;
  853. position: relative;
  854. font-size: 14px;
  855. padding: 18px;
  856. text-align: center;
  857. box-sizing:border-box;
  858. .uni-input{
  859. color: #2e69eb;
  860. }
  861. }
  862. .switch {
  863. position: absolute;
  864. right: 10px;
  865. font-size: 18px;
  866. top: auto;
  867. z-index: 1;
  868. }
  869. .operation2 {
  870. width: 100%;
  871. display: flex;
  872. align-items: center;
  873. justify-content: center;
  874. box-sizing: border-box;
  875. .s {
  876. flex: 1;
  877. width: 200px;
  878. text-align: center;
  879. line-height: 26px;
  880. padding: 10px 0;
  881. font-size: 14px;
  882. color: #697081;
  883. border-right: 1px solid #ddd;
  884. &:last-child {
  885. border-right: none;
  886. }
  887. }
  888. }
  889. }
  890. }
  891. </style>