You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
9.7 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"use strict";!function(){function n(){return!!window.navigator.userAgent.toLowerCase().match(/(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)/i)}function t(){return!0===u||!1!==u&&!!window.navigator.userAgent.toLowerCase().match(/(csdn)/i)}function s(){return"micromessenger"==navigator.userAgent.toLowerCase().match(/MicroMessenger/i)}function e(){return/(?:android)/.test(window.navigator.userAgent.toLowerCase())}function o(){return window.csdn&&window.csdn.toolbarIsBlack}function i(n){var t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.href=n,document.getElementsByTagName("head")[0].appendChild(t)}function a(){var n=window.location.hostname;return n.indexOf("test")>=0||n.indexOf("loc")>=0?"test":n.indexOf("pre")>=0?"pre":"prod"}function p(){return v[a()].mallUrl}function d(n){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s="";for(var e in n)"function"!=typeof n[e]&&(s+=e+"="+(n[e]||"")+"&");return void 0,s=s.substr(0,s.length-1),(t?"?":"&")+s}function c(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=s.path||"";if(delete s.path,t()){var i=""+f+d(s,!1)+g.app[o];void 0,e()?window.jsCallBackListener&&window.jsCallBackListener.csdnjumpnewpage(JSON.stringify({url:i})):window.webkit&&window.webkit.messageHandlers.csdnjumpnewpage.postMessage(JSON.stringify({url:i}))}else n()?window.location.href=""+p()+g.wap[o]+d(s):window.open(p()+"/item/"+s.skuId+"?spm="+(s.spm||""))}function r(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{path:"",skuId:"",keyword:"",cat1:"",cat2:"",ca3:""},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return t&&-1===t.indexOf("mall.csdn.net/item")?void(window.location.href=t):n.path?g.app[n.path]?void c(n):void void 0:void void 0}function l(n,t){void 0,e()?window.jsCallBackListener&&window.jsCallBackListener.csdnapptrack(n,JSON.stringify(t)):window.webkit&&window.webkit.messageHandlers.csdnapptrack.postMessage([n,JSON.stringify(t)])}function h(n){e()?window.jsCallBackListener&&window.jsCallBackListener.csdnjumpnewpage(JSON.stringify({url:n})):window.webkit&&window.webkit.messageHandlers.csdnjumpnewpage.postMessage(JSON.stringify({url:n}))}function w(n){$.ajax({url:"https://img-home.csdnimg.cn/data_json/jsconfig/shop-window-v2.json",type:"get",dataType:"JSON",contentType:"application/x-www-form-urlencoded; charset=utf-8",success:function(t){t&&(v=t),$(function(){new m(n)})},error:function(n){}})}function m(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u=!0===n.isApp||!1!==n.isApp&&t(),this.env=n.env||a(),this.isDark=o(),this.isApp=u,this.userName=n.userName,this.nickName=n.nickName,this.topContainer=n.topEl,this.bottomContainer=n.bottomEl,this.callBack=n.callBack,this.cssLink=v[this.env].cssLink,this.hostUrl=v[this.env].hostUrl,this.h5Url=v[this.env].h5Url,this.adminUrl=v[this.env].adminUrl,this.init()}var u,g={app:{detail:"&path=pages/item/detail",search:"&path=pages/search/index",list:"&path=pages/search/list",catagory:"&path=pages/catagory/index",cart:"&path=pages/cart/list"},wap:{detail:"/pages/item/detail",search:"/pages/search/index",list:"/pages/search/list",catagory:"/pages/catagory/index",cart:"/pages/cart/list "}},f="csdnapp://app.csdn.net/mpTinyApp?id=__UNI__1117CC5",v={test:{hostUrl:"http://test-blog-web.csdn.net",h5Url:"https://test-cms-mall.csdn.net/p/181",cssLink:"../demo/shop-window.css",mallUrl:"https://test-mall.csdn.net",adminUrl:"https://test-mp.csdn.net/console/MyShop"},pre:{hostUrl:"https://pre-blog-web.csdn.net",h5Url:"https://mall.csdn.net/min-shop",cssLink:"https://g.csdnimg.cn/common/shop-window-v2/shop-window.css",mallUrl:"https://mall.csdn.net",adminUrl:"https://test-mp.csdn.net/console/MyShop"},prod:{hostUrl:"https://blog.csdn.net",h5Url:"https://mall.csdn.net/min-shop",cssLink:"https://g.csdnimg.cn/common/shop-window-v2/shop-window.css",mallUrl:"https://mall.csdn.net",adminUrl:"https://mp.csdn.net/console/MyShop"}};m.prototype.init=function(){(this.userName||(void 0,"test"===this.env))&&(i(this.cssLink),this.getDataByUserName(this.render))},m.prototype.render=function(t){function e(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=$(this).attr("data-name");i.isApp?l("w_blog_shopwindow_click",{pagename:"商品",name:i.userName,goods_name:s}):window.csdn.report&&window.csdn.report.reportClick({spm:t});var e=$(this).attr("data-id");e&&r({path:"detail",skuId:e,spm:"1001.2101."+t})}function o(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=i.isApp?i.h5Url+"?username="+i.userName:"https://blog.csdn.net/"+i.userName+"?type=shop";i.isApp?(l("w_blog_shopwindow_click",{pagename:"查看全部商品",name:i.userName,goods_name:t.goodsName}),h(o)):(window.csdn.report&&window.csdn.report.reportClick({spm:e}),s()?window.location.href=o:window.open(o))}var i=this,a="",p="",d={top:!1,bottom:!1};0!==this.topContainer.length&&t[1]&&t[1].items.length>0&&(a=u||n()?this.getWapHtml(t[1]):this.getPcHtml(t[1],"3001.5844",""),this.topContainer.on("click",".csdn-shop-window-item",function(n){e.call(this,n,"3001.5845")}),this.topContainer.on("click",".csdn-shop-window-link",function(n){o(n,"")}),d.top=!0),0!==this.bottomContainer.length&&t[2]&&t[2].items.length>0&&(p=u||n()?this.getWapHtml(t[2]):this.getPcHtml(t[2],"3001.5787","3001.5757"),this.bottomContainer.on("click",".csdn-shop-window-item",function(n){e.call(this,n,"3001.5756")}),this.bottomContainer.on("click",".csdn-shop-window-link",function(n){o(n,"3001.5758")}),d.bottom=!0),this.callBack&&"function"==typeof this.callBack&&this.callBack(d),a&&this.topContainer.append(a),p&&this.bottomContainer.append(p)},m.prototype.getPcHtml=function(n,t,s){var e=this;return"<div "+(e.isApp?"":'data-report-view=\'{"spm": "'+t+"\"}'")+' class="csdn-shop-window csdn-shop-window-pc '+(e.isDark?"csdn-shop-window-dark":"")+'">\n <h5 class="csdn-shop-window-head">\n <span title="'+n.shopWindowName+'" class="csdn-shop-window-title"><i></i>'+n.shopWindowName+"</span>\n "+(n.shopWindowDesc?'<span class="csdn-shop-window-desc"><i></i>'+n.shopWindowDesc+"</span>":"")+'\n <a class="csdn-shop-window-link shop-window-need-show" href="javascript:;"><i></i>更多</a>\n <a data-report-click=\'{"spm": "'+s+'"}\' class="csdn-shop-window-open" href="'+e.adminUrl+'" target="_blank">我也想开通小店</a>\n </h5>\n <div class="csdn-shop-window-body">\n '+n.items.map(function(n){return e.getPcItem(n)}).join("")+'\n <a class="csdn-shop-window-link shop-window-need-hide" href="javascript:;"><i></i><span>更多</span></a>\n </div>\n </div>'},m.prototype.getWapHtml=function(n){var t=this;return"<div "+(t.isApp?"":'data-report-view=\'{"spm": "3001.5787"}\'')+' class="csdn-shop-window csdn-shop-window-wap '+(t.isDark?"csdn-shop-window-dark":"")+'">\n <div class="csdn-shop-window-head">\n '+n.shopWindowName+'\n <a class="csdn-shop-window-link" href="javascript:;" >更多<i></i></a>\n </div>\n <div class="csdn-shop-window-body">\n '+n.items.map(function(n){return t.getWapItem(n)}).join("")+"\n </div>\n </div>"},m.prototype.getPcItem=function(n){var t="";return n.itemAttrList.forEach(function(s){t+='<span><em title="'+(n.owner||"")+'">'+s.key+""+(s.value||"暂无")+"</em></span>"}),'<a class="csdn-shop-window-item" data-id="'+n.itemId+'" data-name="'+n.itemName+'" href="javascript:;">\n <img src="'+n.itemPic+'" alt="">\n <div class="csdn-shop-window-item-content">\n <h6 title="'+n.itemName+'">'+n.itemName+'</h6>\n <p class="csdn-shop-window-item-info">\n '+t+'\n </p>\n <p class="csdn-shop-window-price-info">\n <span class="shop-window-need-hide"><em>好评:'+n.CommentRate+"</em></span>\n <span><em>销售量:"+n.salesVolume+"</em></span>\n <i>¥"+n.price+"</i>\n </p>\n </div>\n </a>"},m.prototype.getWapItem=function(n){var t="";return n.itemAttrList.forEach(function(n){t+='<p class="csdn-shop-window-item-autor">'+n.key+""+(n.value||"暂无")+"</p>"}),'<div class="csdn-shop-window-item" data-id="'+n.itemId+'" data-name="'+n.itemName+'">\n <img src="'+n.itemPic+'" alt=""> \n <div class="csdn-shop-window-item-content">\n <p class="csdn-shop-window-item-name">'+n.itemName+"</p>\n "+t+'\n <p class="csdn-shop-window-item-info">\n <span>好评:'+n.CommentRate+'</span>\n <span class="csdn-shop-window-item-info-num">销量:'+n.salesVolume+'</span>\n <span class="csdn-shop-window-item-info-price">¥'+n.price+"</span>\n </p>\n </div>\n </div>"},m.prototype.getDataByUserName=function(n){var s=this,e=this.hostUrl+"/phoenix/web/v2/get-shop-window-goods-list";t()&&(e="https://mall.csdn.net/mp/mall/api/shopWindow/goodsListV2"),$.ajax({url:e,type:"get",xhrFields:{withCredentials:!0},data:{username:s.userName},dataType:"json",success:function(t){if(200===t.code){var e={};for(var o in t.data)if("shopInfo"!==o){var i=t.data[o].list.reduce(function(n,t){return t.author=t.author||"暂无",t.press=t.press||"暂无",n.shopWindowDesc=t.shopWindowDesc,n.items=n.items.concat(t),n.goodsName=n.goodsName.concat(t.itemName),n},{shopWindowDesc:"",shopWindowName:""+(t.data.shopInfo&&t.data.shopInfo.shopName||"小店橱窗"),items:[],goodsName:[]});e[o]=i}void 0,n&&"function"==typeof n&&n.call(s,e)}},error:function(n){void 0}})},window.csdn.shop={},window.csdn.shop.show=function(n){w(n)}}();