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
+29 -27
View File
@@ -10,12 +10,12 @@ import { getCommonByBrand } from "@/config/api/system"
import { HELP_CONTENT } from "@/constants/help"
// import { GET_PHONE_NUMBER_URL } from "../config/url"
// 微信登录方法
export const wxLogin = () => {
// 支付宝登录方法
export const alipayLogin = () => {
return new Promise((resolve, reject) => {
// 1. 获取微信登录凭证
// 1. 获取支付宝登录凭证
uni.login({
provider: 'weixin',
provider: 'alipay',
success: async (loginRes) => {
try {
@@ -23,7 +23,7 @@ export const wxLogin = () => {
// 2. 发送 code 到后端换取 token
const result = await login({
code: loginRes.code,
appid: "wx2165f0be356ae7a9"
appid: "2021006117693332"
})
if (result.code === 200) {
@@ -42,7 +42,7 @@ export const wxLogin = () => {
throw new Error(result.message || '登录失败')
}
} else {
throw new Error('获取微信登录凭证失败')
throw new Error('获取支付宝登录凭证失败')
}
} catch (error) {
@@ -55,7 +55,7 @@ export const wxLogin = () => {
},
fail: (error) => {
uni.showToast({
title: '微信登录失败',
title: '支付宝登录失败',
icon: 'none'
})
reject(error)
@@ -64,6 +64,9 @@ export const wxLogin = () => {
})
}
// 兼容旧代码,保留wxLogin别名
export const wxLogin = alipayLogin
// 检查登录状态
// export const checkLogin = () => {
// const token = uni.getStorageSync('token')
@@ -104,7 +107,7 @@ export const getUserPhoneNumber = (code) => {
'Content-Type': 'application/json'
},
data: {
code: code, // 微信获取手机号授权后的临时code
code: code, // 支付宝获取手机号授权后的临时code
appid: appid
},
success: (res) => {
@@ -137,34 +140,26 @@ export const getUserPhoneNumber = (code) => {
})
}
// 调用微信支付分接口
export const initiateWeChatScorePayment = (paymentData) => {
// 调用支付宝支付接口
export const initiateAlipayPayment = (paymentData) => {
return new Promise((resolve, reject) => {
// 确保paymentData包含所需数据
if (!paymentData || !paymentData.data || !paymentData.data.package) {
if (!paymentData || !paymentData.data) {
reject(new Error('支付参数不完整'));
return;
}
// 使用wx.openBusinessView打开微信支付分小程序
wx.openBusinessView({
businessType: 'wxpayScoreUse',
extraData: {
mch_id: paymentData.data.mch_id,
package: paymentData.data.package
},
success: (businessRes) => {
// 根据返回结果判断是否完成支付
if (businessRes.errMsg === 'openBusinessView:ok') {
resolve(businessRes);
} else {
reject(new Error('支付流程未完成'));
}
// 使用uni.requestPayment调用支付宝支付
uni.requestPayment({
provider: 'alipay',
orderInfo: paymentData.data.orderInfo || paymentData.data,
success: (res) => {
resolve(res);
},
fail: (error) => {
console.error('微信支付分小程序调用失败', error);
console.error('支付宝支付调用失败', error);
uni.showToast({
title: error.errMsg || '支付接口调用失败',
title: error.errMsg || '支付接口调用失败',
icon: 'none'
});
reject(error);
@@ -173,7 +168,14 @@ export const initiateWeChatScorePayment = (paymentData) => {
});
}
// 兼容旧代码,保留旧函数名
export const initiateWeChatScorePayment = initiateAlipayPayment
export const getQueryString = function(url, name) {
// 添加空值检查,兼容支付宝小程序
if (!url || typeof url !== 'string') {
return null
}
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {