function phonecall(e) { let phone = e.currentTarget.dataset.tel; wx.makePhoneCall({ phoneNumber: phone }) } function pay(that){ wx.requestPayment({ 'timeStamp': that.data.pay_info.result.timestamp, 'nonceStr': that.data.pay_info.result.noncestr, 'package': that.data.pay_info.result.package, 'signType': that.data.pay_info.result.signtype, 'paySign': that.data.pay_info.result.sign, 'success': function (res) { // 支付成功 that.data.wish_box.show_reminder = true; that.setData({ wish_box: that.data.wish_box }) setTimeout(function () { that.data.wish_box.show_reminder = false; that.setData({ wish_box: that.data.wish_box }) wx.navigateTo({ url: '../make_a_wish/index?uniqid=' + that.data.wish_box.uniqid + '&token=' + that.data.wish_box.token }) }, 2000) }, 'fail': function (res) { } }) } function get_wish_status(that, config,app,source,sourceid) { wx.request({ url: config.wish.init, data: { session: wx.getStorageSync('session'), source: source, sourceid: sourceid }, method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT header: app.globalData.header, success: function (res) { var data = app.return_data(res); // istype = 1 and status = 1 已支付 直接走提交步骤 // istype = 0 and status = 1 赠送的,无需支付 直接走提交步骤 // status = 0 调用支付 pay_info 支付参数,支付成功后 直接走提交步骤 if (data.istype == 0 && data.status == 1) { that.data.wish_box.box = 'free'; } else if (data.istype == 1 && data.status == 0) { that.data.wish_box.box = 'charge'; that.data.pay_info = data.pay_info; } else if (data.istype == 1 && data.status == 1) { that.data.wish_box.box = 'paid'; } that.data.wish_box.istype = data.istype; that.data.wish_box.money = data.money; that.data.wish_box.status = data.status; that.data.wish_box.token = data.token; that.data.wish_box.uniqid = data.uniqid; that.setData({ wish_box: that.data.wish_box }) if (that.data.wish_box.box == 'paid') { // 已经支付过了,直接跳走 wx.navigateTo({ url: '../make_a_wish/index?uniqid=' + that.data.wish_box.uniqid + '&token=' + that.data.wish_box.token }) } that.data.wish_box.show = true; that.setData({ wish_box: that.data.wish_box }) }, fail: function (res) { }, complete: function () { } }) } function to_wish(that){ that.get_wish_status } function close_wish_box(that){ that.data.wish_box.show = false; that.setData({ wish_box: that.data.wish_box }) } module.exports = { phonecall: phonecall, pay:pay, to_wish: to_wish, get_wish_status: get_wish_status, close_wish_box: close_wish_box }