Commit 1daa76d5 by 郑炬波

feat: zf

parent c8c1fdcf
{ {
"name": "@ydl-packages/toolkit", "name": "@ydl-packages/toolkit",
"version": "1.0.1-next.22", "version": "1.0.1-next.24",
"description": "", "description": "",
"main": "./dist/index.umd.js", "main": "./dist/index.umd.js",
"scripts": { "scripts": {
......
...@@ -156,12 +156,6 @@ export class Payment { ...@@ -156,12 +156,6 @@ export class Payment {
success: false, success: false,
errorType: PayError.VALIDATE errorType: PayError.VALIDATE
} }
} else if (decodeURIComponent(redirectUrl) === redirectUrl) {
return {
errorMessage: PayErrorMessage.WECHAT_REDIRECT_URL_ENCODE,
success: false,
errorType: PayError.VALIDATE
}
} }
} else { } else {
return { return {
...@@ -203,6 +197,9 @@ export class Payment { ...@@ -203,6 +197,9 @@ export class Payment {
// validate end <<< // validate end <<<
// hack, 后端微信redirectUrl用的quitUrl // hack, 后端微信redirectUrl用的quitUrl
const payChannel = this.getPayChannel(payType) const payChannel = this.getPayChannel(payType)
if (payChannel === PayChannel.WX_MWEB || payChannel === PayChannel.WX_JSAPI) {
quitUrl = redirectUrl
}
const doUnifiedParams: DoUnifiedParams = { const doUnifiedParams: DoUnifiedParams = {
returnUrl, returnUrl,
quitUrl, quitUrl,
...@@ -285,16 +282,18 @@ export class Payment { ...@@ -285,16 +282,18 @@ export class Payment {
}) })
} }
static async loopValidateOrderState(count = 0, callBack: OrderStateCallBack): Promise<void> { static async loopValidateOrderState(count = 0, callBack: OrderStateCallBack, polltime = 3000): Promise<void> {
const [, queryString] = window.location.href.split('?') const [, queryString] = window.location.href.split('?')
const query = queryString ? qs.parse(queryString, {ignoreQueryPrefix: true}) : {} const query = queryString ? qs.parse(queryString, {ignoreQueryPrefix: true}) : {}
const returnParams: BackInfo = {payId: Number(query[BACK_PAY_ID]), orderId: Number(query[BACK_ORDER_ID])} const returnParams: BackInfo = {payId: Number(query[BACK_PAY_ID]), orderId: Number(query[BACK_ORDER_ID])}
let timer: any = null;
const checkLoop = () => { const checkLoop = () => {
if (--count > 0) { if (--count > 0) {
setTimeout(() => { timer = setTimeout(() => {
this.loopValidateOrderState(count, callBack) this.loopValidateOrderState(count, callBack, polltime)
}, 1000) }, polltime)
} else { } else {
clearInterval(timer);
callBack({isPay: false, ...returnParams}) callBack({isPay: false, ...returnParams})
} }
} }
...@@ -304,6 +303,7 @@ export class Payment { ...@@ -304,6 +303,7 @@ export class Payment {
payId: query[BACK_PAY_ID] payId: query[BACK_PAY_ID]
}) })
if (res.code === '200' && res.data === true) { if (res.code === '200' && res.data === true) {
clearInterval(timer);
callBack({isPay: true, ...returnParams}) callBack({isPay: true, ...returnParams})
} else { } else {
checkLoop() checkLoop()
......
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