fix:多平台兼容

This commit is contained in:
2026-03-16 11:52:27 +08:00
parent b3836b8bf2
commit a79cf10bd4
18 changed files with 358 additions and 295 deletions
+1 -1
View File
@@ -197,7 +197,7 @@
return props.bannerImages[currentBannerIndex.value] return props.bannerImages[currentBannerIndex.value]
} }
// 降级:如果没有广告,显示默认图片 // 降级:如果没有广告,显示默认图片
return '/static/index_swiper.png' return ''
}) })
// 验证坐标有效性 // 验证坐标有效性
+3 -2
View File
@@ -50,13 +50,14 @@ export const transformDeviceData = (device) => {
} }
// 立即租借 // 立即租借
export const rentPowerBank = (deviceNo, phone) => { export const rentPowerBank = (deviceNo, phone,payway) => {
return request({ return request({
url: `/app/device/rentPowerBank?deviceNo=${deviceNo}`, url: `/app/device/rentPowerBank?deviceNo=${deviceNo}`,
method: 'post', method: 'post',
data: { data: {
// deviceNo, // deviceNo,
phone phone,
payway
} }
}) })
} }
+6 -4
View File
@@ -37,10 +37,12 @@ export const sendVerifyCode = (phonenumber) => {
// 手机号+验证码登录 // 手机号+验证码登录
export const loginWithCode = (phonenumber, smsCode) => { export const loginWithCode = (phonenumber, smsCode) => {
return request({ // 兼容保留:统一走 quickLoginSMS
url: '/app/user/sms/login', return quickLogin({
method: 'post', loginType: 'SMS',
data: { phonenumber, smsCode } appid,
phonenumber,
smsCode
}) })
} }
+2 -2
View File
@@ -1,7 +1,7 @@
// export const URL = "https://my.gxfs123.com/api" //正式服务器-弃用 // export const URL = "https://my.gxfs123.com/api" //正式服务器-弃用
// export const URL = "https://manager.fdzpower.com/api" //正式服务器 // export const URL = "https://manager.fdzpower.com/api" //正式服务器
export const URL = "https://fansdev.gxfs123.com/api" //测试服务器 // export const URL = "https://fansdev.gxfs123.com/api" //测试服务器
// export const URL = "http://192.168.5.64:8080" //本地调试 export const URL = "http://192.168.5.58:8080" //本地调试
// export const URL = "http://127.0.0.1:8080" //本地调试 // export const URL = "http://127.0.0.1:8080" //本地调试
export const appid = "wx2165f0be356ae7a9" //微信小程序appid export const appid = "wx2165f0be356ae7a9" //微信小程序appid
+3 -1
View File
@@ -60,7 +60,9 @@ export default {
saveSuccess: 'Saved successfully', saveSuccess: 'Saved successfully',
saving: 'Saving...', saving: 'Saving...',
saveFailed: 'Save failed', saveFailed: 'Save failed',
downloadFailed: 'Download failed' downloadFailed: 'Download failed',
reset: 'Reset',
preview: 'Preview'
}, },
nav: { nav: {
+3 -1
View File
@@ -60,7 +60,9 @@ export default {
saveSuccess: 'Berhasil disimpan', saveSuccess: 'Berhasil disimpan',
saving: 'Menyimpan...', saving: 'Menyimpan...',
saveFailed: 'Gagal menyimpan', saveFailed: 'Gagal menyimpan',
downloadFailed: 'Gagal mengunduh' downloadFailed: 'Gagal mengunduh',
reset: 'Atur ulang',
preview: 'Pratinjau'
}, },
nav: { nav: {
+4 -2
View File
@@ -59,7 +59,9 @@ export default {
saveImage: '保存到手机', saveImage: '保存到手机',
saveSuccess: '保存成功', saveSuccess: '保存成功',
saving: '保存中...', saving: '保存中...',
saveFailed: '保存失败' saveFailed: '保存失败',
reset: '重置',
preview: '预览'
}, },
nav: { nav: {
@@ -305,7 +307,7 @@ export default {
customerService: '客服中心', customerService: '客服中心',
feedback: '投诉与建议', feedback: '投诉与建议',
businessLicense: '营业资质', businessLicense: '营业资质',
cooperation: '合作加盟', cooperation: '信息咨询',
settings: '设置', settings: '设置',
userAgreement: '《用户协议》', userAgreement: '《用户协议》',
settinguserAgreement: '用户协议', settinguserAgreement: '用户协议',
+8
View File
@@ -149,6 +149,14 @@
"navigationBarBackgroundColor": "#ffffff", "navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black" "navigationBarTextStyle": "black"
} }
},
{
"path": "return-map",
"style": {
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white"
}
} }
] ]
}, },
+1 -1
View File
@@ -604,7 +604,7 @@
console.log(deviceId.value); 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) { if (rentResult.code !== 200) {
throw new Error(rentResult.msg || t('device.rentFailed')) throw new Error(rentResult.msg || t('device.rentFailed'))
} }
+8 -1
View File
@@ -406,10 +406,17 @@
const getBannerImages = async () => { const getBannerImages = async () => {
try { try {
console.log('加载首页广告') console.log('加载首页广告')
let appPlatform;
// #ifdef MP-WEIXIN
appPlatform = 'wechat'
// #endif
// #ifdef MP-ALIPAY
appPlatform = 'ali'
// #endif
// 调用接口获取广告内容 // 调用接口获取广告内容
const res = await getCurrentAdvertisement({ const res = await getCurrentAdvertisement({
appPlatform: 'wechat', // 微信平台 appPlatform: appPlatform, // 微信平台
appType: 'user' ,// 用户端 appType: 'user' ,// 用户端
pictureLocation:'home_banner' pictureLocation:'home_banner'
}) })
+7 -177
View File
@@ -211,26 +211,6 @@
</view> </view>
</uv-popup> </uv-popup>
<!-- 归还地图弹窗 -->
<view class="return-map-popup" v-if="showReturnMapPopup" @click.self="closeReturnMapPopup">
<view class="popup-mask"></view>
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">{{ $t('order.returnLocationMap') }}</text>
<view class="close-btn" @click="closeReturnMapPopup">
<text class="close-icon">×</text>
</view>
</view>
<view class="popup-body">
<image :src="returnMapImageUrl" mode="widthFix" class="map-image" lazy-load="true"></image>
</view>
<view class="popup-footer">
<view class="save-btn" @click="saveReturnMapImage">
{{ $t('common.saveImage') }}
</view>
</view>
</view>
</view>
</view> </view>
</template> </template>
@@ -327,8 +307,6 @@
const countdownTimer = ref(null) const countdownTimer = ref(null)
const feeRuleText = ref('') const feeRuleText = ref('')
const convertToOwnPopup = ref(null) const convertToOwnPopup = ref(null)
const showReturnMapPopup = ref(false)
const returnMapImageUrl = ref('')
const lastDeviceEjectTime = ref(0) // 上次点击"宝未弹出"的时间戳 const lastDeviceEjectTime = ref(0) // 上次点击"宝未弹出"的时间戳
// 计算属性:是否显示优惠券/会员卡可用提示 // 计算属性:是否显示优惠券/会员卡可用提示
@@ -444,72 +422,22 @@
// 快速归还 // 快速归还
const quickReturn = () => { const quickReturn = () => {
// 检查是否有 returnMapImage 字段 // 检查是否有 returnMapImage 字段
console.log(orderInfo.value.returnMapImage); console.log(orderInfo.value.returnMapImage)
if (orderInfo.value.returnMapImage) { if (orderInfo.value.returnMapImage) {
// 有值则弹窗显示图片 // 有值则跳转到新的地图页查看大图(支持放大)
returnMapImageUrl.value = orderInfo.value.returnMapImage const encodedUrl = encodeURIComponent(orderInfo.value.returnMapImage)
showReturnMapPopup.value = true uni.navigateTo({
url: `/subPackages/order/return-map?imageUrl=${encodedUrl}`
})
} else { } else {
// 没有值则继续执行跳转流程 // 没有值则继续执行原有跳转流程
uni.navigateTo({ uni.navigateTo({
url: '/pages/search/index' 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 = () => { const rentAgain = () => {
uni.reLaunch({ 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;
}
}
}
}
}
</style> </style>
+12 -7
View File
@@ -327,19 +327,24 @@ const handleInitError = (err) => {
if (err.name === 'NotAllowedError' || err.name === 'PermissionDeniedError') { if (err.name === 'NotAllowedError' || err.name === 'PermissionDeniedError') {
errMsg = '摄像头权限被拒绝'; errMsg = '摄像头权限被拒绝';
errDetail = '请在浏览器设置中允许访问摄像头'; errDetail = '请在浏览器设置中允许访问摄像头';
} else if (err.name === 'NotFoundError' || err.name === 'DevicesNotFoundError') { }
else if (err.name === 'NotFoundError' || err.name === 'DevicesNotFoundError') {
errMsg = '未找到可用的摄像头'; errMsg = '未找到可用的摄像头';
errDetail = '请确保设备有摄像头'; errDetail = '请确保设备有摄像头';
} else if (err.name === 'NotReadableError' || err.name === 'TrackStartError') { }
else if (err.name === 'NotReadableError' || err.name === 'TrackStartError') {
errMsg = '摄像头被占用'; errMsg = '摄像头被占用';
errDetail = '请关闭其他使用摄像头的应用'; errDetail = '请关闭其他使用摄像头的应用';
} else if (err.name === 'NotSupportedError') { }
else if (err.name === 'NotSupportedError') {
errMsg = '浏览器不支持'; errMsg = '浏览器不支持';
errDetail = '请使用现代浏览器访问'; errDetail = '请使用现代浏览器访问';
} else if (location.protocol !== 'https:' && location.hostname !== 'localhost' && location.hostname !== '127.0.0.1') { }
errMsg = '需要 HTTPS 环境'; // else if (location.protocol !== 'https:' && location.hostname !== 'localhost' && location.hostname !== '127.0.0.1') {
errDetail = '摄像头功能需要在安全环境下使用'; // errMsg = '需要 HTTPS 环境';
} else { // errDetail = '摄像头功能需要在安全环境下使用';
// }
else {
errMsg = err.message || '摄像头启动失败'; errMsg = err.message || '摄像头启动失败';
errDetail = '请尝试刷新页面或使用其他方式'; errDetail = '请尝试刷新页面或使用其他方式';
} }
+109 -65
View File
@@ -4,7 +4,7 @@
<view class="location-card"> <view class="location-card">
<view class="location-header"> <view class="location-header">
<!-- <view class="location-icon">📍</view> --> <!-- <view class="location-icon">📍</view> -->
<image src="@/static/device_location.png" mode="aspectFit" class="location-icon"></image> <image src="@/static/device_location.png" mode="aspectFit" class="location-icon"></image>
<text class="location-name">{{ locationName }}</text> <text class="location-name">{{ locationName }}</text>
<view class="status-badge">{{ $t('device.available') }}</view> <view class="status-badge">{{ $t('device.available') }}</view>
</view> </view>
@@ -55,6 +55,24 @@
</view> </view>
</view> </view>
<!-- 支付方式选择 -->
<view class="order-card" v-if="paymentMethods.length">
<view class="card-header">
<view class="card-title-bar"></view>
<view class="card-title">{{ $t('payment.paymentMethod') }}</view>
</view>
<view class="payment-method-item" v-for="item in paymentMethods" :key="item.paymentMethodType"
@click="selectPaymentMethod(item.paymentMethodType)">
<view class="method-left">
<text class="method-name">{{ item.paymentMethodName }}</text>
</view>
<view class="method-right">
<view class="method-radio" :class="{ active: selectedPaymentMethod === item.paymentMethodType }">
</view>
</view>
</view>
</view>
<!-- 底部操作栏 --> <!-- 底部操作栏 -->
<view class="bottom-bar"> <view class="bottom-bar">
<view class="pay-btn" @click="handlePayment"> <view class="pay-btn" @click="handlePayment">
@@ -107,10 +125,6 @@
const passedTotalAmount = ref(null) const passedTotalAmount = ref(null)
const passedDepositAmount = ref(null) const passedDepositAmount = ref(null)
// 倒计时相关
const countdown = ref(15 * 60) // 15分钟 = 900秒
let countdownTimer = null
// 支付方式相关(微信/支付宝/H5-Antom 多平台) // 支付方式相关(微信/支付宝/H5-Antom 多平台)
const paymentMethods = ref([]) const paymentMethods = ref([])
const selectedPaymentMethod = ref('WECHAT') // 默认微信 const selectedPaymentMethod = ref('WECHAT') // 默认微信
@@ -195,14 +209,14 @@
deviceNo: orderData.deviceNo, deviceNo: orderData.deviceNo,
createTime: formattedTime, createTime: formattedTime,
deposit: passedDepositAmount.value || orderData.depositAmount || '99.00', deposit: passedDepositAmount.value || orderData.depositAmount || '99.00',
orderStatus:orderData.orderStatus orderStatus: orderData.orderStatus
} }
deviceNo.value = orderData.deviceNo; deviceNo.value = orderData.deviceNo;
await loadDeviceInfo(); await loadDeviceInfo();
await loadPaymentMethods(); await loadPaymentMethods();
// 如果订单状态是等待支付,启动相应的支付状态轮询 // 如果订单状态是等待支付,启动相应的支付状态轮询
if(orderInfo.value.orderStatus=='waiting_for_payment'){ if (orderInfo.value.orderStatus == 'waiting_for_payment') {
// 使用当前选中的支付方式类型进行轮询 // 使用当前选中的支付方式类型进行轮询
startPaymentStatusPolling(); startPaymentStatusPolling();
} }
@@ -263,10 +277,16 @@
// 小程序环境下:微信 / 支付宝 // 小程序环境下:微信 / 支付宝
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
methods.push({ paymentMethodType: 'WECHAT', paymentMethodName: '微信支付' }) methods.push({
paymentMethodType: 'WECHAT',
paymentMethodName: '微信支付'
})
// #endif // #endif
// #ifdef MP-ALIPAY // #ifdef MP-ALIPAY
methods.push({ paymentMethodType: 'ALIPAY', paymentMethodName: '支付宝支付' }) methods.push({
paymentMethodType: 'ALIPAY',
paymentMethodName: '支付宝支付'
})
// #endif // #endif
// H5 环境:使用 Antom 聚合支付(多通道) // H5 环境:使用 Antom 聚合支付(多通道)
@@ -291,7 +311,10 @@
// 兜底:至少保留一个微信 // 兜底:至少保留一个微信
if (!methods.length) { if (!methods.length) {
methods.push({ paymentMethodType: 'WECHAT', paymentMethodName: '微信支付' }) methods.push({
paymentMethodType: 'WECHAT',
paymentMethodName: '微信支付'
})
} }
paymentMethods.value = methods paymentMethods.value = methods
@@ -376,11 +399,17 @@
if (res.resultCode === '9000') { if (res.resultCode === '9000') {
startPaymentStatusPolling('ALIPAY') startPaymentStatusPolling('ALIPAY')
} else { } else {
uni.showToast({ title: t('payment.paymentFailed'), icon: 'none' }) uni.showToast({
title: t('payment.paymentFailed'),
icon: 'none'
})
} }
}, },
fail: () => { fail: () => {
uni.showToast({ title: t('payment.paymentFailed'), icon: 'none' }) uni.showToast({
title: t('payment.paymentFailed'),
icon: 'none'
})
} }
}) })
} else { } else {
@@ -390,11 +419,17 @@
if (res.resultCode === '9000') { if (res.resultCode === '9000') {
startPaymentStatusPolling('ALIPAY') startPaymentStatusPolling('ALIPAY')
} else { } else {
uni.showToast({ title: t('payment.paymentFailed'), icon: 'none' }) uni.showToast({
title: t('payment.paymentFailed'),
icon: 'none'
})
} }
}, },
fail: () => { fail: () => {
uni.showToast({ title: t('payment.paymentFailed'), icon: 'none' }) uni.showToast({
title: t('payment.paymentFailed'),
icon: 'none'
})
} }
}) })
} }
@@ -419,7 +454,12 @@
uni.hideLoading(); uni.hideLoading();
uni.setStorageSync('pendingPaymentNo', orderId.value); 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); startPaymentStatusPolling(method);
@@ -511,6 +551,8 @@
// 处理支付状态结果 // 处理支付状态结果
if (res && res.code === 200 && res.data && status) { if (res && res.code === 200 && res.data && status) {
console.log(status === successStatus);
// 支付成功 // 支付成功
if (status === successStatus) { if (status === successStatus) {
clearInterval(pollingTimer); clearInterval(pollingTimer);
@@ -537,66 +579,23 @@
} }
} }
} catch (error) { } catch (error) {
const errorMsg = methodType === 'ALIPAY' ? '支付宝' : (methodType === 'WECHAT' || methodType === 'WECHATPAY') ? '微信' : '支付'; const errorMsg = methodType === 'ALIPAY' ? '支付宝' : (methodType === 'WECHAT' ||
methodType === 'WECHATPAY') ? '微信' : '支付';
console.error(`查询${errorMsg}支付状态失败:`, error); console.error(`查询${errorMsg}支付状态失败:`, error);
} }
}, 5000); // 每5秒查询一次 }, 10000); // 每10秒查询一次
} }
// 兼容性方法:保持原有函数名,内部调用统一方法 // 兼容性方法:保持原有函数名,内部调用统一方法
const startWxPaymentStatusPolling = () => startPaymentStatusPolling('WECHAT'); const startWxPaymentStatusPolling = () => startPaymentStatusPolling('WECHAT');
const startAliPaymentStatusPolling = () => startPaymentStatusPolling('ALIPAY'); 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(() => { onMounted(() => {
return () => { return () => {
if (pollingTimer) { if (pollingTimer) {
clearInterval(pollingTimer); clearInterval(pollingTimer);
} }
if (countdownTimer) {
clearInterval(countdownTimer);
}
}; };
}); });
@@ -612,8 +611,10 @@
} }
onLoad((options) => { onLoad((options) => {
// 启动倒计时 // 设置导航栏标题为待支付
startCountdown() uni.setNavigationBarTitle({
title: t('payment.waitingForPayment')
})
// 优先从 options 中获取 orderId // 优先从 options 中获取 orderId
if (options && options.orderId) { if (options && options.orderId) {
@@ -644,14 +645,14 @@
// 如果 options 中没有 orderId,尝试从缓存中获取(H5 环境) // 如果 options 中没有 orderId,尝试从缓存中获取(H5 环境)
else { else {
const cachedOrderId = uni.getStorageSync('pendingPaymentNo'); const cachedOrderId = uni.getStorageSync('pendingPaymentNo');
console.log("订单编号:"+cachedOrderId); console.log("订单编号:" + cachedOrderId);
if (cachedOrderId) { if (cachedOrderId) {
orderId.value = cachedOrderId; orderId.value = cachedOrderId;
} }
} }
// #endif // #endif
loadOrderInfo() loadOrderInfo()
// 调用 loadOrderInfo,内部会再次检查 orderId 是否存在 // 调用 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 { .bottom-bar {
+141
View File
@@ -0,0 +1,141 @@
<template>
<view class="return-map-page">
<view class="image-wrapper">
<movable-area class="movable-area">
<movable-view class="movable-view" direction="all" :scale="true" :scale-min="1" :scale-max="4"
:scale-value="scale" @scale="onScaleChange">
<image :src="imageUrl" mode="widthFix" class="map-image" lazy-load="true"></image>
</movable-view>
</movable-area>
</view>
<view class="bottom-bar">
<view class="btn" @click="resetScale">{{ $t('common.reset') }}</view>
<view class="btn primary" @click="previewImage">{{ $t('common.preview') }}</view>
</view>
</view>
</template>
<script setup>
import {
ref
} from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
import {
useI18n
} from '@/utils/i18n.js'
const {
t
} = useI18n()
const imageUrl = ref('')
const scale = ref(1)
onLoad((options) => {
if (options && options.imageUrl) {
try {
imageUrl.value = decodeURIComponent(options.imageUrl)
} catch (e) {
imageUrl.value = options.imageUrl
}
}
if (!imageUrl.value) {
uni.showToast({
title: t('common.loadFailed'),
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 1500)
}
uni.setNavigationBarTitle({
title: t('order.returnLocationMap')
})
})
const onScaleChange = (e) => {
if (e && typeof e.detail?.scale === 'number') {
scale.value = e.detail.scale
}
}
const resetScale = () => {
scale.value = 1
}
const previewImage = () => {
if (!imageUrl.value) return
uni.previewImage({
urls: [imageUrl.value]
})
}
</script>
<style lang="scss" scoped>
.return-map-page {
min-height: 100vh;
background-color: #000;
display: flex;
flex-direction: column;
padding-bottom: env(safe-area-inset-bottom);
box-sizing: border-box;
}
.image-wrapper {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
padding: 20rpx;
box-sizing: border-box;
}
.movable-area {
width: 100%;
height: 100%;
}
.movable-view {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.map-image {
width: 100%;
display: block;
border-radius: 16rpx;
}
.bottom-bar {
padding: 16rpx 30rpx 24rpx;
display: flex;
justify-content: flex-end;
gap: 24rpx;
background: rgba(0, 0, 0, 0.8);
}
.btn {
min-width: 160rpx;
height: 72rpx;
border-radius: 36rpx;
border: 2rpx solid #ffffff;
color: #ffffff;
font-size: 28rpx;
display: flex;
align-items: center;
justify-content: center;
&.primary {
background: #07c160;
border-color: #07c160;
}
}
</style>
+15 -15
View File
@@ -131,18 +131,18 @@
} }
// 微信快捷登录入口(备用,目前主流程使用一键手机号登录) // 微信快捷登录入口(备用,目前主流程使用一键手机号登录)
const onWeChatLogin = async () => { // const onWeChatLogin = async () => {
try { // try {
await checkAgreement() // await checkAgreement()
await wxLogin() // await wxLogin()
uni.showToast({ title: t('auth.loginSuccess'), icon: 'success' }) // uni.showToast({ title: t('auth.loginSuccess'), icon: 'success' })
await navigateAfterLogin() // await navigateAfterLogin()
} catch (error) { // } catch (error) {
if (error.message !== t('auth.pleaseAgreeToTerms')) { // if (error.message !== t('auth.pleaseAgreeToTerms')) {
uni.showToast({ title: error.message || t('auth.loginFailed'), icon: 'none' }) // uni.showToast({ title: error.message || t('auth.loginFailed'), icon: 'none' })
} // }
} // }
} // }
// 支付宝快捷登录入口(支付宝小程序) // 支付宝快捷登录入口(支付宝小程序)
const onAlipayLogin = async () => { const onAlipayLogin = async () => {
@@ -165,12 +165,12 @@
uni.showToast({ title: t('auth.phoneCancelled'), icon: 'none' }) uni.showToast({ title: t('auth.phoneCancelled'), icon: 'none' })
return return
} }
console.log(e);
try { try {
// 先完成微信登录(/app/user/quickLogin,后端建立/查询 WECHAT_MINI 用户) // 先完成微信登录(/app/user/quickLogin,后端建立/查询 WECHAT_MINI 用户)
await wxLogin() await wxLogin(e.detail.code)
// 再用微信返回的临时 code 换取手机号(后端按文档更新 phone 字段) // 再用微信返回的临时 code 换取手机号(后端按文档更新 phone 字段)
await getUserPhoneNumber(e.detail.code) // await getUserPhoneNumber(e.detail.code)
uni.showToast({ title: t('auth.loginSuccess'), icon: 'success' }) uni.showToast({ title: t('auth.loginSuccess'), icon: 'success' })
await navigateAfterLogin() await navigateAfterLogin()
} catch (error) { } catch (error) {
+12 -2
View File
@@ -69,7 +69,8 @@
<script setup> <script setup>
import { ref, onMounted, onUnmounted } from 'vue' import { ref, onMounted, onUnmounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { sendVerifyCode, loginWithCode } from '@/config/api/user.js' import { sendVerifyCode, quickLogin } from '@/config/api/user.js'
import { appid } from '@/config/url.js'
import { fetchAndCacheCustomerPhone } from '@/util/index.js' import { fetchAndCacheCustomerPhone } from '@/util/index.js'
import { useI18n } from '@/utils/i18n.js' import { useI18n } from '@/utils/i18n.js'
@@ -163,7 +164,16 @@
try { try {
uni.showLoading({ title: t('common.loggingIn') }) uni.showLoading({ title: t('common.loggingIn') })
const res = await loginWithCode(phone.value, verifyCode.value) const res = await quickLogin({
loginType: 'SMS',
appid,
phonenumber: phone.value,
smsCode: verifyCode.value
})
if (res && res.code !== 200) {
throw new Error(res.msg || res.message || t('auth.loginFailed'))
}
// 保存token和client_id // 保存token和client_id
// 兼容多种返回格式:res.data.token, res.token, res.data.access_token // 兼容多种返回格式:res.data.token, res.token, res.data.access_token
+8 -1
View File
@@ -186,9 +186,16 @@
// 获取广告图片 // 获取广告图片
const getBannerImages = async () => { const getBannerImages = async () => {
try { try {
let appPlatform;
// #ifdef MP-WEIXIN
appPlatform = 'wechat'
// #endif
// #ifdef MP-ALIPAY
appPlatform = 'ali'
// #endif
// 调用接口获取广告内容 // 调用接口获取广告内容
const res = await getCurrentAdvertisement({ const res = await getCurrentAdvertisement({
appPlatform: 'wechat', // 微信平台 appPlatform: appPlatform, // 微信平台
appType: 'user', // 用户端 appType: 'user', // 用户端
pictureLocation:'userProfile_banner' pictureLocation:'userProfile_banner'
}) })
+5 -3
View File
@@ -15,7 +15,7 @@ import { HELP_CONTENT } from "@/constants/help"
// import { GET_PHONE_NUMBER_URL } from "../config/url" // import { GET_PHONE_NUMBER_URL } from "../config/url"
// 统一快捷登录 - 微信小程序登录(使用 /app/user/quickLogin // 统一快捷登录 - 微信小程序登录(使用 /app/user/quickLogin
export const wxLogin = () => { export const wxLogin = (phoneCode) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 1. 获取微信登录凭证(code -> 后端换 openId // 1. 获取微信登录凭证(code -> 后端换 openId
uni.login({ uni.login({
@@ -30,7 +30,8 @@ export const wxLogin = () => {
const result = await quickLogin({ const result = await quickLogin({
loginType: 'WECHAT', loginType: 'WECHAT',
appid: appid, appid: appid,
code: loginRes.code loginCode: loginRes.code,
code:phoneCode
}) })
if (result.code === 200 && result.data) { if (result.code === 200 && result.data) {
@@ -91,7 +92,7 @@ export const alipayLogin = () => {
const result = await quickLogin({ const result = await quickLogin({
loginType: 'ALIPAY', loginType: 'ALIPAY',
appid: ZFBappid, appid: ZFBappid,
code: res.authCode loginCode: res.authCode
}) })
if (result.code === 200 && result.data) { if (result.code === 200 && result.data) {
@@ -143,6 +144,7 @@ export const alipayLogin = () => {
export const smsQuickLogin = (phonenumber, smsCode) => { export const smsQuickLogin = (phonenumber, smsCode) => {
return quickLogin({ return quickLogin({
loginType: 'SMS', loginType: 'SMS',
appid: appid,
phonenumber, phonenumber,
smsCode smsCode
}) })