"use strict"; const common_vendor = require("../../common/vendor.js"); const enums_appEnums = require("../../enums/appEnums.js"); const utils_client = require("../client.js"); class Alipay { init(name, pay) { pay[name] = this; } openNewPage(options) { const alipayPage = window.open("", "_self"); alipayPage.document.body.innerHTML = options; alipayPage.document.forms[0].submit(); } async run(options) { try { const res = await utils_client.handleClientEvent({ H5: () => { return new Promise((resolve) => { this.openNewPage(options); resolve(enums_appEnums.PayStatusEnum.PENDING); }); }, OA_WEIXIN: () => { return new Promise((resolve) => { this.openNewPage(options); resolve(enums_appEnums.PayStatusEnum.PENDING); }); }, ANDROID: () => { return new Promise((resolve, reject) => { common_vendor.index.requestPayment({ provider: "alipay", orderInfo: options, success() { resolve(enums_appEnums.PayStatusEnum.SUCCESS); }, fail() { resolve(enums_appEnums.PayStatusEnum.FAIL); } }); }); }, IOS: () => { return new Promise((resolve, reject) => { common_vendor.index.requestPayment({ provider: "alipay", orderInfo: options, success() { resolve(enums_appEnums.PayStatusEnum.SUCCESS); }, fail() { resolve(enums_appEnums.PayStatusEnum.FAIL); } }); }); } }); return res; } catch (error) { return Promise.reject(error); } } } exports.Alipay = Alipay;