"use strict";!function(t,e){function n(e){var n=new RegExp("(^|&)"+e+"=([^&]*)(&|$)","i"),o=t.location.search.substr(1).match(n);return null!=o?unescape(o[2]):null}function o(e){for(var n=t.location.search.substring(1),o=n.split("&"),i=0;i=0?i="https://mall.csdn.net":o.match(s)?i="https://test-mall-order.csdn.net":o.match(/^pre-|pre[a-z]*/)&&(i="https://pre-mall.csdn.net"),i}function a(n,o,i){o=isNaN(o)?3e3:o;var a=document.createElement("div");a.innerHTML=n,a.style.cssText="width:124px;opacity: 0.8;height: 40px;background:rgba(34,34,38,1);color: rgb(255, 255, 255);line-height: 40px;text-align: center;border-radius: 4px;position: fixed;top: 35%;left:50%;margin-left:-62px;z-index: 999999;font-size: 16px;",document.getElementById("user-ordertip").appendChild(a),setTimeout(function(){a.style.webkitTransition="-webkit-transform 0.5s ease-in, opacity 0.5s ease-in",a.style.opacity="0",setTimeout(function(){document.getElementById("user-ordertip").removeChild(a),i&&(e("#user-ordertip-box").remove(),t.location.reload())},500)},o)}function s(t,n,o){e("#ordertip_notify").show().html(''+n+""),e("#ordertip_qr_code").html(''),e("#ordertip_notify .pay_icon,#ordertip_notify .pay_tip").on("click",function(){u.getPayCode()})}function d(){s("pay_error","已扫码
请在手机端操作","")}function r(){s("pay_error","获取失败,点击重试","code_2")}function c(){s("pay_time_out","点击重新获取","")}function l(){a("支付成功","2000",!0)}function p(){this.goodType="",this.goodsList={},this.goodsInfo={},this.isUseBalance=!0,this.sale="",this.toPay="",this.errType="",this.reportExt={},this.navList=[],this.payMethods=[],this.price=0,this.payUrl="",this.params={}}t.csdn=t.csdn||{},csdn.userOrderTip=csdn.userOrderTip?csdn.userOrderTip:{};var g="https://g.csdnimg.cn/user-ordertip/4.1.3/images";!function(t){var e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.href=t,document.getElementsByTagName("head")[0].appendChild(e)}("https://g.csdnimg.cn/user-ordertip/4.1.3/user-ordertip.css"),p.prototype={constructor:p,close:function(){e("#user-ordertip").remove()},show:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.getOrderTipData(this.init,t)},init:function(t){var e=this;e.params=t,e.sale=t.sale_source||o("sale_source"),e.reportExt=t.report_ext||{},-1!=this.navList.findIndex(function(e){return e.flag==t.flag})?e.goodType=t.flag:e.goodType=e.goodType,e.getGoodsShowList(t),e.renderDialog(),e.setDefaultGoodsItem()},renderDialog:function(){var t=this;t.renderUserOrderTip(),t.renderNav(),t.renderGoodRights(),t.renderPaymenthods(),t.renderPaymentInfo()},renderUserOrderTip:function(){var t=this,n=e('
\n
\n
\n
\n
\n + \n
\n \n
\n
\n
\n\n
\n
  • \n
    \n \n
    \n
    \n

    \n 扫码支付\n

    \n
  • \n\n
    \n \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    ');e("body").prepend(n),t.$NavBox=n.find(".dialog_title"),t.$ProductBox=n.find(".dialog_product"),t.$RightsBox=n.find(".dialog_rights"),t.$PaymentInfoBox=n.find(".dialog_payment"),t.$PayMethodsBox=n.find(".scan_code"),t.$PayMentInfo=n.find(".commodity_box"),e(".dialog_wrapper_header .dialog_header_btn").on("click",function(e){t.close()}),n.on("click",function(n){e(n.target).find(".ordertip_dialog_wrapper").length&&t.close()})},renderNav:function(){var t=this,n=e(""+t.navList.map(function(e){return e.active=t.goodType==e.flag,'
  • \n "+e.extend1+"\n
  • "}).join(""));return t.$NavBox.append(n),n.on("click",function(n){t.goodType=e(this).data("flag"),t.renderProductList(),t.getGoodsInfo(),e(".dialog_title li").removeClass("active"),t.renderGoodRights(),t.renderPaymentInfo(),e(this).addClass("active")}),this},setDefaultGoodsItem:function(){var t=this,e=t.goodsList.find(function(e){return e.ext.goodsId===t.params.goods_id});t.navList.map(function(n){if(t.params.flag==n.flag&&e)return void(n.default=t.params.goods_id);if(""==n.default){var o=t.goodsList.find(function(t){if(t.ext.flag==n.flag&&t.ext.default)return n});n.default=o.ext&&o.ext.goodsId}}),t.renderProductList()},renderProductList:function(){var t=this,n=t.goodsList.filter(function(e){return e.ext.flag==t.goodType}),o=this.navList.find(function(e){return e.flag==t.goodType}),i=e(""+n.map(function(e,n){return'
    \n '+e.ext.activityContent+'\n
    '+e.title.split(":")[0]+'
    \n

    ¥'+e.ext.price.split(".")[0]+'

    \n
    推荐
    \n
    '}).join("")),a=e(""+n.map(function(e,n){return'
    \n
    '+e.title.split(":")[0]+'
    \n
    \n

    \n ¥'+Number(e.ext.isFirstOrder?e.ext.firstOrderPrice:e.ext.price).toFixed(1)+'\n \n \n 首单特惠\n 连续包月¥'+(1==e.ext.isContract?e.ext.price:e.ext.originalPrice)+'/月\n \n \n 原价'+e.ext.originalPrice+'元\n

    \n
    \n
    自动续费
    \n
    '}).join(""));t.$ProductBox.html(""),"28"==t.goodType?t.$ProductBox.append(a):t.$ProductBox.append(i),e(".dialog_product .dialog_vip").on("click",function(n){var o=this,i={goods_id:e(this).attr("goods_id"),product_id:e(this).attr("product_id"),flag:t.goodType};t.navList.map(function(n){n.flag==t.goodType&&(n.default=e(o).attr("goods_id"))}),e(".dialog_product .dialog_vip").removeClass("default"),e(this).addClass("default"),t.getGoodsInfo(i),t.renderGoodRights(),t.renderPaymentInfo()})},renderGoodRights:function(){var t=this,e='
    \n

    \n '+t.goodsInfo.name+' 权益详情\n

    \n
    ';t.$RightsBox.html(""),t.$RightsBox.append(e)},renderPaymenthods:function(){var t=this,e=""+t.payMethods.map(function(t){return'img'}).join("");t.$PayMethodsBox.prepend(e)},renderPaymentInfo:function(){var t=this,n='';t.$PayMentInfo.html(""),t.$PayMentInfo.append(n),e(".commodity_box .commodity_desc .user_balance").on("click",function(){t.goodsInfo.available_amount&&(t.isUseBalance=!t.isUseBalance,t.goodsCodeData(),t.getPayCode(),t.renderPaymentInfo())})},renderPayCode:function(t,n){QRCode?n.pay_url&&(e("#ordertip_qr_code").html(""),e("#ordertip_notify").hide(),e("#pay_btn").attr("href",n.pay_url),new QRCode(document.getElementById("ordertip_qr_code"),{text:n.pay_url,width:130,height:130})):console.warn("qrcode脚本不存在,请检查!")},getGoodsShowList:function(t){var n=this;e.ajax({url:i()+"/mp/mallorder/api/internal/goods/showList",type:"GET",dataType:"json",contentType:"application/json",async:!1,xhrFields:{withCredentials:!0},success:function(e){e.data&&e.data.length?(n.goodsList=e.data,t.goods_id&&t.flag==n.goodType?n.getGoodsInfo(t):n.getGoodsInfo(n.findDefaultGood())):console.warn("获取商品列表失败")},error:function(t){console.warn("获取商品列表失败")}})},findDefaultGood:function(){var t=this;return t.goodsList.find(function(e){return e.ext.flag==t.goodType&&1===e.ext.default})||{}},getGoodsInfo:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.findDefaultGood(),n=this,o=t;t&&t.ext&&(o={goods_id:t.ext.goodsId,product_id:t.ext.productId,flag:n.goodType}),e.ajax({url:i()+"/mp/mallorder/api/internal/goods/getGoodsInfo",type:"GET",dataType:"json",contentType:"application/json",async:!1,xhrFields:{withCredentials:!0},data:o,success:function(t){200==t.code&&t.data?(n.goodsInfo=t.data,n.payMethods=t.data.payTypeList,n.isUseBalance=!!t.data.available_amount,n.goodsCodeData(),n.getPayCode(t.data)):console.warn("该商品暂无数据")},error:function(t){console.warn("该商品暂无数据")}})},goodsCodeData:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.goodsInfo.new_price,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.goodsInfo.available_amount;if(this.isUseBalance){var o=t-n<0?0:(100*t-100*n)/100;this.price=Number(o).toFixed(2)}else this.price=Number(t);Number(this.price)<=0?e(".recharge_mode").addClass("none"):e(".recharge_mode").removeClass("none")},getPayCode:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.goodsInfo,e=this;cart.qrPay({product_id:t.product_id,goods_id:t.goods_id,flag:t.flag,sale_source:e.sale,report_ext:e.reportExt,is_use_balance:Number(e.isUseBalance),coupon_key:t.coupon_key,use_cache:!0,success_function:e.renderPayCode,error_function:r,timeout_function:c,payment_function:d,get_pay_success_callback:l})},getOrderTipData:function(t,n){var o=this;e.ajax({url:"https://img-home.csdnimg.cn/data_json/jsconfig/mall_ordertip.json",type:"get",dataType:"JSON",contentType:"application/x-www-form-urlencoded; charset=utf-8",success:function(e){o.navList=e.navList,o.goodType=e.goodType,o.showList=e.showList,n&&n.tags&&(o.navList=e.navList.filter(function(t){return n.tags.includes(t.flag)})),t&&t.call(o,n)},error:function(e){t&&t.call(o)}})}};var u=new p;t.csdn.userOrderTip={show:u.show.bind(u),close:u.close.bind(u)}}(window,jQuery);