From 3008f0fcb87992077af811f9842793610fc52239 Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期二, 29 四月 2025 16:07:00 +0800
Subject: [PATCH] 优化首页项目切换逻辑,添加确认弹窗以提升用户体验;更新样式以增强项目选择的可视化效果。
---
pages/home/home.js | 58 +++++++---------------------
pages/home/home.wxml | 3 +
pages/home/home.wxss | 36 ++++++++++++------
images/switch.svg | 1
4 files changed, 43 insertions(+), 55 deletions(-)
diff --git a/images/switch.svg b/images/switch.svg
new file mode 100644
index 0000000..21068d7
--- /dev/null
+++ b/images/switch.svg
@@ -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>
\ No newline at end of file
diff --git a/pages/home/home.js b/pages/home/home.js
index 1257aa1..6e1eda7 100644
--- a/pages/home/home.js
+++ b/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;
- // 濡傛灉鏈塿cId锛屼篃璁剧疆
- 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'
- });
- }
+ });
},
})
\ No newline at end of file
diff --git a/pages/home/home.wxml b/pages/home/home.wxml
index 611bf0d..c3df698 100644
--- a/pages/home/home.wxml
+++ b/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">
diff --git a/pages/home/home.wxss b/pages/home/home.wxss
index 71b6d7c..2be6c16 100644
--- a/pages/home/home.wxss
+++ b/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 {
--
Gitblit v1.8.0