feat:实现了微信小程序、H5、华为快应用三端适配微信 / 支付宝 / 华为官方支付规范的支付功能

This commit is contained in:
Zhukj
2025-12-09 08:50:51 +08:00
parent 86e43e3e6c
commit 5bd0881946
9 changed files with 1139 additions and 769 deletions

View File

@@ -39,7 +39,7 @@ export default {
}, },
fail: (res) => { fail: (res) => {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
let scene = wx.getLaunchOptionsSync().scene; let scene = uni.getLaunchOptionsSync().scene;
if ([1154, 1155].indexOf(scene) == -1) { if ([1154, 1155].indexOf(scene) == -1) {
this.$util.showToast({ this.$util.showToast({
title: res.errMsg title: res.errMsg

View File

@@ -1,3 +1,9 @@
let site = null;
try {
site = require("../site.js"); // 适配发行模式的 site.js 导入
} catch (e) {
site = null; // 开发模式无 site.js 时赋值为 null
}
// 发行版本,配置说明 // 发行版本,配置说明
let releaseCfg = undefined; let releaseCfg = undefined;
try { try {

View File

@@ -206,6 +206,7 @@ export default {
* 获取订单结算数据 * 获取订单结算数据
*/ */
payment() { payment() {
this.$api.sendRequest({ this.$api.sendRequest({
url: this.api.payment, url: this.api.payment,
data: this.handleCreateData(), data: this.handleCreateData(),
@@ -214,7 +215,7 @@ export default {
let data = res.data; let data = res.data;
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
var scene = uni.getStorageSync('is_test') ? 1175 : wx.getLaunchOptionsSync().scene; var scene = uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene;
if ([1175, 1176, 1177, 1191, 1195].indexOf(scene) != -1 && data.delivery.express_type) { if ([1175, 1176, 1177, 1191, 1195].indexOf(scene) != -1 && data.delivery.express_type) {
data.delivery.express_type = data.delivery.express_type.filter(item => item.name == 'express'); data.delivery.express_type = data.delivery.express_type.filter(item => item.name == 'express');
} }

View File

@@ -137,7 +137,7 @@
this.isMatched = 1; this.isMatched = 1;
return; return;
} }
let options = wx.getLaunchOptionsSync(); let options = uni.getLaunchOptionsSync();
this.$api.sendRequest({ this.$api.sendRequest({
url: '/shopcomponent/api/weapp/scenecheck', url: '/shopcomponent/api/weapp/scenecheck',
data: { data: {
@@ -357,7 +357,7 @@
out_trade_no: this.payInfo.out_trade_no, out_trade_no: this.payInfo.out_trade_no,
pay_type: payType.type, pay_type: payType.type,
is_matched: this.isMatched, is_matched: this.isMatched,
scene: uni.getStorageSync('is_test') ? 1175 : wx.getLaunchOptionsSync().scene scene: uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene
}, },
success: res => { success: res => {
uni.hideLoading(); uni.hideLoading();
@@ -365,7 +365,7 @@
var payData = res.data.data; var payData = res.data.data;
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
var scene = uni.getStorageSync('is_test') ? 1175 : wx.getLaunchOptionsSync() var scene = uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync()
.scene; .scene;
if ([1175, 1176, 1177, 1191, 1195].indexOf(scene) != -1) { if ([1175, 1176, 1177, 1191, 1195].indexOf(scene) != -1) {
uni.requestOrderPayment({ uni.requestOrderPayment({

View File

@@ -4,7 +4,7 @@
<uni-popup ref="choosePaymentPopup" type="center" v-if="payInfo" :mask-click="false"> <uni-popup ref="choosePaymentPopup" type="center" v-if="payInfo" :mask-click="false">
<view class="choose-payment-popup popup" @touchmove.prevent.stop> <view class="choose-payment-popup popup" @touchmove.prevent.stop>
<view class="popup-header"> <view class="popup-header">
<text class="tit">支付方式</text> <text class="tit">支付方式-测试</text>
<text class="iconfont icon-close" @click="close()"></text> <text class="iconfont icon-close" @click="close()"></text>
</view> </view>
<scroll-view scroll-y="true" class="popup-body"> <scroll-view scroll-y="true" class="popup-body">
@@ -51,13 +51,13 @@ import uniPopup from '@/components/uni-popup/uni-popup.vue';
import nsSwitch from '@/components/ns-switch/ns-switch.vue'; import nsSwitch from '@/components/ns-switch/ns-switch.vue';
// #ifdef H5 // #ifdef H5
import { import { Weixin } from 'common/js/wx-jssdk.js';
Weixin
} from 'common/js/wx-jssdk.js';
// #endif // #endif
// 引入统一支付工具类 // ========== 引入三端支付工具类(核心:适配官方规范) ==========
import { invokeWechatPay, invokeAlipay, invokeHuaweiPay } from '../../common/js/payCore.js'; import { getWechatPay } from '@/utils/wechat-pay.js';
import { getAlipayPay } from '@/utils/alipay-pay.js';
import { getHuaweiPay } from '@/utils/huawei-pay.js';
export default { export default {
name: 'payment', name: 'payment',
@@ -76,27 +76,24 @@ export default {
return { return {
payIndex: 0, payIndex: 0,
payTypeList: [ payTypeList: [
// #ifdef H5 || MP-ALIPAY // 所有端都显示微信支付
{
name: '支付宝支付',
icon: 'icon-zhifubaozhifu-',
type: 'alipay'
},
// #endif
// #ifdef H5 || MP-WEIXIN
{ {
name: '微信支付', name: '微信支付',
icon: 'icon-weixin1', icon: 'icon-weixin1',
type: 'wechatpay' type: 'wechatpay'
}, },
// #endif // 所有端都显示支付宝支付
// #ifdef H5 || QUICKAPP-HUAWEI {
name: '支付宝支付',
icon: 'icon-zhifubaozhifu-',
type: 'alipay'
},
// 所有端都显示华为支付
{ {
name: '华为支付', name: '华为支付',
icon: 'icon-zhekou', icon: 'icon-zhekou',
type: 'huaweipay' type: 'huaweipay'
}, },
// #endif
{ {
name: '线下支付', name: '线下支付',
icon: 'icondiy icon-yuezhifu', icon: 'icondiy icon-yuezhifu',
@@ -115,11 +112,17 @@ export default {
//重置是否已完成没有完成不能调用api/pay/pay //重置是否已完成没有完成不能调用api/pay/pay
resetPayComplete: true, resetPayComplete: true,
repeatFlag: false, repeatFlag: false,
// ========== 支付工具类实例 ==========
wechatPay: null,
alipayPay: null,
huaweiPay: null
}; };
}, },
created(e) { created(e) {
this.getPayType(); this.getPayType();
if (this.balanceUsable) this.getBalanceConfig(); if (this.balanceUsable) this.getBalanceConfig();
// ========== 初始化三端支付工具类(填写官方申请的参数) ==========
this.initPayUtils();
}, },
computed: { computed: {
balanceDeduct() { balanceDeduct() {
@@ -149,6 +152,34 @@ export default {
} }
}, },
methods: { methods: {
// ========== 初始化支付工具类(核心:配置官方参数) ==========
initPayUtils() {
// 微信支付初始化(替换为你的微信官方参数)
this.wechatPay = getWechatPay({
appId: '你的微信小程序/AppID', // 微信开放平台/AppID
merchantId: '你的微信商户号', // 微信支付商户号
apiKey: '你的微信API密钥', // 微信支付API密钥商户平台获取
privateKey: '你的微信RSA私钥', // 商户私钥
publicKey: '微信支付公钥' // 微信支付公钥
});
// 支付宝支付初始化(替换为你的支付宝官方参数)
this.alipayPay = getAlipayPay({
appId: '你的支付宝AppID', // 支付宝开放平台/AppID
merchantId: '你的支付宝商户号', // 支付宝支付商户号
privateKey: '你的支付宝RSA2私钥', // RSA2私钥
alipayPublicKey: '支付宝公钥' // 支付宝公钥
});
// 华为支付初始化(替换为你的华为官方参数)
this.huaweiPay = getHuaweiPay({
appId: '你的华为AppID', // 华为开发者联盟AppID
merchantId: '你的华为商户号', // 华为支付商户号
publicKey: '华为支付公钥', // 华为支付公钥
privateKey: '你的华为商户私钥', // 华为商户私钥
env: 'sandbox' // 测试环境sandbox生产环境production
});
},
/** /**
* 父级页面onShow调用 * 父级页面onShow调用
*/ */
@@ -162,7 +193,6 @@ export default {
} else { } else {
uni.removeStorageSync('offlinepay'); uni.removeStorageSync('offlinepay');
} }
}, },
close() { close() {
this.$emit('close'); this.$emit('close');
@@ -264,87 +294,156 @@ export default {
// #ifdef H5 // #ifdef H5
pay() { pay() {
var payType = this.payTypeList[this.payIndex]; var payType = this.payTypeList[this.payIndex];
if (!payType || payType.type === 'offlinepay') { var return_url = '';
// 线下支付仍使用原有逻辑 if (this.payInfo.event == 'BlindboxGoodsOrderPayNotify') {
this.payOffline(); return_url = '/pages_promotion/blindbox/index?outTradeNo=';
return; } else {
return_url = '/pages_tool/pay/result?code=';
} }
this.$api.sendRequest({
url: '/api/pay/pay',
data: {
out_trade_no: this.payInfo.out_trade_no,
pay_type: payType ? payType.type : '',
return_url: encodeURIComponent(this.$config.h5Domain + return_url + this.payInfo.out_trade_no),
is_balance: this.isBalance
},
success: async res => { // 新增async支持异步调用
uni.hideLoading();
if (res.code >= 0) {
if (res.data.pay_success) {
this.paySuccess();
return;
}
switch (payType.type) {
// ========== 支付宝支付H5端符合官方RSA2规范 ==========
case 'alipay':
try {
this.repeatFlag = false;
const orderInfo = {
outTradeNo: this.payInfo.out_trade_no,
productName: '订单支付',
price: this.payMoney,
returnUrl: this.$config.h5Domain + return_url + this.payInfo.out_trade_no,
notifyUrl: this.$config.h5Domain + '/api/pay/alipay/notify'
};
// 创建支付宝订单带RSA2签名
const alipayRes = await this.alipayPay.h5Pay(orderInfo);
// 验证支付宝签名(官方规范)
const isAlipaySignValid = this.alipayPay.verifyResult(alipayRes, alipayRes.sign);
if (!isAlipaySignValid) {
this.$util.showToast({ title: '支付宝订单签名验证失败' });
return;
}
// 区分微信浏览器/普通浏览器
if (this.$util.isWeiXin()) {
var wx_alipay = encodeURIComponent(alipayRes.payUrl);
this.$util.redirectTo('/pages_tool/pay/wx_pay', {
wx_alipay: wx_alipay,
out_trade_no: this.payInfo.out_trade_no
}, '', 'redirectTo');
} else {
location.href = alipayRes.payUrl;
this.checkPayStatus();
}
} catch (error) {
this.$util.showToast({ title: '支付宝支付失败:' + error.message });
this.repeatFlag = false;
}
break;
// 使用统一支付工具类进行支付 // ========== 微信支付H5端符合官方JSSDK+签名规范) ==========
this.invokeUnifiedPay(payType.type); case 'wechatpay':
}, try {
this.repeatFlag = false;
const orderInfo = {
outTradeNo: this.payInfo.out_trade_no,
productName: '订单支付',
price: this.payMoney,
openid: this.$store.state.openid,
notifyUrl: this.$config.h5Domain + '/api/pay/wechat/notify',
returnUrl: this.$config.h5Domain + return_url + this.payInfo.out_trade_no,
url: uni.getSystemInfoSync().platform == 'ios' ? uni.getStorageSync('initUrl') : location.href
};
// 微信浏览器内JSSDK支付
if (this.$util.isWeiXin()) {
// 初始化JSSDK官方规范
await this.wechatPay.initJSSDK(orderInfo.url);
// 创建微信订单带HMAC-SHA256签名
const wxPayRes = await this.wechatPay.mpPay(orderInfo);
// 验证签名(官方规范)
const isWxSignValid = this.wechatPay.verifyResult(wxPayRes, wxPayRes.paySign);
if (!isWxSignValid) {
this.$util.showToast({ title: '微信订单签名验证失败' });
return;
}
// 唤起JSSDK支付
await this.wechatPay.h5Pay(wxPayRes);
this.paySuccess();
} else {
// 普通浏览器H5支付链接
const wxH5Res = await this.wechatPay.h5Pay(orderInfo);
console.log('普通浏览器微信支付链接:', wxH5Res.mweb_url);
location.href = wxH5Res.mweb_url;
this.checkPayStatus();
}
} catch (error) {
this.$util.showToast({ title: '微信支付失败:' + error.message });
this.resetpay();
this.repeatFlag = false;
}
break;
/** // ========== 华为支付H5端符合官方RSA签名规范 ==========
* 统一支付调用方法(使用新的支付工具类) case 'huaweipay':
*/ try {
async invokeUnifiedPay(payType) { this.repeatFlag = false;
try { const orderInfo = {
let payResult; productId: 'PROD_' + this.payInfo.out_trade_no,
const amount = this.payMoney; productName: '订单支付',
const outTradeNo = this.payInfo.out_trade_no; price: this.payMoney
const subject = '订单支付'; };
// 创建华为订单带RSA签名
const huaweiRes = await this.huaweiPay.h5Pay(orderInfo);
// 验证签名(官方规范)
const isHuaweiSignValid = this.huaweiPay.verifySignature(JSON.stringify(huaweiRes), huaweiRes.sign);
if (!isHuaweiSignValid) {
this.$util.showToast({ title: '华为订单签名验证失败' });
return;
}
console.log('华为支付跳转链接:', huaweiRes.payUrl);
location.href = huaweiRes.payUrl;
this.checkPayStatus();
} catch (error) {
this.$util.showToast({ title: '华为支付失败:' + error.message });
this.repeatFlag = false;
}
break;
// 根据支付类型调用对应的支付方法 // ========== 线下支付(保留原有逻辑) ==========
switch (payType) { case 'offlinepay':
case 'wechatpay': this.$util.redirectTo('/pages_tool/pay/offlinepay', {
payResult = await invokeWechatPay(outTradeNo, amount, subject); outTradeNo: this.payInfo.out_trade_no
break; });
case 'alipay': this.repeatFlag = false;
payResult = await invokeAlipay(outTradeNo, amount, subject); break;
break; }
case 'huaweipay':
payResult = await invokeHuaweiPay(outTradeNo, amount, subject);
break;
default:
throw new Error('不支持的支付方式');
}
// 处理H5支付跳转
if (payResult.code === 0 && payResult.data?.payUrl) {
// H5端直接跳转其他端需要在WebView中显示
const systemInfo = uni.getSystemInfoSync();
if (systemInfo.platform === 'web') {
window.location.href = payResult.data.payUrl;
this.checkPayStatus();
} else { } else {
// 微信小程序/华为快应用中显示WebView this.$util.showToast({
this.showPayWebView(payResult.data.payUrl); title: res.message
});
this.repeatFlag = false;
} }
} else if (payResult.code === 0) { },
// 原生支付成功 fail: res => {
this.paySuccess(); uni.hideLoading();
} else { this.$util.showToast({
throw new Error(payResult.msg || '支付失败'); title: 'request:fail'
});
this.repeatFlag = false;
} }
} catch (error) {
this.repeatFlag = false;
this.$util.showToast({
title: error.message || '支付失败'
});
}
},
/**
* 显示支付WebView用于微信小程序/华为快应用的H5支付
*/
showPayWebView(payUrl) {
// 这里可以打开一个新的WebView页面来显示支付
// 或者使用现有的跳转逻辑
this.$util.redirectTo('/pages/Pay/Pay', {
payUrl: payUrl,
outTradeNo: this.payInfo.out_trade_no
}); });
}, },
/**
* 线下支付处理(保留原有逻辑)
*/
payOffline() {
this.$util.redirectTo('/pages_tool/pay/offlinepay', {
outTradeNo: this.payInfo.out_trade_no
});
this.repeatFlag = false;
},
checkPayStatus() { checkPayStatus() {
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.$api.sendRequest({ this.$api.sendRequest({
@@ -369,17 +468,142 @@ export default {
// #ifdef MP // #ifdef MP
pay() { pay() {
var payType = this.payTypeList[this.payIndex]; var payType = this.payTypeList[this.payIndex];
if (!payType || payType.type === 'offlinepay') { this.$api.sendRequest({
// 线下支付仍使用原有逻辑 url: '/api/pay/pay',
this.$util.redirectTo('/pages_tool/pay/offlinepay', { data: {
outTradeNo: this.payInfo.out_trade_no out_trade_no: this.payInfo.out_trade_no,
}); pay_type: payType ? payType.type : '',
this.repeatFlag = false; scene: uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene,
return; is_balance: this.isBalance
} },
success: async res => { // 新增async支持异步调用
uni.hideLoading();
if (res.code >= 0) {
if (res.data.pay_success) {
this.paySuccess();
this.repeatFlag = false;
return;
}
if (payType.type == 'offlinepay') {
this.$util.redirectTo('/pages_tool/pay/offlinepay', {
outTradeNo: this.payInfo.out_trade_no
});
this.repeatFlag = false;
} else {
try {
this.repeatFlag = false;
// ========== 华为支付小程序端跳转H5 ==========
if (payType.type == 'huaweipay') {
const orderInfo = {
productId: 'PROD_' + this.payInfo.out_trade_no,
productName: '订单支付',
price: this.payMoney
};
const huaweiRes = await this.huaweiPay.mpWeixinPay(orderInfo);
this.$util.redirectTo('/pages_tool/pay/wx_pay', {
wx_alipay: encodeURIComponent(huaweiRes.payUrl),
out_trade_no: this.payInfo.out_trade_no
});
} else {
// ========== 微信/支付宝小程序支付(符合官方验签规范) ==========
var payData = res.data.data;
// 验证支付参数签名(官方规范)
let isSignValid = false;
if (payType.type == 'wechatpay') {
isSignValid = this.wechatPay.verifyResult(payData, payData.paySign);
} else if (payType.type == 'alipay') {
isSignValid = this.alipayPay.verifyResult(payData, payData.sign);
}
if (!isSignValid) {
this.$util.showToast({ title: '支付参数签名验证失败' });
return;
}
// 小程序端也使用统一支付工具类 // #ifdef MP-WEIXIN
this.invokeUnifiedPay(payType.type); var scene = uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene;
if ([1175, 1176, 1177, 1191, 1195].indexOf(scene) != -1) {
uni.requestOrderPayment({
timeStamp: payData.timeStamp,
nonceStr: payData.nonceStr,
package: payData.package,
signType: payData.signType,
paySign: payData.paySign,
success: res => {
this.paySuccess();
this.repeatFlag = false;
},
fail: res => {
this.flag = false;
if (res.errMsg == 'requestOrderPayment:fail cancel') {
this.$util.showToast({
title: '您已取消支付'
});
this.resetpay();
this.repeatFlag = false;
} else {
uni.showModal({
content: '支付失败,失败原因: ' + res.errMsg,
showCancel: false
});
setTimeout(() => {
this.close();
this.repeatFlag = false;
}, 1500)
}
}
});
return
}
// #endif
uni.requestPayment({
provider: payType.provider,
...payData,
success: res => {
this.paySuccess();
this.repeatFlag = false;
},
fail: res => {
this.flag = false;
if (res.errMsg == 'requestPayment:fail cancel') {
this.$util.showToast({
title: '您已取消支付'
});
this.resetpay();
this.repeatFlag = false;
} else {
uni.showModal({
content: '支付失败,失败原因: ' + res.errMsg,
showCancel: false
});
setTimeout(() => {
this.close();
this.repeatFlag = false;
}, 1500)
}
}
});
}
} catch (error) {
this.$util.showToast({ title: '支付失败:' + error.message });
this.repeatFlag = false;
}
}
} else {
this.$util.showToast({
title: res.message
});
this.repeatFlag = false;
}
},
fail: res => {
uni.hideLoading();
this.$util.showToast({
title: 'request:fail'
});
this.repeatFlag = false;
}
});
}, },
// #endif // #endif
/** /**
@@ -528,8 +752,6 @@ export default {
color: #00a0e9; color: #00a0e9;
} }
.icon-checkboxblank { .icon-checkboxblank {
font-size: 40rpx; font-size: 40rpx;
color: $color-line; color: $color-line;

34
main.js
View File

@@ -27,7 +27,6 @@ Vue.prototype.$lang = Lang.lang; //解析语言包
Vue.prototype.$config = Config; Vue.prototype.$config = Config;
// #ifdef H5 // #ifdef H5
EventBus.setDomBridge(DomEventBridge) EventBus.setDomBridge(DomEventBridge)
// #endif // #endif
@@ -57,8 +56,41 @@ import NsLogin from "@/components/ns-login/ns-login.vue"
Vue.component('ns-login', NsLogin); Vue.component('ns-login', NsLogin);
import PrivacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue'; import PrivacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// 只保留一次组件注册(删除重复行)
Vue.component('privacy-popup', PrivacyPopup) Vue.component('privacy-popup', PrivacyPopup)
// 全局登录方法(替换成你的真实后端接口地址)
Vue.prototype.$doGlobalLogin = async function() {
return new Promise((resolve, reject) => {
uni.login({
success: async (loginRes) => {
if (!loginRes.code) {
reject("获取登录凭证失败,请重试");
return;
}
try {
// !!替换为你的真实后端登录接口地址!!
const res = await uni.request({
url: "https://dev.aigc-quickapp.com/api/user/login",
method: "POST",
data: { code: loginRes.code }
});
if (res.data?.success) {
uni.setStorageSync("token", res.data.token);
resolve(true);
} else {
reject(res.data?.msg || "登录失败");
}
} catch (err) {
reject("网络异常");
}
},
fail: () => reject("登录授权失败")
});
});
};
// 只创建一次Vue实例删除重复声明
const app = new Vue({ const app = new Vue({
...App, ...App,
store store

View File

@@ -1,27 +1,23 @@
{ {
"name" : "lucky_weapp", "name":"lucky_weapp",
"appid" : "__UNI__A3A4830", "appid":"__UNI__A3A4830",
"description" : "", "description":"",
"versionName" : "1.0.0", "versionName":"1.0.0",
"versionCode" : "100", "versionCode":"100",
"transformPx" : false, "transformPx":false,
/* 5+App */ "app-plus":{
"app-plus" : { "usingComponents":true,
"usingComponents" : true, "nvueCompiler":"uni-app",
"nvueCompiler" : "uni-app", "splashscreen":{
"splashscreen" : { "alwaysShowBeforeRender":true,
"alwaysShowBeforeRender" : true, "waiting":true,
"waiting" : true, "autoclose":true,
"autoclose" : true, "delay":0
"delay" : 0
}, },
/* */ "modules":{},
"modules" : {}, "distribute":{
/* */ "android":{
"distribute" : { "permissions":[
/* android */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>", "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
@@ -46,90 +42,164 @@
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
] ]
}, },
/* ios */ "ios":{},
"ios" : {}, "sdkConfigs":{
/* SDK */ "ad":{},
"sdkConfigs" : { // App端支付SDK配置适配原生App支付
"ad" : {} "payment":{
"weixin":{
"appid":"wx1234567890abcdef", // 替换微信开放平台AppID
"universalLink":"https://yourdomain.com/apple-app-site-association" // 替换iOS微信Universal Link
},
"alipay":{
"appid":"2024000000000000" // 替换支付宝开放平台AppID
},
"huawei":{
"appid":"12345678" // 替换华为开发者联盟AppID应用市场申请
}
}
} }
} }
}, },
/* */ "mp-weixin":{
"mp-weixin" : { "appid":"wxa8f94045d9c2fc10", // 你的微信小程序AppID已保留
"appid" : "wxa8f94045d9c2fc10", "setting":{
"setting" : { "urlCheck":false,
"urlCheck" : false, "postcss":false,
"postcss" : false, "es6":true,
"es6" : true, "minified":true
"minified" : true
}, },
"usingComponents" : true, "usingComponents":true,
"permission" : { "permission":{
"scope.userLocation" : { "scope.userLocation":{
"desc" : "为了更好地为您提供服务" "desc":"为了更好地为您提供服务"
}, },
"scope.writePhotosAlbum" : { "scope.writePhotosAlbum":{
"desc" : "为了更好地为您提供服务" "desc":"为了更好地为您提供服务"
} }
}, },
"requiredPrivateInfos" : [ "chooseLocation", "getLocation", "chooseAddress" ], "useDeprecatedAPI":{
"__usePrivacyCheck__" : true, "getSystemInfoSync":false
"optimization" : { },
"subPackages" : true "requiredPrivateInfos":["chooseLocation","getLocation","chooseAddress"],
"__usePrivacyCheck__":true,
"optimization":{
"subPackages":true
},
// 微信小程序支付核心配置(官方规范)
"pay":{
"merchantId":"1688888888", // 替换:你的微信支付商户号(商户平台获取)
"keyPath":"cert/apiclient_key.p12" // 可选:微信支付证书路径(退款/分账等接口需用)
},
"sdkConfigs":{
"jssdk":{
"apis":["chooseWXPay"] // 必须开启微信JSSDK支付接口H5/小程序共用)
}
} }
}, },
"mp-alipay" : { "mp-alipay":{
"usingComponents" : true, "usingComponents":true,
"appid" : "" "appid":"2024000000000000", // 替换你的支付宝小程序AppID开放平台获取
// 支付宝小程序支付配置(官方规范)
"pay":{
"merchantId":"2088888888888888" // 替换:你的支付宝支付商户号
}
}, },
"mp-baidu" : { "mp-baidu":{
"usingComponents" : true "usingComponents":true
}, },
"mp-toutiao" : { "mp-toutiao":{
"usingComponents" : true "usingComponents":true
}, },
"h5" : { "h5":{
"sdkConfigs" : { "sdkConfigs":{
"maps" : { "maps":{
"qqmap" : { "qqmap":{
"key" : "TUHBZ-CNWKU-UHAVP-GZQ26-HNZFO-3YBF4" "key":"TUHBZ-CNWKU-UHAVP-GZQ26-HNZFO-3YBF4" // 已保留
},
// H5端微信/华为支付JSSDK配置
"weixin":{
"appid":"wxa8f94045d9c2fc10" // 和微信小程序AppID一致无需修改
},
"huawei":{
"appid":"12345678" // 替换华为开发者联盟AppID
} }
} }
}, },
"router" : { "router":{
"mode" : "history", "mode":"hash", // 必须hash模式适配支付回调跳转
"base" : "/hwapp/" "base":"/hwapp/"
}, },
"title" : " ", "title":"华为支付演示",
"devServer" : { "devServer":{
"https" : false "https":false,
}, // H5端支付接口跨域代理解决浏览器跨域限制
"optimization" : { "proxy":{
"treeShaking" : { // 华为支付接口代理
"enable" : false "/api/huawei":{
"target":"https://iap-api.cloud.huawei.com",
"changeOrigin":true,
"pathRewrite":{
"^/api/huawei":""
}
},
// 微信支付接口代理
"/api/wechat":{
"target":"https://api.mch.weixin.qq.com",
"changeOrigin":true,
"pathRewrite":{
"^/api/wechat":""
}
},
// 支付宝支付接口代理(沙箱/生产二选一)
"/api/alipay":{
"target":"https://openapi.alipaydev.com", // 沙箱环境生产https://openapi.alipay.com
"changeOrigin":true,
"pathRewrite":{
"^/api/alipay":""
}
}
} }
}, },
"domain" : " ", "optimization":{
"unipush" : { "treeShaking":{
"enable" : false "enable":false
}
}, },
"async" : { "domain":" ",
"loading" : "", "unipush":{
"error" : "", "enable":false
"delay" : 0,
"timeout" : 3000
}, },
"template" : "" "async":{
"loading":"",
"error":"",
"delay":0,
"timeout":3000
},
"template":""
}, },
"uniStatistics" : { "uniStatistics":{
"version" : "2" "version":"2"
}, },
"sassImplementationName" : "node-sass", "sassImplementationName":"node-sass",
/** **/ "quickapp-webview":{
"quickapp-webview" : { "package":"com.jieganfsj.fivegshop", // 已保留:华为快应用包名
"package" : "com.jieganfsj.fivegshop", "minPlatformVersion":1070,
"minPlatformVersion" : 1070, "versionName":"1.0.0",
"versionName" : "1.0.0", "versionCode":0,
"versionCode" : 0 // 华为快应用支付核心配置(官方规范)
"sdkConfigs":{
"huawei":{
"appid":"12345678", // 替换华为开发者联盟AppID
"payment":{
"merchantId":"88888888" // 替换:华为支付商户号(商户平台获取)
}
}
},
// 华为快应用必须声明的支付权限(官方强制)
"features":[
{"name":"system.pay"},
{"name":"huawei.pay"}
]
} }
} }

38
package-lock.json generated
View File

@@ -1,11 +1,14 @@
{ {
"name": "frontend", "name": "lucky_shop",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {
"@dcloudio/uni-quickapp-webview": "^2.0.2-4080420251103001", "@dcloudio/uni-quickapp-webview": "^2.0.2-4080420251103001",
"crypto-js": "^4.1.1",
"js-base64": "^3.7.2",
"jsencrypt": "^3.2.1",
"jweixin-module": "^1.6.0" "jweixin-module": "^1.6.0"
}, },
"devDependencies": { "devDependencies": {
@@ -455,6 +458,12 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/crypto-js": {
"version": "4.2.0",
"resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
"license": "MIT"
},
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.5.4", "version": "1.5.4",
"resolved": "https://repo.huaweicloud.com/repository/npm/electron-to-chromium/-/electron-to-chromium-1.5.4.tgz", "resolved": "https://repo.huaweicloud.com/repository/npm/electron-to-chromium/-/electron-to-chromium-1.5.4.tgz",
@@ -614,6 +623,18 @@
"node": ">= 10.13.0" "node": ">= 10.13.0"
} }
}, },
"node_modules/js-base64": {
"version": "3.7.8",
"resolved": "https://registry.npmmirror.com/js-base64/-/js-base64-3.7.8.tgz",
"integrity": "sha512-hNngCeKxIUQiEUN3GPJOkz4wF/YvdUdbNL9hsBcMQTkKzboD7T/q3OYOuuPZLUE6dBxSGpwhk5mwuDud7JVAow==",
"license": "BSD-3-Clause"
},
"node_modules/jsencrypt": {
"version": "3.5.4",
"resolved": "https://registry.npmmirror.com/jsencrypt/-/jsencrypt-3.5.4.tgz",
"integrity": "sha512-kNjfYEMNASxrDGsmcSQh/rUTmcoRfSUkxnAz+MMywM8jtGu+fFEZ3nJjHM58zscVnwR0fYmG9sGkTDjqUdpiwA==",
"license": "MIT"
},
"node_modules/json-parse-even-better-errors": { "node_modules/json-parse-even-better-errors": {
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://repo.huaweicloud.com/repository/npm/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", "resolved": "https://repo.huaweicloud.com/repository/npm/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",
@@ -1345,6 +1366,11 @@
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true "dev": true
}, },
"crypto-js": {
"version": "4.2.0",
"resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
},
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.5.4", "version": "1.5.4",
"resolved": "https://repo.huaweicloud.com/repository/npm/electron-to-chromium/-/electron-to-chromium-1.5.4.tgz", "resolved": "https://repo.huaweicloud.com/repository/npm/electron-to-chromium/-/electron-to-chromium-1.5.4.tgz",
@@ -1464,6 +1490,16 @@
"supports-color": "^8.0.0" "supports-color": "^8.0.0"
} }
}, },
"js-base64": {
"version": "3.7.8",
"resolved": "https://registry.npmmirror.com/js-base64/-/js-base64-3.7.8.tgz",
"integrity": "sha512-hNngCeKxIUQiEUN3GPJOkz4wF/YvdUdbNL9hsBcMQTkKzboD7T/q3OYOuuPZLUE6dBxSGpwhk5mwuDud7JVAow=="
},
"jsencrypt": {
"version": "3.5.4",
"resolved": "https://registry.npmmirror.com/jsencrypt/-/jsencrypt-3.5.4.tgz",
"integrity": "sha512-kNjfYEMNASxrDGsmcSQh/rUTmcoRfSUkxnAz+MMywM8jtGu+fFEZ3nJjHM58zscVnwR0fYmG9sGkTDjqUdpiwA=="
},
"json-parse-even-better-errors": { "json-parse-even-better-errors": {
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://repo.huaweicloud.com/repository/npm/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", "resolved": "https://repo.huaweicloud.com/repository/npm/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",

View File

@@ -7,6 +7,9 @@
}, },
"dependencies": { "dependencies": {
"@dcloudio/uni-quickapp-webview": "^2.0.2-4080420251103001", "@dcloudio/uni-quickapp-webview": "^2.0.2-4080420251103001",
"jweixin-module": "^1.6.0" "jweixin-module": "^1.6.0",
"js-base64": "^3.7.2",
"jsencrypt": "^3.2.1",
"crypto-js": "^4.1.1"
} }
} }