hookehuyr

refactor(ui): 集中管理弱网络提示文本和弹窗配置

将分散在各处的弱网络提示文本和弹窗配置统一管理到uiText.js
更新相关文件引用新的统一配置
...@@ -13,6 +13,7 @@ import { saveCurrentPagePath, hasAuth, silentAuth, navigateToAuth } from '@/util ...@@ -13,6 +13,7 @@ import { saveCurrentPagePath, hasAuth, silentAuth, navigateToAuth } from '@/util
13 import Taro from '@tarojs/taro' 13 import Taro from '@tarojs/taro'
14 import { refresh_offline_booking_cache, has_offline_booking_cache } from '@/composables/useOfflineBookingCache' 14 import { refresh_offline_booking_cache, has_offline_booking_cache } from '@/composables/useOfflineBookingCache'
15 import { is_usable_network, get_network_type } from '@/utils/network' 15 import { is_usable_network, get_network_type } from '@/utils/network'
16 +import { weak_network_text, get_weak_network_modal_use_cache_options } from '@/utils/uiText'
16 17
17 let has_shown_network_modal = false 18 let has_shown_network_modal = false
18 19
...@@ -78,12 +79,7 @@ const App = createApp({ ...@@ -78,12 +79,7 @@ const App = createApp({
78 79
79 if (has_offline_booking_cache()) { 80 if (has_offline_booking_cache()) {
80 try { 81 try {
81 - const modal_res = await Taro.showModal({ 82 + const modal_res = await Taro.showModal(get_weak_network_modal_use_cache_options())
82 - title: '网络连接不畅',
83 - content: '当前网络信号较弱,可使用已缓存的预约记录进入离线模式',
84 - confirmText: '预约记录',
85 - cancelText: '知道了',
86 - })
87 if (modal_res?.confirm) { 83 if (modal_res?.confirm) {
88 await Taro.reLaunch({ url: '/pages/offlineBookingList/index' }) 84 await Taro.reLaunch({ url: '/pages/offlineBookingList/index' })
89 return true 85 return true
...@@ -93,7 +89,7 @@ const App = createApp({ ...@@ -93,7 +89,7 @@ const App = createApp({
93 } 89 }
94 } else { 90 } else {
95 try { 91 try {
96 - await Taro.showToast({ title: '网络连接不畅', icon: 'none', duration: 2000 }) 92 + await Taro.showToast({ title: weak_network_text.toast_title, icon: 'none', duration: 2000 })
97 } catch (e) { 93 } catch (e) {
98 return is_none_network 94 return is_none_network
99 } 95 }
......
1 <!-- 1 <!--
2 * @Date: 2024-01-16 10:06:47 2 * @Date: 2024-01-16 10:06:47
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-13 16:21:40 4 + * @LastEditTime: 2026-01-13 21:33:58
5 * @FilePath: /xyxBooking-weapp/src/pages/bookingCode/index.vue 5 * @FilePath: /xyxBooking-weapp/src/pages/bookingCode/index.vue
6 * @Description: 预约码页面 6 * @Description: 预约码页面
7 --> 7 -->
...@@ -43,8 +43,7 @@ import icon_5 from '@/assets/images/我的01@2x.png' ...@@ -43,8 +43,7 @@ import icon_5 from '@/assets/images/我的01@2x.png'
43 import { useGo } from '@/hooks/useGo' 43 import { useGo } from '@/hooks/useGo'
44 import { has_offline_booking_cache } from '@/composables/useOfflineBookingCache' 44 import { has_offline_booking_cache } from '@/composables/useOfflineBookingCache'
45 import { is_usable_network } from '@/utils/network' 45 import { is_usable_network } from '@/utils/network'
46 - 46 +import { get_weak_network_modal_no_cache_options } from '@/utils/uiText'
47 -const go = useGo();
48 47
49 useDidShow(() => { 48 useDidShow(() => {
50 Taro.getNetworkType({ 49 Taro.getNetworkType({
...@@ -58,12 +57,7 @@ useDidShow(() => { ...@@ -58,12 +57,7 @@ useDidShow(() => {
58 } 57 }
59 58
60 try { 59 try {
61 - await Taro.showModal({ 60 + await Taro.showModal(get_weak_network_modal_no_cache_options())
62 - title: '网络连接不畅',
63 - content: '当前网络信号较弱,暂无法使用小程序,请到网络更好的地方重试。',
64 - confirmText: '知道了',
65 - showCancel: false,
66 - })
67 } catch (e) { 61 } catch (e) {
68 console.error('show weak network modal failed:', e) 62 console.error('show weak network modal failed:', e)
69 } 63 }
...@@ -75,12 +69,7 @@ useDidShow(() => { ...@@ -75,12 +69,7 @@ useDidShow(() => {
75 return 69 return
76 } 70 }
77 try { 71 try {
78 - await Taro.showModal({ 72 + await Taro.showModal(get_weak_network_modal_no_cache_options())
79 - title: '网络连接不畅',
80 - content: '当前网络信号较弱,暂无法使用小程序,请到网络更好的地方重试。',
81 - confirmText: '知道了',
82 - showCancel: false,
83 - })
84 } catch (e) { 73 } catch (e) {
85 console.error('show weak network modal failed:', e) 74 console.error('show weak network modal failed:', e)
86 } 75 }
......
1 <!-- 1 <!--
2 * @Date: 2023-06-21 10:23:09 2 * @Date: 2023-06-21 10:23:09
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-13 15:51:31 4 + * @LastEditTime: 2026-01-13 21:23:30
5 * @FilePath: /xyxBooking-weapp/src/pages/index/index.vue 5 * @FilePath: /xyxBooking-weapp/src/pages/index/index.vue
6 * @Description: 预约页首页 6 * @Description: 预约页首页
7 --> 7 -->
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
9 <view class="index-page" :class="{ 'is-offline': is_offline }"> 9 <view class="index-page" :class="{ 'is-offline': is_offline }">
10 <view v-if="is_offline" class="offline-banner mx-6 mt-4 rounded-xl px-4 py-3"> 10 <view v-if="is_offline" class="offline-banner mx-6 mt-4 rounded-xl px-4 py-3">
11 <view class="flex items-center"> 11 <view class="flex items-center">
12 - <IconFont name="tips" size="18" /> 12 + <IconFont name="tips" size="14" />
13 - <text class="ml-2 font-medium">离线模式</text> 13 + <text class="ml-2 font-medium">离线提示</text>
14 </view> 14 </view>
15 - <view class="mt-1 text-sm opacity-80">网络不佳,已启用本地显示</view> 15 + <view class="mt-1 text-sm opacity-80">{{ weak_network_banner_desc }}</view>
16 </view> 16 </view>
17 <view class="index-content"> 17 <view class="index-content">
18 <view style="height: 28vh;"> 18 <view style="height: 28vh;">
...@@ -54,10 +54,10 @@ ...@@ -54,10 +54,10 @@
54 <script setup> 54 <script setup>
55 import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro' 55 import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro'
56 import { IconFont } from '@nutui/icons-vue-taro' 56 import { IconFont } from '@nutui/icons-vue-taro'
57 -// import { showSuccessToast, showFailToast } from 'vant'; // NutUI 或 Taro API
58 import { ref } from 'vue' 57 import { ref } from 'vue'
59 import { useGo } from '@/hooks/useGo' 58 import { useGo } from '@/hooks/useGo'
60 import { get_network_type, is_usable_network } from '@/utils/network' 59 import { get_network_type, is_usable_network } from '@/utils/network'
60 +import { weak_network_text } from '@/utils/uiText'
61 import icon_1 from '@/assets/images/立即预约@2x.png' 61 import icon_1 from '@/assets/images/立即预约@2x.png'
62 import icon_3 from '@/assets/images/首页02@2x.png' 62 import icon_3 from '@/assets/images/首页02@2x.png'
63 import icon_4 from '@/assets/images/二维码icon.png' 63 import icon_4 from '@/assets/images/二维码icon.png'
...@@ -65,6 +65,7 @@ import icon_5 from '@/assets/images/我的01@2x.png' ...@@ -65,6 +65,7 @@ import icon_5 from '@/assets/images/我的01@2x.png'
65 65
66 const go = useGo(); 66 const go = useGo();
67 const is_offline = ref(false) 67 const is_offline = ref(false)
68 +const weak_network_banner_desc = weak_network_text.banner_desc
68 69
69 const refresh_offline_state = async () => { 70 const refresh_offline_state = async () => {
70 const network_type = await get_network_type() 71 const network_type = await get_network_type()
...@@ -79,7 +80,7 @@ const toBooking = () => { // 跳转到预约须知 ...@@ -79,7 +80,7 @@ const toBooking = () => { // 跳转到预约须知
79 // 如果是离线模式,不跳转 80 // 如果是离线模式,不跳转
80 if (is_offline.value) { 81 if (is_offline.value) {
81 Taro.showToast({ 82 Taro.showToast({
82 - title: '当前为离线模式,无法预约', 83 + title: weak_network_text.offline_mode_no_booking_toast,
83 icon: 'none' 84 icon: 'none'
84 }) 85 })
85 return 86 return
......
...@@ -41,6 +41,7 @@ import { is_usable_network, get_network_type } from '@/utils/network' ...@@ -41,6 +41,7 @@ import { is_usable_network, get_network_type } from '@/utils/network'
41 import icon_booking from '@/assets/images/预约记录@2x.png' 41 import icon_booking from '@/assets/images/预约记录@2x.png'
42 import icon_visitor from '@/assets/images/我的01@2x.png' 42 import icon_visitor from '@/assets/images/我的01@2x.png'
43 import icon_invite from '@/assets/images/二维码@2x2.png' 43 import icon_invite from '@/assets/images/二维码@2x2.png'
44 +import { weak_network_text, get_weak_network_modal_go_offline_records_options } from '@/utils/uiText'
44 45
45 const go = useGo(); 46 const go = useGo();
46 47
...@@ -52,18 +53,13 @@ const on_menu_tap = async (item) => { ...@@ -52,18 +53,13 @@ const on_menu_tap = async (item) => {
52 const is_weak_network = !is_usable_network(network_type) 53 const is_weak_network = !is_usable_network(network_type)
53 if (is_weak_network) { 54 if (is_weak_network) {
54 if (has_offline_booking_cache()) { 55 if (has_offline_booking_cache()) {
55 - const modal_res = await Taro.showModal({ 56 + const modal_res = await Taro.showModal(get_weak_network_modal_go_offline_records_options())
56 - title: '网络连接不畅',
57 - content: '当前网络信号较弱,是否进入离线预约记录?',
58 - confirmText: '离线记录',
59 - cancelText: '知道了',
60 - })
61 if (modal_res?.confirm) { 57 if (modal_res?.confirm) {
62 go('/pages/offlineBookingList/index') 58 go('/pages/offlineBookingList/index')
63 } 59 }
64 return 60 return
65 } 61 }
66 - Taro.showToast({ title: '网络连接不畅', icon: 'none', duration: 2000 }) 62 + Taro.showToast({ title: weak_network_text.toast_title, icon: 'none', duration: 2000 })
67 return 63 return
68 } 64 }
69 } 65 }
......
1 <!-- 1 <!--
2 * @Date: 2026-01-08 13:02:27 2 * @Date: 2026-01-08 13:02:27
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-08 13:02:39 4 + * @LastEditTime: 2026-01-13 21:25:38
5 * @FilePath: /xyxBooking-weapp/src/pages/weakNetwork/index.vue 5 * @FilePath: /xyxBooking-weapp/src/pages/weakNetwork/index.vue
6 * @Description: 弱网络提示页面 6 * @Description: 弱网络提示页面
7 --> 7 -->
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
11 <view class="icon-wrapper"> 11 <view class="icon-wrapper">
12 <IconFont name="mask-close" size="60" color="#A67939" /> 12 <IconFont name="mask-close" size="60" color="#A67939" />
13 </view> 13 </view>
14 - <view class="title">网络连接不畅</view> 14 + <view class="title">{{ weak_network_title }}</view>
15 - <view class="desc">当前网络信号较弱,已自动为您切换至离线模式</view> 15 + <view class="desc">{{ weak_network_desc }}</view>
16 16
17 <view class="offline-entry" @tap="toOfflineCode"> 17 <view class="offline-entry" @tap="toOfflineCode">
18 <view class="circle-btn"> 18 <view class="circle-btn">
...@@ -34,20 +34,18 @@ import { IconFont } from '@nutui/icons-vue-taro' ...@@ -34,20 +34,18 @@ import { IconFont } from '@nutui/icons-vue-taro'
34 import { useGo } from '@/hooks/useGo' 34 import { useGo } from '@/hooks/useGo'
35 import { onMounted } from 'vue' 35 import { onMounted } from 'vue'
36 import { has_offline_booking_cache } from '@/composables/useOfflineBookingCache' 36 import { has_offline_booking_cache } from '@/composables/useOfflineBookingCache'
37 +import { weak_network_text, get_weak_network_modal_no_cache_options } from '@/utils/uiText'
37 38
38 import icon_invite from '@/assets/images/二维码@2x2.png' 39 import icon_invite from '@/assets/images/二维码@2x2.png'
39 40
40 const go = useGo(); 41 const go = useGo();
42 +const weak_network_title = weak_network_text.title
43 +const weak_network_desc = weak_network_text.offline_page_desc
41 44
42 onMounted(async () => { 45 onMounted(async () => {
43 if (has_offline_booking_cache()) return 46 if (has_offline_booking_cache()) return
44 try { 47 try {
45 - await Taro.showModal({ 48 + await Taro.showModal(get_weak_network_modal_no_cache_options())
46 - title: '网络连接不畅',
47 - content: '当前网络信号较弱,暂无法使用小程序,请到网络更好的地方重试。',
48 - confirmText: '知道了',
49 - showCancel: false,
50 - })
51 } catch (e) { 49 } catch (e) {
52 console.error('show weak network modal failed:', e) 50 console.error('show weak network modal failed:', e)
53 } 51 }
......
1 /* 1 /*
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-13 16:15:35 4 + * @LastEditTime: 2026-01-13 21:29:43
5 * @FilePath: /xyxBooking-weapp/src/utils/request.js 5 * @FilePath: /xyxBooking-weapp/src/utils/request.js
6 * @Description: 简单axios封装,后续按实际处理 6 * @Description: 简单axios封装,后续按实际处理
7 */ 7 */
...@@ -12,6 +12,7 @@ import Taro from '@tarojs/taro' ...@@ -12,6 +12,7 @@ import Taro from '@tarojs/taro'
12 // import { strExist } from './tools' 12 // import { strExist } from './tools'
13 import { refreshSession, saveCurrentPagePath, navigateToAuth } from './authRedirect' 13 import { refreshSession, saveCurrentPagePath, navigateToAuth } from './authRedirect'
14 import { has_offline_booking_cache } from '@/composables/useOfflineBookingCache' 14 import { has_offline_booking_cache } from '@/composables/useOfflineBookingCache'
15 +import { get_weak_network_modal_no_cache_options } from '@/utils/uiText'
15 16
16 // import { ProgressStart, ProgressEnd } from '@/components/axios-progress/progress'; 17 // import { ProgressStart, ProgressEnd } from '@/components/axios-progress/progress';
17 // import store from '@/store' 18 // import store from '@/store'
...@@ -125,12 +126,7 @@ const handle_request_timeout = async () => { ...@@ -125,12 +126,7 @@ const handle_request_timeout = async () => {
125 126
126 // 否则提示用户检查网络连接 127 // 否则提示用户检查网络连接
127 try { 128 try {
128 - await Taro.showModal({ 129 + await Taro.showModal(get_weak_network_modal_no_cache_options())
129 - title: '网络连接不畅',
130 - content: '当前网络信号较弱,暂无法使用小程序,请到网络更好的地方重试。',
131 - confirmText: '知道了',
132 - showCancel: false,
133 - })
134 } catch (e) { 130 } catch (e) {
135 console.error('show weak network modal failed:', e) 131 console.error('show weak network modal failed:', e)
136 } 132 }
......
1 +/*
2 + * @Date: 2026-01-13 21:28:45
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2026-01-13 21:31:17
5 + * @FilePath: /xyxBooking-weapp/src/utils/uiText.js
6 + * @Description: 弱网络提示文本
7 + */
8 +export const weak_network_text = {
9 + title: '网络连接不畅',
10 + toast_title: '网络连接不畅',
11 + banner_desc: '网络开小差啦!请检查网络设置,或更换位置后重新尝试~',
12 + offline_page_desc: '当前网络信号较弱,已自动为您切换至离线模式',
13 + modal_no_cache_content: '当前网络信号较弱,暂无法使用小程序,请检查网络设置,或更换位置后重新尝试~',
14 + modal_use_cache_content: '当前网络信号较弱,可使用已缓存的预约记录进入离线模式',
15 + modal_go_offline_records_content: '当前网络信号较弱,是否进入离线预约记录?',
16 + offline_mode_no_booking_toast: '当前为离线模式,无法预约',
17 + confirm_ok: '知道了',
18 + confirm_booking_records: '预约记录',
19 + confirm_offline_records: '离线记录',
20 +}
21 +
22 +/**
23 + * @description: 获取弱网络提示弹窗配置(无缓存)
24 + * @returns {Object}
25 + */
26 +export const get_weak_network_modal_no_cache_options = () => {
27 + return {
28 + title: weak_network_text.title,
29 + content: weak_network_text.modal_no_cache_content,
30 + confirmText: weak_network_text.confirm_ok,
31 + showCancel: false,
32 + }
33 +}
34 +
35 +/**
36 + * @description: 获取弱网络提示弹窗配置(有缓存)
37 + * @returns {Object}
38 + */
39 +export const get_weak_network_modal_use_cache_options = () => {
40 + return {
41 + title: weak_network_text.title,
42 + content: weak_network_text.modal_use_cache_content,
43 + confirmText: weak_network_text.confirm_booking_records,
44 + cancelText: weak_network_text.confirm_ok,
45 + }
46 +}
47 +
48 +/**
49 + * @description: 获取弱网络提示弹窗配置(进入离线预约记录)
50 + * @returns {Object}
51 + */
52 +export const get_weak_network_modal_go_offline_records_options = () => {
53 + return {
54 + title: weak_network_text.title,
55 + content: weak_network_text.modal_go_offline_records_content,
56 + confirmText: weak_network_text.confirm_offline_records,
57 + cancelText: weak_network_text.confirm_ok,
58 + }
59 +}