From a79cf10bd4c8456aedaf958fae3142baac052114 Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Mon, 16 Mar 2026 11:52:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A4=9A=E5=B9=B3=E5=8F=B0=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/MapComponentAlipay.vue | 2 +- config/api/device.js | 5 +- config/api/user.js | 10 +- config/url.js | 4 +- locale/en-US.js | 4 +- locale/id-ID.js | 4 +- locale/zh-CN.js | 6 +- pages.json | 8 ++ pages/device/detail.vue | 2 +- pages/index/index.vue | 9 +- pages/order/detail.vue | 186 ++--------------------------- pages/scan/index.vue | 19 +-- subPackages/order/payment.vue | 192 ++++++++++++++++++------------ subPackages/order/return-map.vue | 141 ++++++++++++++++++++++ subPackages/user/login/index.vue | 30 ++--- subPackages/user/login/phone.vue | 14 ++- subPackages/user/my/index.vue | 9 +- util/index.js | 8 +- 18 files changed, 358 insertions(+), 295 deletions(-) create mode 100644 subPackages/order/return-map.vue diff --git a/components/MapComponentAlipay.vue b/components/MapComponentAlipay.vue index 4b40eec..2510007 100644 --- a/components/MapComponentAlipay.vue +++ b/components/MapComponentAlipay.vue @@ -197,7 +197,7 @@ return props.bannerImages[currentBannerIndex.value] } // 降级:如果没有广告,显示默认图片 - return '/static/index_swiper.png' + return '' }) // 验证坐标有效性 diff --git a/config/api/device.js b/config/api/device.js index daa379e..470266b 100644 --- a/config/api/device.js +++ b/config/api/device.js @@ -50,13 +50,14 @@ export const transformDeviceData = (device) => { } // 立即租借 -export const rentPowerBank = (deviceNo, phone) => { +export const rentPowerBank = (deviceNo, phone,payway) => { return request({ url: `/app/device/rentPowerBank?deviceNo=${deviceNo}`, method: 'post', data: { // deviceNo, - phone + phone, + payway } }) } diff --git a/config/api/user.js b/config/api/user.js index 8ea14db..42de517 100644 --- a/config/api/user.js +++ b/config/api/user.js @@ -37,10 +37,12 @@ export const sendVerifyCode = (phonenumber) => { // 手机号+验证码登录 export const loginWithCode = (phonenumber, smsCode) => { - return request({ - url: '/app/user/sms/login', - method: 'post', - data: { phonenumber, smsCode } + // 兼容保留:统一走 quickLogin(SMS) + return quickLogin({ + loginType: 'SMS', + appid, + phonenumber, + smsCode }) } diff --git a/config/url.js b/config/url.js index beae7bc..6526cb1 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.64:8080" //本地调试 +// export const URL = "https://fansdev.gxfs123.com/api" //测试服务器 +export const URL = "http://192.168.5.58: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 f21bfac..2cad02b 100644 --- a/locale/en-US.js +++ b/locale/en-US.js @@ -60,7 +60,9 @@ export default { saveSuccess: 'Saved successfully', saving: 'Saving...', saveFailed: 'Save failed', - downloadFailed: 'Download failed' + downloadFailed: 'Download failed', + reset: 'Reset', + preview: 'Preview' }, nav: { diff --git a/locale/id-ID.js b/locale/id-ID.js index 03fa34a..d2e7d8f 100644 --- a/locale/id-ID.js +++ b/locale/id-ID.js @@ -60,7 +60,9 @@ export default { saveSuccess: 'Berhasil disimpan', saving: 'Menyimpan...', saveFailed: 'Gagal menyimpan', - downloadFailed: 'Gagal mengunduh' + downloadFailed: 'Gagal mengunduh', + reset: 'Atur ulang', + preview: 'Pratinjau' }, nav: { diff --git a/locale/zh-CN.js b/locale/zh-CN.js index c7ba755..c784b45 100644 --- a/locale/zh-CN.js +++ b/locale/zh-CN.js @@ -59,7 +59,9 @@ export default { saveImage: '保存到手机', saveSuccess: '保存成功', saving: '保存中...', - saveFailed: '保存失败' + saveFailed: '保存失败', + reset: '重置', + preview: '预览' }, nav: { @@ -305,7 +307,7 @@ export default { customerService: '客服中心', feedback: '投诉与建议', businessLicense: '营业资质', - cooperation: '合作加盟', + cooperation: '信息咨询', settings: '设置', userAgreement: '《用户协议》', settinguserAgreement: '用户协议', diff --git a/pages.json b/pages.json index f67fee8..add2dee 100644 --- a/pages.json +++ b/pages.json @@ -149,6 +149,14 @@ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black" } + }, + { + "path": "return-map", + "style": { + "navigationBarTitleText": "", + "navigationBarBackgroundColor": "#000000", + "navigationBarTextStyle": "white" + } } ] }, diff --git a/pages/device/detail.vue b/pages/device/detail.vue index e77bfa2..2186ce3 100644 --- a/pages/device/detail.vue +++ b/pages/device/detail.vue @@ -604,7 +604,7 @@ console.log(deviceId.value); // 调用设备租借接口 - const rentResult = await rentPowerBank(deviceId.value, phoneNumber.value) + const rentResult = await rentPowerBank(deviceId.value, phoneNumber.value,payWay.value) if (rentResult.code !== 200) { throw new Error(rentResult.msg || t('device.rentFailed')) } diff --git a/pages/index/index.vue b/pages/index/index.vue index afa181d..ee7e9dd 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -406,10 +406,17 @@ const getBannerImages = async () => { try { console.log('加载首页广告') + let appPlatform; + // #ifdef MP-WEIXIN + appPlatform = 'wechat' + // #endif + // #ifdef MP-ALIPAY + appPlatform = 'ali' + // #endif // 调用接口获取广告内容 const res = await getCurrentAdvertisement({ - appPlatform: 'wechat', // 微信平台 + appPlatform: appPlatform, // 微信平台 appType: 'user' ,// 用户端 pictureLocation:'home_banner' }) diff --git a/pages/order/detail.vue b/pages/order/detail.vue index 4634392..df8275c 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -211,26 +211,6 @@ - - - - - - {{ $t('order.returnLocationMap') }} - - × - - - - - - - - {{ $t('common.saveImage') }} - - - - @@ -327,8 +307,6 @@ const countdownTimer = ref(null) const feeRuleText = ref('') const convertToOwnPopup = ref(null) - const showReturnMapPopup = ref(false) - const returnMapImageUrl = ref('') const lastDeviceEjectTime = ref(0) // 上次点击"宝未弹出"的时间戳 // 计算属性:是否显示优惠券/会员卡可用提示 @@ -444,72 +422,22 @@ // 快速归还 const quickReturn = () => { // 检查是否有 returnMapImage 字段 - console.log(orderInfo.value.returnMapImage); - + console.log(orderInfo.value.returnMapImage) + if (orderInfo.value.returnMapImage) { - // 有值则弹窗显示图片 - returnMapImageUrl.value = orderInfo.value.returnMapImage - showReturnMapPopup.value = true + // 有值则跳转到新的地图页查看大图(支持放大) + const encodedUrl = encodeURIComponent(orderInfo.value.returnMapImage) + uni.navigateTo({ + url: `/subPackages/order/return-map?imageUrl=${encodedUrl}` + }) } else { - // 没有值则继续执行跳转流程 + // 没有值则继续执行原有跳转流程 uni.navigateTo({ url: '/pages/search/index' }) } } - // 关闭归还地图弹窗 - const closeReturnMapPopup = () => { - showReturnMapPopup.value = false - } - - // 保存归还地图图片 - const saveReturnMapImage = () => { - uni.showLoading({ - title: t('common.saving') - }) - - uni.downloadFile({ - url: returnMapImageUrl.value, - success: (res) => { - if (res.statusCode === 200) { - uni.saveImageToPhotosAlbum({ - filePath: res.tempFilePath, - success: () => { - uni.hideLoading() - uni.showToast({ - title: t('common.saveSuccess'), - icon: 'success' - }) - }, - fail: (err) => { - uni.hideLoading() - console.error('保存图片失败:', err) - uni.showToast({ - title: t('common.saveFailed'), - icon: 'none' - }) - } - }) - } else { - uni.hideLoading() - uni.showToast({ - title: t('common.downloadFailed'), - icon: 'none' - }) - } - }, - fail: (err) => { - uni.hideLoading() - console.error('下载图片失败:', err) - uni.showToast({ - title: t('common.downloadFailed'), - icon: 'none' - }) - } - }) - } - // 再次租借 const rentAgain = () => { uni.reLaunch({ @@ -1830,102 +1758,4 @@ } } - /* 归还地图弹窗样式 */ - .return-map-popup { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 9999; - display: flex; - align-items: center; - justify-content: center; - - .popup-mask { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: rgba(0, 0, 0, 0.6); - } - - .popup-content { - position: relative; - width: 90%; - max-width: 600rpx; - background: #ffffff; - border-radius: 24rpx; - overflow: hidden; - z-index: 10000; - - .popup-header { - display: flex; - align-items: center; - justify-content: space-between; - padding: 30rpx; - border-bottom: 1rpx solid #f0f0f0; - - .popup-title { - font-size: 32rpx; - font-weight: bold; - color: #333; - } - - .close-btn { - width: 48rpx; - height: 48rpx; - display: flex; - align-items: center; - justify-content: center; - border-radius: 50%; - background: #f5f5f5; - - .close-icon { - font-size: 40rpx; - color: #666; - line-height: 1; - } - - &:active { - opacity: 0.7; - } - } - } - - .popup-body { - padding: 30rpx; - max-height: 60vh; - overflow-y: auto; - - .map-image { - width: 100%; - display: block; - border-radius: 12rpx; - } - } - - .popup-footer { - padding: 20rpx 30rpx 30rpx; - - .save-btn { - width: 100%; - height: 88rpx; - background: linear-gradient(135deg, #07c160, #10d673); - border-radius: 44rpx; - display: flex; - align-items: center; - justify-content: center; - font-size: 32rpx; - font-weight: 600; - color: #fff; - - &:active { - opacity: 0.8; - } - } - } - } - } \ No newline at end of file diff --git a/pages/scan/index.vue b/pages/scan/index.vue index ae8065e..76d2010 100644 --- a/pages/scan/index.vue +++ b/pages/scan/index.vue @@ -327,19 +327,24 @@ const handleInitError = (err) => { if (err.name === 'NotAllowedError' || err.name === 'PermissionDeniedError') { errMsg = '摄像头权限被拒绝'; errDetail = '请在浏览器设置中允许访问摄像头'; - } else if (err.name === 'NotFoundError' || err.name === 'DevicesNotFoundError') { + } + else if (err.name === 'NotFoundError' || err.name === 'DevicesNotFoundError') { errMsg = '未找到可用的摄像头'; errDetail = '请确保设备有摄像头'; - } else if (err.name === 'NotReadableError' || err.name === 'TrackStartError') { + } + else if (err.name === 'NotReadableError' || err.name === 'TrackStartError') { errMsg = '摄像头被占用'; errDetail = '请关闭其他使用摄像头的应用'; - } else if (err.name === 'NotSupportedError') { + } + else if (err.name === 'NotSupportedError') { errMsg = '浏览器不支持'; errDetail = '请使用现代浏览器访问'; - } else if (location.protocol !== 'https:' && location.hostname !== 'localhost' && location.hostname !== '127.0.0.1') { - errMsg = '需要 HTTPS 环境'; - errDetail = '摄像头功能需要在安全环境下使用'; - } else { + } + // else if (location.protocol !== 'https:' && location.hostname !== 'localhost' && location.hostname !== '127.0.0.1') { + // errMsg = '需要 HTTPS 环境'; + // errDetail = '摄像头功能需要在安全环境下使用'; + // } + else { errMsg = err.message || '摄像头启动失败'; errDetail = '请尝试刷新页面或使用其他方式'; } diff --git a/subPackages/order/payment.vue b/subPackages/order/payment.vue index f3bf1e2..90a8721 100644 --- a/subPackages/order/payment.vue +++ b/subPackages/order/payment.vue @@ -4,7 +4,7 @@ - + {{ locationName }} {{ $t('device.available') }} @@ -55,6 +55,24 @@ + + + + + {{ $t('payment.paymentMethod') }} + + + + {{ item.paymentMethodName }} + + + + + + + + @@ -99,7 +117,7 @@ const { t } = useI18n() - + const orderId = ref(null) const deviceNo = ref(null) const orderInfo = ref({}) @@ -107,10 +125,6 @@ const passedTotalAmount = ref(null) const passedDepositAmount = ref(null) - // 倒计时相关 - const countdown = ref(15 * 60) // 15分钟 = 900秒 - let countdownTimer = null - // 支付方式相关(微信/支付宝/H5-Antom 多平台) const paymentMethods = ref([]) const selectedPaymentMethod = ref('WECHAT') // 默认微信 @@ -195,14 +209,14 @@ deviceNo: orderData.deviceNo, createTime: formattedTime, deposit: passedDepositAmount.value || orderData.depositAmount || '99.00', - orderStatus:orderData.orderStatus + orderStatus: orderData.orderStatus } deviceNo.value = orderData.deviceNo; await loadDeviceInfo(); await loadPaymentMethods(); // 如果订单状态是等待支付,启动相应的支付状态轮询 - if(orderInfo.value.orderStatus=='waiting_for_payment'){ + if (orderInfo.value.orderStatus == 'waiting_for_payment') { // 使用当前选中的支付方式类型进行轮询 startPaymentStatusPolling(); } @@ -263,10 +277,16 @@ // 小程序环境下:微信 / 支付宝 // #ifdef MP-WEIXIN - methods.push({ paymentMethodType: 'WECHAT', paymentMethodName: '微信支付' }) + methods.push({ + paymentMethodType: 'WECHAT', + paymentMethodName: '微信支付' + }) // #endif // #ifdef MP-ALIPAY - methods.push({ paymentMethodType: 'ALIPAY', paymentMethodName: '支付宝支付' }) + methods.push({ + paymentMethodType: 'ALIPAY', + paymentMethodName: '支付宝支付' + }) // #endif // H5 环境:使用 Antom 聚合支付(多通道) @@ -291,7 +311,10 @@ // 兜底:至少保留一个微信 if (!methods.length) { - methods.push({ paymentMethodType: 'WECHAT', paymentMethodName: '微信支付' }) + methods.push({ + paymentMethodType: 'WECHAT', + paymentMethodName: '微信支付' + }) } paymentMethods.value = methods @@ -376,11 +399,17 @@ if (res.resultCode === '9000') { startPaymentStatusPolling('ALIPAY') } else { - uni.showToast({ title: t('payment.paymentFailed'), icon: 'none' }) + uni.showToast({ + title: t('payment.paymentFailed'), + icon: 'none' + }) } }, fail: () => { - uni.showToast({ title: t('payment.paymentFailed'), icon: 'none' }) + uni.showToast({ + title: t('payment.paymentFailed'), + icon: 'none' + }) } }) } else { @@ -390,11 +419,17 @@ if (res.resultCode === '9000') { startPaymentStatusPolling('ALIPAY') } else { - uni.showToast({ title: t('payment.paymentFailed'), icon: 'none' }) + uni.showToast({ + title: t('payment.paymentFailed'), + icon: 'none' + }) } }, fail: () => { - uni.showToast({ title: t('payment.paymentFailed'), icon: 'none' }) + uni.showToast({ + title: t('payment.paymentFailed'), + icon: 'none' + }) } }) } @@ -419,7 +454,12 @@ uni.hideLoading(); uni.setStorageSync('pendingPaymentNo', orderId.value); - window.open(paymentUrl); + window.location.href = paymentUrl; + // plus.runtime.openURL(paymentUrl, function(err) { + // console.log('打开失败'); + // window.location.href = paymentUrl; + // }) + // ========================================================== // 开始轮询支付状态(传入当前选中的支付方式类型) startPaymentStatusPolling(method); @@ -441,7 +481,7 @@ // 轮询定时器 let pollingTimer = null; - + /** * 统一的支付状态轮询方法 * @param {string} paymentMethodType - 支付方式类型,如 'WECHAT' | 'ALIPAY' | 'WECHATPAY' 等,与 selectedPaymentMethod 保持一致 @@ -473,7 +513,7 @@ try { let res; let status, successStatus, failStatuses; - + // #ifdef H5 // H5 环境统一使用 Antom 聚合支付 API const osType = getOsType(); @@ -484,7 +524,7 @@ failStatuses = ['FAIL', 'CANCELLED']; } // #endif - + // #ifdef MP-WEIXIN // 微信小程序:根据支付方式类型判断 if (methodType === 'WECHAT' || methodType === 'WECHATPAY') { @@ -496,7 +536,7 @@ } } // #endif - + // #ifdef MP-ALIPAY // 支付宝小程序 if (methodType === 'ALIPAY') { @@ -511,6 +551,8 @@ // 处理支付状态结果 if (res && res.code === 200 && res.data && status) { + console.log(status === successStatus); + // 支付成功 if (status === successStatus) { clearInterval(pollingTimer); @@ -526,7 +568,7 @@ url: `/pages/order/success?orderId=${orderId.value}&deviceId=${orderInfo.value.deviceNo}` }); }, 1500); - } + } // 支付失败 else if (failStatuses && failStatuses.includes(status)) { clearInterval(pollingTimer); @@ -537,66 +579,23 @@ } } } catch (error) { - const errorMsg = methodType === 'ALIPAY' ? '支付宝' : (methodType === 'WECHAT' || methodType === 'WECHATPAY') ? '微信' : '支付'; + const errorMsg = methodType === 'ALIPAY' ? '支付宝' : (methodType === 'WECHAT' || + methodType === 'WECHATPAY') ? '微信' : '支付'; console.error(`查询${errorMsg}支付状态失败:`, error); } - }, 5000); // 每5秒查询一次 + }, 10000); // 每10秒查询一次 } // 兼容性方法:保持原有函数名,内部调用统一方法 const startWxPaymentStatusPolling = () => startPaymentStatusPolling('WECHAT'); const startAliPaymentStatusPolling = () => startPaymentStatusPolling('ALIPAY'); - // 更新导航栏倒计时 - const updateNavBarCountdown = () => { - const minutes = Math.floor(countdown.value / 60).toString().padStart(2, '0') - const seconds = (countdown.value % 60).toString().padStart(2, '0') - uni.setNavigationBarTitle({ - title: `待支付 ${minutes}:${seconds}` - }) - } - - // 开始倒计时 - const startCountdown = () => { - // 清除之前的定时器 - if (countdownTimer) { - clearInterval(countdownTimer) - } - - // 立即更新一次 - updateNavBarCountdown() - - // 每秒更新 - countdownTimer = setInterval(() => { - countdown.value-- - - if (countdown.value <= 0) { - clearInterval(countdownTimer) - uni.showToast({ - title: t('order.paymentFailedRetry'), - icon: 'none' - }) - setTimeout(() => { - uni.switchTab({ - url: '/pages/index/index' - }) - }, 1500) - return - } - - updateNavBarCountdown() - }, 1000) - } - // 页面卸载时清除定时器 onMounted(() => { return () => { if (pollingTimer) { clearInterval(pollingTimer); } - if (countdownTimer) { - clearInterval(countdownTimer); - } }; }); @@ -612,8 +611,10 @@ } onLoad((options) => { - // 启动倒计时 - startCountdown() + // 设置导航栏标题为待支付 + uni.setNavigationBarTitle({ + title: t('payment.waitingForPayment') + }) // 优先从 options 中获取 orderId if (options && options.orderId) { @@ -637,23 +638,23 @@ console.error('解析URL中的feeConfig失败:', e) } } - + loadOrderInfo() } // #ifdef H5 // 如果 options 中没有 orderId,尝试从缓存中获取(H5 环境) else { const cachedOrderId = uni.getStorageSync('pendingPaymentNo'); - console.log("订单编号:"+cachedOrderId); - + console.log("订单编号:" + cachedOrderId); + if (cachedOrderId) { orderId.value = cachedOrderId; } } // #endif -loadOrderInfo() + loadOrderInfo() // 调用 loadOrderInfo,内部会再次检查 orderId 是否存在 - + }) @@ -787,6 +788,49 @@ loadOrderInfo() } } } + + .payment-method-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 24rpx 0; + border-bottom: 1rpx solid #f5f5f5; + + &:last-child { + border-bottom-width: 0; + } + + .method-left { + display: flex; + align-items: center; + flex: 1; + } + + .method-name { + font-size: 28rpx; + color: #333; + } + + .method-right { + display: flex; + align-items: center; + justify-content: flex-end; + margin-left: 24rpx; + } + + .method-radio { + width: 32rpx; + height: 32rpx; + border-radius: 50%; + border: 2rpx solid #d9d9d9; + box-sizing: border-box; + } + + .method-radio.active { + border-color: #52c41a; + background-color: #52c41a; + } + } } .bottom-bar { diff --git a/subPackages/order/return-map.vue b/subPackages/order/return-map.vue new file mode 100644 index 0000000..fb174ad --- /dev/null +++ b/subPackages/order/return-map.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/subPackages/user/login/index.vue b/subPackages/user/login/index.vue index 966d81e..067a30a 100644 --- a/subPackages/user/login/index.vue +++ b/subPackages/user/login/index.vue @@ -131,18 +131,18 @@ } // 微信快捷登录入口(备用,目前主流程使用一键手机号登录) - const onWeChatLogin = async () => { - try { - await checkAgreement() - await wxLogin() - uni.showToast({ title: t('auth.loginSuccess'), icon: 'success' }) - await navigateAfterLogin() - } catch (error) { - if (error.message !== t('auth.pleaseAgreeToTerms')) { - uni.showToast({ title: error.message || t('auth.loginFailed'), icon: 'none' }) - } - } - } + // const onWeChatLogin = async () => { + // try { + // await checkAgreement() + // await wxLogin() + // uni.showToast({ title: t('auth.loginSuccess'), icon: 'success' }) + // await navigateAfterLogin() + // } catch (error) { + // if (error.message !== t('auth.pleaseAgreeToTerms')) { + // uni.showToast({ title: error.message || t('auth.loginFailed'), icon: 'none' }) + // } + // } + // } // 支付宝快捷登录入口(支付宝小程序) const onAlipayLogin = async () => { @@ -165,12 +165,12 @@ uni.showToast({ title: t('auth.phoneCancelled'), icon: 'none' }) return } - + console.log(e); try { // 先完成微信登录(/app/user/quickLogin,后端建立/查询 WECHAT_MINI 用户) - await wxLogin() + await wxLogin(e.detail.code) // 再用微信返回的临时 code 换取手机号(后端按文档更新 phone 字段) - await getUserPhoneNumber(e.detail.code) + // await getUserPhoneNumber(e.detail.code) uni.showToast({ title: t('auth.loginSuccess'), icon: 'success' }) await navigateAfterLogin() } catch (error) { diff --git a/subPackages/user/login/phone.vue b/subPackages/user/login/phone.vue index 088cd16..4100729 100644 --- a/subPackages/user/login/phone.vue +++ b/subPackages/user/login/phone.vue @@ -69,7 +69,8 @@