管灌系统农户端微信小程序(嘉峪关应用)
pages/home/home.js
@@ -639,6 +639,63 @@
      url: '/pages/irrigation/irrigation',
    })
  },
  //跳转模型计算
  modeCompute(){
    const app = getApp();
    // 检查当前项目是否需要登录
    const currentProject = app.globalData.selectedProject;
    if (currentProject && PROJECT_CONFIG[currentProject] && PROJECT_CONFIG[currentProject].needLogin) {
      // 需要登录的项目,检查是否已登录
      if (!app.globalData.isLoggedIn) {
        // 未登录,显示提示并阻止操作
        wx.showToast({
          title: '请先登录',
          icon: 'error',
          duration: 2000
        });
        // 获取项目配置
        const projectConfig = PROJECT_CONFIG[currentProject];
        if (projectConfig) {
          // 询问用户是否前往登录
          wx.showModal({
            title: '提示',
            content: '您需要登录后才能使用综合站监测功能,是否立即登录?',
            confirmText: '前往登录',
            cancelText: '取消',
            success: (res) => {
              if (res.confirm) {
                // 用户点击确认,直接调用wxLogin方法
                this.wxLogin();
              }
            }
          });
        }
        return;
      } else if (!PROJECT_CONFIG[currentProject].monitor) {
        // 未登录,显示提示并阻止操作
        wx.showToast({
          title: '当前项目不可用',
          icon: 'error',
          duration: 2000
        });
        return;
      }
    } else if (!PROJECT_CONFIG[currentProject].monitor) {
      // 未登录,显示提示并阻止操作
      wx.showToast({
        title: '当前项目不可用',
        icon: 'error',
        duration: 2000
      });
      return;
    }
    // 已登录或不需要登录的项目,执行轮灌操作
    wx.navigateTo({
      url: '/pages/modeCompute/modeCompute',
    })
  },
  handleChange(e) {
    const item = e.currentTarget.dataset.item;
    console.log(item);