Procházet zdrojové kódy

refactor(devControl): 重构设备控制页面按钮逻辑

将全局提交按钮拆分为独立操作按钮,移除冗余加载状态
添加操作成功提示,优化异步控制逻辑
allen před 1 týdnem
rodič
revize
eee5ba7138
1 změnil soubory, kde provedl 11 přidání a 7 odebrání
  1. 11 7
      pages/deviceDetails/weatherStation/devControl.vue

+ 11 - 7
pages/deviceDetails/weatherStation/devControl.vue

@@ -24,6 +24,7 @@
           step="1"
         />
       </view>
+       <u-button type="success" class="sub-btn" @click="handleControl('STORAGE_INR')">确定</u-button>
       <view class="title date-title">数据传输间隔(min)</view>
       <view class="date-slider">
         <slider
@@ -37,17 +38,17 @@
           step="1"
         />
       </view>
+       <u-button type="success" class="sub-btn" @click="handleControl('INTERVAL')">确定</u-button>
     </view>
-    <view class="footer-board">
+    <!-- <view class="footer-board">
       <u-button type="success" class="sub-btn" @click="handleSubmit()">确定</u-button>
-    </view>
+    </view> -->
   </view>
 </template>
 
 <script>
 export default {
   onLoad(options) {
-    this.loading = true
     const deviceInfo = JSON.parse(decodeURIComponent(options.deviceInfo));
     console.log(deviceInfo, "deviceInfo");
     this.deviceInfo = deviceInfo;
@@ -69,7 +70,6 @@ export default {
     },
     // 获取设备控制参数信息
     async getDevControlParams() {
-      this.loading = true
       await this.$myRequest({
         url: '/api/api_gateway?method=qxz.device.control_args',
         data: {
@@ -94,11 +94,15 @@ export default {
         data: params
       }).then(res => {
         console.log('设备控制参数信息', res)
+        uni.showToast({
+          title: "操作成功",
+          icon: "none",
+        });
       })
     },
-    handleSubmit() {
-      this.handleControl('STORAGE_INR');
-      this.handleControl('INTERVAL');
+    async handleSubmit() {
+      await this.handleControl('STORAGE_INR');
+      await this.handleControl('INTERVAL');
       uni.showToast({
         title: "操作成功",
         icon: "none",