xctset.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view>
  3. <view class="" v-if="myuser_type">
  4. <view class="tit adminTit">
  5. 联网模块
  6. </view>
  7. <view class="btns">
  8. <button type="warn" @click="equipBtnControl('dtu_update')" size="mini">升级</button>
  9. <button type="warn" @click="equipBtnControl('dtu_reboot')" size="mini">重启</button>
  10. <!-- <button type="warn" @click="equipBtnControl('yfwlw')" size="mini">平台切换</button> -->
  11. </view>
  12. <view class="tit adminTit">
  13. 强制操作
  14. </view>
  15. <view class="btns">
  16. <button type="warn" @click="equipBtnControl('takephoto')" size="mini">拍照</button>
  17. <button type="warn" @click="equipBtnControl('update')" size="mini">升级</button>
  18. <button type="warn" @click="equipBtnControl('reboot')" size="mini">重启</button>
  19. <!-- <button type="warn" @click="equipBtnControl('close_shake')" size="mini">震动关闭</button>
  20. <button type="warn" @click="equipBtnControl('open_shake')" size="mini">震动开启</button> -->
  21. </view>
  22. </view>
  23. <view class="setitem">
  24. 设备编号:{{option.device_id}}
  25. </view>
  26. <view class="setitem">
  27. 设备名称:{{option.device_name}}
  28. </view>
  29. <view class="setitem">
  30. 设备版本:{{option.dtype}}
  31. </view>
  32. <!-- <view class="setitem">
  33. 设备开关:
  34. <view class="uni-list-cell" style="margin-top: 30rpx;">
  35. <picker @change="turnChange($event,'ds')" value="equipContrlForm.ds" :range="dsArr">
  36. <text class="uni-input">{{dsArr[equipContrlForm.ds]}}</text>
  37. <view class="arrow"></view>
  38. </picker>
  39. </view>
  40. </view> -->
  41. <u-form :model="equipContrlForm" :label-width="180">
  42. <u-form-item label="温控开关" :label-width="240">
  43. <u-radio-group v-model="equipContrlForm.limit_temp">
  44. <u-radio :name="1">开</u-radio>
  45. <u-radio :name="0">关</u-radio>
  46. </u-radio-group>
  47. </u-form-item>
  48. <u-form-item label="雨控开关" :label-width="240">
  49. <u-radio-group v-model="equipContrlForm.limit_rain">
  50. <u-radio :name="1">开</u-radio>
  51. <u-radio :name="0">关</u-radio>
  52. </u-radio-group>
  53. </u-form-item>
  54. <u-form-item label="定时模式" :label-width="240">
  55. <u-radio-group v-model="equipContrlForm.ts">
  56. <u-radio :name="1">光控</u-radio>
  57. <u-radio :name="0">时控</u-radio>
  58. <u-radio :name="2">晨曦</u-radio>
  59. </u-radio-group>
  60. </u-form-item>
  61. <u-form-item label="定时时长" :label-width="240" v-if="equipContrlForm.ts == 0">
  62. <text @click="equipContrlForm.show_st= true">{{equipContrlForm.collstart}}</text>-
  63. <text @click="equipContrlForm.show_et= true">{{equipContrlForm.collend}}</text>
  64. <u-picker mode="time" v-model="equipContrlForm.show_st" :default-time="`${equipContrlForm.collstart}:00`"
  65. :params="params" @confirm="(e) => changeControlTime(e, 'collstart')"></u-picker>
  66. <u-picker mode="time" v-model="equipContrlForm.show_et" :default-time="`${equipContrlForm.collend}:00`"
  67. :params="params" @confirm="(e) => changeControlTime(e, 'collend')"></u-picker>
  68. </u-form-item>
  69. <u-form-item label="定时时长(H)" :label-width="200" v-if="equipContrlForm.ts == 1">
  70. <u-input v-model="equipContrlForm.tt" type="number" />
  71. </u-form-item>
  72. <u-form-item label="拍照间隔(min)" :label-width="200">
  73. <u-input v-model="equipContrlForm.pho_f" type="number" />
  74. </u-form-item>
  75. <u-form-item label="高温保护阈值(℃)" :label-width="250">
  76. <u-input v-model="equipContrlForm.tph" type="number" />
  77. </u-form-item>
  78. <u-form-item label="低温保护阈值(℃)" :label-width="250">
  79. <u-input v-model="equipContrlForm.tpl" type="number" />
  80. </u-form-item>
  81. <u-form-item label="数据上传间隔(min)" :label-width="260">
  82. <u-input v-model="equipContrlForm.dat_f" type="number" />
  83. </u-form-item>
  84. <u-form-item label="风量" :label-width="260">
  85. <u-input v-model="equipContrlForm.fan_speed" type="number" />
  86. </u-form-item>
  87. </u-form>
  88. <view class="submit-box">
  89. <u-button @click="submit" type="success">确定</u-button>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. export default {
  95. data() {
  96. return {
  97. myuser_type: false,
  98. option: {},
  99. equipContrlForm: {
  100. "tpl ": "",
  101. "tph": "",
  102. "dat_f": "",
  103. "pho_f": "",
  104. "limit_temp": "",
  105. "limit_rain": "",
  106. "tt": "",
  107. "ts": "",
  108. "collstart": "",
  109. "collend": "",
  110. fan_speed:'',
  111. show_st: false,
  112. show_et: false,
  113. },
  114. params: {
  115. year: false,
  116. month: false,
  117. day: false,
  118. hour: true,
  119. minute: false,
  120. second: false
  121. },
  122. list: [{
  123. value: 0,
  124. label: '00:00'
  125. },
  126. {
  127. value: 1,
  128. label: '01:00'
  129. },
  130. {
  131. value: 2,
  132. label: '02:00'
  133. },
  134. {
  135. value: 3,
  136. label: '03:00'
  137. },
  138. {
  139. value: 4,
  140. label: '04:00'
  141. },
  142. {
  143. value: 5,
  144. label: '05:00'
  145. },
  146. {
  147. value: 6,
  148. label: '06:00'
  149. },
  150. {
  151. value: 7,
  152. label: '04:00'
  153. }, {
  154. value: 8,
  155. label: '08:00'
  156. },
  157. {
  158. value: 9,
  159. label: '09:00'
  160. },
  161. {
  162. value: 10,
  163. label: '10:00'
  164. },
  165. {
  166. value: 11,
  167. label: '11:00'
  168. },
  169. {
  170. value: 12,
  171. label: '12:00'
  172. },
  173. {
  174. value: 13,
  175. label: '13:00'
  176. },
  177. {
  178. value: 14,
  179. label: '14:00'
  180. }, {
  181. value: 15,
  182. label: '15:00'
  183. },
  184. {
  185. value: 16,
  186. label: '16:00'
  187. },
  188. {
  189. value: 17,
  190. label: '17:00'
  191. },
  192. {
  193. value: 18,
  194. label: '18:00'
  195. },
  196. {
  197. value: 19,
  198. label: '19:00'
  199. },
  200. {
  201. value: 20,
  202. label: '20:00'
  203. },
  204. {
  205. value: 21,
  206. label: '21:00'
  207. }, {
  208. value: 22,
  209. label: '22:00'
  210. },
  211. {
  212. value: 23,
  213. label: '23:00'
  214. },
  215. ],
  216. }
  217. },
  218. methods: {
  219. async getconf() {
  220. const res = await this.$myRequest({
  221. url: '/api/api_gateway?method=forecast.haomi.haomi_get_config',
  222. data: {
  223. cmd: "paramconf",
  224. d_id: this.option.d_id
  225. }
  226. })
  227. console.log(res)
  228. if (res && Object.keys(res).length > 0) {
  229. let data = res;
  230. console.log(data);
  231. let newObj = {
  232. ...data,
  233. show_st: false,
  234. show_et: false,
  235. };
  236. newObj.collstart = newObj.collstart > 9 ? newObj.collstart : `0${newObj.collstart}`;
  237. newObj.collend = newObj.collend > 9 ? newObj.collend : `0${newObj.collend}`;
  238. console.log(newObj);
  239. this.equipContrlForm = newObj;
  240. }
  241. },
  242. changeControlTime(e, type) {
  243. console.log(e);
  244. this.equipContrlForm[type] = `${e.hour}`;
  245. console.log(this.equipContrlForm);
  246. },
  247. async submit() {
  248. if(this.equipContrlForm.fan_speed < 10) {
  249. uni.showToast({
  250. title:'风量值不能小于10',
  251. icon:'none'
  252. })
  253. return
  254. }
  255. console.log(this.equipContrlForm)
  256. const res = await this.$myRequest({
  257. url: '/api/api_gateway?method=forecast.haomi.haomi_config',
  258. data: {
  259. d_id: this.option.d_id,
  260. device_id: this.option.device_id,
  261. ...this.equipContrlForm
  262. }
  263. })
  264. if (res == true) {
  265. uni.showToast({
  266. title: '指令下发成功!',
  267. duration: 2000
  268. });
  269. } else {
  270. uni.showToast({
  271. title: '指令下发失败!',
  272. duration: 2000,
  273. icon: "none"
  274. });
  275. }
  276. },
  277. async equipBtnControl(cmd) {
  278. const res = await this.$myRequest({
  279. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  280. data: {
  281. cmd,
  282. device_type_id: 28,
  283. d_id: this.option.d_id,
  284. }
  285. })
  286. console.log(res)
  287. if (res == true) {
  288. uni.showToast({
  289. title: '指令下发成功!',
  290. duration: 2000
  291. });
  292. } else {
  293. uni.showToast({
  294. title: '指令下发失败!',
  295. duration: 2000,
  296. icon: "none"
  297. });
  298. }
  299. }
  300. },
  301. onLoad(option) {
  302. this.option = option
  303. uni.getStorage({
  304. key: "myuser_type",
  305. success: (res) => {
  306. console.log(res.data)
  307. if (Number(res.data) == 1) {
  308. this.myuser_type = true
  309. }
  310. }
  311. })
  312. this.getconf()
  313. }
  314. }
  315. </script>
  316. <style lang="scss">
  317. page {
  318. padding: 20rpx;
  319. box-sizing: border-box;
  320. .tit {
  321. line-height: 30rpx;
  322. font-size: 30rpx;
  323. padding-left: 20rpx;
  324. border-left-width: 2px;
  325. border-left-style: solid;
  326. border-left-color: $uni-color-success;
  327. margin: 30rpx 0;
  328. }
  329. .adminTit {
  330. border-left-color: #e64340;
  331. }
  332. .btns {
  333. display: flex;
  334. justify-content: flex-start;
  335. flex-wrap: no-wrap;
  336. button {
  337. margin: 0;
  338. margin-right: 10rpx;
  339. padding: 0 25rpx;
  340. }
  341. }
  342. .setitem {
  343. margin-top: 30rpx;
  344. .selectTime {
  345. margin-top: 30rpx;
  346. display: flex;
  347. .time {
  348. width: 350rpx;
  349. display: flex;
  350. justify-content: space-between;
  351. }
  352. .line {
  353. width: 50rpx;
  354. text-align: center;
  355. }
  356. }
  357. }
  358. .uni-list-cell {
  359. background: #F7F8FA;
  360. padding: 10rpx 40rpx;
  361. font-size: 28rpx;
  362. box-sizing: border-box;
  363. /* margin-top: 30rpx; */
  364. .arrow {
  365. display: inline-block;
  366. border-width: 12rpx 8rpx;
  367. border-style: solid;
  368. float: right;
  369. margin-top: 10rpx;
  370. border-color: #888 transparent transparent transparent;
  371. }
  372. }
  373. .submit-box {
  374. margin-top: 60rpx
  375. }
  376. }
  377. </style>