123 lines
3.0 KiB
JavaScript
123 lines
3.0 KiB
JavaScript
var app = getApp();
|
||
var yz_pay = require("../../../mycomponent/yz_pay/yz_pay");
|
||
Page({
|
||
behaviors: [yz_pay],
|
||
data: {
|
||
language: "",
|
||
isclick: true,
|
||
order_id: "",
|
||
orderData: null,
|
||
balance: 0,
|
||
payParams: "",
|
||
info_form: {},
|
||
order_sn: "",
|
||
money: "",
|
||
buttons: [],
|
||
pay_sn: "订单编号",
|
||
order_pay_id: "",
|
||
uid: "",
|
||
pid: "",
|
||
status: "",
|
||
},
|
||
fromChild(e){
|
||
if(this.data.money=='0.00') {
|
||
// 0元
|
||
this.sureBtn();
|
||
}else {
|
||
let datas = e.detail.submitArr;
|
||
this.confirm(datas);
|
||
}
|
||
},
|
||
onLoad: function (options) {
|
||
console.log(options.id);
|
||
this.getPaycreate(options.id, options.supplier_id);
|
||
},
|
||
onReady: function () {
|
||
let language = wx.getStorageSync("langIndex");
|
||
this.setData({ language: language.en });
|
||
// 页面渲染完成
|
||
},
|
||
|
||
confirm: function (datas) {
|
||
let type = datas.value;
|
||
let btn = datas.submitArr;
|
||
this.handlePay(btn, type);
|
||
},
|
||
|
||
getPaycreate(id, supplier_id) {
|
||
let that = this;
|
||
let _id = [];
|
||
// 注意ids参数后台可以设置数组一键支付,数组!!!!
|
||
let stringId = id;
|
||
_id = stringId.toString().split(",");
|
||
let urlStr = app.getNetAddresss("plugin.supplier.frontend.insOrder.create");
|
||
let json = {
|
||
ids: _id,
|
||
supplier_id: supplier_id,
|
||
};
|
||
app._postNetWork({
|
||
url: urlStr,
|
||
data: json,
|
||
success: function (resdata) {
|
||
var res = resdata.data;
|
||
console.log(res);
|
||
if (res.result == 1) {
|
||
console.log(res.data.order_ids);
|
||
that.setData({
|
||
order_ids: res.data.order_ids,
|
||
});
|
||
that.getMultipleOrderInfo();
|
||
} else {
|
||
wx.showToast({
|
||
icon: "none",
|
||
title: res.msg,
|
||
duration: 1500,
|
||
});
|
||
}
|
||
},
|
||
fail: function (res) {
|
||
console.log(res);
|
||
},
|
||
});
|
||
},
|
||
getMultipleOrderInfo() {
|
||
let that = this;
|
||
var _url = app.getNetAddresss("order.merge-pay");
|
||
// console.log(options)
|
||
// if (options.status && options.status == 2) {
|
||
// 合并支付
|
||
if (typeof that.data.order_ids == "string") {
|
||
_url += "&order_ids=" + that.data.order_ids;
|
||
} else {
|
||
_url += "&order_ids=" + JSON.parse(that.data.order_ids).toString();
|
||
}
|
||
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
var _data = res.data.data;
|
||
console.log("PayResult::::", _data);
|
||
if (res.data.result == 1) {
|
||
this.hanleIcon(_data);
|
||
that.setData({
|
||
// 购物车ID
|
||
order_sn: _data.order_pay.pay_sn,
|
||
balance: _data.member.credit2,
|
||
money: _data.order_pay.amount,
|
||
uid: _data.order_pay.uid,
|
||
buttons: _data.buttons,
|
||
});
|
||
that.data.order_pay_id = _data.order_pay.id; // 支付id
|
||
} else {
|
||
wx.showToast({
|
||
title: res.data.msg,
|
||
icon: "success",
|
||
duration: 2000,
|
||
});
|
||
console.log("错误", res.data.msg);
|
||
}
|
||
},
|
||
});
|
||
},
|
||
});
|