xctset.vue 8.6 KB

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