devControl.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="device-details-page">
  3. <cu-custom :isBack="true">
  4. <template slot="content">
  5. <view class="nav-title">设备控制</view>
  6. </template>
  7. </cu-custom>
  8. <view class="control-board">
  9. <view class="title">操作</view>
  10. <div style="margin-bottom: 48rpx;">
  11. <u-button type="success" class="reload-btn" @click="handleControl('RESET')">重启</u-button>
  12. </div>
  13. <u-button type="success" class="reload-btn" @click="handleControl('FWUPDATE')">升级</u-button>
  14. <view class="title date-title">本地存储间隔(min)</view>
  15. <view class="date-slider">
  16. <slider
  17. :value="storageVal"
  18. show-value="true"
  19. :min="1"
  20. :max="240"
  21. @change="changeStorageVal"
  22. block-color="#57C878"
  23. activeColor="#57C878"
  24. step="1"
  25. />
  26. </view>
  27. <view class="title date-title">数据传输间隔(min)</view>
  28. <view class="date-slider">
  29. <slider
  30. :value="dataInterval"
  31. show-value="true"
  32. :min="1"
  33. :max="240"
  34. @change="changeDataInterval"
  35. block-color="#57C878"
  36. activeColor="#57C878"
  37. step="1"
  38. />
  39. </view>
  40. </view>
  41. <view class="footer-board">
  42. <u-button type="success" class="sub-btn" @click="handleSubmit()">确定</u-button>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. onLoad(options) {
  49. this.loading = true
  50. const deviceInfo = JSON.parse(decodeURIComponent(options.deviceInfo));
  51. console.log(deviceInfo, "deviceInfo");
  52. this.deviceInfo = deviceInfo;
  53. this.getDevControlParams();
  54. },
  55. data() {
  56. return {
  57. deviceInfo: {},
  58. storageVal: "",
  59. dataInterval: "",
  60. };
  61. },
  62. methods: {
  63. // 改变本地存储间隔
  64. changeStorageVal(e) {
  65. this.storageVal = e.detail.value
  66. },
  67. // 改变数据传输间隔
  68. changeDataInterval(e) {
  69. this.dataInterval = e.detail.value
  70. },
  71. // 获取设备控制参数信息
  72. async getDevControlParams() {
  73. this.loading = true
  74. await this.$myRequest({
  75. url: '/api/api_gateway?method=qxz.device.control_args',
  76. data: {
  77. device_id: this.deviceInfo.devBid,
  78. }
  79. }).then(res => {
  80. console.log('设备控制参数信息', res)
  81. this.storageVal = res.storage_inr
  82. this.dataInterval = res.interval
  83. })
  84. },
  85. async handleControl(cmd) {
  86. const params = {
  87. device_id: this.deviceInfo.devBid,
  88. cmd,
  89. interval: cmd === 'INTERVAL' ? this.dataInterval : undefined,
  90. storage_inr: cmd === 'STORAGE_INR' ? this.storageVal : undefined,
  91. stnid: cmd === 'STNID' ? this.stnidVal : undefined
  92. };
  93. await this.$myRequest({
  94. url: '/api/api_gateway?method=qxz.device.control',
  95. data: params
  96. }).then(res => {
  97. console.log('设备控制参数信息', res)
  98. })
  99. },
  100. handleSubmit() {
  101. this.handleControl('STORAGE_INR');
  102. this.handleControl('INTERVAL');
  103. uni.showToast({
  104. title: "操作成功",
  105. icon: "none",
  106. });
  107. }
  108. },
  109. };
  110. </script>
  111. <style lang="scss" scoped>
  112. .device-details-page {
  113. background: linear-gradient(
  114. 180deg,
  115. #ffffff00 0%,
  116. #f5f6fa 23.64%,
  117. #f5f6fa 100%
  118. ),
  119. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  120. min-height: 100vh;
  121. padding: 0 32rpx;
  122. padding-top: 98rpx;
  123. }
  124. .control-board {
  125. border-radius: 16rpx;
  126. background: #fff;
  127. padding: 32rpx;
  128. margin-top: 46rpx;
  129. .title {
  130. margin-bottom: 16rpx;
  131. color: #303133;
  132. font-size: 28rpx;
  133. font-weight: 400;
  134. }
  135. .date-title {
  136. margin-bottom: 52rpx;
  137. }
  138. .reload-btn {
  139. width: 100%;
  140. background: #0bbc58;
  141. margin-bottom: 48rpx;
  142. border-radius: 16rpx;
  143. }
  144. .date-slider {
  145. }
  146. }
  147. .footer-board {
  148. border-top: 2rpx solid #e4e7ed;
  149. background: #fff;
  150. position: fixed;
  151. bottom: 0;
  152. left: 0;
  153. right: 0;
  154. height: 164rpx;
  155. padding: 16rpx 32rpx 0 32rpx;
  156. .sub-btn {
  157. width: 100%;
  158. background: #0bbc58;
  159. border-radius: 16rpx;
  160. }
  161. }
  162. </style>