1 |
- $(function(){function t(){h="https://csdnimg.cn/release/download/images/pay_error.png",w="已扫码<br>请在手机端操作",$("#payCode").html('<div class="renovate"><img src="'+h+'"><span>'+w+"</span></div>"),$("#payCodeImg").html('<img class="repeat-again" src="'+h+'"><span class="text">'+w+"</span>")}function a(a){var c={goods_id:a,flag:17,request_type:4,success_function:e,error_function:n,timeout_function:i,get_pay_success_callback:o,is_use_balance:l,payment_function:t};$("#payCode").html(C),$("#payCodeImg").html(x),cart.qrPay(c)}function e(t,a){f?r("payCode",a.pay_url):r("payCodeImg",a.pay_url),m=a.pay_url}function o(){y.boxshadow.fadeOut(function(){showToast({text:"支付成功",bottom:"10%",zindex:9e3,speed:500,time:1500}),window.location.reload(),y.payCode.fadeOut(function(){window.location.reload()})})}function n(t){showToast({text:t.errorMessage,bottom:"10%",zindex:9e3,speed:500,time:1500})}function i(){f?y.payCode.find("#payCode").html(k):y.getPay.find("#payCodeImg").html(v)}function c(t){switch(t){case"column":l?d(_,u)>0?$(".now-price").text("¥"+d(_,u)):$(".now-price").text("¥0"):$(".now-price").text("¥"+_);break;case"details":var a=$(".pay-money-span").attr("data-oldprice");l?d(a,u)>0?($(".pay-money-span").text(d(a,u)+"元"),s(!1,330)):($(".pay-money-span").text("0元"),s(!0,202)):($(".pay-money-span").text($(".pay-money-span").attr("data-oldprice")+"元"),s(!1,330))}}function s(t,a){y.payCode.css({height:a+"px"}),t?(y.payCode.find(".content-code").hide(),y.payCode.find(".content-blance").show()):(y.payCode.find(".content-blance").hide(),y.payCode.find(".content-code").show())}function d(t,a){var e=Number(t)-Number(a);return e>0?e.toFixed(2):e<0?e.toFixed(2):e}function p(t,e){$.ajax({type:"GET",url:"https://mall.csdn.net/mp/order/order/get_balance",xhrFields:{withCredentials:!0},crossDomain:!0,success:function(o){u=o.data.balance,I++,I<=1&&(0==u?(l=0,$(".pay-code-radio").prop("disabled",!0)):(l=1,$(".pay-code-radio").attr("data-flag","true"),$(".pay-code-radio").prop("checked",!0))),$(".pay-balance .balance").text(u),$(".pay-code-balance .balance").text(u),c(e),a(t)}})}function r(t,a){var e=qrcode(6,"M");e.addData(a),e.make(),$("#"+t).html(e.createImgTag(3,3)),$("#"+t).html($("#"+t).html()),f&&y.boxshadow.fadeIn(function(){y.payCode.fadeIn()})}var l=0,u=0,m="";$(document).on("click",".tip-subscribe-column>span",function(){$(this).parent().find(".tip").fadeIn()}),$(document).on("click",".tip-subscribe-column .bt-close",function(){$(".tip-subscribe-column").find(".tip").fadeOut()});var b="",y={boxshadow:$(".skin-boxshadow"),btClose:$(".bt-close"),payCode:$(".pay-code"),btSubscribe:$(".bt-subscribe-article"),btSubscribeColumn:$(".bt-subscribe-text"),getPay:$(".get-pay")},f=!1,g=window.location.href;g.indexOf("category_")>-1&&!f&&getCookie("UserName")&&y.btSubscribeColumn.length&&(b=y.getPay.data("id"),p(y.getPay.data("id"),"column")),$(document).on("click",".bt-subscribe",function(){getCookie("UserName")||window.csdn.loginBox.show()}),y.getPay.on("click",function(){f=!1,b=$(this).data("id"),a(b)}),$(document).on("click",".bt-subscribe-article",function(){f=!0,$(".pay-money-span").text($(".pay-money-span").data("nowprice")),getCookie("UserName")?(b=$(this).data("id"),p(b,"details")):window.csdn.loginBox.show()}),$(document).on("click","#bt-click",function(){f=!0,getCookie("UserName")?(b=$(this).data("id"),p(b,"details")):window.csdn.loginBox.show()}),y.payCode.on("click",".renovate",function(){a(b||$(this).parent().data("id"))}),y.btClose.on("click",function(){y.payCode.fadeOut(function(){y.boxshadow.fadeOut()})});var h=blogStaticHost+"dist/pc/img/pay-time-out.png",w="获取中",x='<img class="repeat-again" src="'+h+'"><span class="text">'+w+"</span>",C='<div class="renov-men"><img src="'+h+'"><span>'+w+"</span></div>",k='<div class="renovate"> <img src="'+blogStaticHost+'dist/pc/img/pay-time-out.png"> <span>点击重新获取</span></div>',v='<img class="repeat-again" src="'+blogStaticHost+'dist/pc/img/pay-time-out.png"><span class="text">点击重新获取</span>';$(".now-price").text();$(".pay-code-radio").click(function(){var t=$(this).attr("data-flag");"true"==t?(l=0,$(this).attr("data-flag","false"),$(this).prop("checked",!1)):(l=1,$(this).attr("data-flag","true"),$(this).prop("checked",!0)),p(b,$(this).attr("data-type"))});var _=$(".subscribe-price .now-price").text().slice(1),I=0;y.payCode.on("click",".blance-bt",function(){window.location.href=m})});
|