沙盘演示系统应用的微信小程序
pages/openCard/openCard.js
@@ -1,4 +1,4 @@
// 开卡选择虚拟卡
// 开阀选择虚拟卡
const {
  get,
  post
@@ -14,7 +14,8 @@
    vcId: "",
    activeIndex: -1,
    datetimeVisible: false,
    datetime: new Date().getTime(),
    dateStartTime: new Date().getTime(),
    dateEndTime: new Date().getTime() + 24 * 60 * 60 * 1000,
    datetimeText: '',
    allCardPoints: [], // 所有虚拟卡
    irrigateProfile: [], //获取所选灌溉方式的详细数据
@@ -36,7 +37,9 @@
    radioValue: "0", //开阀方式选中的类型
    costiomTime: "", //自定义灌溉时间
    waterAmount: 0, //定量开阀的水量
    costiomWater:"",//输入的自定义水量
    costiomWater: "", //输入的自定义水量
    isWXRefreshing: false,
    intakeName: "" //扫码开阀从首页传来的取水口名称
  },
  openValva(event) {
    const {
@@ -45,14 +48,20 @@
    if (item.isAlarmValue === true) {
      //金额报警
      wx.navigateTo({
        url: '/pages/rechargeMoney/rechargMoney?vcId=' + item.vcId,
        url: '/pages/rechargeMoney/rechargMoney?vcId=' + item.id,
      })
    } else if (item.inUse === false) {
      // 选择虚拟卡后
      this.initDialogData();
      this.setData({
        vcId: item.vcId,
        vcId: item.id,
      })
      if (this.data.intakeName) {
        //扫码开阀逻辑
        this.postOpenValva(false);
      } else {
        // 选择虚拟卡后
        this.initDialogData();
      }
    }
  },
  handleAutoIrrigation() {},
@@ -62,10 +71,12 @@
   */
  onLoad(options) {
    const {
      intakeId
      intakeId,
      intakeName
    } = options;
    this.setData({
      intakeId: intakeId
      intakeId: intakeId,
      intakeName: intakeName
    })
    console.log('intakeId:' + this.data.intakeId);
    this.getCardList();
@@ -103,7 +114,10 @@
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
    this.setData({
      isWXRefreshing: true
    });
    this.getCardList();
  },
  /**
@@ -163,7 +177,8 @@
    });
    // 更新列表数据
    this.setData({
      allCardPoints: updatedList
      allCardPoints: updatedList,
      isWXRefreshing: false
    });
  },
  handleClost() {
@@ -198,7 +213,7 @@
      this.data.waterAmount = parseInt(this.data.irrigateProfile[index].defaultValue)
      this.setData({
        activeIndex: parseInt(index),
        costiomWater:""
        costiomWater: ""
      });
    }
  },
@@ -249,6 +264,7 @@
      this.setData({
        isOpenTiming: true,
        radioValue: value,
        dateStartTime: new Date().getTime()
      })
    } else {
      this.setData({
@@ -300,7 +316,8 @@
      dialog_time: false,
      dialog_water: false,
      dialog_mode: true,
      group_time: false
      group_time: false,
      activeIndex: -1
    })
  },
  //立即开泵
@@ -313,7 +330,8 @@
    const data = {
      intakeId: this.data.intakeId, //取水口ID
      vcId: this.data.vcId, //虚拟卡ID
      operator: app.globalData.sessionId, //操作员
      intakeName: this.data.intakeName, //取水口名称
      operator: app.globalData.clientId, //操作员
      forceOpen: !!isforce // 使用逻辑非操作符 !! 来确保 isForce 是布尔值  
    };
    post({
@@ -327,7 +345,7 @@
      wx.hideLoading();
      //完成后回到首页
      wx.reLaunch({
        url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写
        url: '/pages/home/home?param=1' // 首页的路径,根据实际情况填写
      });
    }).catch(error => {
@@ -359,7 +377,7 @@
      intakeId: this.data.intakeId, //取水口ID
      vcId: this.data.vcId, //虚拟卡ID
      minutes: this.data.postMinutes, //分钟
      operator: app.globalData.sessionId //操作员
      operator: app.globalData.clientId //操作员
    };
    post({
      url: "wx/valve/timed_close",
@@ -371,7 +389,7 @@
      wx.hideLoading();
      //完成后回到首页
      wx.reLaunch({
        url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写
        url: '/pages/home/home?param=1' // 首页的路径,根据实际情况填写
      });
    }).catch(error => {
      // 加载完成后隐藏加载动画
@@ -395,11 +413,11 @@
      intakeId: this.data.intakeId, //取水口ID
      vcId: this.data.vcId, //虚拟卡ID
      minutes: this.data.postMinutes, //分钟
      operator: app.globalData.sessionId, //操作员
      operator: app.globalData.clientId, //操作员
      plannedOpenTime: this.data.openTime
    };
    post({
      url: "wx/valve/timed_close",
      url: "wx/valve/planed_open_timed_close",
      data: data
    }).then(response => {
      // 处理成功响应
@@ -408,7 +426,7 @@
      wx.hideLoading();
      //完成后回到首页
      wx.reLaunch({
        url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写
        url: '/pages/home/home?param=2' // 首页的路径,根据实际情况填写
      });
    }).catch(error => {
      // 加载完成后隐藏加载动画
@@ -431,11 +449,11 @@
    const data = {
      intakeId: this.data.intakeId, //取水口ID
      vcId: this.data.vcId, //虚拟卡ID
      minutes: this.data.waterAmount, //水量
      operator: app.globalData.sessionId //操作员
      waterAmount: this.data.waterAmount, //水量
      operator: app.globalData.clientId //操作员
    };
    post({
      url: "/wx/valve/quantify_close",
      url: "wx/valve/quantify_close",
      data: data
    }).then(response => {
      // 处理成功响应
@@ -444,7 +462,7 @@
      wx.hideLoading();
      //完成后回到首页
      wx.reLaunch({
        url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写
        url: '/pages/home/home?param=1' // 首页的路径,根据实际情况填写
      });
    }).catch(error => {
      // 加载完成后隐藏加载动画
@@ -468,11 +486,11 @@
      intakeId: this.data.intakeId, //取水口ID
      vcId: this.data.vcId, //虚拟卡ID
      waterAmount: this.data.waterAmount, //水量
      operator: app.globalData.sessionId, //操作员
      operator: app.globalData.clientId, //操作员
      plannedOpenTime: this.data.openTime
    };
    post({
      url: "/wx/valve/planed_open_quantify_close",
      url: "wx/valve/planed_open_quantify_close",
      data: data
    }).then(response => {
      // 处理成功响应
@@ -481,7 +499,7 @@
      wx.hideLoading();
      //完成后回到首页
      wx.reLaunch({
        url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写
        url: '/pages/home/home?param=2' // 首页的路径,根据实际情况填写
      });
    }).catch(error => {
      // 加载完成后隐藏加载动画
@@ -583,7 +601,7 @@
    }
  },
  //输入自定义水量的监听
  onWaterInputChange(data){
  onWaterInputChange(data) {
    console.log(data.detail.value)
    if (data.detail.value !== "") {
      this.setData({
@@ -597,7 +615,7 @@
    }
  },
  // 定量开泵按钮
  btnOpenOnWater(){
  btnOpenOnWater() {
    if (this.data.waterAmount > 0) {
      if (this.data.isOpenTiming) {
        this.quantifyOpenTime();
@@ -610,7 +628,7 @@
        title: '请选择或输入灌溉时间!',
      })
    }
  }
  },
})