donate: function() {
wx.showToast({
title: '正在创建订单',
icon: 'loading',
duration: 10000,
mask: true,
});
Cloud.run('order').then((data) => {
wx.hideToast();
data.success = () => {
wx.showToast({
title: '支付成功',
icon: 'success',
duration: 1500,
});
setTimeout(this.refreshOrders.bind(this), 1500);
}
data.fail = ({errMsg}) => this.setData({ error: errMsg });
wx.requestPayment(data);
}).catch(error => {
console.log("这里")
this.setData({ error: error.message });
wx.hideToast();
})
}
上面这是客户端的
下面的云引擎端
const order = new Order();
order.tradeId = uuid().replace(/-/g, '');
order.status = 'INIT';
order.user = request.currentUser;
order.productDescription = 'LeanCloud-小程序支付测试';
order.amount = 1; 这里支付金额如何从客户端传值过来????????????
order.ip = request.meta.remoteAddress;
if (!(order.ip && /^(?:[0-9]{1,3}.){3}[0-9]{1,3}$/.test(order.ip))) {
order.ip = '127.0.0.1';
}
order.tradeType = 'JSAPI';