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
@@ -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'))
}
+8 -1
View File
@@ -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'
})
+8 -178
View File
@@ -211,26 +211,6 @@
</view>
</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>
</template>
@@ -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;
}
}
}
}
}
</style>
+12 -7
View File
@@ -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 = '请尝试刷新页面或使用其他方式';
}