沙盘演示系统应用的微信小程序
zuoxiao
2024-10-28 f66a9a2c565966e98720be5e20604c6f75030f82
pages/home/home.js
@@ -31,6 +31,8 @@
    showForceConfirm: false, //是否强制开阀
    lastIntakeName: "",
    isLogin: false, //是否已经登录
    showInfoDialog: false,
  },
  openValve: function (e) {
@@ -44,7 +46,6 @@
        icon: 'error'
      })
    }
  },
  calculateScrollViewHeight: function () {
    wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => {
@@ -70,8 +71,6 @@
        icon: 'error'
      })
    }
  },
  //获取用户数据
  getUserData() {
@@ -115,6 +114,9 @@
      const app = getApp();
      storage.getItem('sessionId').then((data) => {
        app.globalData.sessionId = data;
        this.setData({
          isLogin: true
        })
        if (app.globalData.sessionId) {
          this.getOpenList();
          this.getUserDataBySession();
@@ -324,6 +326,7 @@
   * 获取为关阀记录
   */
  getOpenList() {
    if (this.data.isLogin) {
    const app = getApp();
    const params = {
      url: 'wx/valve/get',
@@ -350,6 +353,17 @@
        duration: 3000
      })
    });
    } else {
      wx.showToast({
        title: '请先登录',
        icon: 'error'
      })
      this.setData({
        isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成
        isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成
      })
    }
  },
  /**
   * 确认关闭回调
@@ -403,6 +417,7 @@
   * 扫码开阀
   */
  scenCode() {
    if (this.data.isLogin) {
    const that = this;
    wx.scanCode({
      success(res) {
@@ -415,13 +430,23 @@
            console.error('Error parsing JSON:', error);
          }
        } else {
          that.postOppenValva(res.result)
            wx.navigateTo({
              url: '/pages/openCard/openCard?intakeName=' + res.result,
            })
            // that.postOppenValva()
        }
      },
      fail(err) {
        console.error(err);
      }
    })
    } else {
      wx.showToast({
        title: '请先登录',
        icon: 'error'
      })
    }
  },
  confirmForceDialog() {
    console.log("confirmForceDialog");
@@ -611,5 +636,17 @@
      // 处理错误响应
      console.error('请求失败:', error);
    });
  },
  //点击提示按钮
  infoShow() {
    this.setData({
      showInfoDialog: true
    })
  },
  //提示窗确认按钮
  confirmBtnInfoDialog() {
    this.setData({
      showInfoDialog: false
    })
  }
})