var smoney = ''; var sbookid = commont.getQueryString('book_id', window.location.search, '&') || ''; var schapterid = commont.getQueryString('chapter_id', window.location.search, '&') || ''; $(function () { /* if (typeof cpslog == 'undefined') { window.cpslog = function (arr, callback) { console.log('cps_log.js 未加载'); } }*/ /** * 头像点击s */ var n = 0; $('.re_head_box img').click(function () { n++; if (n > 4) { window.location.href = '/index/index/dev' } }); /** * 选项卡点击 */ $('.re_list_ul a').click(function () { var $this = $(this), goodsId = $this.data('goods-id'), goodsCategory = $this.data('goods-category'), goodsMoney = $this.data('goods-money'), activityId = $this.data('activity-id'); $this.parent().addClass('hover').siblings('li').removeClass('hover'); var but = $('#pay_btn'); but.data('goods-id', goodsId); but.data('goods-category', goodsCategory); but.data('activity-id', activityId); but.data('money', goodsMoney); but.text('立即充值:' + goodsMoney); }); /** * 充值按钮 */ var paystop = true; var payurl = '/api/recharge/pay'; $('.re_but_box a').click(function () { if (!paystop) { return false } paystop = false; var $this = $(this), goodsId = $this.data('goods-id'), goodsCategory = $this.data('goods-category'), activity_id = $this.data('activity-id'), urlid = $this.data('urlid'); ; smoney = $this.data('money'); business_line = parseInt($this.data('business_line')); sbookid = commont.getQueryString('book_id', window.location.search, '&') || ''; schapterid = commont.getQueryString('chapter_id', window.location.search, '&') || ''; cpslog([702, { adid: goodsId, map: { book_id: sbookid, chapter_id: schapterid, business:business_line, money: smoney } }, business_line]); var data = { id: goodsId, activity_id: activity_id, business_line:business_line, category: goodsCategory }; if(sbookid){ data.book_id = sbookid; } if(schapterid){ data.chapter_id = schapterid; } if (urlid) { data.url_id = urlid; } $('.js_loading').show(); $.ajax({ url: payurl, data: data, type: 'POST', timeout: 35000, success: function (data) { paystop = true; if (data.code) { switch (business_line) { case 0: //微信公众号支付 if (data.data) { var oJsonObj = JSON.parse(data.data.json); wechatPay(oJsonObj, goodsId); cpslog([703, { map: { package: oJsonObj.package, xdtype: goodsCategory, result: 1, book_id: sbookid, adid: goodsId, chapter_id: schapterid, business:business_line, money: smoney, urlid:urlid } }, 'xdjg']); } else { consoleMain(data.msg); } break; default: //alipay 支付宝 //wechath5 微信H5支付 break; } } else { consoleMain(data.msg); cpslog([703, { map: { xdtype: goodsCategory, result: 2, book_id: sbookid, adid: goodsId, chapter_id: schapterid, business:business_line, money: smoney, urlid: urlid } }, 'xdjg']); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { consoleMain('异常错误,请刷新页面重试'); cpslog([703, { map: { xdtype: goodsCategory, result: 4, book_id: sbookid, adid: goodsId, chapter_id: schapterid, business:business_line, money: smoney, XMLHttpRequest: XMLHttpRequest.status, textStatus: textStatus, errorThrown: errorThrown } }, 'xdjg']); paystop = true; }, complete: function () { $('.js_loading').hide(); } }) }); /** * 处理默认充值商品自动下单 */ var check = $('.re_but_box a.check'); if(check.length){ check.click(); } }); /** * 微信公众号支付 * @param json 微信支付相关数据 * @param goodsId 商品id */ function wechatPay(json, goodsId) { if (typeof WeixinJSBridge == "undefined") { if (document.addEventListener) { document.addEventListener('WeixinJSBridgeReady', function () { onBridgeReady(json, goodsId); }, false); } else if (document.attachEvent) { document.attachEvent('WeixinJSBridgeReady', function () { onBridgeReady(json, goodsId); }); document.attachEvent('onWeixinJSBridgeReady', function () { onBridgeReady(json, goodsId); }); } } else { onBridgeReady(json, goodsId); } } // 倒计时跳转链接 function innerJumpTime(redirect){ var _dialog_html = '