Commit e2303f39 authored by 郭志伟's avatar 郭志伟

fix: H5支付问题修复

parent 92c11cbc
......@@ -2,11 +2,11 @@
* @Description: 支付微信h5, jsapi, 第三方收银台,跳转)
* @Date: 2020-07-28 15:03:52
* @LastEditors: gzw
* @LastEditTime: 2020-08-13 14:14:32
* @LastEditTime: 2020-08-24 19:59:04
*/
// import cherry from "@qg/cherry-ui";
// import qs from "qs";
import qs from "qs";
// const { Notify } = cherry;
/**
......@@ -55,12 +55,12 @@ function payByWeixinJsapi(info = {}, callback) {
* @param {type}
* @return:
*/
function payByWeixinH5() {
// if (info.url) return;
// const currentPath = encodeURIComponent(
// window.location.href + qs.stringify(info.params, { encode: true, addQueryPrefix: true })
// );
// window.location.href = `${info.url}&redirect_url=${currentPath}`;
function payByWeixinH5(info) {
if (!info.url) return;
const currentPath = encodeURIComponent(
window.location.href + qs.stringify(info.params, { encode: true, addQueryPrefix: true })
);
window.location.href = `${info.url}&redirect_url=${currentPath}`;
}
/**
......@@ -71,12 +71,12 @@ function payByWeixinH5() {
* @param {type}
* @return:
*/
function payByThirdPartyCashier() {
// if (info.url) return;
// const currentPath = encodeURIComponent(
// window.location.href + qs.stringify(info.params, { encode: true, addQueryPrefix: true })
// );
// window.location.href = `${info.url}&redirect_uri=${currentPath}`;
function payByThirdPartyCashier(info) {
if (!info.url) return;
const currentPath = encodeURIComponent(
window.location.href + qs.stringify(info.params, { encode: true, addQueryPrefix: true })
);
window.location.href = `${info.url}&redirect_uri=${currentPath}`;
}
/**
......@@ -88,7 +88,7 @@ function payByThirdPartyCashier() {
*/
export function payByWay(type = "THIRD", payInfo) {
return new Promise(resolve => {
if (type === "JSAPI") {
if (type === "JSAPI" && !payInfo.url) {
payByWeixinJsapi(payInfo, function() {
// if (e === "ok") {
// Notify({ type: "success", message: "支付成功" });
......@@ -98,10 +98,13 @@ export function payByWay(type = "THIRD", payInfo) {
resolve();
});
} else if (type === "MWEB") {
if (payInfo.url.indexOf("weixin") > -1) {
payByWeixinH5(payInfo);
resolve();
} else {
payByThirdPartyCashier(payInfo);
}
resolve();
} else {
resolve();
}
});
......
......@@ -60,7 +60,7 @@ export default {
state: 1
}
};
} else if (tradeType === "JSAPI") {
} else if (tradeType === "JSAPI" && !res.payUrl) {
payInfo = res.payInfo;
} else {
payInfo = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment