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

fix: H5支付问题修复

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