From 9ca377907b9353ec095f7db7a0a5b93e80550f6a Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Wed, 1 Apr 2026 14:12:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=89=E7=A0=81=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 7 +- config/http.js | 50 +- main.js | 32 +- manifest.json | 7 +- pages.json | 6 + pages/device/detail.vue | 15 +- pages/index/index.vue | 86 +-- subPackages/user/login/index.vue | 4 +- subPackages/user/my/index.vue | 26 +- subPackages/user/user/index.vue | 436 +++++++-------- subPackages/user/userProfile/index.vue | 716 +++++++++++++------------ toProgram.vue | 32 ++ 12 files changed, 741 insertions(+), 676 deletions(-) create mode 100644 toProgram.vue diff --git a/App.vue b/App.vue index 9ee83ae..d89da34 100644 --- a/App.vue +++ b/App.vue @@ -11,10 +11,7 @@ // 注意:语言初始化已移至 main.js,确保每次 reLaunch 都能正确加载新语言 }, onShow: async function() { - console.log('========================================') - console.log('=== App onShow 被调用 ===') - console.log('时间戳:', new Date().toLocaleTimeString()) - + // 检查启动路径,如果设置了启动路径则跳转 try { const launchPath = uni.getStorageSync('launchPath') @@ -81,8 +78,6 @@ } catch (e) { console.error('App onShow - 语言检查失败:', e) } - - console.log('========================================') }, onHide: function() { console.log('App Hide') diff --git a/config/http.js b/config/http.js index 851d261..5148627 100644 --- a/config/http.js +++ b/config/http.js @@ -30,14 +30,16 @@ const request = (option) => { mask: true }) } - + uni.request({ url: URL + option.url, method: option.method, data: option.data, header: { - "Content-Type": option.headers && option.headers["Content-Type"] ? option.headers["Content-Type"] : (option.method && option.method.toUpperCase() === 'POST' ? 'application/json' : 'application/x-www-form-urlencoded'), - ...option.headers, + "Content-Type": option.headers && option.headers["Content-Type"] ? option.headers[ + "Content-Type"] : (option.method && option.method.toUpperCase() === 'POST' ? + 'application/json' : 'application/x-www-form-urlencoded'), + ...option.headers, 'appid': platformAppid, 'Authorization': "Bearer " + uni.getStorageSync('token'), 'Clientid': uni.getStorageSync('client_id'), @@ -45,21 +47,23 @@ const request = (option) => { }, success(res) { - + // 检查响应状态码 if (res.statusCode !== 200) { console.error(`HTTP状态码错误: ${res.statusCode}`, res.data) - + // 为了适应某些服务器的异常响应,我们仍然返回数据 if (res.data) { resolve(res.data) return } - - reject({msg: `请求失败,状态码:${res.statusCode}`}) + + reject({ + msg: `请求失败,状态码:${res.statusCode}` + }) return } - + // 未登录或 token 失效处理(支持多种后端返回) if (res.statusCode === 401 || res.data?.code === 401 || res.data?.code === 40101) { try { @@ -68,22 +72,32 @@ const request = (option) => { // 计算重定向地址 const pages = getCurrentPages() const current = pages && pages.length ? pages[pages.length - 1] : null - const route = current && current.route ? ('/' + current.route) : '/pages/index/index' - const query = current && current.options ? Object.keys(current.options).map(k => `${k}=${encodeURIComponent(current.options[k])}`).join('&') : '' + const route = current && current.route ? ('/' + current.route) : + '/pages/index/index' + const query = current && current.options ? Object.keys(current.options).map( + k => `${k}=${encodeURIComponent(current.options[k])}`).join('&') : + '' const redirect = encodeURIComponent(query ? `${route}?${query}` : route) + // console.log(redirect, "==========="); // 跳转到登录页 - uni.reLaunch({ url: `/subPackages/user/login/index?redirect=${redirect}` }) - } catch (e) {} + uni.reLaunch({ + url: "/subPackages/user/login/index" + }) + } catch (e) { + uni.reLaunch({ + url: "/subPackages/user/login/index" + }) + } } // 检查业务状态码 if (res.data && res.data.code !== 200) { console.warn(`业务状态码错误: ${res.data.code}`, res.data) - + // 判断是否需要忽略数据为空的错误 - if (option.ignoreEmptyError && - (res.data.code === 500 && res.data.msg && - (res.data.msg.includes('未找到') || res.data.msg.includes('不存在')))) { + if (option.ignoreEmptyError && + (res.data.code === 500 && res.data.msg && + (res.data.msg.includes('未找到') || res.data.msg.includes('不存在')))) { // 对于指定需要忽略的错误,返回一个标准的"成功但数据为空"的响应 resolve({ code: 200, @@ -92,12 +106,12 @@ const request = (option) => { }) return } - + // 仍然返回数据,由业务逻辑处理 resolve(res.data) return } - + resolve(res.data) }, fail(err) { diff --git a/main.js b/main.js index 24c2432..be2748e 100644 --- a/main.js +++ b/main.js @@ -71,11 +71,7 @@ function getI18nInstance() { // 每次都重新读取当前语言 const currentLang = getSavedLanguage() - console.log('=== getI18nInstance 被调用 ===') - console.log('缓存中的语言:', currentLang) - console.log('当前 i18n 实例存在?', !!i18nInstance) - console.log('当前 i18n.global.locale:', i18nInstance?.global?.locale) - + // 检查是否需要更新语言 if (i18nInstance && i18nInstance.global.locale !== currentLang) { console.log('=== 检测到语言变化,强制更新 ===') @@ -84,19 +80,12 @@ function getI18nInstance() { // 直接更新 locale(这应该会触发所有组件重新渲染) i18nInstance.global.locale = currentLang - - console.log('i18n.global.locale 已更新为:', i18nInstance.global.locale) - console.log('测试翻译 (common.loading):', i18nInstance.global.t('common.loading')) - console.log('测试翻译 (home.title):', i18nInstance.global.t('home.title')) - console.log('===================================') - + return i18nInstance } // 首次创建实例 if (!i18nInstance) { - console.log('=== 首次创建 i18n 实例 ===') - i18nInstance = createI18n({ legacy: true, // 使用 Legacy API 模式,支持全局 $t locale: currentLang, @@ -110,21 +99,13 @@ function getI18nInstance() { silentFallbackWarn: true }) - console.log('i18n 实例已创建,语言:', currentLang) - console.log('测试翻译 (common.loading):', i18nInstance.global.t('common.loading')) - console.log('测试翻译 (home.title):', i18nInstance.global.t('home.title')) - console.log('============================') } return i18nInstance } export function createApp() { - console.log('========================================') - console.log('=== createApp 被调用 ===') - console.log('时间戳:', new Date().toLocaleTimeString()) - console.log('========================================') - + const app = createSSRApp(App) // 使用 uView @@ -153,13 +134,6 @@ export function createApp() { } } - console.log('=== Vue 3 应用创建完成 ===') - console.log('最终 locale:', i18n.global.locale) - console.log('app.config.globalProperties.$t 存在?', !!app.config.globalProperties.$t) - console.log('app.config.globalProperties.$i18n 存在?', !!app.config.globalProperties.$i18n) - console.log('测试 $t 调用:', i18n.global.t('common.loading')) - console.log('===========================') - return { app } diff --git a/manifest.json b/manifest.json index 41c0899..8f6086c 100644 --- a/manifest.json +++ b/manifest.json @@ -93,9 +93,10 @@ } }, "router" : { - "mode" : "hash", - "base" : "./" - } + "mode" : "history", + "base" : "/" + }, + "title" : "FDZPower" }, "uniStatistics" : { "enable" : false diff --git a/pages.json b/pages.json index add2dee..b460bcb 100644 --- a/pages.json +++ b/pages.json @@ -61,6 +61,12 @@ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black" } + }, + { + "path": "toProgram", + "style": { + "navigationStyle": "custom" + } } ], "subPackages": [ diff --git a/pages/device/detail.vue b/pages/device/detail.vue index 2705670..b571fc9 100644 --- a/pages/device/detail.vue +++ b/pages/device/detail.vue @@ -181,7 +181,6 @@ // 生命周期 onLoad 钩子 onLoad(async (options) => { - console.log('options', options) // 普通链接二维码进入时,参数通常在 options.q(且为编码后的完整 URL) if (!options.deviceNo && options.q) { @@ -232,11 +231,6 @@ isAlipayMiniProgram.value = false isH5.value = true // #endif - console.log('当前运行环境:', { - isWechatMiniProgram: isWechatMiniProgram.value, - isAlipayMiniProgram: isAlipayMiniProgram.value, - isH5: isH5.value - }) await checkUserPhone() await fetchDeviceInfo() }) @@ -366,7 +360,7 @@ const fetchDeviceInfo = async () => { try { loading.value = true - console.log(deviceId.value); + // console.log(deviceId.value); const res = await getDeviceInfo(deviceId.value) if (res.code == 200) { deviceInfo.value = res.data.device || {} @@ -404,9 +398,10 @@ } } }else{ - uni.reLaunch({ - url:'/pages/index/index' - }) + + // uni.reLaunch({ + // url:'/pages/index/index' + // }) } }catch(error){ console.error('获取设备信息失败:', error) diff --git a/pages/index/index.vue b/pages/index/index.vue index 727abd1..9ef4e73 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -21,18 +21,18 @@ - - @@ -125,13 +125,8 @@ - @@ -314,11 +309,15 @@ const navbarStyle = computed(() => { // #ifdef MP-ALIPAY // 支付宝小程序:不设置 paddingTop - return { paddingTop: '0px' } + return { + paddingTop: '0px' + } // #endif // #ifndef MP-ALIPAY // 非支付宝小程序:设置 statusBarHeight - return { paddingTop: statusBarHeight.value + 'px' } + return { + paddingTop: statusBarHeight.value + 'px' + } // #endif }) @@ -326,21 +325,29 @@ const topInfoSectionStyle = computed(() => { // #ifdef MP-ALIPAY // 支付宝小程序:使用 paddingTop - return { top: ( navBarHeight.value) + 'px' } + return { + top: (navBarHeight.value) + 'px' + } // #endif // #ifndef MP-ALIPAY // 非支付宝小程序:使用 top - return { top: (statusBarHeight.value + navBarHeight.value) + 'px' } + return { + top: (statusBarHeight.value + navBarHeight.value) + 'px' + } // #endif }) // 主内容区域样式:不同端适配不同的 paddingTop const mainContentStyle = computed(() => { // #ifdef MP-ALIPAY - return { paddingTop: (navBarHeight.value + noticeHeight.value) + 'px' } + return { + paddingTop: (navBarHeight.value + noticeHeight.value) + 'px' + } // #endif // #ifndef MP-ALIPAY - return { paddingTop: (statusBarHeight.value + navBarHeight.value + noticeHeight.value) + 'px' } + return { + paddingTop: (statusBarHeight.value + navBarHeight.value + noticeHeight.value) + 'px' + } // #endif }) @@ -372,7 +379,7 @@ `${k}=${encodeURIComponent(current.options[k])}`).join('&') : '' const redirect = encodeURIComponent(query ? `${route}?${query}` : route) uni.reLaunch({ - url: `/subPackages/user/login/index?redirect=${redirect}` + url: redirect }) } catch (e) { uni.reLaunch({ @@ -437,8 +444,8 @@ // 调用接口获取广告内容 const res = await getCurrentAdvertisement({ appPlatform: appPlatform, // 微信平台 - appType: 'user' ,// 用户端 - pictureLocation:'home_banner' + appType: 'user', // 用户端 + pictureLocation: 'home_banner' }) console.log('首页广告响应:', res) @@ -621,7 +628,7 @@ onMounted(() => { initNavBarHeight() init() - + // #ifdef H5 // 监听 H5 扫码结果 uni.$on('h5ScanSuccess', (data) => { @@ -941,7 +948,7 @@ if (!loc || !loc.longitude || !loc.latitude) { throw new Error('location failed') } - + const newLocation = { longitude: Number(loc.longitude), latitude: Number(loc.latitude) @@ -1076,7 +1083,7 @@ } catch (error) { console.error('查询商品列表失败:', error) uni.hideLoading() - + // 即使查询失败,也跳转到商品页面 uni.navigateTo({ url: '/subPackages/business/device-goods' @@ -1141,11 +1148,11 @@ try { const userInfoRes = await getUserInfo() console.log('userInfoRes', userInfoRes.data.phone); - + const phone = userInfoRes.data.phone || '' expectedUserPhone.value = phone console.log('expectedUserPhone', expectedUserPhone.value); - + // 没有手机号:弹窗引导获取/绑定 if (!phone) { @@ -1242,7 +1249,7 @@ console.log('scanType:', scanResult.scanType); console.log('result:', scanResult.result); console.log('path:', scanResult.path); - + let deviceNo = '' if (scanResult.scanType == 'MANUAL') { deviceNo = extractDeviceNoFromText(scanResult.result) @@ -1336,19 +1343,25 @@ uni.navigateBack({ success: () => { setTimeout(() => { - uni.navigateTo({ url }); + uni.navigateTo({ + url + }); }, 100); } }); } else { - uni.navigateTo({ url }); + uni.navigateTo({ + url + }); } }; if (deviceInfo.feeConfig) { try { const feeConfig = JSON.parse(deviceInfo.feeConfig) - closeScanPageAndNavigate(`/pages/device/detail?deviceNo=${deviceNo}&feeConfig=${encodeURIComponent(deviceInfo.feeConfig)}`); + closeScanPageAndNavigate( + `/pages/device/detail?deviceNo=${deviceNo}&feeConfig=${encodeURIComponent(deviceInfo.feeConfig)}` + ); } catch (e) { closeScanPageAndNavigate(`/pages/device/detail?deviceNo=${deviceNo}`); } @@ -1435,7 +1448,9 @@ // #ifdef MP-ALIPAY try { console.log('[ALIPAY] getAuthorize(phoneNumber) event:', e) - uni.showLoading({ title: t('common.processing') }) + uni.showLoading({ + title: t('common.processing') + }) const res = await getAlipayUserPhoneNumber() const aliPhone = res?.data?.phoneNumber || res?.data?.phone || res?.phoneNumber || '' if (!aliPhone) { @@ -1453,7 +1468,10 @@ } // 缓存本次校验结果(避免每次扫码都弹) - uni.setStorageSync('alipay_phone_verified', { phone: aliPhone, ts: Date.now() }) + uni.setStorageSync('alipay_phone_verified', { + phone: aliPhone, + ts: Date.now() + }) showPhoneAuthPopup.value = false if (pendingScan.value) { @@ -1477,7 +1495,7 @@ // 使用指南弹窗控制 const openPopup = () => { uni.navigateTo({ - url:'/subPackages/business/device-goods' + url: '/subPackages/business/device-goods' }) // try { // showGuidePopup.value = true diff --git a/subPackages/user/login/index.vue b/subPackages/user/login/index.vue index 067a30a..857b522 100644 --- a/subPackages/user/login/index.vue +++ b/subPackages/user/login/index.vue @@ -182,7 +182,9 @@ if (opts && opts.redirect) { try { redirect.value = decodeURIComponent(opts.redirect) - } catch (_) {} + } catch (err) { + + } } // #ifdef H5 isHTML5.value = true diff --git a/subPackages/user/my/index.vue b/subPackages/user/my/index.vue index 4c7a930..46bb4a3 100644 --- a/subPackages/user/my/index.vue +++ b/subPackages/user/my/index.vue @@ -2,7 +2,8 @@ - + + @@ -29,7 +30,8 @@ @@ -78,7 +80,8 @@ - + + {{ $t('user.customerService') }} @@ -118,9 +121,11 @@ - {{ $t('user.userAgreement') }} + {{ $t('user.userAgreement') }} - {{ $t('user.privacyPolicy') }} + {{ $t('user.privacyPolicy') }} {{ $t('user.version') }}{{ appVersion }} @@ -199,7 +204,7 @@ const res = await getCurrentAdvertisement({ appPlatform: appPlatform, // 微信平台 appType: 'user', // 用户端 - pictureLocation:'userProfile_banner' + pictureLocation: 'userProfile_banner' }) if (res && res.code === 200 && res.data) { @@ -267,7 +272,7 @@ uni.setNavigationBarTitle({ title: t('user.personalCenter') }) - getInfo(); + // getInfo(); initVersion(); getBannerImages(); // 加载广告 }); @@ -340,11 +345,12 @@ const query = current && current.options ? Object.keys(current.options).map(k => `${k}=${encodeURIComponent(current.options[k])}`).join('&') : '' const redirect = encodeURIComponent(query ? `${route}?${query}` : route) - uni.reLaunch({ - url: `/subPackages/user/login/index?redirect=${redirect}` + console.log(redirect); + uni.redirectTo({ + url: redirect }) } catch (e) { - uni.reLaunch({ + uni.redirectTo({ url: '/subPackages/user/login/index' }) } diff --git a/subPackages/user/user/index.vue b/subPackages/user/user/index.vue index 5629580..9727574 100644 --- a/subPackages/user/user/index.vue +++ b/subPackages/user/user/index.vue @@ -1,240 +1,252 @@ \ No newline at end of file + .logout-btn { + margin-top: 40rpx; + background-color: #fff; + border-radius: 16rpx; + padding: 30rpx; + text-align: center; + color: #ff4d4f; + font-size: 28rpx; + box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05); + } + \ No newline at end of file diff --git a/subPackages/user/userProfile/index.vue b/subPackages/user/userProfile/index.vue index b7c487b..672035c 100644 --- a/subPackages/user/userProfile/index.vue +++ b/subPackages/user/userProfile/index.vue @@ -2,7 +2,8 @@ - + + @@ -12,407 +13,416 @@ - {{ $t('userProfile.clickToChange') }} - - - - - - {{ $t('userProfile.nickname') }} - - {{ userInfo.nickName || $t('userProfile.notSet') }} - - - - - - - - - - - + {{ $t('userProfile.clickToChange') }} - - {{ $t('userProfile.phone') }} - - {{ userInfo.phone ? maskPhone(userInfo.phone) : $t('userProfile.notBound') }} + + + + {{ $t('userProfile.nickname') }} + + {{ userInfo.nickName || $t('userProfile.notSet') }} + + - - + + + + + + + + + + {{ $t('userProfile.phone') }} + + {{ userInfo.phone ? maskPhone(userInfo.phone) : $t('userProfile.notBound') }} + + + + - + + .label { + font-size: 30rpx; + color: #333333; + font-weight: 500; + } + .value { + display: flex; + align-items: center; + } + + .value-text { + font-size: 28rpx; + color: #666666; + margin-right: 10rpx; + } + + .value-text.amount { + color: #e2231a; + font-weight: 600; + font-size: 32rpx; + } + + /* 昵称编辑区域样式 */ + .nickname-edit-area { + padding: 0 30rpx 30rpx 30rpx; + border-bottom: 1rpx solid #f5f5f5; + animation: slideDown 0.3s ease; + } + + @keyframes slideDown { + from { + opacity: 0; + transform: translateY(-20rpx); + } + + to { + opacity: 1; + transform: translateY(0); + } + } + + .nickname-input { + width: 100%; + height: 80rpx; + border: 1rpx solid #e0e0e0; + border-radius: 10rpx; + padding: 0 20rpx; + font-size: 28rpx; + color: #333333; + box-sizing: border-box; + margin-bottom: 20rpx; + background-color: #fafafa; + } + + .edit-buttons { + display: flex; + justify-content: flex-end; + gap: 20rpx; + } + + .cancel-btn, + .save-btn { + padding: 0 40rpx; + height: 64rpx; + line-height: 64rpx; + text-align: center; + border-radius: 32rpx; + font-size: 28rpx; + border: none; + min-width: 120rpx; + } + + .cancel-btn { + background-color: #f5f5f5; + color: #666666; + } + + .save-btn { + background: linear-gradient(135deg, #42d392 0%, #28c76f 100%); + color: #ffffff; + } + \ No newline at end of file diff --git a/toProgram.vue b/toProgram.vue new file mode 100644 index 0000000..7b6b54e --- /dev/null +++ b/toProgram.vue @@ -0,0 +1,32 @@ + + + + + \ No newline at end of file