管灌系统农户端微信小程序(嘉峪关应用)
优化首页项目切换逻辑,添加确认弹窗以提升用户体验;更新样式以增强项目选择的可视化效果。
1个文件已添加
3个文件已修改
98 ■■■■■ 已修改文件
images/switch.svg 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/home.js 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/home.wxml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/home.wxss 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
images/switch.svg
New file
@@ -0,0 +1 @@
<svg t="1745913691101" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2607" width="200" height="200"><path d="M900.4 424.87c19.47 0 37.03-11.73 44.49-29.73 7.46-17.98 3.33-38.7-10.43-52.48L713.97 122.19c-7.3-7.3-19.12-7.3-26.42 0l-41.69 41.69c-7.3 7.3-7.3 19.13 0 26.42l138.28 138.27H86.32c-10.19 0-18.46 8.26-18.46 18.46v59.39c0 10.19 8.26 18.46 18.46 18.46H900.4zM937.65 598.72H123.8c-19.47 0-37.03 11.73-44.49 29.73-7.46 17.98-3.33 38.7 10.43 52.48l220.49 220.48c7.3 7.3 19.12 7.3 26.42 0l41.69-41.69c7.3-7.3 7.3-19.13 0-26.42L240.06 695.02h697.59c10.32 0 18.68-8.37 18.68-18.68v-58.93c0-10.32-8.36-18.69-18.68-18.69z" p-id="2608" fill="#ffffff"></path></svg>
pages/home/home.js
@@ -1815,50 +1815,22 @@
  },
  // 切换项目
  switchProject(e) {
    const project = e.currentTarget.dataset.project;
    if (config.setBaseUrl(project)) {
      this.setData({
        selectedProject: project
      });
      // 保存选择到本地存储
      try {
        wx.setStorageSync('selectedProject', project);
      } catch (e) {
        console.error('保存项目选择失败:', e);
      }
      // 更新全局变量
      const app = getApp();
      if (app && app.globalData) {
        app.globalData.selectedProject = project;
        // 根据项目配置设置相关参数
        const projectConfig = PROJECT_CONFIG[project];
        if (projectConfig) {
          app.globalData.tag = projectConfig.tag;
          if (!projectConfig.needLogin) {
            app.globalData.operator = projectConfig.operatorId;
            app.globalData.clientId = projectConfig.operatorId;
            app.globalData.isLoggedIn = true;
            app.globalData.sessionId = projectConfig.operatorId;
            // 如果有vcId,也设置
            if (projectConfig.vcId) {
              app.globalData.vcId = projectConfig.vcId;
            }
          }
  switchProject() {
    // 显示二次确认弹窗
    wx.showModal({
      title: '切换项目',
      content: '确定要切换项目吗?切换后需要重新登录。',
      confirmText: '确认切换',
      confirmColor: '#1890FF',
      cancelText: '取消',
      success: (res) => {
        if (res.confirm) {
          // 用户点击确认,显示项目选择弹窗
          this.setData({
            showProjectDialog: true
          });
        }
      }
      // 重新加载页面数据
      this.initData();
    } else {
      wx.showToast({
        title: '切换项目失败',
        icon: 'none'
      });
    }
    });
  },
})
pages/home/home.wxml
@@ -8,6 +8,9 @@
        <t-avatar class="avatar-example" image="{{image}}" size="120rpx" bind:tap="handleAvatarTap" />
         <view class="current-project">
          <text>{{ projectConfig[selectedProject].displayName }}</text>
          <view class="switch-project" bind:tap="switchProject">
            <image class="switch-icon" src="/images/switch.svg" />
          </view>
        </view>
      </view>
      <view class="head-text-wrapper">
pages/home/home.wxss
@@ -755,21 +755,33 @@
  }
  
.current-project {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 20rpx;
  margin-right: 10rpx;
  margin-top: 10rpx;
    display: flex;
    align-items: center;
    margin-left: 20rpx;
margin-top: 10rpx;
}
.current-project text {
  font-size: 28rpx;
  color: #ffffff;
  font-weight: bold;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 15rpx;
  padding: 6rpx 14rpx;
    color: #fff;
    font-size: 32rpx;
    margin-right: 10rpx;
}
.switch-project {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40rpx;
    height: 40rpx;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    margin-left: 5rpx;
}
.switch-icon {
    width: 24rpx;
    height: 24rpx;
}
.avatar-project-container {