var url = require('../constant/url.js') var businessT = require('../tool/business-tool.js') import Net from './../tool/net.js' var net = new Net() function prepay(obj) { wx.login({ success: res => { // res.code 可以到后台换取 openId, sessionKey, unionId net.connectNeedLogin({ url: url.app_host + url.prepay, data: { code: res.code }, success: obj.success, fail: obj.fail }) }, fail: obj.fail }) } function wxPay (obj) { if (businessT.isDebug()) { obj.success() return } wx.requestPayment({ timeStamp: obj.data.wx.timestamp, nonceStr: obj.data.wx.noncestr, package: obj.data.wx.package, signType: 'MD5', paySign: obj.data.wx.sign, success: obj.success, fail: obj.fail }) } module.exports = { prepay: prepay, wxPay: wxPay }