"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"
\n
\n '+n.shopWindowName+"\n "+(n.shopWindowDesc?''+n.shopWindowDesc+"":"")+'\n 更多\n 我也想开通小店\n
\n
\n '+n.items.map(function(n){return e.getPcItem(n)}).join("")+'\n 更多\n
\n
'},m.prototype.getWapHtml=function(n){var t=this;return"
\n
\n '+n.shopWindowName+'\n 更多\n
\n
\n '+n.items.map(function(n){return t.getWapItem(n)}).join("")+"\n
\n
"},m.prototype.getPcItem=function(n){var t="";return n.itemAttrList.forEach(function(s){t+=''+s.key+":"+(s.value||"暂无")+""}),'\n \n
\n
'+n.itemName+'
\n

\n '+t+'\n

\n

\n 好评:'+n.CommentRate+"\n 销售量:"+n.salesVolume+"\n ¥"+n.price+"\n

\n
\n
"},m.prototype.getWapItem=function(n){var t="";return n.itemAttrList.forEach(function(n){t+='

'+n.key+":"+(n.value||"暂无")+"

"}),'
\n \n
\n

'+n.itemName+"

\n "+t+'\n

\n 好评:'+n.CommentRate+'\n 销量:'+n.salesVolume+'\n ¥'+n.price+"\n

\n
\n
"},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)}}();