From 337a92d8c157fd3a3c2253f6f07b872c71136448 Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Thu, 26 Mar 2026 09:47:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E4=B8=8A=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/url.js | 2 +- locale/en-US.js | 5 +- locale/id-ID.js | 5 +- locale/zh-CN.js | 7 +- pages/device/detail.vue | 2 +- pages/index/index.vue | 200 +++++++++++++++++++++++++++++++--- pages/scan/index.vue | 35 +++--- subPackages/user/my/index.vue | 6 +- 8 files changed, 222 insertions(+), 40 deletions(-) diff --git a/config/url.js b/config/url.js index 2b176f2..eb68337 100644 --- a/config/url.js +++ b/config/url.js @@ -1,7 +1,7 @@ // export const URL = "https://my.gxfs123.com/api" //正式服务器-弃用 export const URL = "https://manager.fdzpower.com/api" //正式服务器 // export const URL = "https://fansdev.gxfs123.com/api" //测试服务器 -// export const URL = "http://192.168.5.58:8080" //本地调试 +// export const URL = "http://192.168.5.108:8080" //本地调试 // export const URL = "http://127.0.0.1:8080" //本地调试 export const appid = "wx2165f0be356ae7a9" //微信小程序appid diff --git a/locale/en-US.js b/locale/en-US.js index 2cad02b..fd5adec 100644 --- a/locale/en-US.js +++ b/locale/en-US.js @@ -101,7 +101,9 @@ export default { invalidQRCode: 'Invalid QR code', scanFailed: 'Scan failed', noticeTitle: 'Notice', - getLocationFailed: 'Location unavailable' + getLocationFailed: 'Location unavailable', + locationPermissionOffTip: 'Location permission is not enabled. Nearby devices cannot be found yet. Tap the button below to enable location services.', + enableLocation: 'Enable Location' }, guide: { @@ -147,6 +149,7 @@ export default { autoChargeOvertime: 'Overtime will be charged automatically by hour', useInDesignatedArea: 'Please use the device in designated area', rentDepositFree: 'Rent Deposit-free', + rentNow: 'Rent Now', wxPayScoreDesc: 'WeChat Pay Score | 550+ points enjoy', checking: 'Checking', deviceNoNotRecognized: 'Device number not recognized', diff --git a/locale/id-ID.js b/locale/id-ID.js index d2e7d8f..01be828 100644 --- a/locale/id-ID.js +++ b/locale/id-ID.js @@ -101,7 +101,9 @@ export default { invalidQRCode: 'Kode QR perangkat tidak valid', scanFailed: 'Pemindaian gagal', noticeTitle: 'Pemberitahuan', - getLocationFailed: 'Gagal mendapatkan lokasi, menampilkan peta default' + getLocationFailed: 'Gagal mendapatkan lokasi, menampilkan peta default', + locationPermissionOffTip: 'Izin lokasi belum diaktifkan. Sementara tidak dapat mencari perangkat terdekat. Jika ingin mencari perangkat terdekat, klik tombol di bawah untuk mengaktifkan lokasi.', + enableLocation: 'Aktifkan Lokasi' }, guide: { @@ -148,6 +150,7 @@ export default { autoChargeOvertime: 'Melebihi waktu penggunaan akan dikenakan biaya per jam secara otomatis', useInDesignatedArea: 'Harap gunakan perangkat di area yang ditentukan', rentDepositFree: 'Sewa Tanpa Deposit', + rentNow: 'Sewa Sekarang', wxPayScoreDesc: 'Skor Pembayaran WeChat | Nikmati dengan 550 poin atau lebih', checking: 'Memeriksa', deviceNoNotRecognized: 'Nomor perangkat tidak dikenali', diff --git a/locale/zh-CN.js b/locale/zh-CN.js index c784b45..4752a3b 100644 --- a/locale/zh-CN.js +++ b/locale/zh-CN.js @@ -100,7 +100,9 @@ export default { invalidQRCode: '无效的设备二维码', scanFailed: '扫码失败', noticeTitle: '通知公告', - getLocationFailed: '获取位置失败,显示默认地图' + getLocationFailed: '获取位置失败,显示默认地图', + locationPermissionOffTip: '定位权限未打开,暂无法寻找附近设备。如需寻找附近设备,点击下方按钮开启定位。', + enableLocation: '开启定位' }, guide: { @@ -146,6 +148,7 @@ export default { autoChargeOvertime: '超出使用时间将自动按小时计费', useInDesignatedArea: '请在指定区域内使用设备', rentDepositFree: '免押金租借', + rentNow: '立即租借', wxPayScoreDesc: '微信支付分 | 550分以上优享', checking: '检查中', deviceNoNotRecognized: '未识别到设备编号', @@ -571,7 +574,7 @@ export default { }, join: { - title: '合作加盟', + title: '信息咨询', cooperationTitle: '合作方式', contactUs: '联系我们', phone: '联系电话', diff --git a/pages/device/detail.vue b/pages/device/detail.vue index e40f5e4..2705670 100644 --- a/pages/device/detail.vue +++ b/pages/device/detail.vue @@ -585,7 +585,7 @@ if (isWechatMiniProgram.value) { return t('device.rentDepositFree') } else { - return '立即租借' + return t('device.rentNow') } } diff --git a/pages/index/index.vue b/pages/index/index.vue index ee7e9dd..727abd1 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -17,16 +17,11 @@ - - - - - - + - - + + + + {{ $t('home.locationPermissionOffTip') }} + + {{ $t('home.enableLocation') }} + + + + + + + {{ $t('common.loadingLocation') }} + @@ -282,6 +291,7 @@ const filteredPositions = ref([]) const isExpanded = ref(false) const isLoading = ref(false) + const locationPermissionDenied = ref(false) // MP-ALIPAY:定位权限拒绝后展示引导文案 const showPhoneAuthPopup = ref(false) const pendingScan = ref(false) // 是否是扫码流程触发的手机号校验 const expectedUserPhone = ref('') // 当前登录态下绑定的手机号(用于支付宝一致性校验) @@ -324,6 +334,16 @@ // #endif }) + // 主内容区域样式:不同端适配不同的 paddingTop + const mainContentStyle = computed(() => { + // #ifdef MP-ALIPAY + return { paddingTop: (navBarHeight.value + noticeHeight.value) + 'px' } + // #endif + // #ifndef MP-ALIPAY + return { paddingTop: (statusBarHeight.value + navBarHeight.value + noticeHeight.value) + 'px' } + // #endif + }) + // 使用指南步骤 const guideSteps = ref([{ title: '扫码使用', @@ -619,6 +639,7 @@ // 方法 const init = async () => { + locationPermissionDenied.value = false isLoading.value = true try { // 清理旧版本的缓存键(兼容性处理) @@ -651,6 +672,14 @@ } catch (error) { console.error('初始化失败:', error) + // #ifdef MP-ALIPAY + if (isLocationPermissionDenied(error)) { + locationPermissionDenied.value = true + userLocation.value = null + positionList.value = [] + filteredPositions.value = [] + } + // #endif // uni.showToast({ // title: t('home.getLocationFailed'), // icon: 'none' @@ -660,6 +689,12 @@ } } + const isLocationPermissionDenied = (error) => { + const msg = String(error?.errMsg || error?.message || error || '') + // 覆盖常见文案:permission denied / auth deny / 拒绝 / 未授权 + return /permission\s*denied|auth\s*deny|auth\s*denied|denied|拒绝|未授权|not\s*allowed|not\s*permitted/i.test(msg) + } + const getUserLocationAndAddress = async () => { // 使用腾讯地图SDK获取位置(若失败抛出,由调用方统一处理) const location = await getUserLocation() @@ -719,6 +754,55 @@ return userLocation.value } + const handleEnableLocation = async () => { + isLoading.value = true + try { + // #ifdef MP-ALIPAY + // 支付宝:用权限指引弹窗引导用户开启定位(showAuthGuide 在权限被拒后更可靠) + // 说明:调用后系统会弹出引导/授权界面;用户授权成功后再尝试获取定位。 + try { + if (typeof my !== 'undefined' && my.showAuthGuide) { + await new Promise((resolve) => { + my.showAuthGuide({ + authType: 'LBS', + success: () => resolve(true), + fail: () => resolve(false) + }) + }) + } else if (typeof my !== 'undefined' && my.authorize) { + // 兜底:如果 showAuthGuide 不可用,再尝试 authorize 触发授权 + await new Promise((resolve) => { + my.authorize({ + scope: 'scope.userLocation', + success: () => resolve(true), + fail: () => resolve(false) + }) + }) + } + } catch (_) {} + // #endif + + // 重新触发定位授权/获取流程 + await getUserLocationAndAddress() + await loadPositions() + + // 成功拿到定位后,再隐藏权限提示 + locationPermissionDenied.value = false + } catch (error) { + console.error('开启定位失败:', error) + // #ifdef MP-ALIPAY + if (isLocationPermissionDenied(error)) { + locationPermissionDenied.value = true // 保持在页面上提示,避免出现空白区 + userLocation.value = null + positionList.value = [] + filteredPositions.value = [] + } + // #endif + } finally { + isLoading.value = false + } + } + const loadPositions = async () => { try { if (!userLocation.value || !userLocation.value.latitude || !userLocation.value.longitude) { @@ -1118,6 +1202,39 @@ await doScan() } + // 统一提取 deviceNo,兼容 URL、编码文本、纯设备号 + const extractDeviceNoFromText = (rawText) => { + if (!rawText) return '' + const text = String(rawText).trim() + if (!text) return '' + + const candidates = [text] + try { + const decoded = decodeURIComponent(text) + if (decoded && decoded !== text) { + candidates.push(decoded) + } + } catch (e) {} + + for (const item of candidates) { + const fromQuery = + getQueryString(item, 'deviceNo') || + getQueryString(item, 'deviceno') + if (fromQuery) { + return String(fromQuery).trim() + } + } + + // 二维码内容本身就是设备号时,直接使用原文 + for (const item of candidates) { + if (!item.includes('=') && !item.includes('&') && !item.includes('?')) { + return item + } + } + + return '' + } + const processScanResult = async (scanResult) => { try { console.log('===== 处理扫码结果 ====='); @@ -1126,17 +1243,20 @@ console.log('result:', scanResult.result); console.log('path:', scanResult.path); - let deviceNo; + let deviceNo = '' if (scanResult.scanType == 'MANUAL') { - deviceNo = scanResult.result; - console.log('手动输入模式,设备号:', deviceNo); + deviceNo = extractDeviceNoFromText(scanResult.result) + console.log('手动输入模式,设备号:', deviceNo) } else if (scanResult.scanType == 'QR_CODE') { - // 修复:移除多余的引号 - deviceNo = getQueryString(scanResult.result, 'deviceNo'); - console.log('二维码扫描模式,提取设备号:', deviceNo); + deviceNo = + extractDeviceNoFromText(scanResult.result) || + extractDeviceNoFromText(scanResult.path) + console.log('二维码扫描模式,提取设备号:', deviceNo) } else { - deviceNo = getQueryString(scanResult.path || scanResult.result, 'deviceNo'); - console.log('其他模式,提取设备号:', deviceNo); + deviceNo = + extractDeviceNoFromText(scanResult.path) || + extractDeviceNoFromText(scanResult.result) + console.log('其他模式,提取设备号:', deviceNo) } console.log('最终设备号:', deviceNo); @@ -1986,6 +2106,54 @@ } } + /* 支付宝:定位权限拒绝后的引导文案 */ + .location-denied-placeholder { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 180rpx; + background: #f6f7fb; + display: flex; + align-items: center; + justify-content: center; + z-index: 1; + padding: 0 40rpx; + box-sizing: border-box; + } + + .denied-content { + width: 100%; + background: #ffffff; + border-radius: 16rpx; + padding: 40rpx; + box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06); + } + + .denied-text { + display: block; + font-size: 28rpx; + color: #333; + line-height: 1.6; + } + + .denied-enable-btn { + margin-top: 28rpx; + width: 100%; + height: 88rpx; + background: #3EAB64; + border-radius: 44rpx; + display: flex; + align-items: center; + justify-content: center; + } + + .denied-enable-btn-text { + font-size: 32rpx; + font-weight: 700; + color: #ffffff; + } + /* 手机号授权弹窗 */ .phone-auth-popup { position: fixed; diff --git a/pages/scan/index.vue b/pages/scan/index.vue index 76d2010..649e3dc 100644 --- a/pages/scan/index.vue +++ b/pages/scan/index.vue @@ -63,7 +63,7 @@