chore: 重新与HuaweiPay分支比较,起点

This commit is contained in:
Zhukj
2025-12-10 11:20:42 +08:00
parent 5bd0881946
commit f1c01833e4
10 changed files with 209 additions and 569 deletions

View File

@@ -39,7 +39,7 @@ export default {
}, },
fail: (res) => { fail: (res) => {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
let scene = uni.getLaunchOptionsSync().scene; let scene = wx.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,9 +1,3 @@
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,7 +206,6 @@ export default {
* 获取订单结算数据 * 获取订单结算数据
*/ */
payment() { payment() {
this.$api.sendRequest({ this.$api.sendRequest({
url: this.api.payment, url: this.api.payment,
data: this.handleCreateData(), data: this.handleCreateData(),
@@ -215,7 +214,7 @@ export default {
let data = res.data; let data = res.data;
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
var scene = uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene; var scene = uni.getStorageSync('is_test') ? 1175 : wx.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 = uni.getLaunchOptionsSync(); let options = wx.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 : uni.getLaunchOptionsSync().scene scene: uni.getStorageSync('is_test') ? 1175 : wx.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 : uni.getLaunchOptionsSync() var scene = uni.getStorageSync('is_test') ? 1175 : wx.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 { Weixin } from 'common/js/wx-jssdk.js'; import {
Weixin
} from 'common/js/wx-jssdk.js';
// #endif // #endif
// ========== 引入三端支付工具类(核心:适配官方规范) ========== // 引入统一支付工具类
import { getWechatPay } from '@/utils/wechat-pay.js'; import { invokeWechatPay, invokeAlipay, invokeHuaweiPay } from '../../common/js/payCore.js';
import { getAlipayPay } from '@/utils/alipay-pay.js';
import { getHuaweiPay } from '@/utils/huawei-pay.js';
export default { export default {
name: 'payment', name: 'payment',
@@ -76,24 +76,27 @@ export default {
return { return {
payIndex: 0, payIndex: 0,
payTypeList: [ payTypeList: [
// 所有端都显示微信支付 // #ifdef H5 || MP-ALIPAY
{
name: '微信支付',
icon: 'icon-weixin1',
type: 'wechatpay'
},
// 所有端都显示支付宝支付
{ {
name: '支付宝支付', name: '支付宝支付',
icon: 'icon-zhifubaozhifu-', icon: 'icon-zhifubaozhifu-',
type: 'alipay' type: 'alipay'
}, },
// 所有端都显示华为支付 // #endif
// #ifdef H5 || MP-WEIXIN
{
name: '微信支付',
icon: 'icon-weixin1',
type: 'wechatpay'
},
// #endif
// #ifdef H5 || QUICKAPP-HUAWEI
{ {
name: '华为支付', name: '华为支付',
icon: 'icon-zhekou', icon: 'icon-zhekou',
type: 'huaweipay' type: 'huaweipay'
}, },
// #endif
{ {
name: '线下支付', name: '线下支付',
icon: 'icondiy icon-yuezhifu', icon: 'icondiy icon-yuezhifu',
@@ -112,17 +115,11 @@ 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() {
@@ -152,34 +149,6 @@ 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调用
*/ */
@@ -193,6 +162,7 @@ export default {
} else { } else {
uni.removeStorageSync('offlinepay'); uni.removeStorageSync('offlinepay');
} }
}, },
close() { close() {
this.$emit('close'); this.$emit('close');
@@ -294,156 +264,87 @@ export default {
// #ifdef H5 // #ifdef H5
pay() { pay() {
var payType = this.payTypeList[this.payIndex]; var payType = this.payTypeList[this.payIndex];
var return_url = ''; if (!payType || payType.type === 'offlinepay') {
if (this.payInfo.event == 'BlindboxGoodsOrderPayNotify') { // 线下支付仍使用原有逻辑
return_url = '/pages_promotion/blindbox/index?outTradeNo='; this.payOffline();
} else { return;
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+签名规范) ========== // 使用统一支付工具类进行支付
case 'wechatpay': this.invokeUnifiedPay(payType.type);
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 { */
this.repeatFlag = false; async invokeUnifiedPay(payType) {
const orderInfo = { try {
productId: 'PROD_' + this.payInfo.out_trade_no, let payResult;
productName: '订单支付', const amount = this.payMoney;
price: this.payMoney const outTradeNo = this.payInfo.out_trade_no;
}; 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;
// ========== 线下支付(保留原有逻辑) ========== // 根据支付类型调用对应的支付方法
case 'offlinepay': switch (payType) {
this.$util.redirectTo('/pages_tool/pay/offlinepay', { case 'wechatpay':
outTradeNo: this.payInfo.out_trade_no payResult = await invokeWechatPay(outTradeNo, amount, subject);
}); break;
this.repeatFlag = false; case 'alipay':
break; payResult = await invokeAlipay(outTradeNo, amount, subject);
} break;
} else { case 'huaweipay':
this.$util.showToast({ payResult = await invokeHuaweiPay(outTradeNo, amount, subject);
title: res.message break;
}); default:
this.repeatFlag = false; throw new Error('不支持的支付方式');
}
},
fail: res => {
uni.hideLoading();
this.$util.showToast({
title: 'request:fail'
});
this.repeatFlag = false;
} }
// 处理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 {
// 微信小程序/华为快应用中显示WebView
this.showPayWebView(payResult.data.payUrl);
}
} else if (payResult.code === 0) {
// 原生支付成功
this.paySuccess();
} else {
throw new Error(payResult.msg || '支付失败');
}
} 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({
@@ -468,142 +369,17 @@ export default {
// #ifdef MP // #ifdef MP
pay() { pay() {
var payType = this.payTypeList[this.payIndex]; var payType = this.payTypeList[this.payIndex];
this.$api.sendRequest({ if (!payType || payType.type === 'offlinepay') {
url: '/api/pay/pay', // 线下支付仍使用原有逻辑
data: { this.$util.redirectTo('/pages_tool/pay/offlinepay', {
out_trade_no: this.payInfo.out_trade_no, outTradeNo: this.payInfo.out_trade_no
pay_type: payType ? payType.type : '', });
scene: uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene, this.repeatFlag = false;
is_balance: this.isBalance return;
}, }
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 // 小程序端也使用统一支付工具类
var scene = uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene; this.invokeUnifiedPay(payType.type);
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
/** /**
@@ -752,6 +528,8 @@ export default {
color: #00a0e9; color: #00a0e9;
} }
.icon-checkboxblank { .icon-checkboxblank {
font-size: 40rpx; font-size: 40rpx;
color: $color-line; color: $color-line;

42
main.js
View File

@@ -56,41 +56,19 @@ 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)
// 全局登录方法(替换成你的真实后端接口地址) // ========== 新增注册diy系列组件 ==========
Vue.prototype.$doGlobalLogin = async function() { import DiyBottomNav from '@/components/diy-components/diy-bottom-nav.vue'
return new Promise((resolve, reject) => { import DiyGroup from '@/components/diy-components/diy-group.vue'
uni.login({ import DiyCategory from '@/components/diy-components/diy-category.vue'
success: async (loginRes) => { import DiyIcon from '@/components/diy-components/diy-icon.vue' // 补充diy-icon
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实例删除重复声明 Vue.component('diy-bottom-nav', DiyBottomNav) // 修正拼写错误
Vue.component('diy-group', DiyGroup)
Vue.component('diy-category', DiyCategory)
Vue.component('diy-icon', DiyIcon) // 注册diy-icon
// ========== 新增结束 ==========
const app = new Vue({ const app = new Vue({
...App, ...App,
store store

View File

@@ -1,23 +1,27 @@
{ {
"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,
"app-plus":{ /* 5+App */
"usingComponents":true, "app-plus" : {
"nvueCompiler":"uni-app", "usingComponents" : true,
"splashscreen":{ "nvueCompiler" : "uni-app",
"alwaysShowBeforeRender":true, "splashscreen" : {
"waiting":true, "alwaysShowBeforeRender" : true,
"autoclose":true, "waiting" : true,
"delay":0 "autoclose" : true,
"delay" : 0
}, },
"modules":{}, /* */
"distribute":{ "modules" : {},
"android":{ /* */
"permissions":[ "distribute" : {
/* 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\"/>",
@@ -42,164 +46,90 @@
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
] ]
}, },
"ios":{}, /* ios */
"sdkConfigs":{ "ios" : {},
"ad":{}, /* SDK */
// App端支付SDK配置适配原生App支付 "sdkConfigs" : {
"payment":{ "ad" : {}
"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":{ /* */
"appid":"wxa8f94045d9c2fc10", // 你的微信小程序AppID已保留 "mp-weixin" : {
"setting":{ "appid" : "wxa8f94045d9c2fc10",
"urlCheck":false, "setting" : {
"postcss":false, "urlCheck" : false,
"es6":true, "postcss" : false,
"minified":true "es6" : true,
"minified" : true
}, },
"usingComponents":true, "usingComponents" : true,
"permission":{ "permission" : {
"scope.userLocation":{ "scope.userLocation" : {
"desc":"为了更好地为您提供服务" "desc" : "为了更好地为您提供服务"
}, },
"scope.writePhotosAlbum":{ "scope.writePhotosAlbum" : {
"desc":"为了更好地为您提供服务" "desc" : "为了更好地为您提供服务"
} }
}, },
"useDeprecatedAPI":{ "requiredPrivateInfos" : [ "chooseLocation", "getLocation", "chooseAddress" ],
"getSystemInfoSync":false "__usePrivacyCheck__" : true,
}, "optimization" : {
"requiredPrivateInfos":["chooseLocation","getLocation","chooseAddress"], "subPackages" : true
"__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":"2024000000000000", // 替换你的支付宝小程序AppID开放平台获取 "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":"hash", // 必须hash模式适配支付回调跳转 "mode" : "history",
"base":"/hwapp/" "base" : "/hwapp/"
}, },
"title":"华为支付演示", "title" : " ",
"devServer":{ "devServer" : {
"https":false, "https" : false
// H5端支付接口跨域代理解决浏览器跨域限制 },
"proxy":{ "optimization" : {
// 华为支付接口代理 "treeShaking" : {
"/api/huawei":{ "enable" : false
"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":""
}
}
} }
}, },
"optimization":{ "domain" : " ",
"treeShaking":{ "unipush" : {
"enable":false "enable" : false
}
}, },
"domain":" ", "async" : {
"unipush":{ "loading" : "",
"enable":false "error" : "",
"delay" : 0,
"timeout" : 3000
}, },
"async":{ "template" : ""
"loading":"",
"error":"",
"delay":0,
"timeout":3000
},
"template":""
}, },
"uniStatistics":{ "uniStatistics" : {
"version":"2" "version" : "2"
}, },
"sassImplementationName":"node-sass", "sassImplementationName" : "node-sass",
"quickapp-webview":{ /** **/
"package":"com.jieganfsj.fivegshop", // 已保留:华为快应用包名 "quickapp-webview" : {
"minPlatformVersion":1070, "package" : "com.jieganfsj.fivegshop",
"versionName":"1.0.0", "minPlatformVersion" : 1070,
"versionCode":0, "versionName" : "1.0.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,14 +1,11 @@
{ {
"name": "lucky_shop", "name": "frontend",
"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": {
@@ -458,12 +455,6 @@
"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",
@@ -623,18 +614,6 @@
"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",
@@ -1366,11 +1345,6 @@
"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",
@@ -1490,16 +1464,6 @@
"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,9 +7,6 @@
}, },
"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"
} }
} }

View File

@@ -49,7 +49,7 @@
"disableSWC": true "disableSWC": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.16.1", "libVersion": "3.12.0",
"appid": "wx29215aa1bd97bbd6", "appid": "wx29215aa1bd97bbd6",
"projectname": "niushop_b2c_v4_uniapp", "projectname": "niushop_b2c_v4_uniapp",
"isGameTourist": false, "isGameTourist": false,