From 06a17c236d4cb9b8da75fce43af938cb7ea510bf Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期一, 15 十二月 2025 09:50:12 +0800
Subject: [PATCH] feat: 优化企业微信判断,优化gps分断处理
---
app/pages/login.vue | 10 +
app/static/images/loading.gif | 0
app/utils/wechat.js | 55 +++++++++----
app/pages/qylogin.vue | 16 +++-
ruoyi-system/src/main/resources/mapper/system/VehicleGpsSegmentMileageMapper.xml | 3
ruoyi-admin/src/main/resources/application.yml | 2
app/App.vue | 109 +++++++++++++++++++--------
7 files changed, 135 insertions(+), 60 deletions(-)
diff --git a/app/App.vue b/app/App.vue
index dd3a43f..f45cc42 100644
--- a/app/App.vue
+++ b/app/App.vue
@@ -14,6 +14,7 @@
}
},
onLaunch: function(options) {
+ console.log('App onLaunch, options:', options);
this.lastToken = getToken()
this.initApp(options)
@@ -37,7 +38,11 @@
this.stopMessagePolling()
this.lastToken = null
// 娓呴櫎娑堟伅寰芥爣
- uni.removeTabBarBadge({ index: 3 })
+ try {
+ uni.removeTabBarBadge({ index: 3 })
+ } catch (e) {
+ console.error('娓呴櫎娑堟伅寰芥爣澶辫触:', e)
+ }
})
},
onShow: function() {
@@ -74,10 +79,14 @@
methods: {
// 鍒濆鍖栧簲鐢�
initApp(options) {
- // 鍒濆鍖栧簲鐢ㄩ厤缃�
- this.initConfig()
- // 妫�鏌ョ敤鎴风櫥褰曠姸鎬佸苟鑷姩璺宠浆鍒板悎閫傜殑鐧诲綍椤甸潰
- this.checkLoginAndRedirect(options)
+ try {
+ // 鍒濆鍖栧簲鐢ㄩ厤缃�
+ this.initConfig()
+ // 妫�鏌ョ敤鎴风櫥褰曠姸鎬佸苟鑷姩璺宠浆鍒板悎閫傜殑鐧诲綍椤甸潰
+ this.checkLoginAndRedirect(options)
+ } catch (e) {
+ console.error('鍒濆鍖栧簲鐢ㄥけ璐�:', e)
+ }
// 娉ㄦ剰锛氫笉鍦ㄥ簲鐢ㄥ惎鍔ㄦ椂鑷姩鍚姩杞
// 鍙湁鍦ㄧ敤鎴蜂富鍔ㄧ櫥褰曟垚鍔熷悗鎵嶅惎鍔紙閫氳繃 user-login 浜嬩欢瑙﹀彂锛�
@@ -87,22 +96,40 @@
},
// 妫�鏌ョ櫥褰曠姸鎬佸苟鑷姩璺宠浆鍒板悎閫傜殑鐧诲綍椤甸潰
checkLoginAndRedirect(options) {
- if (!getToken()) {
- // 浣跨敤宸ュ叿绫绘牴鎹幆澧冭嚜鍔ㄨ烦杞埌鍚堥�傜殑鐧诲綍椤甸潰
- redirectToLoginByEnvironment(options, this.$tab);
+ try {
+ if (!getToken()) {
+ console.log('鐢ㄦ埛鏈櫥褰曪紝鍑嗗璺宠浆鍒扮櫥褰曢〉闈�')
+ // 浣跨敤宸ュ叿绫绘牴鎹幆澧冭嚜鍔ㄨ烦杞埌鍚堥�傜殑鐧诲綍椤甸潰
+ redirectToLoginByEnvironment(options, this.$tab);
+ } else {
+ console.log('鐢ㄦ埛宸茬櫥褰曪紝鏃犻渶璺宠浆')
+ }
+ } catch (e) {
+ console.error('妫�鏌ョ櫥褰曠姸鎬佸苟璺宠浆澶辫触:', e)
+ // fallback鍒版櫘閫氱櫥褰曢〉闈�
+ try {
+ this.$tab.reLaunch('/pages/login');
+ } catch (fallbackError) {
+ console.error('fallback璺宠浆涔熷け璐ヤ簡:', fallbackError);
+ }
}
},
// 鍒ゆ柇褰撳墠鏄惁鍦ㄧ櫥褰曢〉闈�
isLoginPage() {
- const pages = getCurrentPages()
- if (pages.length === 0) {
+ try {
+ const pages = getCurrentPages()
+ if (pages.length === 0) {
+ return false
+ }
+ const currentPage = pages[pages.length - 1]
+ const route = currentPage.route || ''
+ // 鍒ゆ柇鏄惁涓虹櫥褰曠浉鍏抽〉闈�
+ return route.includes('login') || route.includes('register')
+ } catch (e) {
+ console.error('鍒ゆ柇鏄惁涓虹櫥褰曢〉闈㈠け璐�:', e)
return false
}
- const currentPage = pages[pages.length - 1]
- const route = currentPage.route || ''
- // 鍒ゆ柇鏄惁涓虹櫥褰曠浉鍏抽〉闈�
- return route.includes('login') || route.includes('register')
},
// 鏇存柊鏈娑堟伅寰芥爣
@@ -119,15 +146,23 @@
if (count > 0) {
// 璁剧疆寰芥爣
- uni.setTabBarBadge({
- index: 3, // 娑堟伅椤甸潰鍦╰abBar涓殑绱㈠紩浣嶇疆锛�0寮�濮嬶級
- text: count > 99 ? '99+' : count.toString()
- })
+ try {
+ uni.setTabBarBadge({
+ index: 3, // 娑堟伅椤甸潰鍦╰abBar涓殑绱㈠紩浣嶇疆锛�0寮�濮嬶級
+ text: count > 99 ? '99+' : count.toString()
+ })
+ } catch (e) {
+ console.error('璁剧疆娑堟伅寰芥爣澶辫触:', e)
+ }
} else {
// 绉婚櫎寰芥爣
- uni.removeTabBarBadge({
- index: 3
- })
+ try {
+ uni.removeTabBarBadge({
+ index: 3
+ })
+ } catch (e) {
+ console.error('绉婚櫎娑堟伅寰芥爣澶辫触:', e)
+ }
}
}).catch(error => {
console.error('鑾峰彇鏈娑堟伅鏁伴噺澶辫触:', error)
@@ -136,22 +171,30 @@
// 鍚姩娑堟伅杞
startMessagePolling() {
- // 姣�30绉掕疆璇竴娆�
- this.messagePollingTimer = setInterval(() => {
- if (getToken()) {
- this.updateUnreadMessageBadge()
- } else {
- // 濡傛灉鐢ㄦ埛宸茬櫥鍑猴紝鍋滄杞
- this.stopMessagePolling()
- }
- }, 30000) // 30绉�
+ try {
+ // 姣�30绉掕疆璇竴娆�
+ this.messagePollingTimer = setInterval(() => {
+ if (getToken()) {
+ this.updateUnreadMessageBadge()
+ } else {
+ // 濡傛灉鐢ㄦ埛宸茬櫥鍑猴紝鍋滄杞
+ this.stopMessagePolling()
+ }
+ }, 30000) // 30绉�
+ } catch (e) {
+ console.error('鍚姩娑堟伅杞澶辫触:', e)
+ }
},
// 鍋滄娑堟伅杞
stopMessagePolling() {
- if (this.messagePollingTimer) {
- clearInterval(this.messagePollingTimer)
- this.messagePollingTimer = null
+ try {
+ if (this.messagePollingTimer) {
+ clearInterval(this.messagePollingTimer)
+ this.messagePollingTimer = null
+ }
+ } catch (e) {
+ console.error('鍋滄娑堟伅杞澶辫触:', e)
}
},
diff --git a/app/pages/login.vue b/app/pages/login.vue
index 8230e42..464d7e4 100644
--- a/app/pages/login.vue
+++ b/app/pages/login.vue
@@ -93,9 +93,13 @@
onLoad(options) {
// 淇濆瓨椤甸潰鍙傛暟
this.pageOptions = options || {}
- if(isWxWorkEnvironment()){
- redirectToQyLogin(options,this.$tab);
- }
+ isWxWorkEnvironment().then(res=>{
+ if(res){
+ // console.log("浼佷笟寰俊鐜 login.vue....")
+ redirectToQyLogin(options,this.$tab);
+ }
+ });
+
},
created() {
this.getCode()
diff --git a/app/pages/qylogin.vue b/app/pages/qylogin.vue
index dacb592..0d47648 100644
--- a/app/pages/qylogin.vue
+++ b/app/pages/qylogin.vue
@@ -34,10 +34,18 @@
},
onLoad(options) {
- // 淇濆瓨椤甸潰鍙傛暟
- this.pageOptions = options || {};
- // 椤甸潰鍔犺浇鏃舵墽琛屽厤鐧绘祦绋�
- this.qyWechatAutoLogin();
+ // 娣诲姞瀹归敊澶勭悊
+ try {
+ // 淇濆瓨椤甸潰鍙傛暟
+ this.pageOptions = options || {};
+ // 椤甸潰鍔犺浇鏃舵墽琛屽厤鐧绘祦绋�
+ this.qyWechatAutoLogin();
+ } catch (e) {
+ console.error('椤甸潰鍔犺浇鍑洪敊:', e);
+ this.loading = false;
+ this.error = true;
+ this.errorMessage = "椤甸潰鍒濆鍖栧け璐ワ紝璇烽噸璇�";
+ }
},
methods: {
diff --git a/app/static/images/loading.gif b/app/static/images/loading.gif
new file mode 100644
index 0000000..e609ba5
--- /dev/null
+++ b/app/static/images/loading.gif
Binary files differ
diff --git a/app/utils/wechat.js b/app/utils/wechat.js
index afd572c..3c05e14 100644
--- a/app/utils/wechat.js
+++ b/app/utils/wechat.js
@@ -12,12 +12,13 @@
try {
// 鑾峰彇绯荤粺淇℃伅
const systemInfo = uni.getSystemInfoSync();
- console.log('绯荤粺淇℃伅:', systemInfo);
-
// 妫�鏌nvironment瀛楁鏄惁涓簑xwork
- resolve(systemInfo.environment === 'wxwork');
+ const isWxWork = systemInfo.environment === 'wxwork';
+ console.log('鐜妫�娴嬬粨鏋�:', isWxWork, systemInfo);
+ resolve(isWxWork);
} catch (e) {
console.error('鑾峰彇绯荤粺淇℃伅澶辫触:', e);
+ // fallback妫�娴�
resolve(false);
}
// #endif
@@ -62,41 +63,61 @@
if (isWxWork) {
console.log('妫�娴嬪埌浼佷笟寰俊鐜锛岃烦杞埌浼佷笟寰俊鍏嶇櫥椤甸潰');
// 鏋勯�犲甫鍙傛暟鐨刄RL
- redirectToQyLogin(options,tab);
+ redirectToQyLogin(options, tab);
return;
} else {
console.log('妫�娴嬪埌鏅�氬井淇$幆澧冿紝璺宠浆鍒板井淇$櫥褰曢〉闈�');
- redirectToLogin(options,tab);
+ redirectToLogin(options, tab);
return;
}
} catch (e) {
console.error('鐜妫�娴嬪け璐�:', e);
- redirectToLogin(options,tab);
+ redirectToLogin(options, tab);
}
// #endif
// #ifndef MP-WEIXIN
// 闈炲井淇″皬绋嬪簭鐜锛岃烦杞埌鏅�氱櫥褰曢〉闈�
console.log('闈炲井淇″皬绋嬪簭鐜锛岃烦杞埌鏅�氱櫥褰曢〉闈�');
- redirectToLogin(options,tab);
+ redirectToLogin(options, tab);
// #endif
}
-export function redirectToQyLogin(options,tab){
+export function redirectToQyLogin(options, tab) {
+ try {
let url = '/pages/qylogin';
- if (options && options.query) {
- url = buildUrlWithParams(url, options.query);
- }
- tab.reLaunch(url);
+ if (options && options.query) {
+ url = buildUrlWithParams(url, options.query);
+ }
+ console.log('璺宠浆鍒颁紒涓氬井淇$櫥褰曢〉闈�:', url);
+ tab.reLaunch(url);
+ } catch (e) {
+ console.error('璺宠浆鍒颁紒涓氬井淇$櫥褰曢〉闈㈠け璐�:', e);
+ // fallback鍒版櫘閫氱櫥褰曢〉闈�
+ redirectToLogin(options, tab);
+ }
}
-export function redirectToLogin(options,tab){
+
+export function redirectToLogin(options, tab) {
+ try {
let url = '/pages/login';
- if (options && options.query) {
- url = buildUrlWithParams(url, options.query);
- }
- tab.reLaunch(url);
+ if (options && options.query) {
+ url = buildUrlWithParams(url, options.query);
+ }
+ console.log('璺宠浆鍒版櫘閫氱櫥褰曢〉闈�:', url);
+ tab.reLaunch(url);
+ } catch (e) {
+ console.error('璺宠浆鍒版櫘閫氱櫥褰曢〉闈㈠け璐�:', e);
+ // 濡傛灉璺宠浆澶辫触锛岃嚦灏戠‘淇濅笉浼氬崱鍦ㄥ綋鍓嶉〉闈�
+ try {
+ tab.reLaunch('/pages/login');
+ } catch (fallbackError) {
+ console.error('fallback璺宠浆涔熷け璐ヤ簡:', fallbackError);
+ }
+ }
}
+
export default {
isWxWorkEnvironment,
buildUrlWithParams,
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index 105bc73..4219d2c 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -58,7 +58,7 @@
basename: i18n/messages
profiles:
# 鐜 dev|test|prod
- active: dev
+ active: prod
# 鏂囦欢涓婁紶
servlet:
multipart:
diff --git a/ruoyi-system/src/main/resources/mapper/system/VehicleGpsSegmentMileageMapper.xml b/ruoyi-system/src/main/resources/mapper/system/VehicleGpsSegmentMileageMapper.xml
index aa125c1..1762ebd 100644
--- a/ruoyi-system/src/main/resources/mapper/system/VehicleGpsSegmentMileageMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/VehicleGpsSegmentMileageMapper.xml
@@ -66,8 +66,7 @@
WHERE vehicle_id = #{vehicleId}
AND segment_start_time <= #{endDate}
AND segment_end_time >= #{startDate}
- AND segment_start_time IS NOT NULL
- AND segment_end_time IS NOT NULL
+ AND segment_distance >0
ORDER BY segment_start_time
</select>
--
Gitblit v1.9.1