chore: 重新与HuaweiPay分支比较,起点
This commit is contained in:
@@ -39,7 +39,7 @@ export default {
|
||||
},
|
||||
fail: (res) => {
|
||||
// #ifdef MP-WEIXIN
|
||||
let scene = uni.getLaunchOptionsSync().scene;
|
||||
let scene = wx.getLaunchOptionsSync().scene;
|
||||
if ([1154, 1155].indexOf(scene) == -1) {
|
||||
this.$util.showToast({
|
||||
title: res.errMsg
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
let site = null;
|
||||
try {
|
||||
site = require("../site.js"); // 适配发行模式的 site.js 导入
|
||||
} catch (e) {
|
||||
site = null; // 开发模式无 site.js 时赋值为 null
|
||||
}
|
||||
// 发行版本,配置说明
|
||||
let releaseCfg = undefined;
|
||||
try {
|
||||
|
||||
@@ -206,7 +206,6 @@ export default {
|
||||
* 获取订单结算数据
|
||||
*/
|
||||
payment() {
|
||||
|
||||
this.$api.sendRequest({
|
||||
url: this.api.payment,
|
||||
data: this.handleCreateData(),
|
||||
@@ -215,7 +214,7 @@ export default {
|
||||
let data = res.data;
|
||||
|
||||
// #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) {
|
||||
data.delivery.express_type = data.delivery.express_type.filter(item => item.name == 'express');
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
this.isMatched = 1;
|
||||
return;
|
||||
}
|
||||
let options = uni.getLaunchOptionsSync();
|
||||
let options = wx.getLaunchOptionsSync();
|
||||
this.$api.sendRequest({
|
||||
url: '/shopcomponent/api/weapp/scenecheck',
|
||||
data: {
|
||||
@@ -357,7 +357,7 @@
|
||||
out_trade_no: this.payInfo.out_trade_no,
|
||||
pay_type: payType.type,
|
||||
is_matched: this.isMatched,
|
||||
scene: uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene
|
||||
scene: uni.getStorageSync('is_test') ? 1175 : wx.getLaunchOptionsSync().scene
|
||||
},
|
||||
success: res => {
|
||||
uni.hideLoading();
|
||||
@@ -365,7 +365,7 @@
|
||||
var payData = res.data.data;
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
var scene = uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync()
|
||||
var scene = uni.getStorageSync('is_test') ? 1175 : wx.getLaunchOptionsSync()
|
||||
.scene;
|
||||
if ([1175, 1176, 1177, 1191, 1195].indexOf(scene) != -1) {
|
||||
uni.requestOrderPayment({
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<uni-popup ref="choosePaymentPopup" type="center" v-if="payInfo" :mask-click="false">
|
||||
<view class="choose-payment-popup popup" @touchmove.prevent.stop>
|
||||
<view class="popup-header">
|
||||
<text class="tit">支付方式-测试</text>
|
||||
<text class="tit">支付方式</text>
|
||||
<text class="iconfont icon-close" @click="close()"></text>
|
||||
</view>
|
||||
<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';
|
||||
|
||||
// #ifdef H5
|
||||
import { Weixin } from 'common/js/wx-jssdk.js';
|
||||
import {
|
||||
Weixin
|
||||
} from 'common/js/wx-jssdk.js';
|
||||
// #endif
|
||||
|
||||
// ========== 引入三端支付工具类(核心:适配官方规范) ==========
|
||||
import { getWechatPay } from '@/utils/wechat-pay.js';
|
||||
import { getAlipayPay } from '@/utils/alipay-pay.js';
|
||||
import { getHuaweiPay } from '@/utils/huawei-pay.js';
|
||||
// 引入统一支付工具类
|
||||
import { invokeWechatPay, invokeAlipay, invokeHuaweiPay } from '../../common/js/payCore.js';
|
||||
|
||||
export default {
|
||||
name: 'payment',
|
||||
@@ -76,24 +76,27 @@ export default {
|
||||
return {
|
||||
payIndex: 0,
|
||||
payTypeList: [
|
||||
// 所有端都显示微信支付
|
||||
{
|
||||
name: '微信支付',
|
||||
icon: 'icon-weixin1',
|
||||
type: 'wechatpay'
|
||||
},
|
||||
// 所有端都显示支付宝支付
|
||||
// #ifdef H5 || MP-ALIPAY
|
||||
{
|
||||
name: '支付宝支付',
|
||||
icon: 'icon-zhifubaozhifu-',
|
||||
type: 'alipay'
|
||||
},
|
||||
// 所有端都显示华为支付
|
||||
// #endif
|
||||
// #ifdef H5 || MP-WEIXIN
|
||||
{
|
||||
name: '微信支付',
|
||||
icon: 'icon-weixin1',
|
||||
type: 'wechatpay'
|
||||
},
|
||||
// #endif
|
||||
// #ifdef H5 || QUICKAPP-HUAWEI
|
||||
{
|
||||
name: '华为支付',
|
||||
icon: 'icon-zhekou',
|
||||
type: 'huaweipay'
|
||||
},
|
||||
// #endif
|
||||
{
|
||||
name: '线下支付',
|
||||
icon: 'icondiy icon-yuezhifu',
|
||||
@@ -112,17 +115,11 @@ export default {
|
||||
//重置是否已完成,没有完成不能调用api/pay/pay
|
||||
resetPayComplete: true,
|
||||
repeatFlag: false,
|
||||
// ========== 支付工具类实例 ==========
|
||||
wechatPay: null,
|
||||
alipayPay: null,
|
||||
huaweiPay: null
|
||||
};
|
||||
},
|
||||
created(e) {
|
||||
this.getPayType();
|
||||
if (this.balanceUsable) this.getBalanceConfig();
|
||||
// ========== 初始化三端支付工具类(填写官方申请的参数) ==========
|
||||
this.initPayUtils();
|
||||
},
|
||||
computed: {
|
||||
balanceDeduct() {
|
||||
@@ -152,34 +149,6 @@ export default {
|
||||
}
|
||||
},
|
||||
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调用
|
||||
*/
|
||||
@@ -193,6 +162,7 @@ export default {
|
||||
} else {
|
||||
uni.removeStorageSync('offlinepay');
|
||||
}
|
||||
|
||||
},
|
||||
close() {
|
||||
this.$emit('close');
|
||||
@@ -294,156 +264,87 @@ export default {
|
||||
// #ifdef H5
|
||||
pay() {
|
||||
var payType = this.payTypeList[this.payIndex];
|
||||
var return_url = '';
|
||||
if (this.payInfo.event == 'BlindboxGoodsOrderPayNotify') {
|
||||
return_url = '/pages_promotion/blindbox/index?outTradeNo=';
|
||||
} else {
|
||||
return_url = '/pages_tool/pay/result?code=';
|
||||
if (!payType || payType.type === 'offlinepay') {
|
||||
// 线下支付仍使用原有逻辑
|
||||
this.payOffline();
|
||||
return;
|
||||
}
|
||||
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':
|
||||
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;
|
||||
// 使用统一支付工具类进行支付
|
||||
this.invokeUnifiedPay(payType.type);
|
||||
},
|
||||
|
||||
// ========== 华为支付(H5端,符合官方RSA签名规范) ==========
|
||||
case 'huaweipay':
|
||||
try {
|
||||
this.repeatFlag = false;
|
||||
const orderInfo = {
|
||||
productId: 'PROD_' + this.payInfo.out_trade_no,
|
||||
productName: '订单支付',
|
||||
price: this.payMoney
|
||||
};
|
||||
// 创建华为订单(带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;
|
||||
/**
|
||||
* 统一支付调用方法(使用新的支付工具类)
|
||||
*/
|
||||
async invokeUnifiedPay(payType) {
|
||||
try {
|
||||
let payResult;
|
||||
const amount = this.payMoney;
|
||||
const outTradeNo = this.payInfo.out_trade_no;
|
||||
const subject = '订单支付';
|
||||
|
||||
// ========== 线下支付(保留原有逻辑) ==========
|
||||
case 'offlinepay':
|
||||
this.$util.redirectTo('/pages_tool/pay/offlinepay', {
|
||||
outTradeNo: this.payInfo.out_trade_no
|
||||
});
|
||||
this.repeatFlag = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.$util.showToast({
|
||||
title: res.message
|
||||
});
|
||||
this.repeatFlag = false;
|
||||
}
|
||||
},
|
||||
fail: res => {
|
||||
uni.hideLoading();
|
||||
this.$util.showToast({
|
||||
title: 'request:fail'
|
||||
});
|
||||
this.repeatFlag = false;
|
||||
// 根据支付类型调用对应的支付方法
|
||||
switch (payType) {
|
||||
case 'wechatpay':
|
||||
payResult = await invokeWechatPay(outTradeNo, amount, subject);
|
||||
break;
|
||||
case 'alipay':
|
||||
payResult = await invokeAlipay(outTradeNo, amount, subject);
|
||||
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 {
|
||||
// 微信小程序/华为快应用中显示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() {
|
||||
this.timer = setInterval(() => {
|
||||
this.$api.sendRequest({
|
||||
@@ -468,142 +369,17 @@ export default {
|
||||
// #ifdef MP
|
||||
pay() {
|
||||
var payType = this.payTypeList[this.payIndex];
|
||||
this.$api.sendRequest({
|
||||
url: '/api/pay/pay',
|
||||
data: {
|
||||
out_trade_no: this.payInfo.out_trade_no,
|
||||
pay_type: payType ? payType.type : '',
|
||||
scene: uni.getStorageSync('is_test') ? 1175 : uni.getLaunchOptionsSync().scene,
|
||||
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;
|
||||
}
|
||||
if (!payType || payType.type === 'offlinepay') {
|
||||
// 线下支付仍使用原有逻辑
|
||||
this.$util.redirectTo('/pages_tool/pay/offlinepay', {
|
||||
outTradeNo: this.payInfo.out_trade_no
|
||||
});
|
||||
this.repeatFlag = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
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;
|
||||
}
|
||||
});
|
||||
// 小程序端也使用统一支付工具类
|
||||
this.invokeUnifiedPay(payType.type);
|
||||
},
|
||||
// #endif
|
||||
/**
|
||||
@@ -752,6 +528,8 @@ export default {
|
||||
color: #00a0e9;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.icon-checkboxblank {
|
||||
font-size: 40rpx;
|
||||
color: $color-line;
|
||||
|
||||
42
main.js
42
main.js
@@ -56,41 +56,19 @@ import NsLogin from "@/components/ns-login/ns-login.vue"
|
||||
Vue.component('ns-login', NsLogin);
|
||||
|
||||
import PrivacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
|
||||
// 只保留一次组件注册(删除重复行)
|
||||
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("登录授权失败")
|
||||
});
|
||||
});
|
||||
};
|
||||
// ========== 新增:注册diy系列组件 ==========
|
||||
import DiyBottomNav from '@/components/diy-components/diy-bottom-nav.vue'
|
||||
import DiyGroup from '@/components/diy-components/diy-group.vue'
|
||||
import DiyCategory from '@/components/diy-components/diy-category.vue'
|
||||
import DiyIcon from '@/components/diy-components/diy-icon.vue' // 补充diy-icon
|
||||
|
||||
// 只创建一次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({
|
||||
...App,
|
||||
store
|
||||
|
||||
240
manifest.json
240
manifest.json
@@ -1,23 +1,27 @@
|
||||
{
|
||||
"name":"lucky_weapp",
|
||||
"appid":"__UNI__A3A4830",
|
||||
"description":"",
|
||||
"versionName":"1.0.0",
|
||||
"versionCode":"100",
|
||||
"transformPx":false,
|
||||
"app-plus":{
|
||||
"usingComponents":true,
|
||||
"nvueCompiler":"uni-app",
|
||||
"splashscreen":{
|
||||
"alwaysShowBeforeRender":true,
|
||||
"waiting":true,
|
||||
"autoclose":true,
|
||||
"delay":0
|
||||
"name" : "lucky_weapp",
|
||||
"appid" : "__UNI__A3A4830",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
"usingComponents" : true,
|
||||
"nvueCompiler" : "uni-app",
|
||||
"splashscreen" : {
|
||||
"alwaysShowBeforeRender" : true,
|
||||
"waiting" : true,
|
||||
"autoclose" : true,
|
||||
"delay" : 0
|
||||
},
|
||||
"modules":{},
|
||||
"distribute":{
|
||||
"android":{
|
||||
"permissions":[
|
||||
/* 模块配置 */
|
||||
"modules" : {},
|
||||
/* 应用发布信息 */
|
||||
"distribute" : {
|
||||
/* android打包配置 */
|
||||
"android" : {
|
||||
"permissions" : [
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
|
||||
@@ -42,164 +46,90 @@
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||
]
|
||||
},
|
||||
"ios":{},
|
||||
"sdkConfigs":{
|
||||
"ad":{},
|
||||
// App端支付SDK配置(适配原生App支付)
|
||||
"payment":{
|
||||
"weixin":{
|
||||
"appid":"wx1234567890abcdef", // 替换:微信开放平台AppID
|
||||
"universalLink":"https://yourdomain.com/apple-app-site-association" // 替换:iOS微信Universal Link
|
||||
},
|
||||
"alipay":{
|
||||
"appid":"2024000000000000" // 替换:支付宝开放平台AppID
|
||||
},
|
||||
"huawei":{
|
||||
"appid":"12345678" // 替换:华为开发者联盟AppID(应用市场申请)
|
||||
}
|
||||
}
|
||||
/* ios打包配置 */
|
||||
"ios" : {},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {
|
||||
"ad" : {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mp-weixin":{
|
||||
"appid":"wxa8f94045d9c2fc10", // 你的微信小程序AppID(已保留)
|
||||
"setting":{
|
||||
"urlCheck":false,
|
||||
"postcss":false,
|
||||
"es6":true,
|
||||
"minified":true
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "wxa8f94045d9c2fc10",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
"postcss" : false,
|
||||
"es6" : true,
|
||||
"minified" : true
|
||||
},
|
||||
"usingComponents":true,
|
||||
"permission":{
|
||||
"scope.userLocation":{
|
||||
"desc":"为了更好地为您提供服务"
|
||||
"usingComponents" : true,
|
||||
"permission" : {
|
||||
"scope.userLocation" : {
|
||||
"desc" : "为了更好地为您提供服务"
|
||||
},
|
||||
"scope.writePhotosAlbum":{
|
||||
"desc":"为了更好地为您提供服务"
|
||||
"scope.writePhotosAlbum" : {
|
||||
"desc" : "为了更好地为您提供服务"
|
||||
}
|
||||
},
|
||||
"useDeprecatedAPI":{
|
||||
"getSystemInfoSync":false
|
||||
},
|
||||
"requiredPrivateInfos":["chooseLocation","getLocation","chooseAddress"],
|
||||
"__usePrivacyCheck__":true,
|
||||
"optimization":{
|
||||
"subPackages":true
|
||||
},
|
||||
// 微信小程序支付核心配置(官方规范)
|
||||
"pay":{
|
||||
"merchantId":"1688888888", // 替换:你的微信支付商户号(商户平台获取)
|
||||
"keyPath":"cert/apiclient_key.p12" // 可选:微信支付证书路径(退款/分账等接口需用)
|
||||
},
|
||||
"sdkConfigs":{
|
||||
"jssdk":{
|
||||
"apis":["chooseWXPay"] // 必须:开启微信JSSDK支付接口(H5/小程序共用)
|
||||
}
|
||||
"requiredPrivateInfos" : [ "chooseLocation", "getLocation", "chooseAddress" ],
|
||||
"__usePrivacyCheck__" : true,
|
||||
"optimization" : {
|
||||
"subPackages" : true
|
||||
}
|
||||
},
|
||||
"mp-alipay":{
|
||||
"usingComponents":true,
|
||||
"appid":"2024000000000000", // 替换:你的支付宝小程序AppID(开放平台获取)
|
||||
// 支付宝小程序支付配置(官方规范)
|
||||
"pay":{
|
||||
"merchantId":"2088888888888888" // 替换:你的支付宝支付商户号
|
||||
}
|
||||
"mp-alipay" : {
|
||||
"usingComponents" : true,
|
||||
"appid" : ""
|
||||
},
|
||||
"mp-baidu":{
|
||||
"usingComponents":true
|
||||
"mp-baidu" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"mp-toutiao":{
|
||||
"usingComponents":true
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"h5":{
|
||||
"sdkConfigs":{
|
||||
"maps":{
|
||||
"qqmap":{
|
||||
"key":"TUHBZ-CNWKU-UHAVP-GZQ26-HNZFO-3YBF4" // 已保留
|
||||
},
|
||||
// H5端微信/华为支付JSSDK配置
|
||||
"weixin":{
|
||||
"appid":"wxa8f94045d9c2fc10" // 和微信小程序AppID一致(无需修改)
|
||||
},
|
||||
"huawei":{
|
||||
"appid":"12345678" // 替换:华为开发者联盟AppID
|
||||
"h5" : {
|
||||
"sdkConfigs" : {
|
||||
"maps" : {
|
||||
"qqmap" : {
|
||||
"key" : "TUHBZ-CNWKU-UHAVP-GZQ26-HNZFO-3YBF4"
|
||||
}
|
||||
}
|
||||
},
|
||||
"router":{
|
||||
"mode":"hash", // 必须:hash模式适配支付回调跳转
|
||||
"base":"/hwapp/"
|
||||
"router" : {
|
||||
"mode" : "history",
|
||||
"base" : "/hwapp/"
|
||||
},
|
||||
"title":"华为支付演示",
|
||||
"devServer":{
|
||||
"https":false,
|
||||
// H5端支付接口跨域代理(解决浏览器跨域限制)
|
||||
"proxy":{
|
||||
// 华为支付接口代理
|
||||
"/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":""
|
||||
}
|
||||
}
|
||||
"title" : " ",
|
||||
"devServer" : {
|
||||
"https" : false
|
||||
},
|
||||
"optimization" : {
|
||||
"treeShaking" : {
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"optimization":{
|
||||
"treeShaking":{
|
||||
"enable":false
|
||||
}
|
||||
"domain" : " ",
|
||||
"unipush" : {
|
||||
"enable" : false
|
||||
},
|
||||
"domain":" ",
|
||||
"unipush":{
|
||||
"enable":false
|
||||
"async" : {
|
||||
"loading" : "",
|
||||
"error" : "",
|
||||
"delay" : 0,
|
||||
"timeout" : 3000
|
||||
},
|
||||
"async":{
|
||||
"loading":"",
|
||||
"error":"",
|
||||
"delay":0,
|
||||
"timeout":3000
|
||||
},
|
||||
"template":""
|
||||
"template" : ""
|
||||
},
|
||||
"uniStatistics":{
|
||||
"version":"2"
|
||||
"uniStatistics" : {
|
||||
"version" : "2"
|
||||
},
|
||||
"sassImplementationName":"node-sass",
|
||||
"quickapp-webview":{
|
||||
"package":"com.jieganfsj.fivegshop", // 已保留:华为快应用包名
|
||||
"minPlatformVersion":1070,
|
||||
"versionName":"1.0.0",
|
||||
"versionCode":0,
|
||||
// 华为快应用支付核心配置(官方规范)
|
||||
"sdkConfigs":{
|
||||
"huawei":{
|
||||
"appid":"12345678", // 替换:华为开发者联盟AppID
|
||||
"payment":{
|
||||
"merchantId":"88888888" // 替换:华为支付商户号(商户平台获取)
|
||||
}
|
||||
}
|
||||
},
|
||||
// 华为快应用必须声明的支付权限(官方强制)
|
||||
"features":[
|
||||
{"name":"system.pay"},
|
||||
{"name":"huawei.pay"}
|
||||
]
|
||||
"sassImplementationName" : "node-sass",
|
||||
/** 快应用配置 **/
|
||||
"quickapp-webview" : {
|
||||
"package" : "com.jieganfsj.fivegshop",
|
||||
"minPlatformVersion" : 1070,
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : 0
|
||||
}
|
||||
}
|
||||
38
package-lock.json
generated
38
package-lock.json
generated
@@ -1,14 +1,11 @@
|
||||
{
|
||||
"name": "lucky_shop",
|
||||
"name": "frontend",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@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"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -458,12 +455,6 @@
|
||||
"dev": true,
|
||||
"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": {
|
||||
"version": "1.5.4",
|
||||
"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_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": {
|
||||
"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",
|
||||
@@ -1366,11 +1345,6 @@
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"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": {
|
||||
"version": "1.5.4",
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"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",
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@dcloudio/uni-quickapp-webview": "^2.0.2-4080420251103001",
|
||||
"jweixin-module": "^1.6.0",
|
||||
"js-base64": "^3.7.2",
|
||||
"jsencrypt": "^3.2.1",
|
||||
"crypto-js": "^4.1.1"
|
||||
"jweixin-module": "^1.6.0"
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@
|
||||
"disableSWC": true
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.16.1",
|
||||
"libVersion": "3.12.0",
|
||||
"appid": "wx29215aa1bd97bbd6",
|
||||
"projectname": "niushop_b2c_v4_uniapp",
|
||||
"isGameTourist": false,
|
||||
|
||||
Reference in New Issue
Block a user