function wxpay (orderInfo) { if(typeof orderInfo !== 'object') throw new Error('orderInfo must object type') return new Promise((resolve, reject) => { uni.requestPayment({ 'provider': 'wxpay', 'orderInfo': { 'appid': orderInfo.appid, 'noncestr': orderInfo.noncestr, 'package': 'Sign=WXPay', 'partnerid': orderInfo.partnerid, 'prepayid': orderInfo.prepayid, 'timestamp': orderInfo.timestamp, 'sign': orderInfo.sign }, success(res) { setTimeout(resolve(res), 500) }, fail(e) { reject(e) } }) }) } function alipay(orderInfo) { if(typeof orderInfo !== 'string') throw new Error('orderInfo must string type') return new Promise((resolve, reject) => { uni.requestPayment({ provider: 'alipay', orderInfo, success: function (res) { setTimeout(resolve(res), 500) }, fail: function (err) { reject(err) } }) }) } function wxmini(orderInfo) { if(typeof orderInfo !== 'object') throw new Error('orderInfo must object type') return new Promise((resolve, reject) => { uni.requestPayment({ provider: 'wxpay', timeStamp: String(Date.now()), nonceStr: orderInfo.nonceStr, package: orderInfo.package, signType: 'MD5', paySign: orderInfo.paySign, success: function (res) { setTimeout(resolve(res), 500) }, fail: function (err) { reject(err) } }) }) } function paymentAuto(orderInfo, type) { // #ifdef APP-PLUS if(type == 'wxpay') return wxpay(orderInfo) if(type == 'alipay') return alipay(orderInfo) // #endif // #ifdef MP-WEIXIN return wxmini(orderInfo) // #endif } export { paymentAuto as default, wxpay, wxmini, alipay }