fix:对接高德地图,修复地图bug

This commit is contained in:
2025-12-23 10:39:41 +08:00
parent d12986b85e
commit 76bdcd1aba
20 changed files with 964 additions and 399 deletions
+20 -45
View File
@@ -72,12 +72,12 @@
<!-- 底部操作区 -->
<view class="footer">
<button class="rent-button" :class="{ 'return-button': hasActiveOrder }"
@click="handleRent('wx-score-pay')">
@click="handleRent('alipay-score-pay')">
<text>{{ hasActiveOrder ? $t('order.returnDevice') : $t('device.rentDepositFree') }}</text>
</button>
<view class="wechat-credit">
<image src="/static/images/wxpayflag.png" mode="aspectFit" class="wx-icon"></image>
<text class="credit-text">{{ $t('device.wxPayScoreDesc') }}</text>
<view class="alipay-credit">
<image src="/static/images/alipay.svg" mode="aspectFit" class="alipay-icon"></image>
<text class="credit-text">{{ $t('device.alipayScoreDesc') }}</text>
</view>
</view>
@@ -123,7 +123,7 @@
cancelOrder
} from '@/config/api/order.js'
import {
initiateWeChatScorePayment,
initiateAlipayPayment,
getUserInfo,
getUserPhoneNumber
} from '@/util/index.js'
@@ -466,32 +466,8 @@
uni.showLoading({
title: $t('common.processing')
})
// --- 第一步:先请求订阅消息(必须在用户点击的同步上下文中)---
if (payWay === 'wx-score-pay') {
console.log('准备请求订阅消息(在异步操作之前),时间:', new Date().toLocaleTimeString());
try {
await new Promise((resolve, reject) => {
uni.requestSubscribeMessage({
tmplIds: ['o7OMTIcHnFBR7mvsggxFtdt8FfIgSl-v0swVUefGx6w'],
success: (subscribeRes) => {
console.log('订阅消息success回调,时间:', new Date()
.toLocaleTimeString(), subscribeRes);
resolve(subscribeRes);
},
fail: (subscribeErr) => {
console.log('订阅消息fail回调,时间:', new Date().toLocaleTimeString(),
subscribeErr);
// 订阅失败不影响主流程
resolve(subscribeErr);
}
});
});
console.log('订阅消息完成,时间:', new Date().toLocaleTimeString());
} catch (subscribeError) {
console.log('订阅消息异常', subscribeError);
}
}
// --- 订阅消息请求完成 ---
// --- 支付宝小程序不需要订阅消息,移除相关代码 ---
// 支付宝小程序使用消息推送,不需要订阅消息
console.log(deviceId.value);
// 调用设备租借接口
@@ -504,7 +480,7 @@
const order = rentResult.data
console.log('订单信息', order);
if (payWay == 'wx-pay') {
if (payWay == 'alipay-pay' || payWay == 'wx-pay') {
// 当支付方式为押金支付时
uni.hideLoading()
const res = await getOrderByOrderNo(order.orderNo);
@@ -519,29 +495,28 @@
url: `/pages/order/payment?orderId=${order.orderId}&packagePrice=${packagePrice}&totalAmount=${totalAmount}&depositAmount=${deposit}${deviceInfo.value && deviceInfo.value.feeConfig ? '&feeConfig=' + encodeURIComponent(deviceInfo.value.feeConfig) : ''}`
})
} else if (payWay == 'wx-score-pay') {
// 当支付方式为支付支付时
} else if (payWay == 'alipay-score-pay' || payWay == 'wx-score-pay') {
// 当支付方式为支付宝信用免押支付时
uni.hideLoading()
// 获取支付所需参数
// 获取支付宝信用免押所需参数
const res = await getOrderByOrderNoScore(order.orderNo);
uni.hideLoading()
if (res && res.code === 200) {
try {
// 调用微信支付分小程序
const payResult = await initiateWeChatScorePayment(res);
console.log('支付调用结果', payResult);
// 调用支付宝信用免押小程序
const payResult = await initiateAlipayPayment(res);
console.log('支付宝信用免押调用结果', payResult);
// 成功则跳转到等待页面
if (payResult.errCode == '0' && payResult.extraData && Object.keys(payResult.extraData)
.length > 0) {
console.log('支付分授权成功,准备跳转到等待页,时间:', new Date().toLocaleTimeString());
// 跳转到等待页面(订阅消息已经在前面完成了)
if (payResult && payResult.success !== false) {
console.log('支付宝信用免押授权成功,准备跳转到等待页,时间:', new Date().toLocaleTimeString());
// 跳转到等待页面
uni.redirectTo({
url: `/pages/waiting/index?orderNo=${order.orderNo}&orderId=${order.orderId}&deviceId=${deviceId.value}`
});
return;
} else {
console.log('支付未完成授权或用户取消extraData:', payResult.extraData);
console.log('支付宝信用免押未完成授权或用户取消:', payResult);
// 用户取消授权,需要取消订单
try {
uni.showLoading({
@@ -876,13 +851,13 @@
}
}
.wechat-credit {
.alipay-credit {
display: flex;
align-items: center;
justify-content: center;
margin-top: 16rpx;
.wx-icon {
.alipay-icon {
width: 48rpx;
height: 38rpx;
margin-right: 8rpx;
+1 -1
View File
@@ -306,7 +306,7 @@
// 获取图片列表(支持字符串或数组)
const getImageList = (item) => {
if (!item) return [];
const pictureSource = item.pictureUrls ?? item.picturePath;
const pictureSource = item.pictureUrls != null ? item.pictureUrls : item.picturePath;
if (!pictureSource) return [];
if (Array.isArray(pictureSource)) {
return pictureSource.filter(img => !!img);
+112 -107
View File
@@ -1,30 +1,31 @@
<template>
<view class="container fullscreen">
<!-- 自定义导航栏 -->
<view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
<view class="navbar-content" :style="{ height: navBarHeight + 'px' }">
<view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'rpx' }">
<view class="navbar-content" :style="{ height: navBarHeight + 'rpx' }">
<text class="navbar-title">{{ $t('home.title') }}</text>
</view>
</view>
<!-- 顶部信息区域通知招商等 -->
<view class="top-info-section" :style="{ top: (statusBarHeight + navBarHeight) + 'px' }">
<!-- 通知栏 -->
<view class="notice-wrapper" v-if="noticeText" @click="openNoticePopup">
<uv-notice-bar :text="noticeText" :speed="50" :show-icon="true" color="#07c160" bg-color="#E8F8EF"
icon="volume"></uv-notice-bar>
<!-- 顶部信息区域通知招商等 -->
<view class="top-info-section" :style="{ top: (statusBarHeight + navBarHeight) + 'rpx' }">
<!-- 通知栏 -->
<view class="notice-wrapper" v-if="noticeText" @click="openNoticePopup">
<uv-notice-bar :text="noticeText" :speed="50" :show-icon="true" color="#07c160" bg-color="#E8F8EF"
icon="volume"></uv-notice-bar>
</view>
</view>
</view>
<!-- 内容区域 -->
<view class="main-content" :style="{ paddingTop: (statusBarHeight + navBarHeight + noticeHeight) + 'px' }">
<!-- 全屏地图组件 -->
<MapComponent v-if="!isLoading && userLocation" ref="mapRef" :userLocation="userLocation"
:positionList="positionList" :filteredPositions="filteredPositions" :searchKeyword="searchKeyword"
:enableMarkers="true" :bannerImages="bannerImages"
:hideMapOverlays="showGuidePopup || showNoticePopup || showActivityPopup"
@relocate="handleRelocate" @scan="handleScan" @showList="showLocationList" @markerTap="selectPosition"
@mapCenterChange="onMapCenterChange" @bannerClick="handleBannerClick" />
<view class="main-content"
:style="{ paddingTop: (statusBarHeight + navBarHeight+navBarHeight + noticeHeight) + 'rpx' }">
<!-- 全屏地图组件 -->
<MapComponent v-if="!isLoading && userLocation" ref="mapRef" :userLocation="userLocation"
:positionList="positionList" :filteredPositions="filteredPositions" :searchKeyword="searchKeyword"
:enableMarkers="true" :bannerImages="bannerImages"
:hideMapOverlays="showGuidePopup || showNoticePopup || showActivityPopup" @relocate="handleRelocate"
@scan="handleScan" @showList="showLocationList" @markerTap="selectPosition"
@mapCenterChange="onMapCenterChange" @bannerClick="handleBannerClick" />
<!-- 地图加载状态 -->
<view v-if="isLoading || !userLocation" class="map-loading-placeholder">
@@ -101,7 +102,7 @@
</view>
<!-- 使用指南居中弹出ref 控制 open/close -->
<uv-popup ref="guidePopup" mode="center" :overlay="true" :closeOnClickOverlay="false"
<uv-popup ref="guidePopup" mode="center" :overlay="true" :closeOnClickOverlay="false"
:safeAreaInsetBottom="false">
<view class="guide-popup">
<view class="guide-header">
@@ -187,7 +188,7 @@
} from 'vue'
import {
getQueryString,
wxLogin
alipayLogin
} from '../../util/index.js'
import {
URL
@@ -218,12 +219,9 @@
useI18n
} from '../../utils/i18n.js'
// 开启右上角分享菜单(仅 mp-weixin 有效)
// #ifdef MP-WEIXIN
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
// 支付宝小程序不支持分享菜单,移除相关代码
// #ifdef MP-ALIPAY
// 支付宝小程序分享功能通过页面配置实现
// #endif
const {
@@ -317,7 +315,7 @@
'Content-Language': languageCode
},
data: {
type: 'wx_user_type' // 微信小程序用户端
type: 'zfb_user_type' // 支付宝小程序用户端
}
})
@@ -365,8 +363,8 @@
'Content-Language': languageCode
},
data: {
appPlatform: 'wechat', // 微信平台
appType: 'user' // 用户端
appPlatform: 'alipay', // 支付宝平台
appType: 'user' // 用户端
}
})
@@ -394,7 +392,9 @@
console.log('点击首页广告:', index, bannerImages.value[index])
// 可以根据需要添加跳转逻辑
// 例如跳转到合作加盟页面
uni.navigateTo({ url: '/pages/join/index' })
uni.navigateTo({
url: '/pages/join/index'
})
}
// 查询最近的活动
@@ -480,15 +480,13 @@
const systemInfo = uni.getSystemInfoSync()
statusBarHeight.value = systemInfo.statusBarHeight || 0
// #ifdef MP-WEIXIN
// 获取胶囊按钮位置信息
const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
// 计算导航栏内容高度:(胶囊底部坐标 - 状态栏高度) 确保与胶囊对齐
navBarHeight.value = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height
// #ifdef MP-ALIPAY
// 支付宝小程序导航栏高度计算
navBarHeight.value = 44
// #endif
// #ifndef MP-WEIXIN
// 非微信小程序使用默认高度
// #ifndef MP-ALIPAY
// 其他平台使用默认高度
navBarHeight.value = 44
// #endif
@@ -523,94 +521,94 @@
console.warn('清理旧缓存失败:', e);
}
// 开发环境测试距离计算
if (process.env.NODE_ENV === 'development') {
testDistanceCalculation()
}
// 并行加载公告和广告(不依赖定位)
await Promise.all([
getNoticeText(),
getBannerImages()
])
// 开发环境测试距离计算
if (process.env.NODE_ENV === 'development') {
testDistanceCalculation()
}
// 1. 先获取用户位置
await getUserLocationAndAddress()
// 并行加载公告和广告(不依赖定位)
await Promise.all([
getNoticeText(),
getBannerImages()
])
// 2. 加载场地列表(依赖定位)
await loadPositions()
// 1. 先获取用户位置
await getUserLocationAndAddress()
// 3. 查询活动并显示弹窗
await checkActiveActivity()
// 2. 加载场地列表(依赖定位)
await loadPositions()
// 3. 查询活动并显示弹窗
await checkActiveActivity()
} catch (error) {
console.error('初始化失败:', error)
uni.showToast({
title: $t('home.getLocationFailed'),
icon: 'none'
})
uni.showToast({
title: $t('home.getLocationFailed'),
icon: 'none'
})
} finally {
isLoading.value = false
}
}
const getUserLocationAndAddress = async () => {
// 使用腾讯地图SDK获取位置(若失败抛出,由调用方统一处理)
const location = await getUserLocation()
// 使用腾讯地图SDK获取位置(若失败抛出,由调用方统一处理)
const location = await getUserLocation()
if (!location?.longitude || !location?.latitude) {
throw new Error('invalid location result')
}
if (!location?.longitude || !location?.latitude) {
throw new Error('invalid location result')
}
// 保存用户位置
userLocation.value = {
longitude: location.longitude,
latitude: location.latitude
}
console.log(userLocation.value);
// 将经纬度写入本地缓存(基础信息)
try {
uni.setStorageSync('userLocation', {
// 保存用户位置
userLocation.value = {
longitude: location.longitude,
latitude: location.latitude
})
} catch (e) {
console.warn('缓存基础定位信息失败:', e)
}
// 只在首次初始化时设置标记
if (!isLocationInitialized.value) {
isLocationInitialized.value = true
}
// 获取详细地址信息
try {
const addressResult = await getRegeo(location.longitude, location.latitude)
if (addressResult.success) {
const addressInfo = addressResult.data
userLocation.value.address = addressInfo.formatted_address
userLocation.value.city = addressInfo.addressComponent.city
userLocation.value.district = addressInfo.addressComponent.district
// 更新本地缓存,包含地址信息
try {
uni.setStorageSync('userLocation', {
longitude: userLocation.value.longitude,
latitude: userLocation.value.latitude,
address: userLocation.value.address,
city: userLocation.value.city,
district: userLocation.value.district
})
} catch (e) {
console.warn('缓存带地址的定位信息失败:', e)
}
}
} catch (error) {
// 忽略地址信息错误,使用基础定位信息
}
return userLocation.value
console.log(userLocation.value);
// 将经纬度写入本地缓存(基础信息)
try {
uni.setStorageSync('userLocation', {
longitude: location.longitude,
latitude: location.latitude
})
} catch (e) {
console.warn('缓存基础定位信息失败:', e)
}
// 只在首次初始化时设置标记
if (!isLocationInitialized.value) {
isLocationInitialized.value = true
}
// 获取详细地址信息
try {
const addressResult = await getRegeo(location.longitude, location.latitude)
if (addressResult.success) {
const addressInfo = addressResult.data
userLocation.value.address = addressInfo.formatted_address
userLocation.value.city = addressInfo.addressComponent.city
userLocation.value.district = addressInfo.addressComponent.district
// 更新本地缓存,包含地址信息
try {
uni.setStorageSync('userLocation', {
longitude: userLocation.value.longitude,
latitude: userLocation.value.latitude,
address: userLocation.value.address,
city: userLocation.value.city,
district: userLocation.value.district
})
} catch (e) {
console.warn('缓存带地址的定位信息失败:', e)
}
}
} catch (error) {
// 忽略地址信息错误,使用基础定位信息
}
return userLocation.value
}
const loadPositions = async () => {
@@ -890,7 +888,11 @@
})
})
let deviceNo = getQueryString(scanResult.path, 'deviceNo')
// 兼容微信和支付宝小程序的扫码结果结构
// 微信小程序:scanResult.path
// 支付宝小程序:scanResult.result
const scanPath = scanResult.path || scanResult.result || ''
let deviceNo = getQueryString(scanPath, 'deviceNo')
if (!deviceNo) {
uni.showToast({
@@ -1079,10 +1081,13 @@
</script>
<style lang="scss" scoped>
/* 支付宝小程序页面背景色通过外层 view 设置 */
.container {
height: 100vh;
width: 100vw;
background-color: #fff;
min-height: 100vh;
/* 支付宝小程序需要设置 min-height */
display: flex;
flex-direction: column;
}
+17 -12
View File
@@ -8,16 +8,16 @@
<view class="title">{{ $t('auth.loginTitle') }}</view>
<view class="subtitle">{{ $t('auth.loginDesc') }}</view>
<!-- 微信一键手机号快捷登录推荐 -->
<!-- 支付宝一键手机号快捷登录推荐 -->
<button v-if="!isAgreed" class="btn primary" @click="handleLoginClick">
{{ $t('auth.getPhoneNumber') }}
</button>
<button v-else class="btn primary" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber">
<button v-else class="btn primary" open-type="getAuthorize" scope="phoneNumber" @getAuthorize="onGetPhoneNumber">
{{ $t('auth.getPhoneNumber') }}
</button>
<!-- 微信登录不授权手机号时使用 -->
<!-- <button class="btn outline" @click="onWeChatLogin">微信登录</button> -->
<!-- 支付宝登录不授权手机号时使用 -->
<!-- <button class="btn outline" @click="onAlipayLogin">支付宝登录</button> -->
<view class="agreement-box">
<checkbox-group @change="onAgreementChange">
@@ -38,7 +38,7 @@
<script setup>
import { ref, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { wxLogin, getUserPhoneNumber, getUserInfo } from '../../util/index.js'
import { alipayLogin, getUserPhoneNumber, getUserInfo } from '../../util/index.js'
import { useI18n } from '@/utils/i18n.js'
const { t: $t } = useI18n()
@@ -113,12 +113,12 @@
uni.reLaunch({ url: target })
}
const onWeChatLogin = async () => {
const onAlipayLogin = async () => {
try {
// 先检查是否同意协议
await checkAgreement()
await wxLogin()
await alipayLogin()
uni.showToast({ title: $t('auth.loginSuccess'), icon: 'success' })
await navigateAfterLogin()
} catch (error) {
@@ -129,16 +129,21 @@
}
const onGetPhoneNumber = async (e) => {
if (!e || e.detail.errMsg !== 'getPhoneNumber:ok') {
// 支付宝获取手机号的回调处理
if (!e || !e.detail || !e.detail.response) {
uni.showToast({ title: $t('auth.phoneCancelled'), icon: 'none' })
return
}
try {
// 先微信登录,获取 token
await wxLogin()
// 再用微信返回的临时 code 换取手机号
await getUserPhoneNumber(e.detail.code)
// 先支付宝登录,获取 token
await alipayLogin()
// 再用支付宝返回的授权码换取手机号
// 支付宝的授权码在 e.detail.response 中
const authCode = e.detail.response?.response?.code || e.detail.response?.code
if (authCode) {
await getUserPhoneNumber(authCode)
}
uni.showToast({ title: $t('auth.loginSuccess'), icon: 'success' })
await navigateAfterLogin()
} catch (error) {
+27 -55
View File
@@ -9,7 +9,7 @@
<view class="nickname">{{ userInfo.nickName || $t('user.clickToLogin') }}</view>
<view class="subtext">{{ userInfo.phone ? maskPhone(userInfo.phone) : $t('user.loginPrompt') }}</view>
</view>
<uv-icon type="right" size="16" color="#999"></uv-icon>
<uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
</view>
@@ -113,7 +113,7 @@
<u-popup ref="authPopup" mode="center" border-radius="15" width="600rpx" @open="onPopupOpen" @close="onPopupClose">
<view class="auth-popup">
<view class="auth-title">授权登录</view>
<view class="auth-desc">获取您的微信头像、昵称等公开信息</view>
<view class="auth-desc">获取您的支付宝头像、昵称等公开信息</view>
<view class="auth-buttons">
<button class="cancel-btn" @click="closeAuthPopup">取消</button>
<button class="confirm-btn" @click="getUserProfile">确定</button>
@@ -135,7 +135,7 @@
} from '@dcloudio/uni-app';
import {
wxLogin,
alipayLogin,
getUserInfo
} from '../../util/index.js';
import {
@@ -184,7 +184,7 @@ import {
'Content-Language': languageCode
},
data: {
appPlatform: 'wechat', // 微信平台
appPlatform: 'alipay', // 支付宝平台
appType: 'user' // 用户端
}
})
@@ -267,11 +267,12 @@ import {
// 初始化应用版本号(多端兼容,取可用信息)
const initVersion = () => {
// #ifdef MP-WEIXIN
// #ifdef MP-ALIPAY
try {
const info = wx.getAccountInfoSync && wx.getAccountInfoSync();
if (info && info.miniProgram && info.miniProgram.version) {
appVersion.value = info.miniProgram.version;
// 支付宝小程序获取版本号
const systemInfo = uni.getSystemInfoSync();
if (systemInfo && systemInfo.version) {
appVersion.value = systemInfo.version;
}
} catch (e) {}
// #endif
@@ -368,12 +369,13 @@ import {
redirectToLogin()
return
}
// #ifdef MP-WEIXIN
getUserProfile()
// #ifdef MP-ALIPAY
// 支付宝小程序通过页面跳转处理用户资料
navigateTo('/pages/userProfile/index')
// #endif
// #ifndef MP-WEIXIN
// #ifndef MP-ALIPAY
uni.showToast({
title: $t('auth.pleaseUseInWechat'),
title: $t('auth.pleaseUseInAlipay'),
icon: 'none'
})
// #endif
@@ -446,65 +448,35 @@ import {
// 这里可以添加弹窗关闭后的逻辑
};
// 获取微信用户个人信息
// 获取支付宝用户个人信息(已废弃,使用页面跳转方式)
const getUserProfile = () => {
// #ifdef MP-WEIXIN
uni.showLoading({
title: $t('common.getting'),
mask: true
});
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
console.log('获取用户信息成功:', res);
updateUserInfo(res.userInfo);
uploadAvatarAndRefresh(res.userInfo);
},
fail: (err) => {
console.error('获取用户信息失败:', err);
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
});
},
complete: () => {
uni.hideLoading();
closeAuthPopup();
}
});
// #ifdef MP-ALIPAY
// 支付宝小程序通过页面跳转处理用户资料
navigateTo('/pages/userProfile/index')
// #endif
// #ifndef MP-WEIXIN
// #ifndef MP-ALIPAY
uni.showToast({
title: $t('auth.pleaseUseInWechat'),
title: $t('auth.pleaseUseInAlipay'),
icon: 'none'
});
closeAuthPopup();
// #endif
};
// 更新用户信息
const updateUserInfo = async (wxUserInfo) => {
// 更新用户信息(支付宝小程序通过页面跳转处理)
const updateUserInfo = async (alipayUserInfo) => {
try {
// 更新本地用户信息
const updatedInfo = {
...userInfo.value,
nickName: wxUserInfo.nickName,
avatar: wxUserInfo.avatarUrl
nickName: alipayUserInfo.nickName,
avatar: alipayUserInfo.avatarUrl
};
userInfo.value = updatedInfo;
uni.setStorageSync('userInfo', updatedInfo);
// 这里可以添加调用后端API更新用户信息的代码
// const updateRes = await updateUserInfoApi({
// openId: openId.value,
// nickName: wxUserInfo.nickName,
// avatarUrl: wxUserInfo.avatarUrl,
// gender: wxUserInfo.gender
// });
uni.showToast({
title: $t('user.updateSuccess'),
icon: 'success'
@@ -522,9 +494,9 @@ import {
};
// 下载并上传头像,更新用户信息
const uploadAvatarAndRefresh = async (wxUserInfo) => {
const uploadAvatarAndRefresh = async (alipayUserInfo) => {
try {
const avatarUrl = wxUserInfo?.avatarUrl
const avatarUrl = alipayUserInfo?.avatarUrl
if (!avatarUrl) {
uni.showToast({
title: '未获取到头像地址',
@@ -532,7 +504,7 @@ import {
})
return
}
// 下载微信头像为本地临时文件
// 下载支付宝头像为本地临时文件
const tempFilePath = await new Promise((resolve, reject) => {
uni.downloadFile({
url: avatarUrl,
+4 -3
View File
@@ -271,9 +271,9 @@
title: $t('common.processing')
});
// 调用后端创建微信支付订单接口
// 调用后端创建支付宝支付订单接口
const res = await uni.request({
url: `${URL || 'http://127.0.0.1:8080'}/app/wx-payment/create/${order.orderNo}`,
url: `${URL || 'http://127.0.0.1:8080'}/app/alipay-payment/create/${order.orderNo}`,
method: 'GET',
header: {
'Authorization': "Bearer " + uni.getStorageSync('token'),
@@ -284,8 +284,9 @@
if (res.statusCode === 200 && res.data.code === 200) {
const payParams = res.data.data;
// 调用微信支付
// 调用支付宝支付
await uni.requestPayment({
provider: 'alipay',
...payParams,
success: async () => {
uni.showToast({
+6 -5
View File
@@ -246,9 +246,9 @@ export default {
title: this.$t('common.processing')
})
// 调用后端创建微信支付订单接口
// 调用后端创建支付宝支付订单接口
const res = await uni.request({
url: `${URL || 'http://127.0.0.1:8080'}/app/wx-payment/create/${this.orderInfo.orderNo}`,
url: `${URL || 'http://127.0.0.1:8080'}/app/alipay-payment/create/${this.orderInfo.orderNo}`,
method: 'GET',
header: {
'Authorization': "Bearer " + uni.getStorageSync('token'),
@@ -259,8 +259,9 @@ export default {
if (res.statusCode === 200 && res.data.code === 200) {
const payParams = res.data.data
// 调用微信支付
// 调用支付宝支付
await uni.requestPayment({
provider: 'alipay',
...payParams,
success: async () => {
uni.showToast({
@@ -373,11 +374,11 @@ export default {
return `${year}-${month}-${day} ${hour}:${minute}`
},
// 检查订单状态(单次查询,不轮询)
// 检查订单状态(单次查询,不轮询)
async checkOrderStatus() {
try {
const res = await uni.request({
url: `${URL || 'http://127.0.0.1:8080'}/app/wx-payment/status/${this.orderInfo.orderNo}`,
url: `${URL || 'http://127.0.0.1:8080'}/app/alipay-payment/status/${this.orderInfo.orderNo}`,
method: 'GET',
header: {
'Authorization': "Bearer " + uni.getStorageSync('token'),
+8 -8
View File
@@ -15,21 +15,21 @@
<!-- 支付方式标识 -->
<view class="device-right">
<!-- 微信支付分标识 -->
<view class="payment-badge wx-score" v-if="orderInfo.payWay == 'wx_score_pay'">
<image src="/static/images/wxpayflag.png" mode="aspectFit" class="badge-icon"></image>
<!-- 支付宝信用免押标识 -->
<view class="payment-badge alipay-score" v-if="orderInfo.payWay == 'alipay_score_pay' || orderInfo.payWay == 'wx_score_pay'">
<image src="/static/images/alipay.svg" mode="aspectFit" class="badge-icon"></image>
<view class="badge-text">
<text>{{ $t('order.wxPayScore') }}</text>
<text>{{ $t('order.alipayScore') }}</text>
<text class="divider">|</text>
<text class="highlight">{{ $t('order.depositFree') }}</text>
</view>
</view>
<!-- 会员订单标识 -->
<view class="payment-badge member" v-else-if="orderInfo.payWay == 'wx_member_pay'">
<view class="payment-badge member" v-else-if="orderInfo.payWay == 'alipay_member_pay' || orderInfo.payWay == 'wx_member_pay'">
<text class="badge-text">{{ $t('order.memberOrder') }}</text>
</view>
<!-- 微信支付押金标识 -->
<view class="payment-badge deposit" v-else-if="orderInfo.payWay == 'wx_pay'">
<!-- 支付宝支付押金标识 -->
<view class="payment-badge deposit" v-else-if="orderInfo.payWay == 'alipay_pay' || orderInfo.payWay == 'wx_pay'">
<text class="badge-text">{{ $t('order.depositPay') }}</text>
</view>
</view>
@@ -322,7 +322,7 @@
this.countdownTimer = null
}
},
// 解析开始时间字符串为时间戳(毫秒),兼容常见格式及 iOS/微信环境
// 解析开始时间字符串为时间戳(毫秒),兼容常见格式及 iOS/支付宝环境
parseStartTimeToMs(timeStr) {
if (!timeStr) return NaN
if (typeof timeStr === 'number') {
+1 -1
View File
@@ -6,7 +6,7 @@
<script>
import {
wxLogin,
alipayLogin,
} from '../../../util/index'
import {
+3 -3
View File
@@ -4,8 +4,8 @@
<view class="avatar-container">
<image class="avatar" v-if="userInfo.avatar" :src="userInfo.avatar" mode="aspectFill"></image>
<image v-else class="avatar" src="@/static/head.png" mode="aspectFill"></image>
<!-- 覆盖在头像上的微信选择头像授权按钮仅小程序生效 -->
<!-- #ifdef MP-WEIXIN -->
<!-- 覆盖在头像上的支付宝选择头像授权按钮仅小程序生效 -->
<!-- #ifdef MP-ALIPAY -->
<button class="avatar-choose-btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"></button>
<!-- #endif -->
</view>
@@ -282,7 +282,7 @@ function maskPhone(phone) {
}
/* 仅小程序端存在,此按钮覆盖在头像上捕获点击以触发选择头像 */
/* #ifdef MP-WEIXIN */
/* #ifdef MP-ALIPAY */
.avatar-choose-btn {
position: absolute;
left: 0;