沙盘演示系统应用的微信小程序
pages/home/home.js
@@ -114,12 +114,12 @@
          isLogin: true
        })
        if (app.globalData.sessionId) {
          this.getOpenList();
          this.getUserDataBySession();
        }
      }).catch((err) => {});
      storage.getItem('clientId').then((data) => {
        app.globalData.clientId = data;
        this.getOpenList();
      }).catch((err) => {});
    } else {
      //本地没有缓存微信登录
@@ -128,7 +128,7 @@
    if (this.data.options.param === "1") {
      this.setData({
        showTipDialog: true,
        tipData: "开阀命令下发成功,约20-60秒后可刷新快速关阀列表查看执行结果。"
        tipData: "开阀命令下发成功,因开阀需要时间,约20-60秒后可刷新快速关阀列表查看执行结果。"
      })
      setTimeout(() => {
        this.getOpenList();
@@ -143,19 +143,22 @@
    }
  },
  wxLogin() {
    const that = this;
    wx.login({
      success: function (res) {
        if (res.code) {
          var code = res.code;
          console.log(code);
          // 将code发送到服务器获取openid
          that.codeLogin(code);
        } else {
          console.log('登录失败!' + res.errMsg);
    // if (!this.data.isLogin) {
      const that = this;
      wx.login({
        success: function (res) {
          if (res.code) {
            var code = res.code;
            console.log(code);
            // 将code发送到服务器获取openid
            that.codeLogin(code);
          } else {
            console.log('登录失败!' + res.errMsg);
          }
        }
      }
    });
      });
    // }
  },
  //微信code登录
  codeLogin(codeData) {
@@ -278,7 +281,7 @@
      showForceConfirm: false,
      showConfirm: false,
      showTipDialog: false,
      showUnBind:false
      showUnBind: false
    });
  },
  /**
@@ -349,7 +352,7 @@
      const params = {
        url: 'wx/valve/get',
        data: {
          operator: app.globalData.sessionId
          operator: app.globalData.clientId
        }
      };
      get(params).then(data => {
@@ -564,9 +567,6 @@
      title: '正在强制删除请稍候...', // 加载提示文字
      mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false
    });
    that.setData({
      lastIntakeName: intakeName
    })
    const data = {
      vcNum: item.vcNum, //取水口ID
      rtuAddr: item.rtuAddr, //阀控器地址
@@ -598,9 +598,22 @@
      } else {
        displayText = "关阀"
      }
      let deleteText = "删除"
      let time;
      if (!item.dt) {
        time = "暂无"
      } else {
        time = this.extractTime(item.dt)
      }
      if (item.waterInstant===null) {
        item.waterInstant = "暂无"
      }
      return {
        ...item,
        displayText
        displayText,
        deleteText,
        time
      }; // 保留所有其他字段,并添加 displayText 字段
    });
    // 更新列表数据
@@ -674,5 +687,15 @@
    this.setData({
      showInfoDialog: false
    })
  },
  //处理时间去掉年月日
  extractTime(datetimeString) {
    const formattedDate = datetimeString.replace(" ", "T");
    const date = new Date(formattedDate);
    // 获取小时、分钟和秒
    const hours = date.getHours().toString().padStart(2, '0');
    const minutes = date.getMinutes().toString().padStart(2, '0');
    const seconds = date.getSeconds().toString().padStart(2, '0');
    return `${hours}:${minutes}:${seconds}`;
  }
})