devControl.vue 3.7 KB

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