devControl.vue 3.8 KB

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