| | |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }); |
| | | |
| | | |
| | | // 获取项目配置 |
| | | const projectConfig = PROJECT_CONFIG[currentProject]; |
| | | if (projectConfig) { |
| | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 已登录或不需要登录的项目,执行开阀操作 |
| | | wx.navigateTo({ |
| | | url: '/pages/waterIntake/waterIntake', |
| | |
| | | const projectConfig = PROJECT_CONFIG[project]; |
| | | if (projectConfig) { |
| | | getApp().globalData.tag = projectConfig.tag; |
| | | |
| | | |
| | | // 根据项目是否需要登录,设置不同的userName |
| | | if (projectConfig.needLogin === false) { |
| | | // 不需要登录的项目,显示项目名称 |
| | |
| | | this.setData({ |
| | | isFromLogin: true |
| | | }); |
| | | |
| | | |
| | | // 登录成功后刷新数据 |
| | | console.log('登录成功后刷新数据'); |
| | | this.initData(); |
| | |
| | | // 初始化处理 |
| | | if (fromLogin || this.data.isFromLogin) { |
| | | console.log('onShow: 从登录页返回,不进行登录检查'); |
| | | |
| | | |
| | | // 如果是从登录页返回,重新加载数据 |
| | | this.initData(); |
| | | } else { |
| | |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }); |
| | | |
| | | |
| | | // 获取项目配置 |
| | | const projectConfig = PROJECT_CONFIG[currentProject]; |
| | | if (projectConfig) { |
| | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 已登录或不需要登录的项目,执行查看记录操作 |
| | | wx.navigateTo({ |
| | | url: '/pages/valveList/valveList', |
| | |
| | | wx.showToast({ |
| | | title: '暂未开放', |
| | | icon: 'none' |
| | | }) |
| | | }, |
| | | // 综合站监测 |
| | | monitor() { |
| | | 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/stationMonitor/stationMonitor', |
| | | }) |
| | | }, |
| | | //解绑用户 |
| | |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }); |
| | | |
| | | |
| | | // 获取项目配置 |
| | | const projectConfig = PROJECT_CONFIG[currentProject]; |
| | | if (projectConfig) { |
| | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 已登录或不需要登录的项目,执行轮灌操作 |
| | | wx.navigateTo({ |
| | | url: '/pages/irrigation/irrigation', |
| | |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }); |
| | | |
| | | |
| | | // 获取项目配置 |
| | | const projectConfig = PROJECT_CONFIG[currentProject]; |
| | | if (projectConfig) { |
| | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 已登录或不需要登录的项目,执行扫码操作 |
| | | const that = this; |
| | | wx.scanCode({ |
| | |
| | | app.globalData.clientId = jsonObj.clientId || clientId; |
| | | app.globalData.tag = jsonObj.tag; |
| | | app.globalData.isLoggedIn = true; |
| | | |
| | | |
| | | // 直接从userData设置用户信息 |
| | | if (jsonObj.clientName && jsonObj.phone) { |
| | | this.setData({ |
| | |
| | | // 如果userData中没有用户信息,调用接口获取 |
| | | this.getUserDataBySession(); |
| | | } |
| | | |
| | | |
| | | console.log("userData已加载:", userData); |
| | | } catch (e) { |
| | | console.error('userData解析失败:', e); |
| | |
| | | app.globalData.isLoggedIn = true; |
| | | this.getUserDataBySession(); |
| | | } |
| | | |
| | | |
| | | // 无论如何都尝试获取开阀列表 |
| | | this.getOpenList(); |
| | | }).catch(err => { |
| | | console.error('恢复登录状态失败:', err); |
| | | this.getOpenList(); |
| | | }); |
| | | |
| | | |
| | | return; |
| | | } |
| | | |
| | |
| | | // 此处不做跳转,注释掉原有代码 |
| | | // const projectInfo = PROJECT_CONFIG[currentProject]; |
| | | // const loginType = projectInfo?.loginType || 'code'; // 默认使用验证码登录 |
| | | |
| | | |
| | | // if (loginType === 'account') { |
| | | // // 账号密码登录 |
| | | // wx.navigateTo({ |
| | |
| | | // 此处不做跳转,注释掉原有代码 |
| | | // const projectInfo = PROJECT_CONFIG[currentProject]; |
| | | // const loginType = projectInfo?.loginType || 'code'; // 默认使用验证码登录 |
| | | |
| | | |
| | | // if (loginType === 'account') { |
| | | // // 账号密码登录 |
| | | // wx.navigateTo({ |
| | |
| | | const currentProject = getApp().globalData.selectedProject; |
| | | if (currentProject && PROJECT_CONFIG[currentProject]) { |
| | | const projectConfig = PROJECT_CONFIG[currentProject]; |
| | | |
| | | |
| | | if (!projectConfig.needLogin) { |
| | | console.log('wxLogin: 当前项目不需要登录:', currentProject); |
| | | // 不需要登录的项目,显示项目名称 |
| | |
| | | // 未绑定账号,根据项目配置的loginType跳转到相应的登录页面 |
| | | const projectInfo = PROJECT_CONFIG[this.data.selectedProject]; |
| | | const loginType = projectInfo?.loginType || 'code'; // 默认使用验证码登录 |
| | | |
| | | |
| | | if (loginType === 'account') { |
| | | // 账号密码登录 |
| | | wx.navigateTo({ |
| | |
| | | // 未绑定账号,根据项目配置的loginType跳转到相应的登录页面 |
| | | const projectInfo = PROJECT_CONFIG[this.data.selectedProject]; |
| | | const loginType = projectInfo?.loginType || 'code'; // 默认使用验证码登录 |
| | | |
| | | |
| | | if (loginType === 'account') { |
| | | // 账号密码登录 |
| | | wx.navigateTo({ |
| | |
| | | }).catch(error => { |
| | | wx.hideLoading(); |
| | | console.error('登录请求失败:', error); |
| | | if(error.code==="1003"){ |
| | | if (error.code === "1003") { |
| | | // 未绑定账号,根据项目配置的loginType跳转到相应的登录页面 |
| | | const projectInfo = PROJECT_CONFIG[this.data.selectedProject]; |
| | | const loginType = projectInfo?.loginType || 'code'; // 默认使用验证码登录 |
| | | |
| | | |
| | | if (loginType === 'account') { |
| | | // 账号密码登录 |
| | | wx.navigateTo({ |
| | |
| | | url: `/pages/login/login?project=${this.data.selectedProject}&projectName=${projectInfo.displayName}` |
| | | }); |
| | | } |
| | | }else{ |
| | | } else { |
| | | wx.showToast({ |
| | | title: '登录失败,请重试', |
| | | icon: 'none' |
| | |
| | | const currentProject = app.globalData.selectedProject; |
| | | if (currentProject && PROJECT_CONFIG[currentProject]) { |
| | | const projectConfig = PROJECT_CONFIG[currentProject]; |
| | | |
| | | |
| | | if (!projectConfig.needLogin) { |
| | | console.log('handleUserTap: 当前项目不需要登录:', currentProject); |
| | | // 不需要登录的项目,显示项目名称 |
| | |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | |
| | | // 根据项目配置的loginType决定跳转到哪个登录页面 |
| | | const loginType = projectConfig.loginType || 'code'; // 默认使用验证码登录 |
| | | |
| | | |
| | | if (loginType === 'account') { |
| | | // 账号密码登录 |
| | | wx.navigateTo({ |