Remotecontrol.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  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" :border="false">
  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" v-if="deviceType=='Relay'">
  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. this.deviceTypeList.forEach((item) => {
  216. item.text = item.dictLabel;
  217. item.value = item.dictValue;
  218. });
  219. this.deviceTypeList = this.deviceTypeList.filter(
  220. (item) => item.value != "WaterMeter" && item.value != "Ammeter"
  221. );
  222. }
  223. }
  224. this.getBuildList();
  225. // this.getDeviceTypeList();
  226. this.setTemperatureList();
  227. this.getDataList()
  228. },
  229. watch: {
  230. "dataForm.buildingId"(newval, oldval) {
  231. if (newval != oldval) {
  232. this.onRefresh();
  233. }
  234. },
  235. "dataForm.storeyId"(newval, oldval) {
  236. if (newval != oldval) {
  237. this.onRefresh();
  238. }
  239. },
  240. },
  241. filters: {
  242. delTimestamp(val) {
  243. if (!val) return "b";
  244. if (val.indexOf("n") > -1) {
  245. return 'a'; //开a
  246. } else {
  247. return 'b'; //关b
  248. }
  249. },
  250. delStatus(item) {
  251. let status = 0;
  252. if (item.attributeList && item.attributeList.length > 0) {
  253. for (let i = 0; i < item.relayNames.length; i++) {
  254. if (
  255. item.attributeList[i].value &&
  256. item.attributeList[i].value.indexOf("n") > -1
  257. ) {
  258. status++;
  259. } else {
  260. status--;
  261. }
  262. }
  263. if (status == item.relayNames.length) {
  264. item.status = 1;
  265. return "全关";
  266. }
  267. if (status == 0 - item.relayNames.length) {
  268. item.status = 0;
  269. return "全开";
  270. }
  271. return "全关";
  272. } else {
  273. return "全关";
  274. }
  275. },
  276. findInd(val, list) {
  277. if (isEmpty(val)) {
  278. return 0;
  279. }
  280. if (list.length > 5) {
  281. return list.findIndex((item) => item == val);
  282. } else {
  283. return list.findIndex((item) => parseFloat(item.dictValue) == val);
  284. }
  285. }
  286. },
  287. methods: {
  288. handleChange(type, val, index, identifier) {
  289. let that = this;
  290. if (type == "switch") {
  291. let msg = "";
  292. let deviceId = this.dataList[index].deviceId;
  293. let params = {
  294. // keyword: "setRelay",
  295. value: val,
  296. deviceId: deviceId,
  297. identifier: identifier,
  298. action: 0,
  299. };
  300. if (val == "a") {
  301. msg = "开启";
  302. }
  303. if (val == "b") {
  304. msg = "关闭";
  305. }
  306. uni.showModal({
  307. title: '提示',
  308. content: `确定执行${msg}操作`,
  309. success(res) {
  310. if (res.confirm) {
  311. that.switchLighting(type, params, index, msg, identifier);
  312. } else {
  313. uni.showToast({
  314. icon: 'none',
  315. title: '已取消'
  316. })
  317. }
  318. },
  319. })
  320. }
  321. },
  322. switchLighting(type, val, index, msg, identifier) {
  323. uni.showLoading({
  324. title: `正在${msg},请稍后`
  325. });
  326. if (type == "switch") {
  327. Api.setControlElec(val).then((res) => {
  328. uni.hideLoading()
  329. if (res.data.code == 0) {
  330. this.getDataList();
  331. uni.showToast({
  332. title: '操作成功'
  333. })
  334. }
  335. });
  336. }
  337. },
  338. findInd2(val, list) {
  339. if (isEmpty(val)) {
  340. return 0;
  341. }
  342. if (list.find((item) => parseFloat(item.dictValue) == val)) {
  343. return list.find((item) => parseFloat(item.dictValue) == val).dictLabel;
  344. } else {
  345. return list[0].dictLabel
  346. }
  347. },
  348. floorchange() {
  349. this.showfloor = true;
  350. },
  351. confirmfloor(e) {
  352. let a="";let b="";
  353. if(e.value[0]){
  354. a=e.value[0].orgName=='全部'?'跨境电商':e.value[0].orgName;
  355. this.dataForm.buildingId = e.value[0].orgId;
  356. }
  357. if(e.value[1]){
  358. b=e.value[1].orgName=='全部'?'':e.value[1].orgName;
  359. this.dataForm.storeyId = e.value[1].orgId?e.value[1].orgId:'';
  360. }
  361. this.mytitle = a+b;
  362. this.showfloor = false;
  363. this.dataList = []; // 清空数组
  364. this.dataForm.page = 1;
  365. this.getDataList()
  366. },
  367. cancelfloor() {
  368. this.showfloor = false;
  369. },
  370. changeHandler(e) {
  371. const {
  372. columnIndex,
  373. index,
  374. // 微信小程序无法将picker实例传出来,只能通过ref操作
  375. picker = this.$refs.uPicker
  376. } = e
  377. if (columnIndex === 0) {
  378. this.loading = true
  379. picker.setColumnValues(1, this.columnData[index])
  380. this.loading = false
  381. }
  382. // this.dataList = []; // 清空数组
  383. // this.dataForm.page = 1;
  384. // this.getDataList()
  385. },
  386. //获取楼栋
  387. getBuildList() {
  388. this.$api.get('/control/getOrgStructureTree/', {})
  389. .then(res => {
  390. if (res.data.code == 0) {
  391. let json = [{
  392. category: "s",
  393. childrenList: null,
  394. orgId: "",
  395. orgName: "全部",
  396. }];
  397. this.dataForm.projectId = res.data.data[0].orgId;
  398. this.mytitle = res.data.data[0].orgName;
  399. this.alldata = res.data.data[0].childrenList;
  400. this.columns = [
  401. json.concat(res.data.data[0].childrenList),
  402. []
  403. ]
  404. let allfloor = [[]];
  405. for (let i = 0; i < res.data.data[0].childrenList.length; i++) {
  406. allfloor.push(json.concat(res.data.data[0].childrenList[i].childrenList));
  407. }
  408. this.columnData = allfloor;
  409. this.dataList = []; // 清空数组
  410. this.dataForm.page = 1;
  411. this.getDataList()
  412. } else {
  413. this.showdct = true
  414. }
  415. })
  416. },
  417. control(deviceId, status) {
  418. let msg = status == 0 ? '全开' : '全关';
  419. let that = this;
  420. uni.showModal({
  421. title: '提示',
  422. content: `确定执行${msg}操作`,
  423. success(res) {
  424. if (res.confirm) {
  425. uni.showLoading({
  426. title: "正在操作,请稍后。。。",
  427. })
  428. Api.setControlElec({
  429. action: 0,
  430. identifier: "",
  431. deviceId: deviceId,
  432. value: status == 0 ? "qk" : "qg",
  433. }).then((res) => {
  434. uni.hideLoading()
  435. if (res.data.code == 0) {
  436. this.dataForm.page=1;
  437. that.getDataList();
  438. uni.showLoading({
  439. title: "操作成功",
  440. })
  441. }
  442. });
  443. } else {
  444. uni.showToast({
  445. icon: 'none',
  446. title: '已取消'
  447. })
  448. }
  449. },
  450. })
  451. },
  452. setTemperatureList() {
  453. this.temperatureList = [];
  454. for (let i = 16; i < 33; i++) {
  455. this.temperatureList.push(i);
  456. }
  457. },
  458. confirmHandle(e, type, deviceId, identifier) {
  459. this.dataForm.page = 1;
  460. if (type == 'position') {
  461. // this.p1 = e.detail.value[0];
  462. // this.p2 = e.detail.value[1];
  463. // this.dataForm.buildingId = this.p1 == 0 ? '' : this.positionList[0][this.p1].orgId;
  464. // this.dataForm.storeyId = this.p2 == 0 ? "" : this.positionList[1][this.p2].orgId;
  465. // let buildName = this.p1 == 0 ? "" : '-' + this.positionList[0][this.p1].orgName;
  466. // let storeyName = this.p2 == 0 ? "" : '-' + this.positionList[1][this.p2].orgName;
  467. // this.name = this.projectName + buildName + storeyName;
  468. } else {
  469. let index = type + "Index";
  470. this[index] = e.detail.value;
  471. if (type == "deviceType") {
  472. this.deviceType = this.deviceTypeList[e.detail.value].value;
  473. this.onRefresh();
  474. }
  475. if (type == "deviceStatus") {
  476. this.deviceStatus = this.deviceStatusList[e.detail.value].value;
  477. this.dataForm.status = this.deviceStatus;
  478. this.onRefresh();
  479. }
  480. if (type == "modeType" || type == "speedType" || type == "temp") {
  481. let data="";
  482. if(type=='modeType'){
  483. data = this.modeTypeList[e.detail.value].dictValue;
  484. }
  485. if(type=='speedType'){
  486. data =this.speedTypeList[e.detail.value].dictValue;
  487. }
  488. if(type=='temp'){
  489. data = this.temperatureList[e.detail.value];
  490. }
  491. this.onConfirmMode(data, deviceId, identifier);
  492. }
  493. }
  494. },
  495. //刷新
  496. onRefresh() {
  497. this.finished = false;
  498. // 重新加载数据
  499. this.dataList = [];
  500. // 将 loading 设置为 true,表示处于加载状态
  501. this.total = 0;
  502. this.loading = true;
  503. this.dataForm.page = 1; // 分页数赋值为1
  504. this.loadData();
  505. },
  506. //加载数据
  507. loadData() {
  508. setTimeout(async () => {
  509. if (this.refreshing) {
  510. this.dataList = [];
  511. this.refreshing = false;
  512. }
  513. await this.getDataList();
  514. //this.dataForm.page++; // 分页数加一
  515. }, 100);
  516. },
  517. getDataList() {
  518. if (this.deviceType == "AirConditioner") {
  519. this.getAircond();
  520. }
  521. if (this.deviceType == "Relay") {
  522. this.getElec();
  523. }
  524. },
  525. // getDeviceTypeList() {
  526. // this.deviceTypeList = JSON.parse(
  527. // JSON.stringify(getDictDataList("DeviceCategory"))
  528. // );
  529. // this.deviceTypeList.forEach((item) => {
  530. // item.text = item.dictLabel;
  531. // item.value = item.dictValue;
  532. // });
  533. // this.deviceTypeList = this.deviceTypeList.filter(
  534. // (item) => item.value != "WaterMeter" && item.value != "Ammeter"
  535. // );
  536. // },
  537. getAircond() {
  538. this.dataForm.status = "";
  539. Api.airconditioner(this.dataForm).then((res) => {
  540. if (res.data.code == 0) {
  541. if (res.data.data) {
  542. if (res.data.data.list.length == 0) {
  543. // 判断获取数据条数若等于0
  544. this.dataList = []; // 清空数组
  545. this.finished = true; // 停止加载
  546. }
  547. // 若数据条数不等于0
  548. if (this.dataForm.page == 1) {
  549. this.dataList = res.data.data.list;
  550. } else {
  551. this.dataList.push(...res.data.data.list); // 将数据放入list中
  552. }
  553. this.loading = false; // 加载状态结束
  554. this.total = res.data.data.total;
  555. // 如果list长度大于等于总数据条数,数据全部加载完成
  556. if (this.dataList.length >= res.data.data.total) {
  557. this.finished = true; // 结束加载状态
  558. }
  559. } else {
  560. // 判断获取数据条数若等于0
  561. this.dataList = []; // 清空数组
  562. this.finished = true; // 停止加载
  563. }
  564. } else {
  565. this.loading = false; // 加载状态结束
  566. this.finished = true; // 停止加载
  567. }
  568. });
  569. },
  570. getElec() {
  571. Api.getElec(this.dataForm).then((res) => {
  572. if (res.data.code == 0) {
  573. if (res.data.data) {
  574. if (res.data.data.list.length == 0) {
  575. // 判断获取数据条数若等于0
  576. this.dataList = []; // 清空数组
  577. this.finished = true; // 停止加载
  578. }
  579. // 若数据条数不等于0
  580. if (this.dataForm.page == 1) {
  581. this.dataList = res.data.data.list;
  582. } else {
  583. this.dataList.push(...res.data.data.list); // 将数据放入list中
  584. }
  585. this.loading = false; // 加载状态结束
  586. this.total = res.data.data.total;
  587. // 如果list长度大于等于总数据条数,数据全部加载完成
  588. if (this.dataList.length >= res.data.data.total) {
  589. this.finished = true; // 结束加载状态
  590. }
  591. } else {
  592. // 判断获取数据条数若等于0
  593. this.dataList = []; // 清空数组
  594. this.finished = true; // 停止加载
  595. }
  596. } else {
  597. this.loading = false; // 加载状态结束
  598. this.finished = true; // 停止加载
  599. }
  600. });
  601. },
  602. //下发指令开关
  603. changeSwitch(type, val, deviceId, index, identifier) {
  604. let msg = "";
  605. if (val.detail.value) {
  606. msg = "开启";
  607. } else {
  608. msg = "关闭";
  609. }
  610. uni.showModal({
  611. title: '提示',
  612. content: `请确认是否【${msg}】此设备`,
  613. success: function(res) {
  614. if (res.confirm) {
  615. if (type == "AirConditioner") {
  616. Api.setControl({
  617. identifier: identifier,
  618. action: 0,
  619. value: val.detail.value ? 1 : 0,
  620. deviceId: deviceId,
  621. }).then((res) => {
  622. if (res.data.code == 0) {
  623. this.dataList[index].attributeList[3].value = val;
  624. uni.showToast({
  625. title: '操作成功',
  626. duration: 2000
  627. });
  628. } else {
  629. uni.showToast({
  630. title: '操作失败',
  631. duration: 2000
  632. });
  633. }
  634. });
  635. }
  636. if (type == "Relay") {
  637. Api.setControlElec({
  638. identifier: identifier,
  639. action: 0,
  640. value: val.detail.value ? 1 : 0,
  641. deviceId: deviceId,
  642. }).then((res) => {
  643. if (res.data.code == 0) {
  644. this.dataList[index].status = val;
  645. uni.showToast({
  646. title: '操作成功',
  647. duration: 2000
  648. });
  649. } else {
  650. uni.showToast({
  651. title: '操作失败',
  652. duration: 2000
  653. });
  654. }
  655. });
  656. }
  657. } else if (res.cancel) {
  658. console.log('用户点击取消');
  659. }
  660. }
  661. });
  662. },
  663. onConfirmMode(data, deviceId, identifier) {
  664. let deviceCommandDTO = {
  665. action: 0,
  666. identifier: identifier,
  667. value: data,
  668. deviceId: deviceId,
  669. };
  670. // switch (module) {
  671. // case "modeTypeList":
  672. // deviceCommandDTO = {
  673. // action: 0,
  674. // identifier:identifier,
  675. // value: data,
  676. // deviceId: deviceId,
  677. // };
  678. // break;
  679. // case "temperatureList":
  680. // deviceCommandDTO = {
  681. // keyword: "setTemp",
  682. // param: data,
  683. // deviceId: deviceId,
  684. // };
  685. // break;
  686. // case "speedTypeList":
  687. // deviceCommandDTO = {
  688. // keyword: "setFan",
  689. // param: data,
  690. // deviceId: deviceId,
  691. // };
  692. // break;
  693. // }
  694. Api.setControl(deviceCommandDTO).then((res) => {
  695. //this.$toast.clear();
  696. if (res.data.code == 0) {
  697. uni.showToast({
  698. title: '操作成功',
  699. duration: 2000
  700. });
  701. this.onRefresh();
  702. }
  703. });
  704. },
  705. }
  706. }
  707. </script>
  708. <style lang="scss" scoped>
  709. .uni-input {
  710. margin-right: 4px;
  711. }
  712. .uni-input,
  713. .inline {
  714. display: inline-block;
  715. }
  716. .form {
  717. display: flex;
  718. height: 48px;
  719. align-items: center;
  720. background-color: #fff;
  721. .drawdownMenu {
  722. display: flex;
  723. text-align: center;
  724. min-width: 50%;
  725. flex:1;
  726. }
  727. }
  728. .header {
  729. background-color: #5c8fff;
  730. height: 25px;
  731. }
  732. .position {
  733. font-size: 16px;
  734. color: #fff;
  735. padding: 10px 16px;
  736. background: #5c8fff;
  737. .positionName {
  738. margin: 0 5px;
  739. }
  740. }
  741. .total {
  742. padding: 0 16px;
  743. margin: 8px 0;
  744. line-height: 15px;
  745. display: flex;
  746. text-align: left;
  747. text {
  748. font-size: 15px;
  749. vertical-align: middle;
  750. }
  751. }
  752. .list {
  753. padding: 0 16px;
  754. .each {
  755. background: #ffffff;
  756. box-shadow: 0px 0px 10px 0px rgba(153, 153, 153, 0.15);
  757. border-radius: 4px;
  758. margin-bottom: 12px;
  759. position: relative;
  760. box-shadow: 0px 0px 2px 4px rgba(87, 134, 238, 0.03);
  761. &.on2 {
  762. background: linear-gradient(to bottom,
  763. rgba(255, 155, 37, 0.25),
  764. rgba(255, 234, 200, 0.13),
  765. rgba(255, 255, 255, 0.04));
  766. }
  767. &.c {
  768. display: flex;
  769. flex-direction: column;
  770. .top1 {
  771. padding: 16px 20px;
  772. border-bottom: 1px solid #E6E7EA;
  773. image{
  774. width: 54px;
  775. height: 56px;
  776. position: absolute;
  777. left: 0;
  778. top: 0;
  779. z-index: 1;
  780. }
  781. }
  782. }
  783. &.bg0,&.bg2{
  784. background: linear-gradient(to bottom,#D2F0FF,#FFFFFF)
  785. }
  786. &.bg1{
  787. background: linear-gradient(to bottom,#FFE2DF,#FFFFFF)
  788. }
  789. &.bg4{
  790. background: linear-gradient(to bottom,#DDF8DC,#FFFFFF)
  791. }
  792. &.bg8{
  793. background: linear-gradient(to bottom,#DEE4FE,#FFFFFF)
  794. }
  795. .top {
  796. padding: 16px 20px;
  797. border-bottom: 1px solid #ddd;
  798. position: relative;
  799. .open {
  800. position: absolute;
  801. right: 0;
  802. top: 0;
  803. height: 100%;
  804. width: 60px;
  805. display: flex;
  806. flex-direction: column;
  807. justify-content: space-between;
  808. align-items: center;
  809. color: #2e69eb;
  810. font-size: 14px;
  811. padding: 12px 0;
  812. border-left: 1px solid #e6e7ea;
  813. box-sizing: border-box;
  814. image {
  815. width: 28px;
  816. height: 26px;
  817. cursor: pointer;
  818. }
  819. }
  820. }
  821. .l1 {
  822. height: 22px;
  823. font-size: 16px;
  824. color: #0c1935;
  825. line-height: 22px;
  826. margin-bottom: 2px;
  827. }
  828. .l2 {
  829. font-size: 12px;
  830. color: #697081;
  831. }
  832. .l3 {
  833. text-align: center;
  834. font-size: 32px;
  835. }
  836. .l4 {
  837. text-align: right;
  838. font-size: 14px;
  839. color: #0C1935;
  840. }
  841. .operation {
  842. display: flex;
  843. width: 100%;
  844. position: relative;
  845. font-size: 14px;
  846. padding: 18px;
  847. text-align: center;
  848. box-sizing:border-box;
  849. .uni-input{
  850. color: #2e69eb;
  851. }
  852. }
  853. .switch {
  854. position: absolute;
  855. right: 10px;
  856. font-size: 18px;
  857. top: auto;
  858. z-index: 1;
  859. }
  860. .operation2 {
  861. width: 100%;
  862. display: flex;
  863. align-items: center;
  864. justify-content: center;
  865. box-sizing: border-box;
  866. .s {
  867. flex: 1;
  868. width: 200px;
  869. text-align: center;
  870. line-height: 26px;
  871. padding: 10px 0;
  872. font-size: 14px;
  873. color: #697081;
  874. border-right: 1px solid #ddd;
  875. &:last-child {
  876. border-right: none;
  877. }
  878. }
  879. }
  880. }
  881. }
  882. </style>