1290 lines
40 KiB
JavaScript
1290 lines
40 KiB
JavaScript
import {
|
||
payKeyboardAsync
|
||
} from "../payKeyboard/PayKeyboardAsync";
|
||
/**
|
||
* 目前商城主要有三种订单支付流程
|
||
* 1、recharge充值支付 主要使用订单号ordersn 使用rechargePay方法
|
||
* 2、打赏类的支付(没有订单号) 直接用金额请求接口 使用handleOtherPay方法
|
||
* 3、商城订单支付类型 (有订单号) 支付后触发跳转 使用handlePay方法
|
||
*
|
||
* var yz_pay = require("../../../mycomponent/yz_pay/yz_pay"); //引入支付方法
|
||
* behaviors: [yz_pay],
|
||
*
|
||
* **/
|
||
var app = getApp();
|
||
module.exports = Behavior({
|
||
data: {
|
||
confirmPayText: '确定',
|
||
popupSpecs: false,
|
||
isPayClick: false,
|
||
pageTag: ""
|
||
},
|
||
observers: {
|
||
buttons(val) {
|
||
if (val && val.constructor === Array && val.length > 0) {
|
||
val.map(item => {
|
||
if (item.value == 54) {
|
||
this.setData({
|
||
confirmPayText: item.name || '确定'
|
||
});
|
||
}
|
||
});
|
||
}
|
||
}
|
||
},
|
||
methods: {
|
||
// 处理图标
|
||
hanleIcon(_data) {
|
||
let keyarr = [];
|
||
for (let key in _data.buttons) {
|
||
if (
|
||
_data.buttons[key].code == "wechatPay" ||
|
||
_data.buttons[key].code == "wechatMinPay" ||
|
||
_data.buttons[key].code == "cloudPayWechat" ||
|
||
_data.buttons[key].code == "wechatApp" ||
|
||
_data.buttons[key].code == "yunPayWechat" ||
|
||
_data.buttons[key].code == "yop" ||
|
||
_data.buttons[key].code == "convergePayWechat" ||
|
||
_data.buttons[key].code == "WechatScan" ||
|
||
_data.buttons[key].code == "WechatFace" ||
|
||
_data.buttons[key].code == "WechatJsapi" ||
|
||
_data.buttons[key].code == "wechatAggregatePay" ||
|
||
_data.buttons[key].code == "leshuaWechat"
|
||
) {
|
||
_data.buttons[key].icon = "icon-pay_wechat";
|
||
_data.buttons[key].color = "#09bb07";
|
||
} else if (_data.buttons[key].code == "MemberCard" || _data.buttons[key].code == "balance") {
|
||
_data.buttons[key].icon = "icon-pay_yue";
|
||
_data.buttons[key].color = "#ff7433";
|
||
} else if (_data.buttons[key].code == "anotherPay") {
|
||
_data.buttons[key].icon = "icon-pay_otherpay";
|
||
_data.buttons[key].color = "#ffba00";
|
||
} else if (_data.buttons[key].code == "UsdtPay") {
|
||
_data.buttons[key].icon = "icon-pay_utsd";
|
||
_data.buttons[key].color = "#9000ff";
|
||
} else if (_data.buttons[key].code == "DepositPay") {
|
||
_data.buttons[key].icon = "icon-pay_prepay";
|
||
_data.buttons[key].color = "#9000ff";
|
||
} else if (_data.buttons[key].code == "COD") {
|
||
_data.buttons[key].icon = "icon-pay_cashondelivery";
|
||
_data.buttons[key].color = "#ed3800";
|
||
} else if (_data.buttons[key].code == "convergeQuickPay") {
|
||
_data.buttons[key].icon = "icon-pay_quick";
|
||
_data.buttons[key].color = "#46e0d1";
|
||
} else if (_data.buttons[key].code == "remittance") {
|
||
_data.buttons[key].icon = "icon-pay_remittance";
|
||
_data.buttons[key].color = "#ff7433";
|
||
} else if (
|
||
_data.buttons[key].code == "alipay" ||
|
||
_data.buttons[key].code == "cloudPayAlipay" ||
|
||
_data.buttons[key].code == "alipayApp" ||
|
||
_data.buttons[key].code == "yunPayAlipay" ||
|
||
_data.buttons[key].code == "wftAlipay" ||
|
||
_data.buttons[key].code == "convergePayAlipay" ||
|
||
_data.buttons[key].code == "yopAlipay" ||
|
||
_data.buttons[key].code == "AlipayScan" ||
|
||
_data.buttons[key].code == "AlipayFace" ||
|
||
_data.buttons[key].code == "AlipayJsapi" ||
|
||
_data.buttons[key].code == "alipayAggregatePay"
|
||
) {
|
||
_data.buttons[key].icon = "icon-pay_alipay";
|
||
_data.buttons[key].color = "#29a1f7";
|
||
} else if (_data.buttons[key].code == "parentPayment") {
|
||
_data.buttons[key].icon = "icon-fontclass-daifu1";
|
||
_data.buttons[key].color = "#f15353";
|
||
} else if (_data.buttons[key].code == "dcmScanPay") {
|
||
_data.buttons[key].icon = "icon-fontclass-saomazhifu";
|
||
_data.buttons[key].color = "#f4a556";
|
||
} else {
|
||
_data.buttons[key].icon = "icon-pay_default";
|
||
_data.buttons[key].color = "#538ff9";
|
||
}
|
||
keyarr.push(key);
|
||
}
|
||
},
|
||
btnclass(type) {
|
||
console.log(type, '3232');
|
||
if (type == 1 || type == 55 || type == 6 || type == 9 || type == 12 || type == 20 || type == 22 || type == 28) {
|
||
return "icon-balance_i";
|
||
} else if (type == 2 || type == 10) {
|
||
return "icon-balance_j";
|
||
} else if (type == 18) {
|
||
return "icon-balance_d";
|
||
} else if (type == 19) {
|
||
return "icon-balance_g";
|
||
} else {
|
||
return "icon-balance_h";
|
||
}
|
||
},
|
||
|
||
rechargePay(pay_type, res, ordersn, flag) {
|
||
let payParams = {};
|
||
if (pay_type == 1 || pay_type == 55 || pay_type == 48) {
|
||
let pay_data = {};
|
||
if (flag === "credit") {
|
||
pay_data = res;
|
||
} else {
|
||
pay_data = res.data.config;
|
||
}
|
||
payParams = {
|
||
timestamp: pay_data.timestamp,
|
||
nonceStr: pay_data.nonceStr,
|
||
package: pay_data.package,
|
||
signType: pay_data.signType,
|
||
paySign: pay_data.paySign,
|
||
};
|
||
this.WXPay_other(payParams, "back");
|
||
} else if (pay_type == 3) {
|
||
if (flag === "clock") {
|
||
this._getTodayClockOn(); //重新获取
|
||
this._getCurrentPayStatus();
|
||
}
|
||
wx.showToast({
|
||
title: res.msg || "支付成功",
|
||
icon: "none",
|
||
duration: 1500,
|
||
success() {
|
||
setTimeout(() => {
|
||
wx.navigateBack({
|
||
delta: 1,
|
||
});
|
||
}, 1500);
|
||
},
|
||
});
|
||
} else if (pay_type == 28) {
|
||
if (flag === "credit") {
|
||
this.HJWXPay({
|
||
appId: res.appId,
|
||
timeStamp: res.timeStamp,
|
||
nonceStr: res.nonceStr,
|
||
package: res.package,
|
||
signType: res.signType,
|
||
paySign: res.paySign,
|
||
});
|
||
} else {
|
||
if (res.data.msg == "成功") {
|
||
let obj = JSON.parse(res.data.data.rc_Result);
|
||
payParams = {
|
||
appId: obj.appId,
|
||
timeStamp: obj.timeStamp,
|
||
nonceStr: obj.nonceStr,
|
||
package: obj.package,
|
||
signType: obj.signType,
|
||
paySign: obj.paySign,
|
||
};
|
||
this.HJWXPay(payParams, "noRect");
|
||
} else {
|
||
wx.showToast({
|
||
title: res.data.msg,
|
||
icon: "none",
|
||
});
|
||
}
|
||
}
|
||
} else if (pay_type == 33) {
|
||
this.jueqiAlipay(ordersn);
|
||
} else if(pay_type == 86){
|
||
this.WXPay_other(res.data.pay_msg);
|
||
} else if (pay_type = 59) {
|
||
this.rechargePay_quick_pay(ordersn, flag);
|
||
} else if (pay_type == 78) {
|
||
this.HJWXPay(res.data.pay_msg.js_prepay_info);
|
||
} else if (pay_type == 82) {
|
||
this.WXPay_other(res.data.pay_msg.js_prepay_info);
|
||
} else {
|
||
wx.showToast({
|
||
title: "暂不支持该支付方式",
|
||
icon: "none",
|
||
});
|
||
}
|
||
},
|
||
async handleOtherPay(btn, type, resData, flag) {
|
||
this.data.pageTag = flag;
|
||
if (type == 3 && btn.need_password == 1) {
|
||
// 是否开启余额密码支付
|
||
let pass = await this.getPayKeyboardPassword();
|
||
this.getVerifyPassword(pass, "noRect"); // 请求密码验证接口
|
||
}
|
||
if (type == 3 && btn.need_password != 1) {
|
||
//余额支付
|
||
wx.showModal({
|
||
title: "提示",
|
||
content: "支付成功",
|
||
showCancel: false,
|
||
success(res) {
|
||
if (res.confirm) {
|
||
if (flag === "circle") {
|
||
try {
|
||
let pages = getCurrentPages();
|
||
let page = pages[pages.length - 2];
|
||
page.updateView();
|
||
} catch (error) {
|
||
console.log(error);
|
||
}
|
||
} else if (flag === 'groupWork') {
|
||
wx.navigateTo({
|
||
url: '/packageI/groupWork/groupWorkMy/groupWorkMy'
|
||
});
|
||
return;
|
||
}
|
||
wx.navigateBack({
|
||
delta: 1,
|
||
});
|
||
}
|
||
},
|
||
});
|
||
} else if (type == 1 || type == 55) {
|
||
//微信
|
||
this.WXPay_other(resData.config);
|
||
} else if (type == 28) {
|
||
// 汇聚支付
|
||
if (resData.msg == "成功") {
|
||
let data = JSON.parse(resData.data.rc_Result);
|
||
this.HJWXPay(data, "noRect");
|
||
} else {
|
||
wx.showToast({
|
||
title: resData.msg,
|
||
icon: "none",
|
||
});
|
||
}
|
||
} else if (type == 82) {
|
||
this.OtherPay_sandWXpay();
|
||
} else if (type == 86){
|
||
this.WXPay_other(resData.data.pay_msg);
|
||
}else {
|
||
wx.showToast({
|
||
title: "暂不支持该支付方式",
|
||
icon: "none",
|
||
});
|
||
}
|
||
},
|
||
OtherPay_sandWXpay() {
|
||
let _url = app.getNetAddresss("order.merge-pay.sandpay-wechat");
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
let resData = res.data.pay_msg;
|
||
if (resData.result == 1) {
|
||
this.WXPay_other(resData);
|
||
} else {
|
||
wx.showToast({
|
||
title: resData.msg,
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
WXPay_other(payParams, flag) {
|
||
let that = this;
|
||
wx.requestPayment({
|
||
timeStamp: payParams.timestamp,
|
||
nonceStr: payParams.nonceStr,
|
||
package: payParams.package,
|
||
signType: payParams.signType ? payParams.signType : "MD5",
|
||
paySign: payParams.paySign,
|
||
success: (res) => {
|
||
wx.showModal({
|
||
title: "提示",
|
||
content: "支付成功",
|
||
showCancel: false,
|
||
success(res) {
|
||
if (res.confirm) {
|
||
if (that.data.pageTag == 'groupWork') {
|
||
wx.navigateTo({
|
||
url: '/packageI/groupWork/groupWorkMy/groupWorkMy'
|
||
});
|
||
return;
|
||
}
|
||
if (flag === 'back') {
|
||
wx.navigateBack({
|
||
delta: 1,
|
||
});
|
||
}
|
||
}
|
||
},
|
||
});
|
||
},
|
||
fail: (res) => {
|
||
console.log(res);
|
||
wx.showToast({
|
||
title: "支付失败请稍后重试",
|
||
icon: "none",
|
||
duration: 2000,
|
||
});
|
||
},
|
||
});
|
||
},
|
||
// 消费红包
|
||
checkoutConsumePacket() {
|
||
this.toRedirect();
|
||
},
|
||
payCallBack() {
|
||
if (app.globalData.store_alone_temp == 1) {
|
||
// 开启了门店独立直接跳首页
|
||
wx.reLaunch({
|
||
url: '/packageG/independent_store/index/index?store_id=' + app.globalData.STORE_ID,
|
||
});
|
||
return;
|
||
}
|
||
// 支付完根据订单号例如order_sn:PN2107291603FE0BF4重定向跳转地址
|
||
let _url = app.getNetAddresss("payment.callback-page.index");
|
||
_url += "&sn=" + this.data.order_sn;
|
||
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
let resData = res.data;
|
||
if (resData.result == 1) {
|
||
try {
|
||
if (this.data.name == "groups" && resData.data.redirect.indexOf("group_detail") != -1) {
|
||
// 拼团
|
||
let str = resData.data.redirect.match(/group_detail\/(\S*)\?i/)[1];
|
||
str = str.split("/");
|
||
let id = str[0];
|
||
if (str[1]) {
|
||
wx.navigateTo({
|
||
url: "/packageB/member/group/GroupDetail/GroupDetail?id=" + id + "&store_id=" + str[1],
|
||
});
|
||
} else {
|
||
wx.navigateTo({
|
||
url: "/packageB/member/group/GroupDetail/GroupDetail?id=" + id,
|
||
});
|
||
}
|
||
} else {
|
||
wx.redirectTo({
|
||
url: resData.data.min_redirect,
|
||
fail: (err) => {
|
||
console.log(err);
|
||
wx.reLaunch({
|
||
url: "/packageG/index/index",
|
||
});
|
||
},
|
||
});
|
||
}
|
||
} catch (e) {
|
||
wx.reLaunch({
|
||
url: "/packageG/index/index",
|
||
});
|
||
}
|
||
} else {
|
||
wx.reLaunch({
|
||
url: "/packageG/index/index",
|
||
});
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
wx.reLaunch({
|
||
url: "/packageG/index/index",
|
||
});
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
toRedirect() {
|
||
|
||
if (this.data.is_cps) {
|
||
wx.redirectTo({
|
||
url: "/packageI/pay_back/pay_back?is_cps=" + this.data.is_cps + '&ids=' + this.data.order_pay_id,
|
||
});
|
||
return;
|
||
}
|
||
if (this.data.name == "Myshaky" || this.data.name == "blindBox") {
|
||
wx.redirectTo({
|
||
url: "/packageI/pay_back/pay_back?name=" + this.data.name + '&ids=' + this.data.order_pay_id +'&sn='+this.data.order_sn,
|
||
});
|
||
return;
|
||
}
|
||
if (this.data.order_sn) {
|
||
wx.redirectTo({
|
||
url: `/packageI/pay_back/pay_back?ids=${this.data.order_pay_id}&sn=${this.data.order_sn}${this.data.name ? '&name='+this.data.name : '' }`
|
||
});
|
||
} else {
|
||
wx.redirectTo({
|
||
url: "/packageI/pay_back/pay_back?ids=" + this.data.order_pay_id + '&name=' + this.data.name,
|
||
});
|
||
}
|
||
|
||
},
|
||
async handlePay(btn, type) {
|
||
if (this.data.isPayClick) {
|
||
// 控制支付请求多次
|
||
app.tips("还在请求支付,请等待~");
|
||
return;
|
||
}
|
||
|
||
this.data.isPayClick = true;
|
||
|
||
if (type == 1 || type == 6 || type == 63 || type == 55) {
|
||
// 微信
|
||
this.getWeChatPayParams(type);
|
||
} else if (type == 3) {
|
||
// 是否开启余额密码支付
|
||
if (btn.need_password == 1) {
|
||
let pass = await this.getPayKeyboardPassword();
|
||
this.getVerifyPassword(pass); // 请求密码验证接口
|
||
} else {
|
||
this.balancePay(""); // 无密码
|
||
}
|
||
} else if (type == 14) {
|
||
this.data.isPayClick = false;
|
||
wx.redirectTo({
|
||
url: "/packageD/buy/payanother/payanother?order_id=" + JSON.parse(this.data.order_id).toString(),
|
||
});
|
||
} else if (type == 11 || type == "cashPay") {
|
||
// 到店支付
|
||
this.cashPay(type);
|
||
} else if (type == 8) {
|
||
// 现金支付
|
||
this.cashPay(type);
|
||
} else if (type == 16) {
|
||
this.transferAccounts();
|
||
} else if (type == 28) {
|
||
// 第三方支付汇聚微信
|
||
this.getWepayHj();
|
||
} else if (type == 17) {
|
||
this.payMoney();
|
||
} else if (type == 33) {
|
||
this.jueqiAlipay();
|
||
} else if (type == 48) {
|
||
this.wechatJsapiPay();
|
||
} else if (btn == 54) {
|
||
this.sureBtn();
|
||
} else if (type == 59) {
|
||
this.quick_pay();
|
||
} else if (type == 75) {
|
||
this.huiju_wechat();
|
||
} else if (type == 77) {
|
||
this.data.isPayClick = false;
|
||
wx.redirectTo({
|
||
url: "/packageH/superior_payment/superiorPaymentIndex/superiorPaymentIndex?order_id=" + JSON.parse(this.data.order_id).toString(),
|
||
});
|
||
} else if (type == 68) {
|
||
this.scancodeAccounts();
|
||
} else if (type == 78) {
|
||
this.xfpayWechat();
|
||
} else if (type == 80) {
|
||
this.storeBalance();
|
||
} else if (type == 82) {
|
||
this.sandpayWechat();
|
||
} else if (type == 83) {
|
||
this.lakalaWechat();
|
||
} else if (type == 86){
|
||
this.Otherleshua()
|
||
} else {
|
||
wx.showToast({
|
||
title: "暂不支持该支付方式",
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
async lakalaWechat(){
|
||
let _url = app.getNetAddresss("order.merge-pay.lakala-wechat");
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
res = res.data;
|
||
if (res.result == 1) {
|
||
var pay_data = res.data.pay_msg;
|
||
if (pay_data) {
|
||
var payParams = {
|
||
timeStamp: pay_data.timeStamp,
|
||
nonceStr: pay_data.nonceStr,
|
||
package: pay_data.package,
|
||
signType: pay_data.signType,
|
||
paySign: pay_data.paySign,
|
||
};
|
||
// 默认跳首页
|
||
this.WXPay(payParams, 'home');
|
||
}
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
})
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
sandpayWechat(){
|
||
let _url = app.getNetAddresss("order.merge-pay.sandpay-wechat");
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
res = res.data;
|
||
if (res.result == 1) {
|
||
var pay_data = res.data.pay_msg;
|
||
if (pay_data) {
|
||
var payParams = {
|
||
timeStamp: pay_data.timestamp,
|
||
nonceStr: pay_data.nonceStr,
|
||
package: pay_data.package,
|
||
signType: pay_data.signType,
|
||
paySign: pay_data.paySign,
|
||
};
|
||
// 默认跳首页
|
||
this.WXPay(payParams, 'home');
|
||
}
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
storeBalance() {
|
||
let urlStr = app.getNetAddresss("plugin.store-balance.frontend.pay.index");
|
||
app._getNetWork({
|
||
url: urlStr,
|
||
data: {
|
||
order_pay_id: this.data.order_pay_id,
|
||
store_id: this.data.store_id
|
||
},
|
||
success: (resdata) => {
|
||
var res = resdata.data;
|
||
if (res.result == 1) {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: 'none',
|
||
duration: 1000,
|
||
complete: () => {
|
||
this.payCallBack();
|
||
}
|
||
});
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: 'none',
|
||
duration: 1000
|
||
});
|
||
}
|
||
},
|
||
fail: (res) => {
|
||
console.log(res);
|
||
},
|
||
});
|
||
},
|
||
getWeChatPayParams(type) {
|
||
let _postUrl = type == 63 ? "plugin.store-aggregate-pay.frontend.aggregate-pay.wechat" : "order.merge-pay.wechatPay";
|
||
let _url = app.getNetAddresss(_postUrl);
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
_url += "&client_type=2";
|
||
|
||
if (this.data.mid) {
|
||
_url += "&mid=" + this.data.mid;
|
||
}
|
||
|
||
if (this.data.pid) {
|
||
_url += "&pid=" + this.data.pid;
|
||
}
|
||
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
if (res.data.result == 0) {
|
||
app.tips(res.data.msg);
|
||
}
|
||
if (type != 63) {
|
||
var pay_data = res.data.data.config;
|
||
if (pay_data) {
|
||
var payParams = {
|
||
timeStamp: pay_data.timestamp,
|
||
nonceStr: pay_data.nonceStr,
|
||
package: pay_data.package,
|
||
signType: pay_data.signType,
|
||
paySign: pay_data.paySign,
|
||
};
|
||
// console.log('senceKey::::', this.data.senceKey);
|
||
if (this.data.senceKey == '1177' || this.data.senceKey == '1175' || this.data.senceKey == '1176' || this.data.senceKey == '1195' || this.data.senceKey == '1191') {
|
||
this.newScene(this.data.senceKey, payParams, res.data.data.redirect);
|
||
} else {
|
||
this.WXPay(payParams, res.data.data.redirect || 'home');
|
||
}
|
||
}
|
||
} else {
|
||
wx.setClipboardData({
|
||
data: res.data.jsapi_pay_url,
|
||
success(res) {
|
||
wx.showToast({
|
||
title: "已复制链接请用浏览器打开",
|
||
icon: "none",
|
||
duration: 5000,
|
||
});
|
||
},
|
||
fail() {
|
||
wx.showToast({
|
||
title: "复制链接失败",
|
||
icon: "none",
|
||
duration: 2500,
|
||
});
|
||
},
|
||
});
|
||
}
|
||
this.data.isPayClick = false;
|
||
},
|
||
fail: (res) => {
|
||
this.data.isPayClick = false;
|
||
},
|
||
});
|
||
},
|
||
newScene(key, payParams, redirect) {
|
||
let _url = app.getNetAddresss("plugin.wechat-trade.frontend.order.index");
|
||
console.log(payParams);
|
||
_url += "&scene=" + key;
|
||
_url += "&pay_type=0";
|
||
_url += "&prepay_time=" + payParams.timeStamp;
|
||
_url += "&prepay_id=" + payParams.package;
|
||
_url += "&pay_sn=" + this.data.order_sn;
|
||
if (this.data.pid) {
|
||
_url += "&pid=" + this.data.pid;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
let resData = res.data;
|
||
if (resData.result == 1) {
|
||
if (resData.data.state == 0) {
|
||
this.WXPay(payParams, redirect || 'home');
|
||
} else {
|
||
wx.requestOrderPayment({
|
||
timeStamp: payParams.timeStamp,
|
||
nonceStr: payParams.nonceStr,
|
||
package: payParams.package,
|
||
signType: payParams.signType ? payParams.signType : "MD5",
|
||
paySign: payParams.paySign,
|
||
orderInfo: resData.data.data, // 需要新增的 订单 信息
|
||
success: (res) => {
|
||
this.toRedirect();
|
||
},
|
||
fail: (err) => {
|
||
console.log(err);
|
||
},
|
||
});
|
||
}
|
||
} else {
|
||
this.data.isPayClick = false;
|
||
wx.showModal({
|
||
title: resData.msg,
|
||
duration: 2000,
|
||
showCancel: false,
|
||
success: (e) => {
|
||
if (e.confirm) {
|
||
this.WXPay(payParams, redirect);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
this.WXPay(payParams, redirect);
|
||
},
|
||
});
|
||
},
|
||
WXPay(payParams, url) {
|
||
let urlStr = app.getNetAddresss("order.mini-app.index");
|
||
console.log(payParams,":dddd")
|
||
wx.requestPayment({
|
||
timeStamp: payParams.timeStamp,
|
||
nonceStr: payParams.nonceStr,
|
||
package: payParams.package,
|
||
signType: payParams.signType ? payParams.signType : "MD5",
|
||
paySign: payParams.paySign,
|
||
success: (res) => {
|
||
let json = {
|
||
formID: payParams.package.slice(10),
|
||
orderId: this.data.order_id,
|
||
};
|
||
app._postNetWork({
|
||
url: urlStr,
|
||
showToastIn: false,
|
||
data: json,
|
||
success: (resdata) => {
|
||
let res = resdata.data;
|
||
if (res.result == 0) {
|
||
wx.showToast({
|
||
icon: "none",
|
||
title: res.msg,
|
||
duration: 1500,
|
||
});
|
||
}
|
||
|
||
if (url) {
|
||
this.setData({
|
||
cbHref: {
|
||
cbHref: url,
|
||
},
|
||
});
|
||
this.checkoutConsumePacket();
|
||
} else {
|
||
wx.navigateBack({
|
||
delta: 1,
|
||
});
|
||
}
|
||
},
|
||
});
|
||
},
|
||
fail: (res) => {
|
||
this.data.isPayClick = false;
|
||
console.log(res);
|
||
wx.showToast({
|
||
title: "支付失败请稍后重试",
|
||
icon: "none",
|
||
duration: 2000,
|
||
});
|
||
},
|
||
});
|
||
},
|
||
payKeyboardComplete(evt) {
|
||
this.setData({
|
||
popupSpecs: false
|
||
});
|
||
payKeyboardAsync.complete(evt.detail);
|
||
},
|
||
getPayKeyboardPassword() {
|
||
this.setData({
|
||
popupSpecs: true
|
||
});
|
||
return new Promise((resove, reject) => {
|
||
payKeyboardAsync.addCompleteFn((pass) => {
|
||
resove(pass);
|
||
});
|
||
});
|
||
},
|
||
payKeyboardClose() {
|
||
this.setData({
|
||
popupSpecs: false
|
||
});
|
||
this.data.isPayClick = false;
|
||
},
|
||
// 验证密码
|
||
getVerifyPassword(pwd, flag) {
|
||
let urlStr = app.getNetAddresss("payment.password.check");
|
||
urlStr += "&password=" + pwd;
|
||
app._getNetWork({
|
||
url: urlStr,
|
||
success: (resdata) => {
|
||
var res = resdata.data;
|
||
if (res.result == 1) {
|
||
if (flag === "noRect") {
|
||
wx.showToast({
|
||
icon: "none",
|
||
title: "支付成功",
|
||
duration: 2000,
|
||
});
|
||
} else {
|
||
this.balancePay(pwd);
|
||
}
|
||
} else {
|
||
this.data.isPayClick = false;
|
||
this.verifyPasswordError(res);
|
||
}
|
||
},
|
||
fail: (res) => {
|
||
console.log(res);
|
||
},
|
||
});
|
||
},
|
||
verifyPasswordError(res) {
|
||
wx.showModal({
|
||
title: "提示",
|
||
content: res.msg,
|
||
success(restext) {
|
||
if (restext.confirm) {
|
||
if (res.data.code == 2001) {
|
||
// 商城支付密码设置未开启
|
||
} else if (res.data.code == 2002) {
|
||
// 用户未设置支付密码
|
||
// 去设置密码
|
||
wx.navigateTo({
|
||
url: "/packageA/member/set_balance_password/set_balance_password",
|
||
});
|
||
} else if (res.data.code == 2003) {
|
||
// 支付密码错误
|
||
}
|
||
} else if (restext.cancel) {
|
||
if (res.data.code == 2001) {
|
||
// 商城支付密码设置未开启
|
||
} else if (res.data.code == 2002) {
|
||
// 用户未设置支付密码
|
||
} else if (res.data.code == 2003) {
|
||
// 支付密码错误
|
||
}
|
||
}
|
||
},
|
||
});
|
||
},
|
||
// 密码支付
|
||
balancePay(password) {
|
||
let _url = app.getNetAddresss("order.credit-merge-pay.credit2");
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
if (!app._isTextEmpty(password)) {
|
||
_url += "&payment_password=" + password;
|
||
}
|
||
if (this.data.pid) {
|
||
_url += "&pid=" + this.data.pid;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
if (res.data.result == 1) {
|
||
this.setData({
|
||
redirectData: res.data,
|
||
cbHref: {},
|
||
});
|
||
this.checkoutConsumePacket();
|
||
} else {
|
||
wx.showToast({
|
||
title: res.data.msg,
|
||
icon: "none",
|
||
duration: 2000,
|
||
});
|
||
// console.log('错误', res.data.msg);
|
||
}
|
||
setTimeout(() => {
|
||
this.data.isPayClick = false;
|
||
}, 2000);
|
||
},
|
||
});
|
||
},
|
||
cashPay(value) {
|
||
if (value == '8') {
|
||
// 现金支付
|
||
let _url = app.getNetAddresss("plugin.store-cashier.frontend.payment.cashPay.cashPay");
|
||
_url += "&client_type=2&order_pay_id=" + this.data.order_pay_id;
|
||
if (this.data.mid) {
|
||
_url += "&mid=" + this.data.mid;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
res = res.data;
|
||
if (res.result == 1) {
|
||
wx.showModal({
|
||
title: '提示',
|
||
content: res.msg,
|
||
showCancel: false,
|
||
success(res) {
|
||
if (res.confirm) {
|
||
wx.reLaunch({
|
||
url: "/packageG/member_v2/member_v2",
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
return;
|
||
}
|
||
wx.redirectTo({
|
||
url: "/packageA/member/order/orderCash/orderCash?order_pay_id=" + this.data.order_pay_id + "&pid=" + (this.data.pid ? this.data.pid : this.data.uid),
|
||
});
|
||
this.data.isPayClick = false;
|
||
},
|
||
// 转账支付
|
||
transferAccounts() {
|
||
wx.redirectTo({
|
||
url: "/packageA/member/order/TransferAccount/TransferAccount?id=" + this.data.order_pay_id + "&order_ids=" + this.data.order_id + "&status=" + this.data.status,
|
||
});
|
||
this.data.isPayClick = false;
|
||
},
|
||
// 微信支付
|
||
getWepayHj() {
|
||
let _url = app.getNetAddresss("order.merge-pay.wechat-pay-hj");
|
||
_url += "&client_type=2&order_pay_id=" + this.data.order_pay_id;
|
||
if (this.data.mid) {
|
||
_url += "&mid=" + this.data.mid;
|
||
}
|
||
|
||
if (this.data.pid) {
|
||
_url += "&pid=" + this.data.pid;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
res = res.data;
|
||
if (res.result == 1) {
|
||
let data = JSON.parse(res.data.data.rc_Result);
|
||
this.HJWXPay(data);
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
// 汇聚支付
|
||
HJWXPay(payParams, flag) {
|
||
wx.requestPayment({
|
||
appId: payParams.appId,
|
||
timeStamp: payParams.timeStamp,
|
||
nonceStr: payParams.nonceStr,
|
||
package: payParams.package,
|
||
signType: payParams.signType,
|
||
paySign: payParams.paySign,
|
||
success: (res) => {
|
||
wx.showToast({
|
||
title: "支付成功",
|
||
icon: "success",
|
||
duration: 2000,
|
||
success: () => {
|
||
setTimeout(() => {
|
||
if (this.data.pageTag == 'groupWork') {
|
||
wx.navigateTo({
|
||
url: '/packageI/groupWork/groupWorkMy/groupWorkMy'
|
||
});
|
||
return;
|
||
}
|
||
if (flag === 'noRect') {
|
||
wx.navigateBack({
|
||
delta: 1,
|
||
});
|
||
} else {
|
||
this.setData({
|
||
redirectData: {},
|
||
cbHref: {},
|
||
});
|
||
this.checkoutConsumePacket();
|
||
}
|
||
}, 2000); // 延迟时间
|
||
},
|
||
});
|
||
},
|
||
fail: (res) => {
|
||
console.log(res);
|
||
console.log(payParams, "参数");
|
||
wx.showToast({
|
||
title: "支付失败请稍后重试",
|
||
icon: "none",
|
||
duration: 2000,
|
||
});
|
||
},
|
||
});
|
||
this.data.isPayClick = false;
|
||
},
|
||
// 货到付款
|
||
payMoney() {
|
||
let json = {
|
||
order_pay_id: this.data.order_pay_id,
|
||
};
|
||
let urlStr = app.getNetAddresss("order.mergePay.COD");
|
||
app._getNetWork({
|
||
url: urlStr,
|
||
data: json,
|
||
success: (resdata) => {
|
||
let res = resdata.data;
|
||
if (res.result == 1) {
|
||
this.setData({
|
||
redirectData: res,
|
||
cbHref: {},
|
||
});
|
||
this.checkoutConsumePacket();
|
||
} else {
|
||
wx.showToast({
|
||
icon: "none",
|
||
title: res.msg,
|
||
duration: 2000,
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (res) => {
|
||
console.log(res);
|
||
},
|
||
});
|
||
},
|
||
rechargePay_quick_pay(ordersn, flag) {
|
||
let status = 3;
|
||
let isurl = app.getNetAddresss("plugin.converge_pay.frontend.controllers.quick-pay.love-recharge");
|
||
if (flag === "balance") {
|
||
status = 2;
|
||
isurl = app.getNetAddresss("plugin.converge_pay.frontend.controllers.quick-pay.show-recharge");
|
||
} else if (flag === "recharge") {
|
||
status = 1;
|
||
isurl = app.getNetAddresss("plugin.converge_pay.frontend.controllers.quick-pay.credit-recharge");
|
||
}
|
||
app._getNetWork({
|
||
url: isurl,
|
||
data: {
|
||
ordersn: ordersn,
|
||
},
|
||
success: (res) => {
|
||
this.data.isPayClick = false;
|
||
if (res.data.result == 1) {
|
||
if (res.data.data.have_bank_card == 0) {
|
||
wx.navigateTo({
|
||
url: "/packageD/quickPay/add_bank_first/add_bank_first?order_pay_id=" + ordersn + "&status=" + status,
|
||
});
|
||
} else {
|
||
wx.navigateTo({
|
||
url: "/packageD/quickPay/choose_bank/choose_bank?order_pay_id=" + ordersn + "&status=" + status,
|
||
});
|
||
}
|
||
} else {
|
||
wx.showToast({
|
||
title: res.data.msg,
|
||
duration: 1000,
|
||
icon: "none",
|
||
});
|
||
}
|
||
},
|
||
fail: (err) => {
|
||
console.log(err);
|
||
},
|
||
});
|
||
},
|
||
jueqiAlipay(ordersn) {
|
||
let _url = app.getNetAddresss("order.merge-pay.wechat-pay-jueqi");
|
||
if (ordersn) {
|
||
_url += "&order_pay_id=" + ordersn;
|
||
} else {
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
}
|
||
if (this.data.pid) {
|
||
_url += "&pid=" + this.data.pid;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
let resData = res.data;
|
||
if (resData.result == 1) {
|
||
this.HJWXPay(resData.data);
|
||
} else {
|
||
wx.showToast({
|
||
title: resData.msg,
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
wechatJsapiPay() {
|
||
let _url = app.getNetAddresss("order.merge-pay.wechat-jsapi-pay");
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
if (this.data.pid) {
|
||
_url += "&pid=" + this.data.pid;
|
||
}
|
||
if(this.data.store_id){
|
||
_url += "&store_id=" + this.data.store_id;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
let resData = res.data;
|
||
if (resData.result == 1) {
|
||
this.HJWXPay(resData.data.config);
|
||
} else {
|
||
wx.showToast({
|
||
title: resData.msg,
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
quick_pay() {
|
||
let isurl = app.getNetAddresss("plugin.converge_pay.frontend.controllers.quick-pay.pay");
|
||
if (this.data.pid) {
|
||
isurl += "&pid=" + this.data.pid;
|
||
}
|
||
app._getNetWork({
|
||
url: isurl,
|
||
data: {
|
||
order_pay_id: this.data.order_pay_id,
|
||
},
|
||
success: (res) => {
|
||
this.data.isPayClick = false;
|
||
if (res.data.result == 1) {
|
||
if (res.data.data.have_bank_card == 0) {
|
||
wx.navigateTo({
|
||
url: "/packageD/quickPay/add_bank_first/add_bank_first?order_pay_id=" + this.data.order_pay_id,
|
||
});
|
||
} else {
|
||
wx.navigateTo({
|
||
url: "/packageD/quickPay/choose_bank/choose_bank?order_pay_id=" + this.data.order_pay_id,
|
||
});
|
||
}
|
||
} else {
|
||
wx.showToast({
|
||
title: res.data.msg,
|
||
duration: 1000,
|
||
icon: "none",
|
||
});
|
||
}
|
||
},
|
||
fail: (err) => {
|
||
console.log(err);
|
||
},
|
||
});
|
||
},
|
||
huiju_wechat() {
|
||
// 汇聚微信支付-分账
|
||
let _url = app.getNetAddresss("plugin.converge-alloc-funds.frontend.controllers.converge-separate.pay");
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
if (this.data.pid) {
|
||
_url += "&pid=" + this.data.pid;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
res = res.data;
|
||
if (res.result == 1) {
|
||
let data = JSON.parse(res.data.rc_Result);
|
||
this.HJWXPay(data);
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
// 扫码支付
|
||
scancodeAccounts() {
|
||
wx.redirectTo({
|
||
url: "/packageA/member/order/scancodeAccount/scancodeAccount?id=" + this.data.order_pay_id + "&order_ids=" + this.data.order_id + "&status=" + this.data.status,
|
||
});
|
||
this.data.isPayClick = false;
|
||
},
|
||
// money=='0.00'
|
||
sureBtn() {
|
||
let _url = app.getNetAddresss("order.merge-pay.confirm-pay");
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
if (this.data.pid) {
|
||
_url += "&pid=" + this.data.pid;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
let resData = res.data;
|
||
if (resData.result == 1) {
|
||
this.checkoutConsumePacket();
|
||
} else {
|
||
this.data.isPayClick = false;
|
||
wx.showToast({
|
||
title: resData.msg,
|
||
icon: "none",
|
||
duration: 2000,
|
||
});
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
xfpayWechat() {
|
||
let _url = app.getNetAddresss("order.merge-pay.xfpay-wechat");
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
res = res.data;
|
||
if (res.result == 1) {
|
||
if (res.data.pay_msg && res.data.pay_msg.js_prepay_info) {
|
||
// let data = JSON.parse(res.data.pay_msg.js_prepay_info);
|
||
this.HJWXPay(res.data.pay_msg.js_prepay_info);
|
||
} else {
|
||
wx.showToast({
|
||
title: '第三方支付预付单信息为空,请选择其他支付方式!',
|
||
icon: "none",
|
||
duration: 2500
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
});
|
||
this.data.isPayClick = false;
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
},
|
||
// 乐刷
|
||
Otherleshua(){
|
||
let _url = app.getNetAddresss("order.merge-pay.leshua-wechat");
|
||
if(this.data.order_pay_id){
|
||
//支付
|
||
_url += "&order_pay_id=" + this.data.order_pay_id;
|
||
}
|
||
app._getNetWork({
|
||
url: _url,
|
||
success: (res) => {
|
||
res = res.data;
|
||
if (res.result == 1) {
|
||
var pay_data = res.data.pay_msg;
|
||
if (pay_data) {
|
||
var payParams = {
|
||
timeStamp: pay_data.timeStamp,
|
||
nonceStr: pay_data.nonceStr,
|
||
package: pay_data.package,
|
||
signType: pay_data.signType,
|
||
paySign: pay_data.paySign,
|
||
};
|
||
// 默认跳首页
|
||
this.WXPay(payParams, 'home');
|
||
}
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
})
|
||
}
|
||
},
|
||
fail: (error) => {
|
||
console.log(error, "错误");
|
||
},
|
||
});
|
||
}
|
||
},
|
||
}); |