xctset.vue 8.1 KB

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