'use strict'; var hlbWechatMixin = function () { return { methods: { hlb_WxRequestPaymentFn:function(){ // 普通订单合利宝公众号支付 var _this = this; var params={ payType:'GZH', payAmount:Math.round(_this.payAmount*100), code:_this.wechatcode, state:_this.rand(1000,9999), shopOrderId:_this.shopOrderId, returnUrl:'https://www.caimei365.com/', }; console.log('=========>普通订单合利宝公众号支付',params) PayApi.PayOrderPcScanWxPay(params,function(response){ _this.hlb_handlResponse(response) }) }, hlb_WxRequestPaymentVipFn: function(){ // 超级会员合利宝公众号支付 var _this = this; var params = { payType:'GZH', code: _this.wechatcode, state: _this.rand(1000, 9999), vipId: _this.vipId, vipRecordId: _this.vipRecordId, returnUrl: 'https://www.caimei365.com/', }; PayApi.PayVipMiniWxPay(params,function(response){ _this.hlb_handlResponse(response) }); }, hlb_WxRequestPaymentCouponFn: function(){// 优惠券合利宝公众号支付 var _this = this; var params = { payType:'GZH', code: _this.wechatcode, state: _this.rand(1000, 9999), userId: _this.userId, couponId: _this.couponId, couponRecordId:_this.couponRecordId, returnUrl: 'https://www.caimei365.com/', source:2 //支付来源 1 小程序 2 WWW }; PayApi.PayCouponMiniWxPay(params,function(response){ _this.hlb_handlResponse(response) }); }, hlb_WxRequestPaymentAuthVipFn: function(){// 认证通会员合利宝公众号支付 var _this = this; var params = { payType:'GZH', code: _this.wechatcode, state: _this.rand(1000, 9999), vipId: _this.vipId, vipRecordId: _this.vipRecordId, returnUrl: 'https://www.caimei365.com/', }; PayApi.PayAuthVipMiniWxPay(params,function(response){ _this.hlb_handlResponse(response) }); }, hlb_WxRequestsecondHandPay:function(params){ // 二手发布合利宝公众号支付 var _this = this; var params = { payType:'GZH', code: _this.wechatcode, state: _this.rand(1000, 9999), productId: _this.productId, returnUrl: 'https://www.caimei365.com/', }; PayApi.PayOrdersecondWechat(params,function(response){ _this.hlb_handlResponse(response) }); }, hlb_handlResponse:function (response) { if(response.code == 0){ var PayInfo = JSON.parse(response.data.data.payInfo); if (typeof WeixinJSBridge == "undefined"){ if( document.addEventListener ){ document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false); }else if (document.attachEvent){ document.attachEvent('WeixinJSBridgeReady', onBridgeReady); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady); } }else{ _this.mh_onBridgeReady(PayInfo); } }else{ CAIMEI.dialog("支付链接已失效,请重新扫码支付"); setTimeout(function(){ WeixinJSBridge.call('closeWindow'); },3000); } }, hlb_onBridgeReady:function(data){// 调起微信公众号支付 console.log('支付验证签名',data); WeixinJSBridge.invoke('getBrandWCPayRequest', { "appId":data.appId, //公众号名称,由商户传入 "timeStamp":data.timeStamp,//时间戳,自1970年以来的秒数 "nonceStr":data.nonceStr, //随机串 "package":data.package, "signType":data.signType, //微信签名方式: "paySign":data.paySign, //微信签名 }, function(res) { if(res.err_msg == "get_brand_wcpay_request:ok"){ CAIMEI.dialog('支付成功'); window.open("https://www.caimei365.com/"); }else if(res.err_msg == "get_brand_wcpay_request:cancel"){ CAIMEI.dialog("用户取消支付,请重新扫码支付"); setTimeout(function(){ WeixinJSBridge.call('closeWindow'); },3000); }else{ CAIMEI.dialog("支付失败,请重新扫码支付"); setTimeout(function(){ WeixinJSBridge.call('closeWindow'); },3000); } }); }, } }; }();