管灌系统农户端微信小程序(嘉峪关应用)
zuoxiao
2024-08-12 19804e37592d2250c551fcf5df1d87cdf551f1d1
pages/waterIntake/waterIntake.js
@@ -9,6 +9,11 @@
    searchQuery: "",
    commonWaterPoints: [], // 常用取水口数据
    allWaterPoints: [], // 所有取水口数据
    searchData: [{
      intakeNum: "1111111"
    }, {
      intakeNum: "2222222"
    }],
    isRefreshing_all: false,
    isRefreshing_common: false,
    showConfirm: false,
@@ -19,6 +24,9 @@
    confirmBtn: {
      content: '确认'
    },
    showForceConfirm: false,
    forceIntakeId: "", //强制开阀的取水口id
    inputValue:""
  },
  // 切换 Tabs
@@ -39,7 +47,9 @@
      this.getallWaterPoints(query)
      // 在这里进行搜索操作,更新 allWaterPoints 数据
    } else {
      this.getallWaterPoints(query)
      this.setData({
        allWaterPoints: []
      })
    }
  },
@@ -48,9 +58,11 @@
   * @param {} event 
   */
  choseCard(event) {
    //显示二次确认弹窗
    this.setData({
      showConfirm: true,
      choseItem: event.currentTarget.dataset.item
      choseItem: event.currentTarget.dataset.item,
      allWaterPoints: []
    })
    //  console.log(intakeId);
    //   wx.navigateTo({
@@ -59,7 +71,16 @@
  },
  //开泵通信
  postOpenValva(intakeId) {
  /**
   *
   * @param {*} intakeId 取水口id
   * @param {*} isforce 是否强制开阀
   */
  postOpenValva(intakeId, isforce) {
    this.setData({
      inputValue:""
    })
    console.log("intakeId:" + intakeId + "   isforce:" + isforce)
    wx.showLoading({
      title: '正在开阀请稍候...', // 加载提示文字
      mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false
@@ -68,7 +89,8 @@
    const data = {
      intakeId: intakeId, //取水口ID
      // vcId: vcId, //虚拟卡ID
      operator: app.globalData.sessionId //操作员
      operator: app.globalData.sessionId, //操作员
      forceOpen: !!isforce // 使用逻辑非操作符 !! 来确保 isForce 是布尔值
    };
    post({
      url: "wx/valve/open_wx",
@@ -90,12 +112,17 @@
      wx.hideLoading();
      // 处理错误响应
      console.error('请求失败:', error);
      this.setData({
        showErrorDialog: true,
        errorData: error.msg
      })
      if (error.code === "10005") {
        this.setData({
          forceIntakeId: intakeId,
          showForceConfirm: true
        })
      } else {
        this.setData({
          showErrorDialog: true,
          errorData: error.msg
        })
      }
    });
  },
@@ -110,7 +137,6 @@
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    this.getallWaterPoints();
    this.getcommonWaterPoints();
  },
@@ -152,7 +178,7 @@
  },
  /**
   * 获取所有取水口
   *在所有取水口搜索
   */
  getallWaterPoints: function (intakeNum) {
    let params = {
@@ -169,9 +195,17 @@
          isRefreshing_all: false
        });
        if (data.success && data.code === "0001") {
          this.setData({
            allWaterPoints: data.content.obj
          });
          if (!data.content) {
            wx.showToast({
              title: '没有搜索到取水口',
              icon: 'error',
            })
          }else{
            this.setData({
              allWaterPoints:[data.content]
            });
          }
        } else {
          wx.showToast({
            title: data.msg,
@@ -250,5 +284,20 @@
    this.setData({
      showErrorDialog: false
    })
  },
  cancelDialog() {
    this.setData({
      showForceConfirm: false
    });
  },
  //强制开阀
  confirmForceDialog() {
    this.postOpenValva(this.data.forceIntakeId, true);
  },
  closeSearch(){
    this.setData({
      allWaterPoints:[],
      inputValue:""
    })
  }
})