|
@@ -3,9 +3,11 @@
|
|
|
*/
|
|
|
var payContainer = new Vue({
|
|
|
el:"#payContainer",
|
|
|
+ mixins: [mhWechatMixin,hlbWechatMixin],
|
|
|
data: {
|
|
|
+ paymentChannel:'HLB',
|
|
|
orderID:'',
|
|
|
- pageType:'',//页面跳转类型 1为二手 0为订单
|
|
|
+ pageType:0,//页面跳转类型 0:订单 1:二手 2:超级会员 3:优惠券 4:认证通会员
|
|
|
payAmount:0,//本次支付金额
|
|
|
wechatcode:'',//微信code
|
|
|
state:0,//随机数
|
|
@@ -23,10 +25,10 @@ var payContainer = new Vue({
|
|
|
methods: {
|
|
|
infoPayOrderCheckoutCounter:function(){//初始化订单数据
|
|
|
var _this = this;
|
|
|
- _this.wechatcode = CAIMEI.getUrlParam('code');
|
|
|
- _this.state = JSON.parse(decodeURIComponent(CAIMEI.getUrlParam('state')));
|
|
|
- _this.payAmount = _this.state.payAmount;
|
|
|
- _this.pageType = _this.state.pageType;
|
|
|
+ // _this.wechatcode = CAIMEI.getUrlParam('code');
|
|
|
+ // _this.state = JSON.parse(decodeURIComponent(CAIMEI.getUrlParam('state')));
|
|
|
+ // _this.payAmount = _this.state.payAmount;
|
|
|
+ // _this.pageType = _this.state.pageType;
|
|
|
_this.isRequest = true;
|
|
|
if( _this.pageType == 1){
|
|
|
_this.productId = _this.state.productId;
|
|
@@ -42,197 +44,39 @@ var payContainer = new Vue({
|
|
|
}
|
|
|
},
|
|
|
WxPaySubmit:function(){
|
|
|
- if (this.pageType == 1) {
|
|
|
- this.WxRequestsecondHandPay();
|
|
|
+ if(this.paymentChannel == 'HLB'){
|
|
|
+ this.hlbWechatPayFn()
|
|
|
+ }else{
|
|
|
+ this.mhWechatPayFn()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ hlbWechatPayFn:function () {// 合利宝
|
|
|
+ console.log('=========>合利宝')
|
|
|
+ if (this.pageType == 1) {// 二手
|
|
|
+ this.hlb_WxRequestsecondHandPay();
|
|
|
} else if (this.pageType == 2) {
|
|
|
- this.WxRequestPaymentVipFn();
|
|
|
+ this.hlb_WxRequestPaymentVipFn();
|
|
|
} else if (this.pageType == 3) {
|
|
|
- this.WxRequestPaymentCouponFn();
|
|
|
+ this.hlb_WxRequestPaymentCouponFn();
|
|
|
} else if (this.pageType === 4){
|
|
|
- this.WxRequestPaymentAuthVipFn();
|
|
|
+ this.hlb_WxRequestPaymentAuthVipFn();
|
|
|
} else {
|
|
|
- this.WxRequestPaymentFn();
|
|
|
+ this.hlb_WxRequestPaymentFn();
|
|
|
}
|
|
|
},
|
|
|
- // 会员支付
|
|
|
- WxRequestPaymentVipFn: function(){
|
|
|
- var _this = this;
|
|
|
- var params = {
|
|
|
- code: _this.wechatcode,
|
|
|
- state: _this.rand(1000, 9999),
|
|
|
- vipId: _this.vipId,
|
|
|
- vipRecordId: _this.vipRecordId,
|
|
|
- returnUrl: 'https://www.caimei365.com/',
|
|
|
- };
|
|
|
- PayApi.PayVipMiniWxPay(params,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.onBridgeReady(PayInfo);
|
|
|
- }
|
|
|
- }else{
|
|
|
- CAIMEI.dialog("支付链接已失效,请重新扫码支付");
|
|
|
- setTimeout(function(){
|
|
|
- WeixinJSBridge.call('closeWindow');
|
|
|
- },3000);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- WxRequestPaymentAuthVipFn: function(){
|
|
|
- var _this = this;
|
|
|
- var params = {
|
|
|
- code: _this.wechatcode,
|
|
|
- state: _this.rand(1000, 9999),
|
|
|
- vipId: _this.vipId,
|
|
|
- vipRecordId: _this.vipRecordId,
|
|
|
- returnUrl: 'https://www.caimei365.com/',
|
|
|
- };
|
|
|
- PayApi.PayAuthVipMiniWxPay(params,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.onBridgeReady(PayInfo);
|
|
|
- }
|
|
|
- }else{
|
|
|
- CAIMEI.dialog("支付链接已失效,请重新扫码支付");
|
|
|
- setTimeout(function(){
|
|
|
- WeixinJSBridge.call('closeWindow');
|
|
|
- },3000);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- // 优惠券支付
|
|
|
- WxRequestPaymentCouponFn: function(){
|
|
|
- var _this = this;
|
|
|
- var params = {
|
|
|
- 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){
|
|
|
- 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.onBridgeReady(PayInfo);
|
|
|
- }
|
|
|
- }else{
|
|
|
- CAIMEI.dialog("支付链接已失效,请重新扫码支付");
|
|
|
- setTimeout(function(){
|
|
|
- WeixinJSBridge.call('closeWindow');
|
|
|
- },3000);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- WxRequestsecondHandPay:function(){ // 二手商品支付
|
|
|
- var _this = this;
|
|
|
- var params = {
|
|
|
- code: _this.wechatcode,
|
|
|
- state: _this.rand(1000, 9999),
|
|
|
- productId: _this.productId,
|
|
|
- returnUrl: 'https://www.caimei365.com/',
|
|
|
- };
|
|
|
- PayApi.PayOrdersecondWechat(params,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.onBridgeReady(PayInfo);
|
|
|
- }
|
|
|
- }else{
|
|
|
- CAIMEI.dialog("支付链接已失效,请重新扫码支付");
|
|
|
- setTimeout(function(){
|
|
|
- WeixinJSBridge.call('closeWindow');
|
|
|
- },3000);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- WxRequestPaymentFn:function(){ // 普通订单支付
|
|
|
- var _this = this;
|
|
|
- var params={
|
|
|
- payAmount:Math.round(_this.payAmount*100),
|
|
|
- code:_this.wechatcode,
|
|
|
- state:_this.rand(1000,9999),
|
|
|
- orderId:_this.orderID,
|
|
|
- returnUrl:'https://www.caimei365.com/',
|
|
|
- };
|
|
|
- PayApi.PayOrderMiniWxPay(params,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.onBridgeReady(PayInfo);
|
|
|
- }
|
|
|
- }else{
|
|
|
- CAIMEI.dialog('支付链接已失效,请重新扫码支付');
|
|
|
- setTimeout(function(){
|
|
|
- WeixinJSBridge.call('closeWindow');
|
|
|
- },3000);
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- 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);
|
|
|
- }
|
|
|
- });
|
|
|
+ mhWechatPayFn:function () {// 米花
|
|
|
+ console.log('=========>米花')
|
|
|
+ if (this.pageType == 1) {
|
|
|
+ this.mh_WxRequestsecondHandPay();
|
|
|
+ } else if (this.pageType == 2) {
|
|
|
+ this.mh_WxRequestPaymentVipFn();
|
|
|
+ } else if (this.pageType == 3) {
|
|
|
+ this.mh_WxRequestPaymentCouponFn();
|
|
|
+ } else if (this.pageType === 4){
|
|
|
+ this.mh_WxRequestPaymentAuthVipFn();
|
|
|
+ } else {
|
|
|
+ this.mh_WxRequestPaymentFn();
|
|
|
+ }
|
|
|
},
|
|
|
rand:function (min,max) {//随机数
|
|
|
return Math.floor(Math.random()*(max-min))+min;
|