1(function (doc, win, $, undefined) { 2 3 Array.prototype.unique = function () { 4 var res = []; 5 var json = {}; 6 for (var i = 0; i < this.length; i++) { 7 if (!json[this[i]]) { 8 res.push(this[i]); 9 json[this[i]] = 1; 10 } 11 } 12 return res; 13 } 14 15 //æ¯éä¸ä½å°æ°å éå· 16 function toThousands(nStr) { 17 nStr += ''; 18 x = nStr.split('.'); 19 x1 = x[0]; 20 x2 = x.length > 1 ? '.' + x[1] : ''; 21 var rgx = /(\d+)(\d{3})/; 22 while (rgx.test(x1)) { 23 x1 = x1.replace(rgx, '$1' + ',' + '$2'); 24 } 25 return x1 + x2; 26 } 27 28 //æ¯éä¸ä½å°æ°å ç©ºæ ¼ 29 function toThousands2(nStr) { 30 nStr += ''; 31 x = nStr.split('.'); 32 x1 = x[0]; 33 x2 = x.length > 1 ? '.' + x[1] : ''; 34 var rgx = /(\d+)(\d{3})/; 35 while (rgx.test(x1)) { 36 x1 = x1.replace(rgx, '$1' + ' ' + '$2'); 37 } 38 return x1 + x2; 39 } 40 41 function getTime(seconds, type) { 42 if (seconds == '' || seconds == 0) return ''; 43 var date = new Date(parseInt(seconds) * 1000); 44 var time = ''; 45 if (!type) { 46 Y = date.getFullYear() + '-'; 47 M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; 48 D = date.getDate(); 49 h = date.getHours(); 50 m = date.getMinutes(); 51 s = date.getSeconds(); 52 D = D < 10 ? "0" + D : D; 53 h = h < 10 ? "0" + h : h; 54 m = m < 10 ? "0" + m : m; 55 s = s < 10 ? "0" + s : s; 56 time = Y + M + D + " " + h + ":" + m + ":" + s; 57 return time; 58 } else { 59 var month = new Array(12); 60 month[0] = "01", 61 month[1] = "02", 62 month[2] = "03", 63 month[3] = "04", 64 month[4] = "05", 65 month[5] = "06", 66 month[6] = "07", 67 month[7] = "08", 68 month[8] = "09", 69 month[9] = "10", 70 month[10] = "11", 71 month[11] = "12"; 72 73 Y = date.getFullYear(); 74 M = month[date.getMonth()]; 75 D = date.getDate(); 76 D = D < 10 ? "0" + D : D; 77 time = D + "/" + M + "/" + Y; 78 return time; 79 } 80 81 } 82 83 /* èæµå½æ° */ 84 function throttle (fn, delay) { 85 var args = arguments, 86 context = this, 87 timer = null, 88 remaining = 0, 89 previous = new Date(); 90 91 return function () { 92 var now = new Date(); 93 remaining = now - previous; 94 95 if (remaining >= delay) { 96 if (timer) { 97 clearTimeout(timer); 98 } 99 100 fn.apply(context, args); 101 previous = now; 102 } else { 103 if (!timer) { 104 timer = setTimeout(function () { 105 fn.apply(context, args); 106 previous = new Date(); 107 }, delay - remaining); 108 } 109 } 110 }; 111 } 112 113 function PoaHandler(options) { 114 this.checkEquipment(); 115 this.shippingModalPositon(); 116 this.$wrapper = $('.js-product-info').eq(0); 117 this.theme = $("#theme").val(); 118 this.pid = options.pid;//产åID 119 this.poaCodeList = options.poaCodeList;//屿§ç»å对åºçpoaç 120 this.wsData = options.wsData; 121 this.defaultPoaVid = options.defaultPoaVid ? JSON.parse(options.defaultPoaVid) : {};//é»è®¤éæ©ç屿§å符串ï¼ç¨.é´é 122 this.semData = options.semData ? JSON.parse(options.semData) : null;//semåæ°ï¼ä¼å 级æé«ï¼é»è®¤éä¸å±æ§å¼ 123 this.cur_warehouse = options.cur_warehouse;//产åæå¨ä»åº 124 this.isWsdataNull = this.wsData.length == 0 ? true : false; 125 this.stockQty = 0;//åºåæ°é 126 this.shopCartNum = 0; //è´ç©è½¦æ°é 127 this.poaNum = options.defaultPoa == '' ? options.selPoa : options.defaultPoa;//å½åååpoa,è¥æ poaå为sku 128 this.poaAttr = $(".poaItem");//屿§wrapper对象 129 this.poaLength = this.poaAttr.length;//屿§æ°é 130 this.activeNameArr = [];//屿§åæ°ç» 131 this.activeIndex = new Array(this.poaLength);//åæ¾data-vidçæ°ç» 132 this.activeIndex2 = new Array(this.poaLength);//åæ¾data-pidçæ°ç» 133 this.activeSortVid = new Array(this.poaLength);//åæ¾data-vidçæ°ç»,å¹¶å°æ°å¼ä»å¤§å°å°æåº 134 this.addBtnDisabled = false;//add to cartæé®æ¯å¦å¯ç¨; 135 this.shopStatus = $("#shopStatus").val() == 1 ? true : false;
136 this.wishId = $("#wishId").val(); 137 this.defaultSel = $('#currencyDefault').val(); 138 this.usPrice = Number($("#usPrice").val()); //产ååå§ä»·æ ¼(ç¾å ) 139 this.fbsendPrice = Number($("#usPrice").val()); //产åsku/poaç¾å ä»·æ ¼ï¼fbåç¹æ¶æäº¤è¯¥ä»·æ ¼ 140 this.oldUsPrice = Number($("#oldUsPrice").val()); 141 this.sel = null;//æå¨åæ¢çå¸ç§å¼ 142 this.selIcon = $.trim(this.$wrapper.find(".product_price .price_datalist").find('b').text());//å½åå¸ç§ç¬¦å· 143 this.isFTLoaded = false;//æ¯å¦è°ç¨è¿getPoaDataæ¹æ³ 144 this.isDefaultSelected = false;//æ¯å¦å·²ç»è¿è¡é»è®¤éä¸å±æ§ 145 this.defaultPoa =options.defaultPoa;//é»è®¤poaå¼ 146 this.shippingCode = '';//é®å¯æ¹å¼id 147 this.pcCountDownTimer = null; 148 this.mCountDownTimer = null; 149 150 this.poaCache = {};//ç¼å请æ±è¿çpoaä¿¡æ¯ 151 152 // var promos_allPage = Number($("#activity-total").attr('data-all-total')); 153 // this.promos_pageSize = 20; 154 // this.promos_allPage = promos_allPage % this.promos_pageSize === 0 ? (promos_allPage / this.promos_pageSize) : ( Number.parseInt(promos_allPage/this.promos_pageSize) + 1);//ææé¡µæ° 155 this.promos_pager = 1; //loadMore请æ±é¡µæ° 156 this.pro_loading = false; 157 this.pro_isLoadOver = false;//æ¯å¦æ²¡ææ´å¤é¡µæ°å è½½ 158 159 160 if (this.shopStatus) { 161 this.CurrencyCfg = CurrencyCfg;//å¸ç§æ±ç; 162 this.CurrencyLoss = CurrencyLoss;//è½¬æ¢æå¤±çï¼ 163 this.CurrencyBGLoss = CurrencyBGLoss;//è½¬æ¢æå¤±çï¼ 164 this.CurrencyBGEurLoss = CurrencyBGEurLoss;//æ¬§å æå¤±ç 165 this.CurrencyBGMxnLoss = CurrencyBGMxnLoss;//æ¬§å æå¤±ç 166 } 167 this.SKUResult = {}; 168 this.giftResult = {}; 169 170 if (this.isPc) { 171 this.$qtyBox = $(".js-product-info .quantity-container"); 172 this.$addBtn = $('.js-product-info .addToCart').eq(0); 173 this.$buyNowBtn = $('.js-product-info .js-buynow'); 174 this.$paypalBtn = $('.js-product-info .js-paypal'); 175 this.$startMyGroupBtn = $('.js-product-info .js-start-group'); 176 this.$wishlistWrap = $('.wishlist_wrap').eq(0); 177 this.$isMultiWishWrap = $('.isMultiPurpose-addWish'); 178 } else { 179 this.$qtyBox = $(".qty_box_m"); 180 this.$addBtn = $('.addToCart_m'); 181 this.$buyNowBtn = $('.js-buynow'); 182 this.$paypalBtn = $('.js-paypal'); 183 this.$startMyGroupBtn = $('.js-start-group'); 184 this.$wishlistWrap = $('.wishlist_m').eq(0); 185 this.$shareBtn = $('#share_m'); 186 this.$bottomBar = $('.fixed_bottom_btnWrap'); 187 } 188 189 this.$qtyInput = this.$qtyBox.find('.quantity_input');//æ°éè¾å ¥æ¡ 190 this.$minusBtn = this.$qtyBox.find('.minus');//æ°éåå°æé® 191 this.$plusBtn = this.$qtyBox.find('.plus');//æ°éå¢å æé® 192 //this.$previewImg = $(".single_pic").find('img');//ç¨äºé¢è§çimg对象 193 this.$giftList = $(".js-product-info .item_box.gift").find('.gift_list'); 194 this.$poaWrapper = $('.js-product-info .poa_wrap'); 195 this.$giftWrapper = $('.js-product-info .gift_wrap'); 196 this.$wholesaleWrap = $("#wholesale"); 197 this.dianzanPopTip = $('.js-dianzan-pop'); 198 this.productId = $('#product_id').val(); 199 200 this.initHeaderInfo();//åå§åç¨æ·ä¿¡æ¯æ¥å£æ°æ® 201 this.hasAccessory = false; 202 this.recordClickParams();//ç¸å ³æ¨èåç¹åæ° 203 this.checkAccessory();//æ£æ¥æ¯å¦å¼å¯ååç»å 204 this.init(); 205 206 } 207 208 PoaHandler.prototype = { 209 init: function () { 210 var _this = this; 211 this.initSKU(); //åå§åå¾å°poaç»æé 212 this.failedEdmLink();//edmé®ä»¶é¾æ¥è·³è½¬å¤ç 213 this._buildEvent(); //äºä»¶ç»å® 214 this.checkAmazonBtn(); 215 if (!this.isPc) { 216 this.buyWayInit(true);//M端åå§åç¬¬ä¸æ¹æé® 217 //this.btnOrderInit();//M端ä¸å模æ¿ï¼ä¸æ¹æé®é¡ºåºä¸å 218 if (this.poaLength > 0) { 219 this.attrPreviewInit();//M端æå±æ§æ¶ï¼POAå ¥å£åå§å 220 } 221 } 222 223 this.productBindEvent();//详æ 页äºä»¶ç»å® 224 this.keyCodeStockLimit();//æ°éå è´äº¤äºå¤ç 225 this.sizeChartDialog();//å°ºç 表交äºå¤ç 226 this.sizeChange();//å°ºç 屿§åæ¢ 227 228 this.judgeGaProductDetail();//è¡¡é产åè¯¦æ æ¥ç 229 this.initDefaultClick(); 230 this.checkShippingMethod();//è·åé»è®¤ä»åºçé®å¯æ¹å¼ 231 232 if(!this.isPc && this.getCookie('isChangedWarehouse')
232== '1'){ 233 $('.poa_wrap_title').click() 234 this.setCookie('isChangedWarehouse', '0', 0.5) 235 } 236 this.groupBuyRule_m(); 237 if(!this.isPc){ 238 this.scrollBind_m(); 239 } 240 }, 241 //n95产åï¼é®ä»¶é¾æ¥å¤±æå¤çï¼é¾æ¥å å«utm_medium=audew10074_1734ï¼è·³è½¬è³page_not_found 242 failedEdmLink: function(){ 243 var url = win.location.href 244 var len = (url.split('?')).length-1;//è¿æ¥ä¸?çé¿åº¦ 245 if(len>1 && url.indexOf('utm_medium=audew10074_1734')> -1){ 246 win.location.href = '/page_not_found' 247 } 248 }, 249 recordClickParams:function(){ 250 var rmmds = this.getQueryString("rmmds"); 251 var rp_url = localStorage.getItem("referer"); 252 var regObj = { 253 c: /-c-(.+)(?=\.html)/, 254 p: /-p-(.+)(?=\.html)/, 255 }; 256 this.recObj = {}; 257 if(localStorage.getItem("rec_keywords") != null){ 258 this.recObj.r_keywords = localStorage.getItem("rec_keywords"); 259 } 260 if(rmmds !== null && rmmds !== undefined ){ 261 this.recObj.r_position = rmmds 262 } 263 try{ 264 if(rp_url && rp_url != "null"){ 265 if (rp_url.indexOf('-c-') > -1) { 266 var rp_cs = rp_url.match(regObj.c), 267 rp_cid = rp_cs ? encodeURIComponent(rp_cs[1]) : 0; 268 this.recObj.r_cid = rp_cid; 269 } 270 271 if (rp_url.indexOf('-p-') > -1) { 272 var rp_cs = rp_url.match(regObj.p), 273 rp_pid = rp_cs ? encodeURIComponent(rp_cs[1]) : 0; 274 this.recObj.r_pid = rp_pid 275 } 276 } 277 } catch (error) { 278 console.log(error); 279 } 280 }, 281 checkAccessory:function(){ 282 var _this = this; 283 /* 没æpoa屿§æ¶å¨è¿é请æ±ä¸æ¬¡ç»åhtml,æpoaæ¶å·²ç»æ§è¡updatePoaæ¹æ³è¯·æ±æ¥å£ */ 284 if(_this.shopStatus){ 285 headerInfoAjax.then(function(data){ 286 _this.hasAccessory = data.data.has_acce; 287 if(_this.hasAccessory && !_this.defaultPoa){ 288 _this.getAccessoryHtml(); 289 } 290 }) 291 292 } 293 294 }, 295 setShipCountry: function(){ 296 var countryInfo = this.headerInfo.coutry_data; 297 var countryHtml = ''
298 countryHtml += '<em class="icon-flag icon-flag-'+ countryInfo.code +'" style="margin-right:5px"></em>' + 299 '<span>'+countryInfo.name+' </span>' 300 $('.js-shipto-country').html(countryHtml); //å¼¹æ¡æ¾ç¤ºship toå½å®¶ 301 $('.js-shipping-country').html(countryInfo.name); 302 }, 303 //è·åéä¸ä»åºåpoaçé®å¯æ¹å¼ 304 checkShippingMethod: function() { 305 var _this = this; 306 var poa = _this.poaNum != ''? _this.poaNum : _this.defaultPoa != '' ? _this.defaultPoa : productSKU ; 307 var code = $('.js-detail-warehouse .js-warehouse-item .active').attr('war_code'); //é»è®¤éä¸çä»åº 308 var len = $('.js-detail-warehouse .js-warehouse-item li').length; 309 if(len > 0) { 310 $.ajax({ 311 url: '/index.php?com=product&t=getProductShippingList', 312 type: 'get', 313 dataType: 'json', 314 data: { 315 'products_id': this.pid, 316 'poa':poa, 317 'code':code, 318 }, 319 success: function (response) { 320 var data = response.data, 321 str = '', 322 m_str = '', 323 selIcon = _this.selIcon, 324 $shipWrap = $('.ship_box_center'); 325 if(data.length){ 326 $shipWrap.show(); 327 //æ´æ°é®å¯æ¹å¼ 328 $.each(data, function (index, value) { 329 var PriceText = value.us_price == 0 ? 'Free Shipping' : _this.transformCurrencyText(value.currency, value.price) 330 if(index === 0) { 331 //æ´æ°è¯¦æ 页shippingå°åºæåæ¾ç¤º,æ¾ç¤ºç¬¬ä¸ä¸ªé®å¯æ¹å¼ 332 $shipWrap.find('.js-shipping-price').text(PriceText).attr('usprice',value.us_price); 333 $shipWrap.parent().find('.js-shipping-price').text(PriceText).attr('usprice',value.us_price); 334 $shipWrap.find('.js-shipping-method a, .js-mship-method a').text(value.name); 335 $shipWrap.find('.js-shipping-range').html(value.shipday); 336 } 337 var active = ''; 338 if(!this.shippingCode || this.shippingCode == ''){ 339 active = index == 0 ? 'active' : '' 340 } else { 341 active = value.code == this.shippingCode ? 'active' : '' 342 } 343 var tracked = value.tracked ? 'Tracked' : 'Not Tracked' 344 str += ' <li ship_days="'+ value.shipday +'" ship_name="'+ value.name +'" ship_price="'+ value.price +'" usprice="'+ value.us_price +'" class="ship_item '+ active +' ">' + 345 '<div class="list_cell list_name"><label></label>'+value.name+'</div>' + 346 '<div class="list_cell list_shipcost">'+PriceText+'</div>' + 347 '<div class="list_cell list_days"><u>'+value.shipday+'</u> business days</div>' + 348 '<div class="list_cell list_track">'+ tracked+'</div>' + 349 '</li>' 350 m_str += '<li ship_days="'+ value.shipday +'" ship_name="'+ value.name +'" ship_price="'+ value.price +'" usprice="'+ value.us_price +'" class="ship_m_item ship_item ' +active+'">' + 351 '<div class="ship_left"><label></label></div>' + 352 '<div><div class="ship_m_price">'+ PriceText +'</div>' + 353 '<div class="ship_m_method">'+value.name +', '+ value.shipday+' business days</div> <div>' + 354 '</li>' 355 }); 356 if(_this.isPc){ 357 $('.js-shipping-poplist').html(str) 358 } else { 359 $('.js-shipping-poplist').html(m_str) 360 } 361 } else { 362 $shipWrap.hide(); 363 } 364 }, 365 error: function () { 366 console.log('error'); 367 } 368 }) 369 } else { 370 var shippingText = 'sold out', 371 $shipping = $('.js-product-info').find(".shipping_text"); 372 $shipping.html(shippingText).addClass('warn'); 373 this.$addBtn.addClass('gray'); 374 this.$buyNowBtn.addClass('gray');
375 this.$paypalBtn.addClass('gray'); 376 this.$startMyGroupBtn.addClass('gray'); 377 this.isBtnDisabled = true; 378 } 379 380 }, 381 // è¿è´¹æ¾ç¤ºæ ¼å¼ä¿®æ£ 382 transformCurrencyText:function(currency,price) { 383 var selIcon = this.selIcon; 384 var strText = '' 385 var newCurrency = currency == ''? selIcon : currency 386 if (newCurrency == 'ÑÑб.' || newCurrency == 'AED') { 387 strText = strText = price + ' ' + newCurrency 388 } else { 389 strText = newCurrency + price 390 } 391 return strText 392 }, 393 productBindEvent: function () { 394 $('.js-product-info .js-apply-free').on('click', $.proxy(this.applyFreeProduct, this));//æµè¯é¡µç³è¯· 395 $(document).on('click', '.js-dianzan-pop .js-dianzan-close', $.proxy(this.dianZanHandler, this));//ç¹èµ or åæ¶ç¹èµ 396 }, 397 applyFreeProduct: function (e) { 398 var _this = this; 399 var applyUrl = $('.js-apply-free').attr('href'); 400 e.preventDefault(); 401 $.ajax({ 402 url: '/index.php?com=superuser&t=getUserVerify&products_id=' + _this.productId, 403 type: 'post', 404 dataType: 'json', 405 beforeSend: function () { 406 $('.m-makeup2-free').find('.loading_bg').show(); 407 $(e.target).parents().siblings('.loading_wrap').show(); 408 }, 409 success: function (data) { 410 $('.m-makeup2-free').find('.loading_bg').hide(); 411 $(e.target).parents().siblings('.loading_wrap').hide(); 412 if (data.code == 200) { 413 window.location.href = data.data.url; 414 } else if (data.code == 401) { 415 $(win).width() < 769 ? window.location.href = 'login.html' : _this.showPopLogin(); 416 } else if (data.code == 403) { 417 _this.dianzanPopTip.fadeIn().find('.ajax-tip').html(data.message); 418 setTimeout(function () { 419 window.location.href = applyUrl; 420 }, 3000); 421 } else { 422 _this.dianzanPopTip.fadeIn().find('.ajax-tip').html(data.message); 423 } 424 } 425 }) 426 }, 427 dianZanHandler: function (e) { 428 this.dianzanPopTip.hide().find('.ajax-tip').html(''); 429 }, 430 /* æ£æµè®¾å¤å®½åº¦ */ 431 checkEquipment: function () { 432 var winWidth = $(window).width(); 433 if (winWidth >= 845) { 434 this.isPc = true; 435 } else { 436 this.isPc = false; 437 } 438 }, 439 /*è·åPOAä¿¡æ¯*/ 440 getPoaData: function () { 441 var cacheData = this.poaCache[this.poaNum]; 442 //æ¯å¦æç¼åæ°æ® 443 if (cacheData) { 444 this.isUseCacheData = true; 445 this.poaDataHanlder(cacheData); 446 } else { 447 this.isUseCacheData = false; 448 this.showBtnLoading(); 449 var _this = this; 450 var data = new FormData(); 451 data.append('sel_poa', this.poaNum);//poa 452 data.append('products_id', _this.pid);//产åid 453 data.append('cur_warehouse', _this.cur_warehouse); 454 /* 没æå±æ§é åä¸ä¼ products_attr_id */ 455 if (_this.poaLength) { 456 $.each(this.activeIndex, function (i, val) { 457 data.append('products_attr_id[' + _this.activeIndex2[i] + ']', val); 458 }); 459 } 460 461 $.ajax({ 462 url: '/stockMessage.html', 463 type: 'post', 464 dataType: 'json', 465 data: data, 466 cache: false, 467 processData: false, 468 contentType: false, 469 success: function (data) { 470 _this.poaCache[_this.poaNum] = data;//ç¼åpoaæ°æ® 471 472 _this.poaDataHanlder(data);
473 _this.setCouponInfo(data.productCoupons); 474 475 if (!_this.isDefaultSelected) { 476 _this.isDefaultSelected = true; 477 } 478 479 _this.hideBtnLoading(); 480 }, 481 error: function () { 482 console.log('error'); 483 } 484 }) 485 486 } 487 if(!!this.isDefaultSelected){//é»è®¤é䏿¶ä¸è§¦åï¼å·²ç»é»è®¤éä¸ä¹åçpoaåæ¢ææ§è¡ 488 this.checkShippingMethod();//è·åææ°çè¿è´¹ 489 } 490 }, 491 /* äºä»¶ç»å® */ 492 _buildEvent: function () { 493 var _this = this, 494 qtyInput = '', 495 addToCartBtn = ''; 496 497 if (this.isPc) { 498 qtyInput = '.js-product-info .quantity-container .quantity_input'; 499 addToCartBtn = '.js-product-info .addToCart'; 500 501 /* æ¯å¦å¼å¯è´ç©è½¦ */ 502 if (this.shopStatus) { 503 this._giftEvent(); 504 } 505 506 this.countryHandler(); 507 $(doc).on('click', '.js-product-info .poaItem .attrimg:not(.gray)', $.proxy(this.previewPic, this));//é¢è§å¾ç 508 509 $(doc).on('click', '.js-amazon-btn, js-mbuy-amazon', $.proxy(this.thirdChannelFbEvents, this));//amazonæé®è½¬åç 510 $('.js-product-info .wholesale_price_wrap').hover(function () { 511 $(this).find('.wholesale_price_container').show(); 512 }, function () { 513 $(this).find('.wholesale_price_container').hide(); 514 }); 515 516 $(window).resize(this.shippingModalPositon); 517 } else { 518 qtyInput = '.qty_box_m .quantity_input'; 519 addToCartBtn = '.addToCart_m'; 520 this.poaHandler_m(); 521 this.giftHandler_m(); 522 this.wholeSaleHandler_m(); 523 this.share_m(); 524 this.countryHandler_m(); //ç¬¬ä¸æ¹æé®å½å®¶éæ© 525 526 $(doc).on('click', '.js-product-info .poaItem .attrimg', $.proxy(this.previewPic_m, this));//é¢è§å¾ç 527 528 this.buywayHandler_m(); 529 this.discountHandler_m();//M端满å 530 531 if (this.shopStatus) { 532 this.priceHandler_m(); 533 } 534 535 this.$bottomBar.find('.wishlist_m').on('click', $.proxy(this.triggerWishlist, this)); 536 } 537 538 if (this.shopStatus) { 539 $(doc).on('click', '.js-product-info .count.plus', $.proxy(this.plus, this));//æ°é+ 540 $(doc).on('click', '.js-product-info .count.minus', $.proxy(this.minus, this));//æ°é- 541 $(doc).on('click', addToCartBtn, $.proxy(this.addToCart, this));//å è´æé®äºä»¶ 542 $(doc).on('click', '.js-product-info .js-start-group', $.proxy(this.startMyGroup, this));//ç¹å»å¼å¢äºä»¶ 543 $(doc).on('click', '.js-product-info .js-buynow, .js-product-info .js-paypal', $.proxy(this.buyNow, this));//buynowäºä»¶ 544 $(doc).on('change', qtyInput, $.proxy(this.changeQty, this));//ä¿®æ¹æ°éäºä»¶ 545 $(doc).on('keypress', qtyInput, $.proxy(this.checkQtyVaild, this));//æ£éªé®çè¾å ¥æ°éäºä»¶ 546 $(doc).on('click', '.js-product-info .price_datalist li', $.proxy(this.changeCurrency, this));//忢å¸ç§ 547 $(doc).on('click', '.js-product-info .viewcart_btn', function () { 548 window.location.href = '/shopcart'; 549 }); 550 $(doc).on('click', '.shipping-modal .continue_btn,.shipping-modal .close_btn', function () { 551 _this.modalRemove(); 552 }); 553 win.modal_remove = this.addModalRemove.bind(this); 554 555 this.couponHandler(); 556 } 557 558 $(doc).on('click', '.js-product-info .poaItem .attr_item', $.proxy(this.updatePoa, this)); 559 $(doc).on('click', '.js-product-info .add_wish_list', $.proxy(this.triggerWishlist, this)); 560 $(doc).on('click', '.js-product-info .attrcolor, .js-product-info .attrimg', $.proxy(this.switchColorName, this)); //éä¸å¾çæè²åæ¾ç¤ºå±æ§å¼ 561 $(doc).on('click', '.js-product-info .js-close-fixed', $.proxy(this.closeFixed, this)); 562 $(window).resize($.proxy(this.shippingModalPositon, this)); 563 $(doc).on('click', '.js-detail-warehouse .js-warehouse-item .war_item:not(.disabled)', $.proxy(this.changeWarehouse, this));//忢ä»åºæ¶è·åä»åºè¿è¾æ¹å¼ 564 $(doc).on('click', '.js-detail-shipbox .js-shipping-method, .js-detail-module .js-shipping-close', $.proxy(this.changeShippingModal, this));//æ¾ç¤º/éèç©æµå¼¹æ¡ 565 $(doc).on('click', '.js-shipping-poplist li', $.proxy(this.changeShipping, this));//忢é®å¯æ¹å¼ 566 567 }, 568 /* æäº¤è´ç©è½¦ */ 569 addToCart: function (e) { 570 var _this = this, 571 $this = $(e.target); 572 if ($this.hasClass('gray')) return false;
573 if ($this.hasClass('forbidGray')) return false;//ç¦å®å°åº 574 if ($this.hasClass('loading_bg')) return false; 575 576 _this.judgeGaAddToCart(); 577 /* 屿§æ°éä¸ä¸º0 */ 578 if (this.poaLength !== 0) { 579 if (!this.isPc) { 580 /* M端 */ 581 var wrapIsShow = this.$poaWrapper.find('.poa_list_wrap').css('display') === 'none' ? false : true;//å¼¹æ¡æ¾ç¤ºç¶æ 582 if (wrapIsShow) { 583 /* ç¹å»å¼¹æ¡çå è´æé® */ 584 if (this.checkSelected(true)) { 585 this.addRequire(); 586 } 587 } else { 588 /* ç¹å»é¡µé¢ä¸æ¹çå è´æé® */ 589 this.openModal(); 590 this.$giftWrapper.removeClass('show').find('.gift_list_wrap').hide(); 591 this.$poaWrapper.find('.poa_list_wrap').show().find('.submit_box .addToCart_m').show().removeClass('bgwhite').css({'margin-left': 0,'margin-right': 0}).siblings().hide();//poaçªå£æ¾ç¤º 592 setTimeout(function () { 593 _this.$poaWrapper.addClass('show'); 594 }, 0); 595 //this.$poaWrapper.find('.poa_list_wrap').show().end().addClass('show'); 596 } 597 598 } else { 599 /* PC端 */ 600 if (this.checkSelected(true)) { 601 this.addRequire(); 602 } 603 } 604 605 } else { 606 this.addRequire(); 607 } 608 609 // Bingå¢è®¾åç¹ 610 _this.reportBingCustomEvent('click', 'product', 'middle_addToCart_button') 611 612 }, 613 /* å¼å¢æé®äºä»¶å¤ç */ 614 startMyGroup: function (e) { 615 var _this = this, 616 $this = $(e.currentTarget); 617 618 if ($this.hasClass('gray')) return false; 619 if ($this.hasClass('forbidGray')) return false;//ç¦å®å°åº 620 if ($this.hasClass('loading_bg')) return false; 621 622 _this.judgeGaAddToCart(); 623 /* 屿§æ°éä¸ä¸º0 */ 624 if (this.poaLength !== 0) { 625 if (!this.isPc) { 626 /* M端 */ 627 var wrapIsShow = this.$poaWrapper.find('.poa_list_wrap').css('display') === 'none' ? false : true;//å¼¹æ¡æ¾ç¤ºç¶æ 628 if (wrapIsShow) { 629 /* ç¹å»å¼¹æ¡çå è´æé® */ 630 if (this.checkSelected(true)) { 631 this.startGroupRequire(); 632 } 633 } else { 634 /* ç¹å»é¡µé¢ä¸æ¹çå è´æé® */ 635 this.openModal(); 636 this.$giftWrapper.removeClass('show').find('.gift_list_wrap').hide(); 637 this.$poaWrapper.find('.poa_list_wrap').show().find('.submit_box .addToCart_m').show().removeClass('bgwhite').css({'margin-left': 0,'margin-right': 0}).siblings().hide();//poaçªå£æ¾ç¤º 638 setTimeout(function () { 639 _this.$poaWrapper.addClass('show'); 640 }, 0); 641 //this.$poaWrapper.find('.poa_list_wrap').show().end().addClass('show'); 642 } 643 644 } else { 645 /* PC端 */ 646 if (this.checkSelected(true)) { 647 this.startGroupRequire(); 648 } 649 } 650 651 } else { 652 this.startGroupRequire(); 653 } 654 655 }, 656 /* æ¼å¢start my groupè¯·æ± */ 657 startGroupRequire: function () { 658 this.showBtnLoading(4); 659 660 var _this = this, 661 data = this.packAddData(), 662 quantity = this.$qtyInput.val(); 663 664 $.ajax({ 665 url: '/startGroupBuying.html', 666 type: 'post', 667 dataType: 'json', 668 data: data, 669 cache: false, 670 processData: false, 671 contentType: false, 672 success: function (res) { 673 if (res.code == 200) { 674 window.location.href = res.data.url; 675 } else { 676 _this.errorAlert(res.message); 677 } 678 _this.hideBtnLoading(); 679 680 //ç¹å»å è´æåå追踪æ¨è使°æ® 681 _this.recObj["ac"] = "cart"; 682 _this.recObj["products_id"] = _this.pid; 683 Record.rec(_this.recObj); 684 var rmmds = _this.getQueryString("rmmds") 685 if(rmmds === 'search'){ 686 nDC.RecordClick('startGroup', [_this.pid]) 687 } 688 //FBäºä»¶çæµ 689 _this.sendFbEvents('AddToCart') 690 }, 691 error: function (data) { 692 console.log(data); 693 _this.hideBtnLoading(); 694 } 695 }) 696 697 }, 698 /* éæ©ä»åºäº¤äº */ 699 changeWarehouse: function(e) { 700 var _this = this, 701 url = win.location.href, 702 newUrl = "", 703 gmcWarehouse = _this.getQueryString('cur_warehouse'), 704 $this = $(e.target); 705 if($this.hasClass('active')){ 706 return false;
707 } 708 if(!_this.isPc){ 709 _this.setCookie('isChangedWarehouse', '1', 0.5) 710 } 711 var code = $this.attr('war_code'); 712 if(gmcWarehouse == null || gmcWarehouse == ''){ 713 newUrl = url.indexOf('?') > -1 ? url + '&cur_warehouse=' + code : url + '?cur_warehouse=' + code 714 } else { 715 newUrl = _this.replaceParamVal(url,'cur_warehouse',code); 716 } 717 window.location.href = newUrl; 718 }, 719 //æ¿æ¢æå®ä¼ å ¥åæ°çå¼,url为å°å,paramNameä¸ºåæ°,replaceWith为æ°å¼ 720 replaceParamVal: function(url,paramName,replaceVal) { 721 var oUrl = url.toString(); 722 var re=eval('/('+ paramName+'=)([^&]*)/gi'); 723 var nUrl = oUrl.replace(re,paramName+'='+replaceVal); 724 return nUrl; 725 }, 726 /* è¿è¾æ¹å¼å¼¹æ¡ */ 727 changeShippingModal: function(e) { 728 if($('.js-detail-module').css('display') == 'none'){ 729 $('.js-detail-module').fadeIn(); 730 } else { 731 $('.js-detail-module').fadeOut(); 732 } 733 }, 734 /* 忢é®å¯æ¹å¼ */ 735 changeShipping: function(e) { 736 var $target = $(e.target).hasClass('ship_item')? $(e.target) : $(e.target).parents('.ship_item'); 737 $shipWrap = $('.js-detail-shipbox'); 738 $target.addClass('active').siblings().removeClass('active') 739 this.shippingCode = $target.attr('ship_code') 740 var pcShippingPrice = $target.find('.list_shipcost').text() 741 var mShippingPrice = $target.find('.ship_m_price').text() 742 //æ´æ°è¯¦æ 页shippingå°åºæåæ¾ç¤º,æ¾ç¤ºç¬¬ä¸ä¸ªé®å¯æ¹å¼ 743 if(this.isPc){ 744 $shipWrap.parent().find('.js-shipping-price').text(pcShippingPrice); 745 } else { 746 $shipWrap.find('.js-shipping-price').text(mShippingPrice); 747 } 748 $shipWrap.find('.js-shipping-method a, .js-mship-method a').text($target.attr('ship_name')); 749 $shipWrap.find('.js-shipping-range').html($target.attr('ship_days')); 750 $('.js-detail-module').fadeOut(); 751 }, 752 /** 753 * @desc æ£æµæ¯å¦äº§å屿§å ¨é 754 * @author lijiahao 755 * @param boolean isClickAddBtn æ¯å¦éè¿ç¹å»add to cartæé®è§¦å,ç¨äºæ¾ç¤ºæç¤ºè¯ 756 * @return boolean status 产å屿§æ¯å¦å ¨é 757 * */ 758 checkSelected: function (isClickAddBtn) { 759 var status = false, 760 length = 0, 761 _this = this; 762 if (this.poaAttr.length === 0) { 763 return true; 764 } 765 this.poaAttr.each(function () { 766 var isSelected = false, 767 $this = $(this); 768 769 $this.find('a').each(function () { 770 if ($(this).hasClass('active')) { 771 isSelected = true; 772 length++; 773 return false; 774 } 775 }); 776 /* æªéæ©å±æ§ && éè¿ç¹å»æé®è§¦å */ 777 if (!isSelected && isClickAddBtn) { 778 $this.find('.select_prompt').show(); 779 } 780 }); 781 if (length == this.poaLength) { 782 status = true; 783 } 784 return status; 785 }, 786 /*è·ååºåæ°é*/ 787 // getInventory: function(){ 788 // var data = this.poaData; 789 // for(var i = 0,j = this.activeIndex.length;i<j;i++){ 790 // data = data[this.activeIndex[i]]; 791 // } 792 // 793 // return data; 794 // }, 795 /* éæ©äº§å屿§è§¦å */ 796 updatePoa: function (e) { 797 /* 夿ç¹å»çæ¯å¦ä¸ºç©ºç<a>æ ç¾ï¼å¦<a>é颿<img>ï¼åéæ©<img>çç¶å ç´ <a> */ 798 if (!$(e.target).is('a')) { 799 e.target = $(e.target).parent(); 800 } 801 var _this = this, 802 activeNameArr = [], 803 $target = $(e.target), 804 $poaItem = $target.parents('.poaItem'), 805 poaIndex = $poaItem.attr('data-poaIndex'), 806 $errorTips = $target.parent().siblings('.select_prompt'); 807 808 //ææ åºåçæ åµ 809 if (!$target.hasClass('gray')){ 810 /* æåºå */ 811 if ($target.hasClass('active')) { 812 $target.removeClass('active'); 813 this.activeIndex[poaIndex] = ''; 814 this.activeIndex2[poaIndex] = ''; 815 } else { 816 $target.addClass('active').siblings().removeClass('active'); 817 this.activeIndex[poaIndex] = $(e.target).attr('data-vid'); 818 this.activeIndex2[poaIndex] = $(e.target).attr('data-pid'); 819 820 821 /* Mç«¯éæ©å±æ§åï¼æ¾ç¤ºææå·²é屿§å */ 822 if(!_this.isPc){ 823 var $active = $('.box_wrap .poaItem a.active');//å·²éç屿§ 824 $active.each(function () { 825 var str = '"' + $(this).attr('title') + '"' 826 activeNameArr.push(str); //æ¯ä¸ªå±æ§åç§° 827 }); 828 $('.js-selected-attr').html(activeNameArr.join(',')) 829 } 830 } 831 this.activeSortVid = $.extend(true,[],this.activeIndex); //æ·±æ·è´å·²éä¸çvidæ°ç» 832 this.activeSortVid.sort(function (value1, value2) { //å¯¹å ¶è¿è¡æåº 833 return parseInt(value1) - parseInt(value2); 834 }); 835 var $activeLen = $target.closest('.poa_wrap').find('.attr_item.active').length; 836 837 this.$qtyInput.parents('.limitContent').find('.limitQty').slide
837Up();//éèonly xxx left æç¤ºè¯ 838 839 /* éèæç¤ºè¯ */ 840 if ($errorTips.css('display') == 'none' ? false : true) { 841 $errorTips.hide(); 842 } 843 844 /* å·²é屿§æ°é = 屿§æ°é */ 845 if (this.poaLength == $activeLen) { 846 if (this.shopStatus) { 847 this.getPoaNum(); 848 this.getPoaData(); 849 // this.checkShippingMethod();//ææ¶ç§»å¨å°æ¤å¤ä¿æè¯·æ±poaæ£ç¡® 850 if (!this.isWsdataNull) { 851 this.updateWsTable(false); 852 } 853 } else { 854 this.updatePrice(); 855 } 856 857 //æååç»åç¹å»POAæ¶æéæ°è¯·æ±æ´æ°ååç»å 858 headerInfoAjax.then(function (data) { 859 _this.hasAccessory = data.data.has_acce; 860 if (_this.hasAccessory) { 861 _this.getAccessoryHtml(); 862 } 863 }) 864 } else { 865 if (this.shopStatus) { 866 /*è¥å±æ§æ²¡æéä¸ï¼å è´æé®ç½®ç°ï¼æ¾ç¤ºæç¤ºè¯*/ 867 this.$addBtn.addClass('gray'); 868 this.$buyNowBtn.addClass('gray'); 869 this.$paypalBtn.addClass('gray'); 870 this.$startMyGroupBtn.addClass('gray'); 871 this.checkSelected(true); 872 /* å·²ç»é»è®¤éä¸åï¼æè§¦å */ 873 if (this.isDefaultSelected) { 874 /* 请æ±åºå */ 875 this.getOthersStock(); 876 } 877 } 878 } 879 880 } 881 882 883 }, 884 /* è·å屿§ç»å对åºçpoaç */ 885 getPoaNum: function () { 886 var arr = [], 887 _this = this, 888 poaNum = null; 889 890 $.each(this.poaCodeList, function (i, val) { 891 arr = i.split(';'); 892 var len = 0; 893 $.each(arr, function (j, val2) { 894 if (_this.activeIndex.indexOf(val2) !== -1) { 895 len++ 896 } 897 }); 898 if (len == _this.activeIndex.length) { 899 poaNum = val; 900 return false; 901 } 902 }); 903 this.poaNum = poaNum; 904 }, 905 plus: function (e) { 906 var quantity = Number(this.$qtyInput.val()); 907 if (this.checkSelected(false)) { 908 if (this.stockQty > quantity) { 909 if (this.$plusBtn.hasClass('gray')) return false; 910 this.$qtyInput.val(++quantity); 911 //å½å®é åºåä¸ç¨æ·æ°é大äº300æ¶ 912 if (this.stockQty > 300 && quantity > 299) { 913 this.$qtyInput.val(300); 914 this.$qtyInput.parents('.limitContent').find('.limitQty').show().find('.moreStock').show().siblings().hide(); 915 this.$plusBtn.addClass('gray') 916 } 917 //å½å®é åºå<300ä¸å°äºç¨æ·å è´æ°éæ¶ 918 if (this.stockQty <= quantity && this.stockQty < 300) { 919 this.$plusBtn.addClass('gray'); 920 var stockTip = this.stockData.isPreorder == 1 && this.stockData.preorderInfo.once_limit_amount > 0 ? 'maximum '+this.stockQty+' pcs at a time' : 'Only ' + this.stockQty + ' left'; 921 this.$qtyInput.parents('.limitContent').find('.limitQty').show().find('.onlyStock').html(stockTip).show().siblings().hide(); 922 } 923 if (this.$minusBtn.hasClass('gray')) { 924 this.$minusBtn.removeClass('gray'); 925 } 926 } 927 } else { 928 if (this.$plusBtn.hasClass('gray')) return false;
929 this.$qtyInput.val(++quantity); 930 //å½å®é åºåä¸ç¨æ·æ°é大äº300æ¶ 931 if (this.stockQty > 300 && quantity > 299) { 932 this.$qtyInput.val(300); 933 this.$qtyInput.parents('.limitContent').find('.limitQty').show().find('.moreStock').show().siblings().hide(); 934 this.$plusBtn.addClass('gray') 935 } 936 //å½å®é åºå<300ä¸å°äºç¨æ·å è´æ°éæ¶ 937 if (this.stockQty <= quantity && this.stockQty < 300) { 938 this.$plusBtn.addClass('gray'); 939 var stockTip = this.stockData.isPreorder == 1 && this.stockData.preorderInfo.once_limit_amount > 0 ? 'maximum '+this.stockQty+' pcs at a time' : 'Only ' + this.stockQty + ' left'; 940 this.$qtyInput.parents('.limitContent').find('.limitQty').show().find('.onlyStock').html(stockTip).show().siblings().hide(); 941 } 942 943 944 if (this.$minusBtn.hasClass('gray')) { 945 this.$minusBtn.removeClass('gray'); 946 } 947 } 948 }, 949 minus: function (e) { 950 var quantity = this.$qtyInput.val(); 951 if (this.$minusBtn.hasClass('gray')) return false; 952 this.$qtyInput.val(--quantity); 953 if (this.$plusBtn.hasClass('gray')) { 954 this.$plusBtn.removeClass('gray'); 955 this.$qtyInput.parents('.limitContent').find('.limitQty').slideUp(); 956 } 957 958 if (quantity == 1) { 959 this.$minusBtn.addClass('gray'); 960 } 961 }, 962 plusHandler: function () { 963 var inputValue = Number(this.$qtyInput.val()); 964 if (inputValue >= this.stockQty) { 965 this.$plusBtn.addClass('gray'); 966 } else { 967 this.$plusBtn.removeClass('gray'); 968 } 969 }, 970 setPreSaleHandle: function(data, obj) { 971 var _this = this; 972 $('.js-isPreSale').css('display', 'block'); 973 var countDownTime = _this.getCountTimer(data.endTime); 974 if (_this.isPc) { 975 $('.js-pre-sale-activity').find('.js-pre-sale-name').text(data.name); 976 $('.js-pre-sale-activity').find('.js-counting-time').attr('data-time', countDownTime); 977 _this.pcCountDownTimer = new TimeFormat(); 978 $('.js-pre-sale-activity').find('.js-counting-time').each(function () { 979 _this.pcCountDownTimer.PhoneCountdownTime(this); 980 }); 981 $('.price_value_box').find('.js-pre-sale-price-box').show(0, $('.js-pre-sale-price-box').find('.js-discount').text(data.discount)); 982 $('.js-pre-sale-price-box').find('.js-isPreSale').attr('href', data.url); 983 } else { 984 $('.js-m-pre-sale-activity-box').find('.js-counting-time').attr('data-time', countDownTime); 985 _this.mCountDownTimer = new TimeFormat(); 986 $('.js-m-pre-sale-activity-box').find('.js-counting-time').each(function () { 987 _this.mCountDownTimer.PhoneCountdownTime(this); 988 }); 989 $('.js-m-pre-sale-activity-box').find('.js-view-more').attr('href', data.url); 990 $('.js-m-pop-wrap').find('.js-pre-sale-shipping').html(obj.message); 991 } 992 }, 993 getCountTimer: function(endTime) { 994 var timeStamp = (Date.parse(new Date())) / 1000; 995 var time = parseInt((endTime - timeStamp)); 996 return time; 997 }, 998 minusHandler: function () { 999 var inputValue = Number(this.$qtyInput.val()); 1000 if (inputValue != 1) { 1001 this.$minusBtn.removeClass('gray'); 1002 } else { 1003 this.$minusBtn.addClass('gray'); 1004 } 1005 }, 1006 /* æ´æ¹æ°éï¼å¦æªå ¨é屿§ï¼ä¸åéå¶ */ 1007 changeQty: function (e) { 1008 if (this.checkSelected(false)) { 1009 var num = this.stockQty; 1010 this.updateInput(num); 1011 } 1012 this.minusHandler(); 1013 }, 1014 /* æ£æµè¾å ¥æ¯å¦ä¸ºæ°å */ 1015 checkQtyVaild: function (e) { 1016 var keyCode = e.which; 1017 if (keyCode >= 48 && keyCode <= 57) { 1018 return true; 1019 } else { 1020 return false;
1021 } 1022 }, 1023 /** 1024 * @desc æ ¹æ®åºåæ°é对inputæ¡èµå¼ 1025 * @author lijiahao 1026 * @param Number num åºåæ°é 1027 * 1028 **/ 1029 updateInput: function (num) { 1030 var inputValue = this.$qtyInput.val(); 1031 if (inputValue > num && num > 0) { 1032 this.$qtyInput.val(num); 1033 } 1034 if (inputValue == 0 || num <= 0) { 1035 this.$qtyInput.val(1); 1036 } 1037 }, 1038 /* æ¾ç¤ºåºåä¿¡æ¯ */ 1039 updateStockInfo: function () { 1040 var stockQty = this.stockQty; 1041 var shippingText = this.stockData.message, 1042 $shipping = $('.js-product-info').find(".shipping_text"), 1043 warLen = $('.js-detail-warehouse .js-warehouse-item li').length, //ä»åºæ°éï¼æ ä»»ä½ä»åºåæ ä»»ä½é鮿¹å¼ 1044 ware_code = $('.js-warehouse-item').find('.war_item.active'); 1045 1046 if (stockQty > 0 && warLen > 0) { 1047 $shipping.removeClass('warn').html(shippingText); 1048 this.$addBtn.removeClass('gray'); 1049 this.$buyNowBtn.removeClass('gray'); 1050 this.$paypalBtn.removeClass('gray'); 1051 //æ¼å¢å¼å¢æé®åªæä¸ä»ææ 1052 if(ware_code === "CN"){ 1053 this.$startMyGroupBtn.removeClass('gray'); 1054 } 1055 this.isBtnDisabled = false; 1056 } else { 1057 $shipping.html('sold out').addClass('warn'); 1058 this.$addBtn.addClass('gray'); 1059 this.$buyNowBtn.addClass('gray'); 1060 this.$paypalBtn.addClass('gray'); 1061 this.$startMyGroupBtn.addClass('gray'); 1062 this.isBtnDisabled = true; 1063 } 1064 1065 }, 1066 //çå¬è¾å ¥æ°éinputåºåå è´å¤ç(éå¶ä¸è¶ 300) 1067 keyCodeStockLimit: function (e) { 1068 var _this = this; 1069 var inputChange = 0; 1070 var $limitTip = _this.$qtyInput.parents('.limitContent').find('.limitQty'); 1071 _this.$qtyInput.on('input propertychange', function () { 1072 inputChange = $(this).val(); 1073 if (_this.$plusBtn.hasClass('gray')) { 1074 _this.$plusBtn.removeClass('gray'); 1075 } 1076 $limitTip.slideUp(); 1077 }).blur(function () { 1078 var stockQty = _this.stockQty; 1079 var isPreorder = _this.stockData.isPreorder; 1080 var preorderLimit = _this.stockData.preorderInfo.once_limit_amount; 1081 var inputValue = Number($(this).val()); 1082 //å½å®é åºåä¸ç¨æ·æ°é大äº300æ¶ 1083 if (stockQty > 300 && inputValue > 299) { 1084 $limitTip.slideDown().find('.moreStock').show().siblings().hide(); 1085 _this.$plusBtn.addClass('gray'); 1086 $(this).val(300); 1087 } 1088 //å½å®é åºå<300ä¸å°äºç¨æ·å è´æ°éæ¶ 1089 if (stockQty < 300 && stockQty <= inputValue) { 1090 $(this).val(stockQty); 1091 _this.$plusBtn.addClass('gray'); 1092 var stockTip = isPreorder == 1 && preorderLimit > 0 ? 'maximum '+ stockQty+' pcs at a time' : 'Only ' + stockQty + ' left'; 1093 $limitTip.slideDown().find('.onlyStock').html(stockTip).show().siblings().hide(); 1094 } 1095 }) 1096 1097 }, 1098 1099 /* å å ¥è´ç©è½¦è¯·æ± */ 1100 addRequire: function () { 1101 this.showBtnLoading(1); 1102 1103 var _this = this, 1104 data = this.packAddData(), 1105 quantity = this.$qtyInput.val(); 1106 1107 1108 $.ajax({ 1109 url: '/addProduct.html', 1110 type: 'post', 1111 dataType: 'json', 1112 data: data, 1113 cache: false, 1114 processData: false, 1115 contentType: false, 1116 success: function (data) { 1117 if (data.message == 'success') { 1118 1119 var selected_total = _this.shopCartNum = data.data.selected_total; 1120 if(!_this.isPc){ 1121 $('.js-m-pop-wrap').removeClass('show') //å ³époa屿§éæ©å¼¹æ¡ 1122 $('.js-m-pop-wrap').find('.poa_list_wrap').hide(300); 1123 _this.closeModal() //æ¢å¤é¡µé¢æ»å¨ 1124 } 1125 1126 1127 /* é£å ¥å¯¼èªç¹æå¼å§ */ 1128 window.scrollTo(0,0) //æ»å¨å°é¡µé¢é¡¶é¨ 1129 if(_this.isPc) { 1130 var offset = $(".shopCart-box").offset(); 1131 var boxLeft = $('.js-addcart-flyer .addToCart').offset().left; 1132 var boxTop = $('.js-addcart-flyer .addToCart').offset().top - $(window).scrollTop(); 1133 leftNum = 7 1134 } else { 1135 var offset = $(".shopcart_m").offset(); 1136 var boxLeft = $(window).width()/2; 1137 var boxTop = 100; 1138 leftNum = 15 1139 } 1140 var img = $('#thumbs-banner>.swiper-wrapper').eq(0).find('img').attr('data-original'); 1141 var flyer = $('<img class="img-flyer" src="'+img+'">'); 1142 //é£å ¥å¯¼èªç¹æ 1143 flyer.fly({ 1144 start: { 1145 left: boxLeft, 1146 top: boxTop, 1147 }, 1148 end: { 1149 left: offset.left+ leftNum, 1150 top: offset.top - $(window).scrollTop() + 10, 1151 width: 20, 1152 height: 20 1153 }, 1154 speed: _this.isPc ? 0.9 : 0.8, //è¶å¤§è¶å¿«ï¼é»è®¤1.2 1155 onEnd: function(){ 1156 //ä¿®æ¹å¯¼èªå¤è´ç©è½¦æ°é 1157 if(_this.isPc){ 1158 $('.shopCart-box').find('.msg_sum').text(selected_total).show(); 1159 }else{ 1160 if(_this.theme === 'makeup2'){ 1161 $("#js-nav-container .m-nav-shopCart .msg_sum").text(selected_total).show(); 1162 } 1163 _this.$bottomBar.find('.shopcart_m .num').text(selected_total).show(); 1164 $('#js-nav-container .m-shopcart .num').text(selected_total).show(); 1165 } 1166 this.destory(); 1167 } 1168 }); 1169 1170 /* é£å ¥å¯¼èªç¹æç»æ */ 1171 1172 $('.shopcart-products-container').html(data.data.shopcart_list); 1173 1174 } else { 1175 _this.errorAlert(data.msg); 1176 } 1177 _this.hideBtnLoading(); 1178 1179 //ç¹å»å è´æåå追踪æ¨è使°æ® 1180 _this.recObj["ac"] = "cart"; 1181 _this.recObj["products_id"] = _this.pid; 1182 Record.rec(_this.recObj); 1183 var rmmds = _this.getQueryString('rmmds'); 1184 if(rmmds === 'search'){ 1185 //æç´¢åç¹ 1186 nDC.RecordClick('cart', [_this.pid]) 1187 } 1188 1189 //FBäºä»¶çæµ 1190 _this.sendFbEvents('AddToCart') 1191 }, 1192 error: function (data) { 1193 console.log(data); 1194 _this.hideBtnLoading(); 1195 } 1196 }) 1197 1198 }, 1199 //è·åurlä¸queryåæ° 1200 getQueryString: function (name) { 1201 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 1202 var r = window.location.search.substr(1).match(reg); 1203 if (r != null) return unescape(r[2]); 1204 return null; 1205 }, 1206 /*ç¹å»å è´æé®åæ·»å å¿æ¿åæé®åéFBäºä»¶ */ 1207 sendFbEvents: function (eventName) { 1208 var sku = productSKU,//产åsku 1209 currency = this.sel !== null ? this.sel : this.defaultSel,//å½åå¸ç§ 1210 quantity = this.$qtyInput.val(),//æ°é 1211 type = '',//content_typeç±»å 1212 price = this.fbsendPrice,//产åç¾å ä»·æ ¼ 1213 productData = pointData.pointData, 1214 gmcCountry = this.getQueryString('gmcCountry'), 1215 code = this.headerInfo.coutry_data.code, 1216 poaList = [], //poaæ°ç» 1217 id= '', 1218 obj = {}; 1219 var country = gmcCountry && gmcCountry !== '' ? gmcCountry : code; 1220 if (poaKeys.length) { 1221 type = 'product_group' 1222 } else { 1223 type = 'product' 1224 } 1225 if(poaCodeList != null) { 1226 Object.keys(poaCodeList).forEach(function(key){ 1227 var poaId = productData.products_id + '-' + poaCodeList[key].replace('POA', '') + '-' + country + '-' + productData.warehouse; //产åID-POAæ°å-å½å®¶ç¼ç -ä»åº 1228 poaList.push(poaId) 1229 }); 1230 } 1231 if (poaKeys.length) { 1232 this.getPoaNum(); 1233 } 1234 if (this.poaLength > 0) { 1235 if(poaCodeList != null){ 1236 id = productData.products_id + '-' + poaCodeList[this.activeSortVid.join(";")].replace('POA', '') + '-' + country + '-' + productData.warehouse; //产åID-POAæ°å-å½å®¶ç¼ç -ä»åº 1237 } 1238 } else { 1239 id = productData.products_id + '-' + productData.sku.replace('SKU', '') + '-' + country + '-' + productData.warehouse; //产åID-SKUæ°å-å½å®¶ç¼ç -ä»åº 1240 1241 } 1242 if (eventName === 'AddToCart') { 1243 obj = { 1244 value: (Number(quantity) * Number(price)).toFixed(2), 1245 currency: currency, 1246 content_ids: id, 1247 content_type: 'product', 1248 item_group_id: productData.products_id, 1249 contents: [ 1250 { 1251 id: id, 1252 quantity: quantity, 1253 item_price: price 1254 } 1255 ], 1256 } 1257 1258 } else if (eventName === 'AddToWishlist') { 1259 if (!poaKeys.length) { 1260 obj.content_ids = id 1261 } else { 1262 obj.content_ids = poaList 1263 } 1264 obj.content_type = type 1265 } 1266 //fb idå卿µåéäºä»¶ 1267 if (fbNo && fbNo != '') { 1268 fbq('track', eventName, obj); 1269 } 1270 1271 }, 1272 /* matccç«ç¹Buy At Amazon 转åçåç¹*/ 1273 thirdChannelFbEvents: function(){ 1274 var price = this.fbsendPrice,//产åç¾å ä»·æ ¼ 1275 host = win.location.host; 1276 1277 // audewç«ç¹SKU979938ä¸ä¸æ¥ 1278 if (host.indexOf('audew') > -1 && [100058].includes(+productID)) { 1279 return 1280 } 1281 try{ 1282 //åå夿-å忝å¦å å«matcc 1283 if(host.indexOf('matcc') > -1){ 1284 gtag('event', 'conversion', { 1285 'send_to': 'AW-715655859/F73FCOPS-q0BELOVoNUC', 1286 'value': Number(price*0.15).toFixed(2),//ç¾å ä»·æ ¼*0.15åç订åéé¢ 1287 'currency': 'USD',//åºå®ä¸å 1288 }); 1289 } else { 1290 awInfo.forEach(function(item){ 1291 gtag('event', 'conversion', { 1292 'send_to': item.id + '/' + item.label 1293 }); 1294 }) 1295 } 1296 1297 } catch (errors){ 1298 console.log('Fb id ä¸åå¨') 1299 } 1300 }, 1301 /* éèæ¨¡ææ¡ */ 1302 modalRemove: function () { 1303 $(".shipping-modal").hide(); 1304 }, 1305 /* å ³éå è´æåæç¤ºæ¨¡ææ¡ */ 1306 addModalRemove: function () { 1307 var _this = this, 1308 leftNum = 0, 1309 selected_total = this.shopCartNum; 1310 $(".shipping-modal").hide(); 1311 if(_this.isPc) { 1312 var offset = $(".shopCart-box").offset(); 1313 var boxLeft = $('.js-addcart-flyer .addToCart').offset().left; 1314 var boxTop = $('.js-addcart-flyer .addToCart').offset().top - $(window).scrollTop(); 1315 leftNum = 7 1316 } else { 1317 var offset = $(".shopcart_m").offset(); 1318 var boxLeft = $(window).width()/2; 1319 var boxTop = 100; 1320 leftNum = 15 1321 } 1322 var img = $('#thumbs-banner>.swiper-wrapper').eq(0).find('img').attr('data-original'); 1323 var flyer = $('<img class="img-flyer" src="'+img+'">'); 1324 //é£å ¥å¯¼èªç¹æ 1325 flyer.fly({ 1326 start: { 1327 left: boxLeft, 1328 top: boxTop, 1329 }, 1330 end: { 1331 left: offset.left+ leftNum, 1332 top: offset.top - $(window).scrollTop() + 10, 1333 width: 20, 1334 height: 20 1335 }, 1336 speed: _this.isPc ? 0.9 : 0.8, //è¶å¤§è¶å¿«ï¼é»è®¤1.2 1337 onEnd: function(){ 1338 //ä¿®æ¹å¯¼èªå¤è´ç©è½¦æ°é 1339 if(_this.isPc){ 1340 $('.shopCart-box').find('.msg_sum').text(selected_total).show(); 1341 }else{ 1342 if(_this.theme === 'makeup2'){ 1343 $("#js-nav-container .m-nav-shopCart .msg_sum").text(selected_total).show(); 1344 } 1345 _this.$bottomBar.find('.shopcart_m .num').text(selected_total).show(); 1346 $('#js-nav-container .m-shopcart .num').text(selected_total).show(); 1347 } 1348 this.destory(); 1349 } 1350 }); 1351 }, 1352 /* æ´æ¹é®å¯æ¹å¼ */ 1353 selShipment: function (self) { 1354 var $this = $(self); 1355 1356 $this.prop('checked', true); 1357 $shipments = $("#item_shipments_box"); 1358 $shipments.find('.shipping_type').html($this.attr('ship') + '<u><span class="arrow_a"><i><i></i></i></span></u>'); 1359 $shipments.find('.changePrice').html($this.attr('fee')); 1360 $shipments.find('.shipping_time>em').html($this.attr('time')); 1361 1362 }, 1363 /* è®¡ç®æ¨¡ææ¡ä½ç½® */ 1364 shippingModalPositon: function () { 1365 var modal_container = $('.shipping-modal .modal_container');//æ¨¡ææ¡container 1366 var modal_content = modal_container.children().eq(0);//æ¨¡ææ¡content对象 1367 var modal_content_width = modal_content.outerWidth(true);//content宽度 1368 var modal_content_height = modal_content.outerHeight(true);//contenté«åº¦ 1369 var window_width = $(window).outerWidth(true);//å±å¹å®½åº¦ 1370 var window_height = $(window).outerHeight(true);//å±å¹é«åº¦ 1371 var sum = 50;//ç¸å¯¹å¼ 1372 modal_content.css({ 1373 margin: '0 auto' 1374 }); 1375 if (!this.isPc) { 1376 modal_container.css({ 1377 marginTop: '225px' 1378 }); 1379 return; 1380 } 1381 if (modal_content_height >= window_height - sum) { 1382 modal_container.css({ 1383 marginTop: sum + 'px' 1384 }); 1385 } else { 1386 if ((window_height - modal_content_height) / 2 <= sum) { 1387 modal_container.css({ 1388 marginTop: sum + 'px' 1389 }); 1390 } else
1390 { 1391 modal_container.css({ 1392 marginTop: (window_height - modal_content_height) / 2 + 'px' 1393 }); 1394 } 1395 } 1396 1397 }, 1398 /* è¯¢é®æ¯å¦è¿å ¥è´ç©è½¦ */ 1399 // asking: function (quantity) { 1400 // var terminal = this.isPc ? '_pc' : '_m' 1401 // if(templates['asking'][this.theme + terminal]){ 1402 // $(".shipping-modal").show(200).find('.modal_container').html(templates['asking'][this.theme + terminal].replace(templates['asking']['replaceKey'], quantity )); 1403 // }else{ 1404 // $(".shipping-modal").show(200).find('.modal_container').html(templates['asking']['common'].replace(templates['asking']['replaceKey'], quantity )); 1405 // } 1406 // }, 1407 getObjKeys: function (obj) { 1408 if (obj !== Object(obj)) throw new TypeError('Invalid object'); 1409 var keys = []; 1410 for (var key in obj) 1411 if (Object.prototype.hasOwnProperty.call(obj, key)) 1412 keys[keys.length] = key; 1413 return keys; 1414 }, 1415 //æç»åçkeyæ¾å ¥ç»æéSKUResult 1416 add2SKUResult: function (combArrItem, sku) { 1417 var key = combArrItem.join(";"); 1418 if (this.SKUResult[key]) {//SKUä¿¡æ¯key屿§Â· 1419 this.SKUResult[key].count += sku.count; 1420 this.SKUResult[key].prices.push(sku.price); 1421 this.SKUResult[key].usPrice.push(sku.usPrice); 1422 this.SKUResult[key].usMarketPrice.push(sku.usMarketPrice); 1423 } else { 1424 this.SKUResult[key] = { 1425 prices: [sku.price], 1426 usPrice: [sku.usPrice], 1427 usMarketPrice: [sku.usMarketPrice], 1428 }; 1429 } 1430 }, 1431 add2GiftResult: function (combArrItem, sku, num) { 1432 var key = combArrItem.join(";"); 1433 if (!this.giftResult[num]) { 1434 this.giftResult[num] = {} 1435 } 1436 if (this.giftResult[num][key]) {//SKUä¿¡æ¯key屿§Â· 1437 //this.giftResult[key].count += sku.count; 1438 this.giftResult[num][key].prices.push(sku.price); 1439 } else { 1440 this.giftResult[num][key] = { 1441 prices: [sku.price] 1442 }; 1443 } 1444 }, 1445 //åå§åå¾å°ç»æé 1446 initSKU: function () { 1447 var i, j, skuKeys = this.getObjKeys(poaData); 1448 for (i = 0; i < skuKeys.length; i++) { 1449 var skuKey = skuKeys[i];//䏿¡poaä¿¡æ¯key 1450 var sku = poaData[skuKey]; //䏿¡poaä¿¡æ¯value 1451 var skuKeyAttrs = skuKey.split(";"); //poaä¿¡æ¯key屿§å¼æ°ç» 1452 var len = skuKeyAttrs.length; 1453 //对æ¯ä¸ªSKUä¿¡æ¯key屿§å¼è¿è¡æåç»å 1454 var combArr = this.arrayCombine(skuKeyAttrs); 1455 for (j = 0; j < combArr.length; j++) { 1456 this.add2SKUResult(combArr[j], sku); 1457 } 1458 //ç»æéæ¥æ¾å ¥SKUResult 1459 this.SKUResult[skuKey] = { 1460 prices: [sku.price], 1461 usPrices: [sku.usPrice], 1462 usMarketPrice: [sku.usMarketPrice] 1463 } 1464 } 1465 }, 1466 initGift: function () { 1467 for (var item in this.giftInfo) { 1468 var i, j, skuKeys = this.getObjKeys(this.giftInfo[item]); 1469 if (!skuKeys.length) { 1470 this.giftResult[item] = {}; 1471 } 1472 for (i = 0; i < skuKeys.length; i++) { 1473 var skuKey = skuKeys[i];//䏿¡poaä¿¡æ¯key 1474 var sku = this.giftInfo[item][skuKey]; //䏿¡poaä¿¡æ¯value 1475 var skuKeyAttrs = skuKey.split(";"); //poaä¿¡æ¯key屿§å¼æ°ç» 1476 var len = skuKeyAttrs.length; 1477 //对æ¯ä¸ªSKUä¿¡æ¯key屿§å¼è¿è¡æåç»å 1478 var combArr = this.arrayCombine(skuKeyAttrs); 1479 for (j = 0; j < combArr.length; j++) { 1480 this.add2GiftResult(combArr[j], sku, item); 1481 } 1482 //ç»æéæ¥æ¾å ¥SKUResult 1483 this.giftResult[item][skuKey] = { 1484 prices: [sku.price] 1485 } 1486 } 1487 } 1488 }, 1489 pad: function (num, len) { 1490 var num = num.toString(2).toString(); 1491 var length = num.length 1492 for (var i = 0; i < (len - length); i++) { 1493 num = "0" + num; 1494 } 1495 return num.split(''); 1496 '' 1497 }, 1498 /** 1499 * 仿°ç»ä¸çææå®é¿åº¦çç»å 1500 */ 1501 arrayCombine: function (targetArr) { 1502 if (!targetArr || !targetArr.length) { 1503 return []; 1504 } 1505 var len = targetArr.length; 1506 var resultArrs = []; 1507 // ææç»å 1508 var flagArrs = []; 1509 var combineTotal = Math.pow(2, 4) - 1; 1510 for (var n = 1; n <= combineTotal; n++) { 1511 flagArrs.push(this.pad(n, len)); 1512 } 1513 for (var i = 0; i < flagArrs.length; i++) { 1514 var combArr = []; 1515 var flagArr = flagArrs[i]; 1516 for (var j = 0; j < len; j++) { 1517 (flagArr[j] > 0) && combArr.push(targetArr[j]); 1518 } 1519 resultArrs.push(combArr); 1520 } 1521 return resultArrs; 1522 }, 1523 /**
1524 * @desc æªå¼å¯è´ç©è½¦æ¶çä»·æ ¼åæ¢ 1525 * @author lijiahao 1526 */ 1527 updatePrice: function () { 1528 var _this = this, 1529 $active = $('.poaItem a.active');//å·²é屿§çæ°é 1530 1531 if ($active.length === this.poaLength) { 1532 var selectedIds = [];//åæ¾data-vidï¼ 1533 $active.each(function () { 1534 selectedIds.push($(this).attr('data-vid')); 1535 }); 1536 /* 屿§å¼ç±å°å°å¤§æåº */ 1537 selectedIds.sort(function (value1, value2) { 1538 return parseInt(value1) - parseInt(value2); 1539 }); 1540 1541 var selIcon = $.trim($(".product_price .price_datalist").find('b').text()); 1542 var usPrices = this.SKUResult[selectedIds.join(';')].usPrices; 1543 var usMarketPrice = this.SKUResult[selectedIds.join(';')].usMarketPrice; 1544 var maxPrice = Math.max.apply(Math, usPrices); 1545 var minPrice = Math.min.apply(Math, usPrices); 1546 var maxUsMarketPrice = Math.max.apply(Math, usMarketPrice); 1547 1548 // maxPrice = _this.transformPrice(maxPrice); 1549 // maxUsMarketPrice = _this.transformPrice(maxUsMarketPrice); 1550 1551 if (this.isPc) { 1552 $(".product_price").find('.new_price>.price_value').text(toThousands(maxPrice)); 1553 if (selIcon != 'ÑÑб.' && selIcon != 'AED') { 1554 $(".product_price").find('.old_price').text(selIcon + toThousands(maxUsMarketPrice)); 1555 } else { 1556 $(".product_price").find('.old_price').text(toThousands(maxUsMarketPrice) + ' ' + selIcon); 1557 } 1558 } else { 1559 if (selIcon != 'ÑÑб.' && selIcon != 'AED') { 1560 $(".product_price").find('.new_price>.price_value').text(selIcon + toThousands(maxPrice)); 1561 $(".product_price").find('.old_price').text(selIcon + toThousands(maxUsMarketPrice)); 1562 } else { 1563 $(".product_price").find('.new_price>.price_value').text(toThousands(maxPrice) + ' ' + selIcon); 1564 $(".product_price").find('.old_price').text(toThousands(maxUsMarketPrice) + ' ' + selIcon); 1565 } 1566 } 1567 } 1568 1569 }, 1570 /** 1571 * @desc ä»stockMessageæ¥å£è·åä»·æ ¼åæ´æ°ä»·æ ¼ 1572 * @author lijiahao 1573 */ 1574 updatePrice2: function () { 1575 var _this = this, 1576 sel = this.sel !== null ? this.sel : this.defaultSel,//å½åå¸ç§ 1577 selIcon = $.trim($(".product_price .price_datalist").find('b').text()),//å½åå¸ç§icon 1578 stockData = this.stockData,//åºåä¿¡æ¯ 1579 final_price = this.transformPrice(stockData.final_price_usd), 1580 market_price = this.transformPrice(stockData.market_price_usd); 1581 1582 this.fbsendPrice = stockData.final_price_usd; //è·åpoaçusä»·æ ¼ 1583 1584 if(this.isUseCacheData){ 1585 if (_this.isPc) { 1586 if(selIcon != 'ÑÑб.'){ 1587 $(".product_price").find('.new_price>.price_value').text(toThousands(final_price)); 1588 }else{ 1589 $(".product_price").find('.new_price>.price_value').text(toThousands2(final_price)); 1590 } 1591 } else { 1592 if (selIcon == 'ÑÑб.' || selIcon == 'AED') { 1593 $(".product_price").find('.new_price>.price_value').html(toThousands(final_price) + ' ' + selIcon); 1594 $(".activity-phone .product-info .activity-price").html(toThousands(final_price) + ' ' + selIcon);//M端活å¨ä»· 1595 } else { 1596 $(".product_price").find('.new_price>.price_value').html(selIcon + toThousands(final_price)); 1597 $(".activity-phone .product-info .activity-price").html(selIcon + toThousands(final_price));//M端活å¨ä»· 1598 } 1599 } 1600 1601 if (selIcon == 'ÑÑб.' || selIcon == 'AED') { 1602 if(selIcon != 'ÑÑб.'){ 1603 $(".product_price").find('.old_price').text(toThousands(market_price) + ' ' + selIcon); 1604 $(".activity-phone .product-info .activity-del").text(toThousands(market_price) + ' ' + selIcon);//M端活å¨ä»· 1605 }else{ 1606 $(".product_price").find('.old_price').text(toThousands2(market_price) + ' ' + selIcon); 1607 $(".activity-phone .product-info .activity-del").text(toThousands2(market_price) + ' ' + selIcon);//M端活å¨ä»· 1608 } 1609 } else { 1610 $(".product_price").find('.old_price').text(selIcon + toThousands(market_price)); 1611 $(".activity-phone .product-info .activity-del").text(selIcon + toThousands(market_price));//M端活å¨ä»· 1612 } 1613 }else{ 1614 /* data-uspriceç¨äºå³ä¸è§åæ¢å¸ç§æ¶ç¨çæ°æ® */ 1615 if (this.isPc) { 1616 $(".product_price").find('.new_price>.price_value').text(stockData.final_price).attr('data-usprice', stockData.final_price_usd); 1617 } else { 1618 $(".product_price").find('.new_price>.price_value').text(stockData.format_final_price).attr('data-usprice', stockData.final_price_usd); 1619 //å¤çæ´»å¨åºåä»·æ ¼æ¾ç¤º 1620 $(".activity-phone").find('.activity-price').text(stockData.format_final_price).attr('data-usprice', stockData.final_price_usd); 1621 } 1622 1623 if (sel === 'USD') { 1624 $(".product_price").find('.old_price').text(stockData.format_market_price).attr('data-usprice', stockData.market_price_usd); 1625 $(".activity-phone").find('.activity-del').text(stockData.format_market_price).attr('data-usprice', stockData.market_price_usd); 1626 } else { 1627 if (selIcon != 'ÑÑб.' && selIcon != 'AED') { 1628 $(".product_price").find('.old_price').text(selIcon + stockData.market_price).attr('data-usprice', stockData.market_price_usd); 1629 $(".activity-phone").find('.activity-del').text(selIcon + stockData.market_price).attr('data-usprice', stockData.market_price_usd); 1630 } else { 1631 $(".product_price").find('.old_price').text(stockData.market_price + ' ' + selIcon).attr('data-usprice', stockData.market_price_usd); 1632 $(".activity-phone").find('.activity-del').text(stockData.market_price + ' ' + selIcon).attr('data-usprice', stockData.market_price_usd); 1633 } 1634 } 1635 } 1636 1637 }, 1638 showAmazonList: function (e) { 1639 $(e.target).siblings('.dropdown_list').toggle(); 1640 }, 1641 chooseGift: function (e) { 1642 var $gift_item = $(e.target).closest('.gift_item'); 1643 if ($gift_item.hasClass('disabled')) return false;
1644 if ($gift_item.hasClass('isChecked')) { 1645 $gift_item.removeClass('isChecked'); 1646 if (!this.isPc) { 1647 $gift_item.find('.clickIcon:visible>i').removeClass('icon-M-selected').addClass('icon-M-Notselected'); 1648 this.changeGiftText_m(); 1649 } 1650 } else { 1651 var isNull = false; 1652 var $attr_item = $gift_item.find('.gift_info_wrap').find('.info_attr'); 1653 $attr_item.each(function () { 1654 if ($(this).find('.gift_attr.active').length == 0) { 1655 isNull = true; 1656 } 1657 }); 1658 if (isNull) return false; 1659 $gift_item.addClass('isChecked'); 1660 if (!this.isPc) { 1661 $gift_item.find('.clickIcon>i').addClass('icon-M-selected').removeClass('icon-M-Notselected'); 1662 this.changeGiftText_m(); 1663 } 1664 e.stopPropagation(); 1665 } 1666 }, 1667 _giftEvent: function () { 1668 var _this = this; 1669 $(doc).on('click', '.js-product-info .gift .gift_attr:not(.gray)', $.proxy(this.updateGift, this)); 1670 $(doc).on('click', '.js-product-info .gift_info_wrap', function (e) { 1671 e.stopPropagation(); 1672 }); 1673 1674 $(doc).on('click', '.js-product-info .gift_item>.clickIcon', $.proxy(this.chooseGift, this)); 1675 $(doc).on('click', '.js-product-info .gift_item>a:not(.gray)', function (e) { 1676 if ($(this).siblings('.gift_info_wrap').find('.info_attr').length == 0) { 1677 window.open($(this).attr('data-url')); 1678 return false; 1679 } 1680 // if($(this).parent().hasClass('showInfo')){ 1681 // $(this).parent().removeClass('showInfo'); 1682 // return false; 1683 // } 1684 $('.gift_item').removeClass('showInfo'); 1685 $(this).parent().addClass('showInfo'); 1686 1687 /* æ ¹æ®wrapé«åº¦ï¼éæ°è®¾ç½®topå¼ */ 1688 var $wrap = $(this).next('.gift_info_wrap'); 1689 _this.giftModalPostion($wrap); 1690 1691 e.stopPropagation(); 1692 }); 1693 $(doc).on('click', '.js-product-info .gift_info_wrap .ok_btn', $.proxy(this.checkGift, this)); 1694 $(doc).on('click', '.js-product-info .gift_info_wrap .cancel_btn', function () { 1695 var $wrap = $(this).closest('.gift_info_wrap'); 1696 $(this).parents('.gift_item').removeClass('showInfo'); 1697 if ($wrap.find('.info_attr').length !== $wrap.find('.gift_attr.active').length) { 1698 $wrap.closest('.gift_item').removeClass('isChecked'); 1699 } 1700 }); 1701 }, 1702 updateGift: function (e) { 1703 /* 夿ç¹å»çæ¯å¦ä¸ºç©ºç<a>æ ç¾ï¼å¦<a>é颿<img>ï¼åéæ©<img>çç¶å ç´ <a> */ 1704 1705 if (!$(e.target).is('a')) { 1706 e.target = $(e.target).parent(); 1707 } 1708 1709 var _this = this, 1710 $target = $(e.target), 1711 gift_id = $target.closest('.gift_item').attr('data-giftid'); 1712 1713 if ($target.hasClass('active')) { 1714 $target.removeClass('active'); 1715 } else { 1716 $target.addClass('active').siblings().removeClass('active'); 1717 $target.closest('.info_attr').attr('data-activeIndex', $target.index()); 1718 } 1719 1720 $target.closest('.gift_info').next('.gift_tips').hide(); 1721 this.giftModalPostion($target.closest('.gift_info_wrap')); 1722 1723 if (!this.checkSelected(false)) return false; 1724 var selectedObjs = $target.closest('.gift_info').find('.gift_attr.active'); 1725 1726 if (selectedObjs.length) { 1727 //è·å¾ç»åkeyä»·æ ¼ 1728 var selectedIds = []; 1729 selectedObjs.each(function () { 1730 selectedIds.push($(this).attr('data-valueid')); 1731 }); 1732 selectedIds.sort(function (value1, value2) { 1733 return parseInt(value1) - parseInt(value2); 1734 }); 1735 var len = selectedIds.length; 1736 1737 1738 //ç¨å·²éä¸çèç¹éªè¯å¾ æµè¯èç¹ underTestObjs 1739 $target.closest('.gift_info').find('.gift_attr').not(selectedObjs).each(function () { 1740 var siblingsSelectedObj = $(this).siblings('.active'); 1741 var testAttrIds = [];//ä»éä¸èç¹ä¸å»æéä¸çå å¼èç¹ 1742 if (siblingsSelectedObj.length) { 1743 var siblingsSelectedObjId = siblingsSelectedObj.attr('data-valueid'); 1744 for (var i = 0; i < len; i++) { 1745 (selectedIds[i] != siblingsSelectedObjId) && testAttrIds.push(selectedIds[i]); 1746 } 1747 } else { 1748 testAttrIds = selectedIds.concat(); 1749 } 1750 testAttrIds = testAttrIds.concat($(this).attr('data-valueid')); 1751 testAttrIds.sort(function (value1, value2) { 1752 return parseInt(value1) - parseInt(value2); 1753 }); 1754 if (!_this.giftResult[gift_id][testAttrIds.join(';')]) { 1755 $(this).addClass('gray').removeClass('active'); 1756 } else { 1757 $(this).removeClass('gray'); 1758 } 1759 }); 1760 } 1761 1762 }, 1763 checkAmazonBtn: function () { 1764 if (this.isPc) { 1765 var $way_box = $('.way_btn_box'); 1766 var $country_wrap = $way_box.find('.country-fa'); 1767 var thirdChannel = $way_box.find('.way_btn_bg') 1768 if(thirdChannel.length < 2) { //ç¬¬ä¸æ¹æé®åªæä¸ä¸ªæ¶ï¼åæ¶é«äº®æ ·å¼ 1769 thirdChannel.eq(0).removeClass('first_btn') 1770 } 1771 if ($way_box.height() == 0) { 1772 $way_box.closest('.buy_way_wrap').hide(); 1773 return false;
1774 } 1775 $country_wrap.each(function () { 1776 if ($(this).find('.attrCountry').find('li').length == 0) { 1777 $(this).remove(); 1778 //$(this).addClass('gray'); 1779 } 1780 }); 1781 } else { 1782 $('.buy_way_wrap').remove(); 1783 var $buy_btn_list = $(".buybtn_list_wrap .btnlist"), 1784 btnLen = $(".buybtn_list_wrap").find('a').length; 1785 if (!btnLen) { 1786 this.$bottomBar.find('.abtest_buyway_btn,.countryBox').hide().end().find('.addToCart_m').css('width', '100%'); //M端æ ç¬¬ä¸æ¹æé®æ¶ï¼buy At æé®éè 1787 } 1788 } 1789 }, 1790 previewPic: function (e) { 1791 $('#bigImg-container .imgLoading').show(); 1792 if (!$(e.target).is('img')) { 1793 e.target = $(e.target).find('img'); 1794 } 1795 var pic_big_url = $(e.target).attr('pic_big'); 1796 $('.single_pic').eq(0).find('img').attr('src', pic_big_url).closest('.single_pic').show().siblings('.product_img_list').hide(); 1797 document.querySelector('.single_pic img').onload = function() { 1798 $('#bigImg-container .imgLoading').hide(); 1799 } 1800 }, 1801 previewPic_m: function (e) { 1802 if (!$(e.target).is('img')) { 1803 e.target = $(e.target).find('img'); 1804 } 1805 var pic_big_url = $(e.target).attr('pic_big'); 1806 $(".poa_wrap .base_img img").attr('src', pic_big_url); 1807 }, 1808 checkGift: function (e) { 1809 var $attr_item = $(e.target).parent().siblings('.gift_info').find('.info_attr'), 1810 attr_name = '', 1811 status = true; 1812 1813 $attr_item.each(function () { 1814 if ($(this).find('.gift_attr.active').length === 0) { 1815 status = false; 1816 attr_name = $(this).attr('data-name'); 1817 return false; 1818 } 1819 }); 1820 1821 if (!status) { 1822 $(e.target).parent().siblings('.gift_tips').show().children('span').text('please select a ' + attr_name); 1823 } else { 1824 $(e.target).closest('.gift_item').removeClass('showInfo').addClass('isChecked'); 1825 } 1826 1827 this.giftModalPostion($(e.target).closest('.gift_info_wrap')); 1828 }, 1829 /** 1830 * @desc ä¿®æ¹giftModalçä½ç½® 1831 * @author lijiahao 1832 * @param $wrap modalå®¹å¨ 1833 * 1834 **/ 1835 giftModalPostion: function ($wrap) { 1836 var wrapHeight = $wrap.outerHeight(); 1837 $wrap.css('top', -wrapHeight - 10); 1838 }, 1839 setGiftInfo: function () { 1840 var _this = this, 1841 $gift_item = $('.gift').find('.gift_item'); 1842 1843 $gift_item.each(function () { 1844 $(this).addClass('isChecked').removeClass('disabled'); 1845 $(this).find('.gift_attr').removeClass('active').addClass('gray'); 1846 }); 1847 1848 $gift_item.each(function () { 1849 var gift_id = $(this).attr('data-giftid'); 1850 if (_this.giftResult.hasOwnProperty(gift_id)) { 1851 var obj = _this.giftResult[gift_id]; 1852 for (var item in obj) { 1853 if (!/;/.test(item)) { 1854 $(this).find('.gift_attr[data-valueid=' + item + ']').removeClass('gray'); 1855 } 1856 } 1857 $(this).find('.attr_list').each(function () { 1858 /* activeIndex:åå å·²éåçindexå¼,忢poaæ¶éæ°éå */ 1859 var activeIndex = $(this).parent().attr('data-activeIndex'); 1860 if (activeIndex == undefined) { 1861 $(this).find('.gift_attr:not(.gray)').eq(0).click(); 1862 } else { 1863 if ($(this).find('.gift_attr').eq(activeIndex).hasClass('gray')) { 1864 $(this).find('.gift_attr:not(.gray)').eq(0).click(); 1865 } else { 1866 $(this).find('.gift_attr').eq(activeIndex).click(); 1867 } 1868 } 1869 1870 }); 1871 } else { 1872 $(this).removeClass('isChecked').addClass('disabled'); 1873 $(this).find('.gift_attr').removeClass('active').addClass('gray'); 1874 } 1875 }); 1876 1877 }, 1878 /**
1879 * @desc æé®loading 1880 * @param { number || undefined } type æé®ç±»å,1:add to cart; 2:buy now; 3:paypal 4:æ¼å¢start my group 1881 */ 1882 showBtnLoading: function (type) { 1883 var $loading = '<div class="loading_bg" style="display:block;"><img src="/templates/common/src/shopCart/images/loading.gif" class="loading"></div>'; 1884 if (type) { 1885 if (type === 1) { 1886 this.$addBtn.addClass('gray').append($loading); 1887 } else if (type === 2) { 1888 this.$buyNowBtn.addClass('gray').append($loading); 1889 } else if(type === 3){ 1890 this.$paypalBtn.addClass('gray').append($loading); 1891 }else if(type === 4){ 1892 this.$startMyGroupBtn.addClass('gray').append($loading); 1893 } 1894 } else { 1895 this.$addBtn.addClass('gray').append($loading); 1896 this.$buyNowBtn.addClass('gray').append($loading); 1897 this.$paypalBtn.addClass('gray').append($loading); 1898 this.$startMyGroupBtn.addClass('gray').append($loading); 1899 } 1900 }, 1901 hideBtnLoading: function () { 1902 if (!this.isBtnDisabled) { 1903 this.$addBtn.removeClass('gray').find('.loading_bg').remove(); 1904 this.$buyNowBtn.removeClass('gray').find('.loading_bg').remove(); 1905 this.$paypalBtn.removeClass('gray').find('.loading_bg').remove(); 1906 var ware_code = $('.js-warehouse-item').find('.war_item.active').attr('war_code'); 1907 //æ¼å¢å¼å¢æé®åªæä¸ä»ææ 1908 if(ware_code === "CN"){ 1909 this.$startMyGroupBtn.removeClass('gray') 1910 } 1911 this.$startMyGroupBtn.find('.loading_bg').remove(); 1912 } else { 1913 this.$addBtn.find('.loading_bg').remove(); 1914 this.$buyNowBtn.find('.loading_bg').remove(); 1915 this.$paypalBtn.find('.loading_bg').remove(); 1916 this.$startMyGroupBtn.find('.loading_bg').remove(); 1917 } 1918 }, 1919 changeShippingCurrency: function(){ 1920 var _this = this, 1921 sel = _this.sel, 1922 selIcon = _this.selIcon; 1923 $('.js-detail-module .js-shipping-poplist li').each(function(){ 1924 var usPrice = Number($(this).attr('usprice')); 1925 if(usPrice != 0) { //ä»·æ ¼ä¸º0ï¼å è¿è´¹ï¼åæ éåæ¢ä»·æ ¼ 1926 var newPrice = _this.transformPrice(usPrice); 1927 $(this).attr('ship_price',newPrice) 1928 if (selIcon == 'ÑÑб.' || selIcon == 'AED') { 1929 if (selIcon != 'ÑÑб.') { 1930 $(this).find('.list_shipcost, .ship_m_price').text(toThousands(newPrice) + ' ' + selIcon); 1931 1932 } else { 1933 $(this).find('.list_shipcost, .ship_m_price').text(toThousands2(newPrice) + ' ' + selIcon); 1934 } 1935 } else { 1936 $(this).find('.list_shipcost, .ship_m_price').text(selIcon + toThousands(newPrice)); 1937 } 1938 } 1939 }) 1940 var currentUsPrice = $('.js-detail-module .js-shipping-poplist li.active').attr('usprice') 1941 var currentShip = $('.js-detail-module .js-shipping-poplist li.active').attr('ship_price') 1942 var priceText = '' 1943 if(Number(currentUsPrice) == 0){ 1944 return false 1945 } 1946 if (selIcon == 'ÑÑб.' || selIcon == 'AED') { 1947 if (selIcon != 'ÑÑб.') { 1948 priceText = currentShip + ' ' + selIcon; 1949 } else { 1950 priceText = currentShip + ' ' + selIcon; 1951 } 1952 } else { 1953 priceText = selIcon + currentShip; 1954 } 1955 $('.js-detail-shipbox').find('.js-shipping-price').html(priceText) 1956 }, 1957 changeCurrency: function (e) { 1958 var _this = this, 1959 $this = $(e.target).closest('li'), 1960 $activeLen = $('.poa_wrap').find('.attr_item.active').length;; 1961 1962 if (_this.CurrencyCfg) { 1963 var sel = $this.attr('sel'), 1964 selHtml = $this.find('a').html(), 1965 selIcon = $this.find('u').eq(0).text(), 1966 $product_price = $(".product_price"), 1967 wsStatus = null; 1968 1969 _this.sel = sel; 1970 _this.selIcon = selIcon; 1971 1972 _this.changeShippingCurrency(); 1973 1974 /* å·²é屿§æ°é != 屿§æ°é */ 1975 if (this.poaLength != $activeLen || this.poaLength == 0) { 1976 wsStatus = true; 1977 1978 var new_new_price = _this.transformPrice(_this.usPrice), 1979 new_old_price = _this.transformPrice(_this.oldUsPrice); 1980 1981 } else { 1982 wsStatus = false;
1983 var $active = $('.poaItem a.active');//å·²é屿§çæ°é 1984 var selectedIds = [];//åæ¾data-vidï¼ 1985 $active.each(function () { 1986 selectedIds.push($(this).attr('data-vid')); 1987 }); 1988 /* 屿§å¼ç±å°å°å¤§æåº */ 1989 selectedIds.sort(function (value1, value2) { 1990 return parseInt(value1) - parseInt(value2); 1991 }); 1992 1993 1994 var usPrices = this.SKUResult[selectedIds.join(';')].usPrices; 1995 var usMarketPrice = this.SKUResult[selectedIds.join(';')].usMarketPrice; 1996 var maxPrice = Math.max.apply(Math, usPrices); 1997 var maxUsMarketPrice = Math.max.apply(Math, usMarketPrice); 1998 1999 var new_new_price = _this.transformPrice(maxPrice), 2000 new_old_price = _this.transformPrice(maxUsMarketPrice); 2001 } 2002 2003 //$product_price.find('.price_datalist>b').html(_this.CurrencyCfg[sel][1]+'<i class="icon shopCart icon-arrows_down1"></i>'); 2004 $product_price.find('.price_datalist>b').html(selIcon + ' ' + '<i class="icon shopCart icon-arrows_down1"></i>'); 2005 2006 if (_this.isPc) { 2007 if(selIcon != 'ÑÑб.'){ 2008 $product_price.find('.new_price>.price_value').text(toThousands(new_new_price)); 2009 }else{ 2010 $product_price.find('.new_price>.price_value').text(toThousands2(new_new_price)); 2011 } 2012 } else { 2013 if (selIcon == 'ÑÑб.' || selIcon == 'AED') { 2014 $product_price.find('.new_price>.price_value').html(toThousands(new_new_price) + ' ' + selIcon); 2015 $(".activity-phone .product-info .activity-price").html(toThousands(new_new_price) + ' ' + selIcon);//M端活å¨ä»· 2016 } else { 2017 $product_price.find('.new_price>.price_value').html(selIcon + toThousands(new_new_price)); 2018 $(".activity-phone .product-info .activity-price").html(selIcon + toThousands(new_new_price));//M端活å¨ä»· 2019 } 2020 } 2021 2022 if (selIcon == 'ÑÑб.' || selIcon == 'AED') { 2023 if(selIcon != 'ÑÑб.'){ 2024 $product_price.find('.old_price').text(toThousands(new_old_price) + ' ' + selIcon); 2025 $(".activity-phone .product-info .activity-del").text(toThousands(new_old_price) + ' ' + selIcon);//M端活å¨ä»· 2026 }else{ 2027 $product_price.find('.old_price').text(toThousands2(new_old_price) + ' ' + selIcon); 2028 $(".activity-phone .product-info .activity-del").text(toThousands2(new_old_price) + ' ' + selIcon);//M端活å¨ä»· 2029 } 2030 } else { 2031 $product_price.find('.old_price').text(selIcon + toThousands(new_old_price)); 2032 $(".activity-phone .product-info .activity-del").text(selIcon + toThousands(new_old_price));//M端活å¨ä»· 2033 } 2034 var $topCountryBox = $(".top-country-box").eq(0); 2035 $topCountryBox.find('.currency').find('.active').find('span').html(selHtml); 2036 $topCountryBox.find('.currency_name').text(sel); 2037 $topCountryBox.find('.currency_box').find('li[sel=' + sel + ']').addClass('selected').siblings().removeClass('selected'); 2038 _this.setCurRequire(sel); 2039 if (!_this.isWsdataNull) { 2040 _this.updateWsTable(wsStatus);//ä¿®æ¹æ¹åä»· 2041 } 2042 2043 if (!_this.isPc) { 2044 $('.price_datalist').fadeOut(); 2045 } 2046 2047 } 2048 //详æ é¡µå ¶ä»çåä»·æ ¼åæ¢ 2049 _this.detailPanelPrice(selIcon); 2050 ProductMixHandle.changeTotalPrice(); //æ´æ°ç»åååä»·æ ¼js 2051 }, 2052 setCookie: function(name,value, day) { 2053 var exp = new Date(); 2054 exp.setTime(exp.getTime() + day*24*60*60*1000); 2055 document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 2056 }, 2057 //è·åcookieä¿¡æ¯ 2058 getCookie: function(name){ 2059 var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); 2060 if(arr=document.cookie.match(reg)) 2061 return unescape(arr[2]); 2062 else 2063 return null; 2064 }, 2065 triggerWishlist: function (e) { 2066 var _this = this; 2067 if (this.$wishlistWrap.hasClass('submiting')) return false;
2068 if(_this.theme === 'MultiPurpose'){ 2069 this.$isMultiWishWrap.addClass('submiting') 2070 }else{ 2071 _this.$wishlistWrap.addClass('submiting'); 2072 } 2073 2074 2075 this.userInfoRequire().then(function (data) { 2076 /* æ£æµæ°æ®ï¼å¤ææ¯å¦å·²ç»å½ */ 2077 if (_this.checkLogin(data)) { 2078 if (_this.wishId != '0') { 2079 _this.deleteWishlist(); 2080 } else { 2081 _this.addToWishlist(); 2082 } 2083 } else { 2084 //å½ç¨æ·æªç»å½æ¶cookieè®°å½äº§åId 2085 var obj = {'products_id': _this.pid,'entrance': 0} 2086 _this.setCookie('add_products_wish', JSON.stringify(obj), 7) //ç¨æ·ç¹å»å¿æ¿åä¿¡æ¯ä¿åå°cookie7天 2087 _this.showPopLogin(); 2088 _this.$wishlistWrap.removeClass('submiting'); 2089 _this.$isMultiWishWrap.removeClass('submiting'); 2090 } 2091 }); 2092 }, 2093 /* æ·»å ååå°wishlist */ 2094 addToWishlist: function () { 2095 if (this.pid == '') return false; 2096 var _this = this; 2097 $.get("index.php", { com: "account", t: "addUserWish", "products_id": this.pid, entrance:'0' }, 2098 function (res) { 2099 if(res.code === 200){ 2100 if (_this.isPc) { 2101 var $wishlist_btn = $('.add_wish_list'); 2102 } else { 2103 var $wishlist_btn = $('.wishlist_m'); 2104 } 2105 2106 _this.wishId = res.data.wish_id; 2107 var rmmds = _this.getQueryString('rmmds'); 2108 var offsetLeft = $(".js-pc-wishlist-box").offset().left ; 2109 var offsetTop = $(".js-pc-wishlist-box").offset().top - $(window).scrollTop(); 2110 var flyer = $('<i class="icon shopCart icon-collect wishlist-copy"></i>'); 2111 //é£å ¥å¯¼èªç¹æ 2112 flyer.fly({ 2113 start: { 2114 left: $wishlist_btn.offset().left, 2115 top: $wishlist_btn.offset().top - $(window).scrollTop(), 2116 }, 2117 end: { 2118 left: offsetLeft-6, 2119 top: offsetTop + 5, 2120 width: 0, 2121 height: 0 2122 }, 2123 onEnd: function(){ 2124 $wishlist_btn.attr('data-ga', 'products-right_removeWishlist_button_180718').find('i').removeClass('icon-collect').addClass('icon-collect1'); 2125 //ä¿®æ¹å¯¼èªå¿æ¿åæ°é 2126 var wishListNum = $('.productWishNum em').html() || 0; 2127 if (wishListNum === 0) { 2128 if(_this.theme === 'MultiPurpose'){ 2129 if(!_this.shopStatus){ 2130 var count = '<span class="productWishNum"><em>(0)</em></span>'; 2131 }else{ 2132 var count = '<span class="productWishNum"><em>0</em></span>'; 2133 } 2134 2135 }else{ 2136 var count = '<span class="productWishNum">(<em>0</em>)</span>'; 2137 } 2138 2139 $('.add_wish_list').append(count); 2140 } 2141 wishListNum++; 2142 $('.productWishNum em').html(wishListNum); 2143 2144 var myWishNum = $('.js-myWishNum').html() || 0; 2145 myWishNum++; 2146 this.destory(); 2147 $('.js-myWishNum').html(myWishNum); 2148 } 2149 }); 2150 2151 //ç¹å»æ¶èæå追踪æ¨è使°æ® 2152 _this.recObj["ac"] = "wish"; 2153 _this.recObj["products_id"] = _this.pid; 2154 Record.rec(_this.recObj); 2155 if(rmmds === 'search'){ 2156 nDC.RecordClick('wish', [_this.pid]) 2157 } 2158 //FBäºä»¶çæµ 2159 try { 2160 _this.sendFbEvents('AddToWishlist'); 2161 } 2162 catch (err) { 2163 console.log(err, 'err'); 2164 } 2165 2166 _this.$wishlistWrap.removeClass('submiting'); 2167 _this.$isMultiWishWrap.removeClass('submiting'); 2168 } 2169 } 2170 ); 2171 2172 //åéæ°æ®å°éæ¹æ¥å£ 2173 var bguser = _this.getCookie('__bguser'); //è·åbguser cookie åæ° 2174 var visit_page = window.location.href; //å½å访é®é¡µé¢ 2175 var referer = document.referrer; //è®¿é®æ¥æºçä¸ä¸ä¸ªå°å 2176 2177 $.get("https://dc.banggood.com/index.php?com=sess&t=collectWish", 2178 { 2179 'bguser': bguser, 2180 "products_id": this.pid, 2181 'visit_page':visit_page, 2182 'referer':referer 2183 2184 },function (res) { 2185 console.log(res) 2186 } 2187 ); 2188 //æ°éæ¹ééæ¥å£ 2189 var portName = window.location.hostname.split('.')[0] 2190 var beeData={ 2191 '__key':'wish', 2192 'domain': 124, 2193 'site_port': portName && portName.indexOf('m') > 0 ? 'm' : 'pc', 2194 'products_id': this.pid, 2195 'visit_page': visit_page, 2196 'referer': referer, 2197 'wish_method': 'details_page' 2198 } 2199 Record.rec(beeData); 2200 }, 2201 /* ä»wishlistå é¤åå */ 2202 deleteWishlist: function () { 2203 if (this.pid == '') return false;
2204 var _this = this; 2205 $.get("index.php", { com: "account", t: "delectUserWish", "wish_id": this.wishId }, 2206 function (res) { 2207 if(res.code === 200){ 2208 if (_this.isPc) { 2209 var $wishlist_btn = $('.add_wish_list'); 2210 } else { 2211 var $wishlist_btn = $('.wishlist_m'); 2212 } 2213 $wishlist_btn.attr('data-ga', 'products-right_addWishlist_button_180718').find('i').removeClass('icon-collect1').addClass('icon-collect'); 2214 2215 _this.wishId = '0'; 2216 2217 var wishListNum = $('.productWishNum em').html(); 2218 wishListNum--; 2219 2220 $('.productWishNum em').html(wishListNum); 2221 if (!wishListNum) { 2222 $('.productWishNum').remove(); 2223 } 2224 2225 var myWishNum = Number($('.js-myWishNum').html()) ; 2226 myWishNum--; 2227 if(myWishNum === 0) myWishNum = ''; 2228 $('.js-myWishNum').html(myWishNum); 2229 _this.$wishlistWrap.removeClass('submiting'); 2230 _this.$isMultiWishWrap.removeClass('submiting') 2231 } 2232 } 2233 ); 2234 }, 2235 /** 2236 * @desc ç»å¶æ¹åä»·è¡¨æ ¼ 2237 * @author lijiahao 2238 * @param status 使ç¨SKUè¿æ¯POAçæ¹åä»·æ°æ® true:使ç¨SKUæ°æ® false: 使ç¨POAæ°æ® 2239 * */ 2240 updateWsTable: function (status) { 2241 var poaNum = this.poaNum, 2242 _this = this, 2243 data = status || this.poaNum == null ? this.wsData['ws'] : this.wsData['ws_' + poaNum], 2244 numArr = [], 2245 priceArr = [], 2246 headHTML = '', 2247 bodyHTML = '', 2248 selector = '', 2249 selIcon = $(".product_price .price_datalist").find('b').text(); 2250 2251 2252 if (this.isPc) { 2253 selector = '.wholesale_price_container'; 2254 data.forEach(function (obj) { 2255 numArr.push(obj.num); 2256 priceArr.push(obj.price); 2257 }); 2258 2259 headHTML += '<tr><td>Quantity</td>'; 2260 numArr.forEach(function (val) { 2261 headHTML += '<td>' + val + '</td>'; 2262 }); 2263 headHTML += '</tr>'; 2264 2265 if (this.sel) { 2266 bodyHTML += '<tr><td class="js-changeSelIcon">Price ' + this.sel + ' ' + selIcon + '</td>'; 2267 } else { 2268 bodyHTML += '<tr><td class="js-changeSelIcon">Price ' + this.defaultSel + ' ' + selIcon + '</td>'; 2269 } 2270 2271 priceArr.forEach(function (val) { 2272 var original = val; 2273 val = _this.transformPrice(val); 2274 2275 bodyHTML += '<td class="js-changePrice" data-USPrice="' + original + '" data-unit="1">' + val + '</td>'; 2276 }); 2277 bodyHTML += '</tr>'; 2278 } else { 2279 selector = '.wholesale_price_container_m'; 2280 if (this.sel) { 2281 headHTML = '<tr><td>Quantity</td><td>Price ' + this.sel + ' ' + selIcon + '</td></tr>' 2282 } else { 2283 headHTML = '<tr><td>Quantity</td><td>Price ' + this.defaultSel + ' ' + selIcon + '</td></tr>' 2284 } 2285 data.forEach(function (obj) { 2286 var price = _this.transformPrice(obj.price); 2287 bodyHTML += '<tr><td>' + obj.num + '</td><td>' + price + '</td></tr>' 2288 }); 2289 } 2290 2291 this.$wholesaleWrap.find(selector).find('thead').html(headHTML); 2292 this.$wholesaleWrap.find(selector).find('tbody').html(bodyHTML); 2293 2294 }, 2295 transformPrice: function (price) { 2296 var _this = this; 2297 2298 if(typeof price === 'string'){ 2299 price = price.replace(/[,\s]/, '');//å»é¤ä»·æ ¼ä¸çéå·åç©ºæ ¼ 2300 } 2301 2302 if (_this.sel != null) { 2303 if (_this.sel != 'USD') { 2304 if (_this.sel != 'EUR' && _this.sel != 'MXN') { 2305 price = Number(price) * _this.CurrencyCfg[_this.sel][0] * _this.CurrencyBGLoss; 2306 } else {
2307 if (_this.sel == 'EUR') price = Number(price) * _this.CurrencyCfg[_this.sel][0] * _this.CurrencyBGEurLoss; 2308 if (_this.sel == 'MXN') price = Number(price) * _this.CurrencyCfg[_this.sel][0] * _this.CurrencyBGMxnLoss; 2309 } 2310 } 2311 price = _this.transformDecimals(price); 2312 } else { 2313 if (_this.defaultSel != 'USD') { 2314 if (_this.defaultSel != 'EUR' && _this.defaultSel != 'MXN') { 2315 price = Number(price) * _this.CurrencyCfg[_this.defaultSel][0] * _this.CurrencyBGLoss; 2316 } else { 2317 if (_this.defaultSel == 'EUR') price = Number(price) * _this.CurrencyCfg[_this.defaultSel][0] * _this.CurrencyBGEurLoss; 2318 if (_this.defaultSel == 'MXN') price = Number(price) * _this.CurrencyCfg[_this.defaultSel][0] * _this.CurrencyBGMxnLoss; 2319 } 2320 } 2321 price = _this.transformDecimals(price); 2322 } 2323 return price; 2324 }, 2325 transformDecimals: function (price) { 2326 var _this = this; 2327 if (_this.sel != null) { 2328 if (_this.CurrencyCfg[_this.sel][3] == '2') { 2329 price = Number(price).toFixed(2); 2330 } else { 2331 price = Number(price).toFixed(0); 2332 } 2333 } else { 2334 if (_this.CurrencyCfg[_this.defaultSel][3] == '2') { 2335 price = Number(price).toFixed(2); 2336 } else { 2337 price = Number(price).toFixed(0); 2338 } 2339 } 2340 return price; 2341 }, 2342 changePrice: function (obj,isMain) { 2343 var _this = this 2344 if(isMain == '1'){ 2345 var oldMainPrice = $(obj).attr('data-original-usprice'), //主产ååå§ä»· 2346 mainOriginalPrice = _this.transformPrice(oldMainPrice); 2347 var oldPrice = $(obj).attr('data-USPrice'),//USåèä»·æ ¼ 2348 newPrice = _this.transformPrice(oldPrice);//éè¿è½¬æ¢ä¹åçä»·æ ¼ 2349 2350 return { 2351 newPrice:newPrice, 2352 originalPrice:mainOriginalPrice, 2353 } 2354 2355 } else{ 2356 var oldPrice = $(obj).attr('data-USPrice'),//USåèä»·æ ¼ 2357 newPrice = _this.transformPrice(oldPrice);//éè¿è½¬æ¢ä¹åçä»·æ ¼ 2358 return newPrice; 2359 } 2360 2361 2362 2363 }, 2364 detailPanelPrice:function(selIcon){ 2365 var _this = this; 2366 var selIcon = selIcon; 2367 $('.js-changePrice:not(.old_price,.price_value)').each(function () { 2368 //主产åä»·æ ¼åå 2369 var $this = $(this); 2370 var isMainPro = $this.parents('.mix-product-price').hasClass('main-pro-price') ? true :false; 2371 if(isMainPro){ 2372 var price = _this.changePrice(this,1); 2373 }else{ 2374 var currentPrice = _this.changePrice(this,0); 2375 } 2376 //å½å 容ä¸ä¸ºç©ºæ¶åå ¥æ°ä»·æ ¼ 2377 if($this.html().trim() != ''){ 2378 if (selIcon == 'ÑÑб.' || selIcon == 'AED') { 2379 if(isMainPro){ 2380 $(this).attr('data-original-price',price.originalPrice); 2381 $(this).html(toThousands(price.newPrice) + ' ' + selIcon).attr('data-price',price.newPrice); 2382 }else{ 2383 $(this).html(toThousands(currentPrice) + ' ' + selIcon).attr('data-price',currentPrice); 2384 } 2385 2386 } else { 2387 if(isMainPro){ 2388 $(this).attr('data-original-price',price.originalPrice); 2389 $(this).html(selIcon + toThousands(price.newPrice)).attr('data-price',price.newPrice); 2390 }else{ 2391 $(this).html(selIcon + toThousands(currentPrice)).attr('data-price',currentPrice); 2392 } 2393 2394 } 2395 if($(this).attr('data-maketprice')){ 2396 $(this).attr('data-maketprice',currentPrice) 2397 } 2398 } 2399 }); 2400 }, 2401 getAccessoryHtml:function(){ 2402 var _this = this; 2403 var data = new FormData(); 2404 data.append('sel_poa', _this.poaNum);//poa 2405 data.append('products_id', _this.pid);//产åid 2406 data.append('cur_warehouse', _this.cur_warehouse); 2407 $.ajax({ 2408 url: '/getAccessory.html', 2409 type: 'post', 2410 data: data, 2411 dataType: 'json', 2412 cache: false, 2413 processData: false, 2414 contentType: false, 2415 success: function (data) { 2416 if(data.code == 200){
2417 $('.js-html-mixProduct').html(data.data); 2418 $("img.lazy").lazyload({ 2419 effect: "fadeIn", 2420 failure_limit:50, 2421 check_appear_throttle_time: 300, 2422 parentClass: 'loading-gif-bg', 2423 }); 2424 ProductMixHandle.mixProductSlide();//ç»ååå交äºå¤ç 2425 ProductMixHandle.totalCount = Number($('.mix-main-product').find('.current-price').attr('data-original-price')); //éä¸ä»»ä½é ä»¶æ¶ååä»· 2426 } 2427 }, 2428 error: function () { 2429 console.log('error'); 2430 } 2431 }) 2432 }, 2433 errorAlert: function (msg) { 2434 var text = msg || 'Item(s) added to your cart unsuccessfully.'; 2435 $(".shipping-modal").show().find('.modal_container').html('<div class="modal_shipping">' + 2436 '<div class="modal_shipping_con">' + 2437 '<i class="delete_btn icon shopCart icon-pinpaizhangouwuche_guanbi" onclick="modal_remove();"></i>' + 2438 '<div class="img_wrap text-center"><img src="/templates/common/dist/shopCart/images/payError.png" alt="" style="width:50px;height:50px;margin-top: 10px;"></div>' + 2439 '<div class="text-center" style="font-size:16px;margin: 20px 0;">
2439' + text + '</div>' + 2440 '<div class="after_btn_wrap">' + 2441 '<div class="afterAddBtn text-center"><a href="javascript:void(0)" class="product_info_btn close_btn">close</a><div style="clear:both;"></div></div>' + 2442 '</div>' + 2443 '</div>' + 2444 '</div>'); 2445 }, 2446 poaHandler_m: function () { 2447 var _this = this; 2448 $('.js-product-info .poa_wrap_title').on('click', function (e) { 2449 var $this = $(this); 2450 window.scrollTo(0,0);//æå¼å¼¹çªåå°é¡µé¢é¡¶é¨ 2451 _this.openModal(); 2452 2453 $this.siblings('.poa_list_wrap').show().find('.addToCart_m').addClass('bgwhite').end().find('.submit_box > a').show().eq(0).css('margin-right','5px');//poaçªå£æ¾ç¤º 2454 setTimeout(function () { 2455 $this.closest('.poa_wrap').addClass('show'); 2456 }, 0); 2457 //e.preventDefault(); 2458 }).closest('.poa_wrap').find('.closeBtn').on('click', function (e) { 2459 var $this = $(this); 2460 2461 _this.closeModal(); 2462 2463 $this.closest('.poa_wrap').removeClass('show'); 2464 setTimeout(function () { 2465 $this.closest('.poa_list_wrap').hide(); 2466 }, 200); 2467 e.stopPropagation(); 2468 e.preventDefault(); 2469 }); 2470 }, 2471 2472 giftHandler_m: function () { 2473 var _this = this; 2474 $('.js-product-info .item_box.gift').find('.item_name').on('click', function (e) { 2475 var $this = $(this); 2476 2477 _this.openModal(); 2478 2479 $this.siblings('.gift_list_wrap').show();//poaçªå£æ¾ç¤º 2480 setTimeout(function () { 2481 $this.closest('.gift_wrap').addClass('show'); 2482 }, 0); 2483 //e.preventDefault(); 2484 }).closest('.gift_wrap').find('.closeBtn').on('click', function (e) { 2485 var $this = $(this); 2486 2487 _this.closeModal(); 2488 2489 $this.closest('.gift_wrap').removeClass('show'); 2490 setTimeout(function () { 2491 $this.closest('.gift_list_wrap').hide(); 2492 }, 200); 2493 e.stopPropagation(); 2494 e.preventDefault(); 2495 }); 2496 2497 $(doc).on('click', '.js-product-info .gift_item>.clickIcon', $.proxy(this.chooseGift, this)); 2498 $(doc).on('click', '.js-product-info .gift .gift_attr:not(.gray)', $.proxy(this.updateGift, this)); 2499 }, 2500 /* ç§»å¨ç«¯å¸åºä»·äºä»¶ */ 2501 wholeSaleHandler_m: function () { 2502 var _this = this; 2503 $(".js-product-info .wholesale_price_wrap").find('.wholesale_price_label').on('click', function (e) { 2504 2505 _this.openModal(); 2506 2507 var $price_wrap = $(this).siblings('.price_wrap'); 2508 $price_wrap.show(); 2509 setTimeout(function () { 2510 $price_wrap.addClass('show'); 2511 }, 0); 2512 }).end().find('.back').on('click', function (e) { 2513 2514 _this.closeModal(); 2515 2516 var $price_wrap = $(this).closest('.price_wrap'); 2517 $price_wrap.removeClass('show'); 2518 setTimeout(function () { 2519 $price_wrap.hide(); 2520 }, 200); 2521 e.stopPropagation(); 2522 }); 2523 }, 2524 /* Mç«¯éæ©èµ ååçæç¤ºè¯ */ 2525 changeGiftText_m: function () { 2526 var activeLen = this.$giftList.find('.gift_item.isChecked').length, 2527 giftText = activeLen > 1 ? 'gifts' : 'gift'; 2528 if (activeLen === 0) { 2529 this.$giftList.find('.selected_text').text(''); 2530 } else { 2531 this.$giftList.find('.selected_text').text(activeLen + ' ' + giftText + ' have been selected'); 2532 } 2533 }, 2534 share_m: function () { 2535 var _this = this; 2536 this.$shareBtn.on('click', function () { 2537 _this.openModal(); 2538 $('.share_container:last').show(); 2539 }); 2540 $(doc).on('click', '.share_container .closeBtn,.share_container .share_bg', function () { 2541 _this.closeModal(); 2542 $('.share_container:last').hide(); 2543 }); 2544 }, 2545 /* è¯·æ±æ¯å¦ç»å½æ¥å£ */ 2546 userInfoRequire: function () { 2547 var _this = this; 2548 return $.ajax({ 2549 url: '/userHeaderInfo.html', 2550 dataType: 'json', 2551 success: function (data) { 2552 2553 } 2554 }); 2555 2556 }, 2557 checkLogin: function (data) { 2558 if (data.data.customer_info.length !== 0 && data.data.customer_info.customers_id) { 2559 return true; 2560 } 2561 return false;
2562 }, 2563 priceHandler_m: function () { 2564 var $priceList = $('.js-product-info .price_datalist'), 2565 _this = this; 2566 2567 $(".js-product-info .poa_wrap").find('.new_price').on('click', function () { 2568 var has_activity = _this.$wrapper.hasClass('has_activity'); 2569 if(has_activity){ 2570 $('.price_value_box').show(); 2571 } 2572 $priceList.fadeIn(); 2573 }); 2574 $priceList.find('.back').on('click', function () { 2575 var has_activity = _this.$wrapper.hasClass('has_activity'); 2576 $priceList.fadeOut(function(){ 2577 if(has_activity){ 2578 $(".price_value_box").hide(); 2579 } 2580 }); 2581 }); 2582 }, 2583 scrollHandler_m: function () { 2584 $('.js-product-info .poa_wrap,.gift_wrap,.wholesale_price_wrap,.js-product-info .price_datalist,.share_container,.fixed_wrap').on('touchmove', function (e) { 2585 e.preventDefault(); 2586 }); 2587 }, 2588 setCurRequire: function (currency_id) { 2589 var input = $('.top-country-box').children('.country-container'), 2590 country_id = input.find('[name=country_sel]').val(); 2591 2592 $.ajax({ 2593 url: '/setDefaltCountry.html?country=' + country_id + '¤cy=' + currency_id, 2594 type: 'post', 2595 dataType: 'text', 2596 success: function (data) { 2597 $.cookie('currency', currency_id); 2598 }, 2599 error: function (error) { 2600 console.log(error); 2601 } 2602 }) 2603 }, 2604 /*éä¸å¾çæè²åæ¾ç¤ºå±æ§å¼ by Li Xiaojun*/ 2605 switchColorName: function (e) { 2606 var $isAttrTitle = $('.js-attr-title'); 2607 /* 夿ç¹å»çæ¯å¦ä¸ºç©ºç<a>æ ç¾ï¼å¦<a>é颿<img>ï¼åéæ©<img>çç¶å ç´ <a> */ 2608 if (!$(e.target).is('a')) { 2609 e.target = $(e.target).parent(); 2610 } 2611 if ($isAttrTitle.length) { 2612 var colorTitle = $(e.target).attr('title'); 2613 if(!$(e.target).hasClass('gray')){ 2614 $(e.target).parents('.poaItem').find('.js-attr-title').html(colorTitle); 2615 } 2616 } 2617 }, 2618 /** 2619 * @desc æ ¹æ®å½å®¶ä¸æé项忢æé®é¾æ¥-amazon\ebay 2620 * @author lijiahao 2621 **/ 2622 countryHandler: function () { 2623 var _this = this, 2624 $country = _this.$wrapper.find('.way_btn_country'), 2625 $btnWrap = $('.buy_way_wrap .way_btn_box'); 2626 2627 $country.find('.country_icon').on('click', function (e) { 2628 $country.not($(this).closest('.way_btn_country')).removeClass('show'); 2629 $(this).closest('.way_btn_country').toggleClass('show'); 2630 e.stopPropagation(); 2631 }); 2632 2633 $(doc).on('click', function (e) { 2634 $country.removeClass('show'); 2635 }); 2636 2637 $country.find('.country_item').on('click', function () { 2638 var country_id = $(this).attr('data-country-id'), 2639 flag = $(this).find('i').prop("outerHTML"), 2640 url = $(this).attr('data-url'), 2641 type = $(this).closest('.way_btn_country').attr('data-type'); 2642 2643 $(this).addClass('act').siblings().removeClass('act'); 2644 $(this).closest('.country_contain').find('.way_title').attr('data-url', url).end().find('.country_icon').html(flag); 2645 _this.setThirdDeliveryCountry(country_id, type); 2646 }); 2647 2648 $country.find('.way_title').on('click', function () { 2649 var url = $(this).attr('data-url') 2650 if (url) { 2651 window.open(url); 2652 } 2653 }); 2654 }, 2655 /** 2656 * @desc M ç«¯æ¬æµ®æ å½å®¶ç¹å»äºä»¶ 2657 * @author lijiahao 2658 **/ 2659 countryHandler_m: function () { 2660 /* æ¬æµ®æ å½å®¶ç¹å»äºä»¶ */ 2661 this.$bottomBar.find('.countryBox').on('click', $.proxy(this.showCountry, this)); 2662 2663 /* countryå ³éæé®äºä»¶ */ 2664 $('.country_list_wrap .closeBtn').on('click', $.proxy(this.hideCountry, this)); 2665 $('.country_list_wrap .wrap_bg').on('click', $.proxy(this.hideCountry, this)); 2666 2667 $('.country_list_m .country_ul').find('li').on('click', $.proxy(this.updateCountry, this)); 2668 2669 /* è§£å³æå¨ç©¿é */ 2670 $('.country_list_wrap').on('touchmove', function (e) { e.stopPropagation(); }) 2671 }, 2672 // M 端æé®æ¾ç¤ºåå§å 2673 buyWayInit: function (isFirstTime) { 2674 var $selected = $(".country_list_m").find('.country_ul .selected'); 2675 //amazoné»è®¤éä¸çå½å®¶æebayç龿¥ï¼æ¾ç¤ºebayæé® 2676 if (isFirstTime && $selected.attr('data-ebay')) { 2677 $('.buybtn_list_wrap .buybtn_list .btnlist').find('.js-mbuy-ebay').removeClass('forbid').addClass('go'); 2678 } 2679 2680 var wayWrap = $('.buybtn_list_wrap .btnlist'), 2681 wayList = wayWrap.find('a.go'), 2682 wayBtn = this.$bottomBar.find('.abtest_buyway_btn'), 2683 btnList = $('.js-mbtn-container').children('a'); 2684 2685 if (btnList.length === 0) { 2686 if(this.theme !== 'outerdo'){ 2687 $('.js-mbtn-container').addClass('only_wishlist') 2688 }else{ 2689 this.$bottomBar.hide(); 2690 $(document).ready(function(){ 2691 $('.footer').css('padding-bottom', '0'); 2692 }); 2693 } 2694 } 2695 if (wayList.length === 1) { /* å表length为1æ¶ï¼å¤é¨æé®æ¾ç¤ºä¸ºå表ç第ä¸ä¸ª */ 2696 var firstEle = wayList.eq(0), 2697 firstText = firstEle.text(), 2698 firstHref = firstEle.attr('href'), 2699 firstId = firstEle.attr('data-id'), 2700 firstGa = firstEle.attr('data-ga'); 2701 firstFb = firstEle.attr('data-fb'); 2702 2703 wayBtn.off('click').text('Buy At ' + firstText).attr('href', firstHref).attr('data-ga', '').attr('data-ga', firstGa); 2704 if(typeof (firstFb) != 'undefined'){ 2705 wayBtn.attr('data-fb', '').attr('data-fb', firstFb) 2706 } 2707 if(firstEle.hasClass('js-mbuy-amazon')) { //å¤æè¯¥æé®æ¯å¦ä¸ºamazonæé® 2708 wayBtn.addClass('js-mbuy-amazon') 2709 } 2710
2711 //ædata-idçæ ç¾ééå½å®¶åå跳转 2712 // if(firstId){ 2713 // wayBtn.attr('data-id',firstId).on('click',function(){ 2714 // $("#"+firstId).show().addClass('show'); 2715 // }); 2716 // } 2717 } else if (wayList.length > 1 && !isFirstTime) { 2718 if (this.shopStatus) { 2719 wayBtn.off('click').text('Other Channels'); 2720 } else { 2721 wayBtn.off('click').text('BUY NOW'); 2722 } 2723 wayBtn.attr('href', 'javascript:void(0);').attr('data-ga', 'product-bottom_BuyNowButton_20181119').on('click', $.proxy(this.showBuyList, this)); 2724 } 2725 2726 /* äº§åæ²¡æå±æ§å¯éï¼å¢å GAåç¹ */ 2727 if(this.poaLength === 0){ 2728 this.$bottomBar.find('.addToCart_m').attr('data-ga', 'products-right_addToCart_button_180920'); 2729 } 2730 2731 }, 2732 buywayHandler_m: function () { 2733 this.$bottomBar.find('.abtest_buyway_btn').on('click', $.proxy(this.showBuyList, this)); 2734 2735 $('.buybtn_list_wrap .closeBtn').on('click', $.proxy(this.hideBuyList, this)); 2736 $('.buybtn_list_wrap .wrap_bg').on('click', $.proxy(this.hideBuyList, this)); 2737 2738 this.$bottomBar.on('touchmove', function (e) { e.stopPropagation(); }) 2739 }, 2740 showCountry: function () { 2741 $('.country_list_wrap').show(); 2742 this.openModal(); 2743 setTimeout(function () { 2744 $('.country_list_wrap').addClass('show'); 2745 }, 0); 2746 }, 2747 closeFixed: function () { 2748 this.closeModal(); 2749 }, 2750 hideCountry: function () { 2751 $('.country_list_wrap').removeClass('show'); 2752 setTimeout(function () { 2753 $('.country_list_wrap').hide(); 2754 }, 300); 2755 }, 2756 showBuyList: function () { 2757 $('.buybtn_list_wrap').show(); 2758 this.openModal(); 2759 setTimeout(function () { 2760 $('.buybtn_list_wrap').addClass('show'); 2761 }, 0); 2762 }, 2763 hideBuyList: function () { 2764 $('.buybtn_list_wrap').removeClass('show'); 2765 this.closeModal(); 2766 setTimeout(function () { 2767 $('.buybtn_list_wrap').hide(); 2768 }, 300); 2769 }, 2770 updateCountry: function (e) { 2771 var $ele = $(e.currentTarget), 2772 country_name = $ele.attr('name'), 2773 country_name2 = country_name; 2774 if ($ele.hasClass('selected')) return false; 2775 2776 if (country_name === 'uk') country_name = 'gb'; 2777 2778 $ele.addClass('selected').siblings().removeClass('selected'); 2779 this.$bottomBar.find('.countryBox').html('<i class="icon-flag icon-flag-' + country_name.toUpperCase() + '"></i><span>' + country_name2.toUpperCase() + '</span>') 2780 this.hideCountry(); 2781 2782 /* æ¿æ¢amazonæé®çhref */ 2783 var amazonLink = $ele.attr('data-href'), 2784 ebayLink = $ele.attr('data-ebay'), 2785 country_id = $ele.attr('data-country-id'); 2786 2787 if (!this.shopStatus) { 2788 var currency = $ele.attr('currency'), 2789 price = $ele.attr('data-price'), 2790 $product_price = $(".product_price"); 2791 if (price) { 2792 2793 if (currency == 'ÑÑб.' || currency == 'AED') { 2794 $product_price.find('.new_price').html('</span><span class="price_value">' + price + '</span>' + '<span class="currencys_m mobile">' + currency); 2795 } else { 2796 $product_price.find('.new_price').html('<span class="currencys_m mobile">' + currency + '</span><span class="price_value">' + price + '</span>'); 2797 } 2798 2799 } 2800 } 2801 2802 $('.buybtn_list .js-mbuy-amazon').attr('href', amazonLink); 2803 $('.buybtn_list .js-mbuy-ebay').attr('href', ebayLink); 2804 if (amazonLink != '') { 2805 $('.buybtn_list .js-mbuy-amazon').removeClass('forbid').addClass('go') 2806 } else { 2807 $('.buybtn_list .js-mbuy-amazon').removeClass('go').addClass('forbid') 2808 } 2809 if (ebayLink != '') { 2810 $('.buybtn_list .js-mbuy-ebay').removeClass('forbid').addClass('go') 2811 } else { 2812 $('.buybtn_list .js-mbuy-ebay').removeClass('go').addClass('forbid') 2813 } 2814 2815 /* åå§åæé® */ 2816 this.buyWayInit(false); 2817 this.setThirdDeliveryCountry(country_id, 'third_delivery_country'); 2818 this.closeModal(); 2819 }, 2820 setThirdDeliveryCountry: function (country_id, type) { 2821 2822 $.ajax({ 2823 url: 'setThirdDeliveryCountry.html', 2824 type: 'post', 2825 dataType: 'json', 2826 data: { 2827 'country_id': country_id, 2828 'type': type, 2829 }, 2830 success: function (data) { 2831 2832 }, 2833 error: function () { 2834 2835 } 2836 }) 2837 }, 2838 openModal: function () { 2839 this.bodyTop = document.scrollingElement.scrollTop; 2840 document.body.style.top = -this.bodyTop + 'px'; 2841 $('body').addClass('overflow');//bodyæ·»å position:fixedï¼é²æ¢æå¨poa页颿¶ï¼bodyä¹éçæå¨ã 2842 }, 2843 closeModal: function () { 2844 $('body').removeClass('overflow'); 2845 document.scrollingElement.scrollTop = this.bodyTop; 2846 document.body.style.top = ''; 2847 }, 2848 /** 2849 * é»è®¤éä¸å±æ§å¼ 2850 * @param {Array} 屿§å¼æ°ç» 2851 */ 2852 onClickHandler: function (arr) { 2853 this.$poaWrapper.find('.box_wrap .attr_item').each(function () { 2854 var vid = $(this).attr('data-vid'), 2855 $this = $(this); 2856 if (arr && arr.length && arr.indexOf(vid) > -1) { 2857 setTimeout(function () { 2858 $this.click(); 2859 }, 0); 2860 } 2861 }); 2862 }, 2863 attrPreviewInit: function () { 2864 var _this = this, 2865 isLoaded = false, 2866 $poaItem = this.$poaWrapper.find('.box_wrap .poaItem'), 2867 $previewWrap = $("#poa_preview"); 2868 2869 $poaItem.each(function (index) { 2870 var $list = $(this).find('.attr_value_list'), 2871 imgLen = $list.find('.attrimg').length, 2872 itemLen = $list.find('.attr_item').length, 2873 attr_name = $(this).attr('data-attr-name'), 2874 plural = itemLen > 1 ? 's' : ''; 2875 2876 /* poaæå¾çä¼å æ¾ç¤ºæå¾çç */ 2877 if (imgLen > 0) {
2878 var $newDiv = $('<div></div>'); 2879 $newDiv.html($list.html()); 2880 $newDiv.append('<label class="num_tips" style="margin-top:5px;">' + itemLen + ' ' + attr_name + plural + ' to choose</label>'); 2881 $previewWrap.html($newDiv.html()); 2882 isLoaded = true; 2883 $previewWrap.parent().addClass('show').parent().addClass('hasPoa'); 2884 _this.poaCheckInline(); 2885 return false; 2886 } 2887 }); 2888 2889 //Poa屿§æé¢è²å 2890 if (!isLoaded) { 2891 $poaItem.each(function (index) { 2892 var $list = $(this).find('.attr_value_list'), 2893 colorLen = $list.find('.attrcolor').length, 2894 itemLen = $list.find('.attr_item').length, 2895 attr_name = $(this).attr('data-attr-name'), 2896 plural = itemLen > 1 ? 's' : ''; 2897 2898 /* poaæå¾çä¼å æ¾ç¤ºæå¾çç */ 2899 if (colorLen > 0) { 2900 var $newDiv = $('<div></div>'); 2901 $newDiv.html($list.html()); 2902 $newDiv.append('<label class="num_tips">' + itemLen + ' ' + attr_name + plural + ' to choose</label>'); 2903 $previewWrap.html($newDiv.html()); 2904 isLoaded = true; 2905 $previewWrap.parent().addClass('show').parent().addClass('hasPoa'); 2906 _this.poaCheckInline(); 2907 return false; 2908 } 2909 }); 2910 } 2911 2912 //Poa屿§æ²¡æå¾ç 2913 if (!isLoaded) { 2914 $poaItem.each(function (index) { 2915 var $list = $(this).find('.attr_value_list'), 2916 itemLen = $list.find('.attr_item').length, 2917 attr_name = $(this).attr('data-attr-name'), 2918 plural = itemLen > 1 ? 's' : ''; 2919 2920 /* æå屿§åªæ¾ç¤ºsizeï¼å ¶ä½ä¸æ¾ç¤º */ 2921 if (attr_name.toLowerCase() === 'size') { 2922 var $newDiv = $('<div></div>'); 2923 $newDiv.html($list.html()); 2924 $newDiv.append('<label class="num_tips">' + itemLen + ' ' + attr_name + plural + ' to choose</label>'); 2925 $previewWrap.html($newDiv.html()); 2926 $previewWrap.parent().addClass('show').parent().addClass('hasPoa'); 2927 _this.poaCheckInline(); 2928 } 2929 }); 2930 } 2931 2932 }, 2933 /** 2934 * @desc poaå ¥å£æ¾ç¤ºç屿§è¶ åºç¶å ç´ ï¼å¯¹å ç´ è¿è¡ç§»é¤; 2935 * @author lijiahao 2936 **/ 2937 poaCheckInline: function () { 2938 var $previewWrap = $("#poa_preview"), 2939 $wrap = $previewWrap.parent(); 2940 2941 if ($previewWrap.width() === $wrap.width()) { 2942 var $items = $previewWrap.find('.attr_item'); 2943 $items.slice($items.length - 1).remove(); 2944 this.poaCheckInline(); 2945 } else { 2946 return false; 2947 } 2948 }, 2949 poaDataHanlder: function (data) { 2950 var _this = this, 2951 attrVids = Object.keys(data.stockVids), 2952 attrLen = attrVids.length, 2953 $discount = $(".js-discount-update"); 2954 2955 this.giftResult = {}; 2956 this.stockData = data; 2957 this.stockQty = Number(data.stock);//åºå 2958 if(data.isPreorder === 1 && Object.keys(data.preorderInfo).length > 0 && data.preorderInfo.once_limit_amount > 0 ){ 2959 this.stockQty = Number(data.preorderInfo.once_limit_amount) 2960 } 2961 this.giftInfo = data.validGifts;//èµ åä¿¡æ¯ 2962 this.cur_warehouse = data.warehouse;//该POAæå¨ä»åº,å è´æ¶ä½¿ç¨ 2963 this.updatePrice2();//æ´æ°ä»·æ ¼ 2964 this.updateStockInfo();//æ´æ°åºåæç¤º 2965 this.updateInput(this.stockQty);//æ°éä¿®æ¹ 2966 this.plusHandler();//+å·ç¶ææ´æ°
2967 this.setCouponInfo(data.productCoupons);//忢poaæ¶æ´æ°couponå±ç¤º 2968 if (data.isPreorder === 1 && Object.keys(data.preorderInfo).length > 0) { 2969 this.setPreSaleHandle(data.preorderInfo, data); 2970 if (!_this.isPc) { 2971 //m端ç å¨é¢å®çæ¶å ææ®éä»·æ ¼éè 2972 $('.js-product-info').find('.m-js-product-price').hide(); 2973 } 2974 } else { 2975 $('.js-isPreSale').hide(); 2976 if (!_this.isPc) { 2977 //m端ç å¨é¢å®çæ¶å ææ®éä»·æ ¼éè 2978 $('.js-product-info').find('.m-js-product-price').show(); 2979 } 2980 if (_this.pcCountDownTimer !== null) { 2981 $('.js-pre-sale-activity').find('.js-counting-time').each(function () { 2982 _this.pcCountDownTimer.destroyedTimer(); 2983 }); 2984 } 2985 if (_this.mCountDownTimer !== null) { 2986 $('.js-m-pre-sale-activity-box').find('.js-counting-time').each(function () { 2987 _this.mCountDownTimer.destroyedTimer(); 2988 }); 2989 } 2990 } 2991 2992 if (attrLen === 1 && !_this.isFTLoaded) { 2993 var attr_ids = data.stockVids[attrVids[0]].split('.'); 2994 $(".poaItem").find('.attr_item').addClass('gray').each(function () { 2995 var vid = $(this).attr('data-vid'); 2996 if (attr_ids && attr_ids.length && attr_ids.indexOf(vid) > -1) { 2997 $(this).removeClass('gray'); 2998 } 2999 }); 3000 } 3001 3002 if (attrLen > 1) { 3003 var attr_ids = []; 3004 Object.keys(data.stockVids).forEach(function (key) { 3005 attr_ids = data.stockVids[key].split('.').concat(attr_ids); 3006 }); 3007 3008 $(".poaItem").find('.attr_item').addClass('gray').each(function () { 3009 var vid = $(this).attr('data-vid'); 3010 if (attr_ids && attr_ids.length && attr_ids.indexOf(vid) > -1) { 3011 $(this).removeClass('gray'); 3012 } 3013 }); 3014 } 3015 3016 if (!this.isPc) { 3017 this.changeGiftText_m(); 3018 } 3019 3020 if($discount.length){ 3021 /* 忢poaæ´æ°æ´»å¨äº§åçææ£ */ 3022 var newDiscount = (((data.market_price_usd - data.final_price_usd) / data.market_price_usd * 100)).toFixed(0); 3023 if(newDiscount > 0){ //ææ£å¤§ä½0æ¶æ¾ç¤º 3024 $discount.text(newDiscount + '%'); 3025 } else { 3026 $discount.parents('.m-discount').hide() 3027 } 3028 } 3029 3030 /* ç¬¬ä¸æ¬¡è°ç¨ å»é¤ä»·æ ¼loadingææ */ 3031 if (!this.isFTLoaded) { 3032 $('.product_price').removeClass('loading'); 3033 this.isFTLoaded = true; 3034 } 3035 }, 3036 /** 3037 * @description æ ¹æ®å·²éæ©å±æ§ æ¥è·åå ¶ä»æªéæ©å±æ§æ¯å¦æåºåï¼ 3038 */ 3039 getOthersStock: function () { 3040 var _this = this, 3041 formData = new FormData; 3042 3043 formData.append('products_id', this.pid);//产åid 3044 3045 /* 没æå±æ§é åä¸ä¼ products_attr_id */ 3046 if (this.poaLength) { 3047 $.each(this.activeIndex, function (i, val) { 3048 if (val) { 3049 formData.append('products_attr_id[' + _this.activeIndex2[i] + ']', val); 3050 } 3051 }); 3052 } 3053 3054 $.ajax({ 3055 url: '/stockMessage.html', 3056 type: 'post', 3057 dataType: 'json', 3058 data: formData, 3059 cache: false, 3060 processData: false, 3061 contentType: false, 3062 success: function (data) { 3063 var attr_ids = []; 3064 Object.keys(data.stockVids).forEach(function (key) { 3065 attr_ids = data.stockVids[key].split('.').concat(attr_ids); 3066 }); 3067 3068 $(".poaItem").find('.attr_item').addClass('gray').each(function () { 3069 var vid = $(this).attr('data-vid'); 3070 if (attr_ids && attr_ids.length && attr_ids.indexOf(vid) > -1) { 3071 $(this).removeClass('gray'); 3072 } 3073 }); 3074 }, 3075 error: function () { 3076 console.log('error'); 3077 } 3078 }) 3079 }, 3080 /* æ ¹æ®ä¿¡æ¯æ¥å£åå§åæ°æ® */ 3081 initHeaderInfo: function () { 3082 var _this = this; 3083 headerInfoAjax.then(function (data) { 3084 _this.headerInfo = data.data; 3085 3086 _this.setActivityStatus(); 3087 _this.setPromotion(); 3088 _this.setSuperUser(); 3089 _this.setIsWishlist(); 3090 _this.setHeaderWishlist(); 3091 _this.setUnsaleArea(); 3092 3093 if(!_this.isPc){ 3094 _this.setShopcart(); 3095 } 3096 _this.setShipCountry(); 3097 3098 }); 3099 }, 3100 /* 设置wishlistæ°é */ 3101 setHeaderWishlist: function () { 3102 var customerInfo = this.headerInfo.customer_info; 3103 3104 if (customerInfo.productWishNum && customerInfo.productWishNum > 0) { 3105 if(this.theme === 'MultiPurpose'){ 3106 if(!this.shopStatus){ 3107 var count = '<span class="productWishNum"><em>(' + customerInfo.productWishNum + ')</em></span>'; 3108 }else{ 3109 var count = '<span class="productWishNum"><em>' + customerInfo.productWishNum + '</em></span>'; 3110 } 3111 3112 }else{ 3113 var count = '<span class="productWishNum">(<em>' + customerInfo.productWishNum + '</em>)</span>'; 3114 } 3115 3116 $('.add_wish_list').append(count); 3117 } 3118 }, 3119 /* æ ¹æ®äº§åçæ´»å¨ç¶æä¿®æ¹classï¼æ§å¶domæ¯å¦æ¾ç¤º */
3120 setActivityStatus: function(){ 3121 var actInfo = this.headerInfo.products_items_list.activity_info; 3122 3123 if(actInfo.has_activity){ 3124 this.$wrapper.addClass('has_activity'); 3125 3126 if(actInfo.is_started){ 3127 this.$wrapper.addClass('activity_started'); 3128 3129 /* Mç«¯æ´»å¨æ¹åä»·æ ·å¼ */ 3130 if(!this.isPc){ 3131 this.$wholesaleWrap.addClass('activity-start'); 3132 } 3133 } 3134 } 3135 }, 3136 setSuperUser: function(){ 3137 var isSuperUser = this.headerInfo.products_items_list.is_superuser; 3138 /* å ¨é¨æ¨¡æ¿éç¨ apply for free */ 3139 if(isSuperUser != '0' ){ 3140 if(this.isPc){ 3141 $(".apply-forfree-box").show(); 3142 $('.forfreeShow').show(); 3143 }else{ 3144 $(".m-makeup2-free").show(); 3145 } 3146 } 3147 }, 3148 setIsWishlist: function(){ 3149 var is_add_to_wishlist = this.headerInfo.products_items_list.is_add_to_wishlist; 3150 /* 没å¼è´ç©è½¦ && å¯ä»¥æ¶è */ 3151 if(!this.shopStatus && is_add_to_wishlist){ 3152 $('.wishlist_wrap tips').show(); 3153 } 3154 }, 3155 /* æ¯å¦ç¦å®äº§å */ 3156 setUnsaleArea: function(){ 3157 var isUnsalesArea = this.headerInfo.products_items_list.is_unsales_area, 3158 country = this.headerInfo.country_name_ip; 3159 3160 if(!isUnsalesArea){ 3161 this.$addBtn.removeClass('forbidGray'); 3162 this.$buyNowBtn.removeClass('forbidGray'); 3163 this.$paypalBtn.removeClass('forbidGray'); 3164 this.$startMyGroupBtn.removeClass('forbidGray'); 3165 }else{ 3166 3167 $("#item_shipments_box").remove(); 3168 $('.shipping_box').remove();//M端shippingæç¤ºè¯å»é¤ 3169 $(".js_forbidOrder_country").text(country); 3170 3171 if(this.isPc){ 3172 this.$addBtn.html('<span class="not_allow">Not Available</span>'); 3173 this.$buyNowBtn.hide(); 3174 this.$paypalBtn.hide(); 3175 this.$startMyGroupBtn.hide(); 3176 $('.forbidOrder').show(); 3177 }else{ 3178 $('.forbidOrder-m').show(); 3179 } 3180 } 3181 }, 3182 setCouponInfo: function(html){ 3183 $(".coupon-container").html(html); 3184 if(html){ 3185 $(".coupon-container").find('.couponTime').each(function () { 3186 var format_date = getTime($(this).attr('data-time'), 1); 3187 $(this).text(format_date); 3188 }); 3189 } 3190 }, 3191 couponHandler: function(){ 3192 var _this = this; 3193 $(doc).on('click', '.js-product-info .coupon_list .coupon_item:not(.successful),.js-product-info .coupon_alllist_modal .coupon_item .getCoupons,.js-getAll-coupon:not(.disabled)', $.proxy(this.getCouponRequire, this));//é¢å伿 å¸ 3194 $(doc).on('click', '.js-product-info .item_coupon .more_btn,.phone-js-showCoupon', $.proxy(this.showCouponModal, this)); 3195 $(doc).on('click', ".js-product-info .coupon_alllist_modal .modal_content>.close_btn", $.proxy(this.hideCouponModal,this)); 3196 _this.hoverCouponList(); //pc端hoveræ¾ç¤ºå ¨é¨ 3197 }, 3198 getCouponRequire: function(e){ 3199 e.stopPropagation(); 3200 var $this = $(e.currentTarget), 3201 _this = this, 3202 isAllEle = $this.attr('data-isAll'),//æ¯å¦æ¯ç§»å¨ç«¯ä¸é®è·å 3203 isModalEvent = !$this.is('.outerCoupon');//æ¯å¦å¨modaléé¢é¢åç 3204 var coupons = []; 3205 var formData = new FormData(); 3206 formData.append('products_id', _this.pid); 3207 if(isAllEle){ 3208 //è·åæææªé¢åçcoupon_id 3209 coupons = $('.coupon_alllist_modal .coupon_list .getCoupons'); 3210 $.each(coupons,function(){ 3211 var coupon_id = $(this).attr('data-id'); 3212 formData.append('coupon_ids[]', coupon_id); 3213 }) 3214 } else{ 3215 coupons = $this.attr('data-id'); 3216 formData.append('coupon_ids[]', coupons); 3217 } 3218 3219 3220 headerInfoAjax.then(function(res){ 3221 if(_this.checkLogin(res)){ 3222 /* å·²ç»å½ */ 3223 if($this.hasClass('loading'))return false;
3224 if(!isModalEvent){ 3225 $this.find('.item_control').addClass('loading').html('<img src="/templates/common/src/shopCart/images/loading.gif" alt="" class="loading_img">'); 3226 }else{ 3227 $this.addClass('loading'); 3228 } 3229 3230 $.ajax({ 3231 url: '/getCoupon.html', 3232 type: 'post', 3233 dataType:'json', 3234 contentType: false, 3235 data: formData, 3236 processData: false, 3237 success: function(res){ 3238 if(res.code === 200){ 3239 /* å¤é¢é¢ååmodalå é¢åå®é½å·æ°é¡µé¢ */ 3240 $('#coupon-container').html(res.productCoupons); 3241 if(isModalEvent){ 3242 _this.showCouponModal(); 3243 if(!_this.isPc){ 3244 if(isAllEle){ 3245 $this.addClass('disabled'); 3246 } 3247 _this.hideCouponModal(); 3248 setTimeout(function(){ 3249 _this.tipsModal('Success !'); 3250 }) 3251 } 3252 }else{ 3253 $this.find('.item_control').removeClass('loading').html('<i class="icon shopCart icon-pinpaizhangouwuche_gouxuan"></i>'); 3254 _this.tipsModal('Success !'); 3255 } 3256 } 3257 } 3258 }) 3259 }else{ 3260 _this.showPopLogin(); 3261 $('.coupon_alllist_modal').addClass('zIndex') 3262 3263 } 3264 }); 3265 }, 3266 hoverCouponList:function(){ 3267 var _this = this; 3268 if(_this.isPc){ 3269 $(".coupon-container").delegate('.coupon_list','mouseenter',function(){ 3270 $(this).addClass('removeHeight') 3271 }) 3272 $(".coupon-container").delegate('.coupon_list','mouseleave',function(){ 3273 $(this).removeClass('removeHeight') 3274 }) 3275 } 3276 }, 3277 showPopLogin: function(){ 3278 var isMakeUp2 = $('#themeId'),themeFlag = false; 3279 if(isMakeUp2){ 3280 themeFlag = isMakeUp2.val() == 'makeup2' ? true : false; 3281 } 3282 if (!this.isPc) { 3283 var $mPopLogin = $('.mPopLogin'); 3284 $mPopLogin.show(); 3285 setTimeout(function () { 3286 $mPopLogin.addClass('show');//æ¾ç¤ºå¼¹çª 3287 }, 100); 3288 } else { 3289 if(themeFlag){ 3290 $(".popLogin").find('.tab-list li').eq(1).addClass('active').siblings().removeClass('active'); 3291 }else{ 3292 3293 $(".popLogin").find('.tab-list li').eq(0).addClass('active').siblings().removeClass('active'); 3294 } 3295 $(".popLogin").show().find('.loginWrapper').addClass('show').show().siblings('.registerWrapper').removeClass('show').hide(); 3296 3297 } 3298 }, 3299 showCouponModal: function(){ 3300 var _this = this; 3301 // headerInfoAjax.then(function(res){ 3302 // if(_this.checkLogin(res)){ 3303 // /* å·²ç»å½ */ 3304 // if(_this.isPc){ 3305 // $('.coupon_alllist_modal').show(); 3306 // }else{ 3307 // _this.openModal(); 3308 3309 // $('.coupon_alllist_modal').show();//poaçªå£æ¾ç¤º 3310 // setTimeout(function () { 3311 // $('.coupon_alllist_modal').addClass('show'); 3312 // }, 0); 3313 // } 3314 // }else{ 3315 // _this.showPopLogin(); 3316 // } 3317 // }); 3318 3319 //åé¢éæ±ä¼åæ é夿ç»å½å¯æ¾ç¤ºä¼æ å¸ï¼åªæé¢åå使ç¨ä¼æ å¸ééªè¯ç»å½ 3320 if (_this.isPc) { 3321 $('.coupon_alllist_modal').show(); 3322 } else { 3323 _this.openModal(); 3324 $('.coupon_alllist_modal').show();//poaçªå£æ¾ç¤º 3325 setTimeout(function () { 3326 $('.coupon_alllist_modal').addClass('show'); 3327 }, 0); 3328 } 3329 }, 3330 hideCouponModal: function(){ 3331 if(this.isPc){ 3332 $('.coupon_alllist_modal').hide(); 3333 }else{ 3334 this.closeModal(); 3335 $('.coupon_alllist_modal').removeClass('show'); 3336 setTimeout(function(){ 3337 $('.coupon_alllist_modal').hide(); 3338 },200); 3339 } 3340 }, 3341 /* æç¤ºå± */ 3342 tipsModal: function(content){ 3343 var $success = $('<div class="tipsModal">' + 3344 '<div class="iconbox">' + 3345 '<i class="icon shopCart icon-pinpaizhangouwuche_gouxuan"></i>' + 3346 '</div>'+ content +'</div>'); 3347 3348 $('body').append($success); 3349 3350 var $eleW = $success.innerWidth(), 3351 $eleH = $success.innerHeight(), 3352 winW = $(win).width(), 3353 winH = $(win).height(), 3354 offsetLeft = (winW - $eleW) / 2, 3355 offsetTop = (winH - $eleH) / 2; 3356 3357 $success.css({ 3358 top: offsetTop, 3359 left: offsetLeft, 3360 }) 3361 3362 $success.fadeIn(); 3363 setTimeout(function(){ 3364 $success.fadeOut(); 3365 },3000); 3366 setTimeout(function(){ 3367 $success.remove(); 3368 },3500); 3369 }, 3370 setShopcart: function(){ 3371 var selected_total = this.headerInfo.selected_total; 3372 3373 if(selected_total > 0){ 3374 this.$bottomBar.find('.shopcart_m .num').text(selected_total).show(); 3375 } 3376 3377 }, 3378 /* å°ºç 表 */ 3379 sizeChartDialog:function(){ 3380 var _this = this; 3381 var $sizeChartWrap = $('.size_chart_dialog_wrapper'); 3382 var $transitionWrap = $('.size_dialog-wrap'); 3383 var $body = $('body'); 3384 var win_w = $(window).width(); 3385 // 交äºå¤ç 3386 $('.js-size_chart_anchor,.js-sizeChart-close,.size_dialog-backdrop').on('click', function (e) { 3387 var $this = $(this); 3388 if($this.hasClass('size_chart')){ 3389 if ($this.hasClass('js-isDetail')) { 3390 try { 3391 if(gaNo && gaNo != ''){ 3392 gtag('event', 'click', { 3393 'event_category': 'productDetails', 3394 'event_label': 'sizeChart', 3395 'value': 0, 3396 }); 3397 } 3398 } catch (err) { 3399 console.log(err); 3400 } 3401 e.stopPropagation(); 3402 } 3403 $sizeChartWrap.addClass('chartShow'); 3404 setTimeout(function(){ 3405 $transitionWrap.addClass('isShowSize'); 3406 },100) 3407 $body.addClass('forbid-to-scroll'); 3408 }else{ 3409 $sizeChartWrap.removeClass('chartShow'); 3410 $transitionWrap.removeClass('isShowSize'); 3411 $body.removeClass('forbid-to-scroll'); 3412 } 3413 }) 3414 // å½å®¶ä¸æ 3415 var $sizeCountryList = $('.size_list_box .list'); 3416 if(win_w>768){ 3417 $('.size_list_box').hover(function(){ 3418 $sizeCountryList.stop(true,true).slideDown(); 3419 },function(){
3420 $sizeCountryList.stop(true,true).slideUp(); 3421 }) 3422 }else{ 3423 $('.size_list_box').click(function(){ 3424 $sizeCountryList.stop(true,true).slideDown(); 3425 }); 3426 } 3427 3428 3429 //hoverä¸ä¸å¯¹åº 3430 $(doc).on('mouseenter', '.size_content-wrap .tab-chart-size-wrap td', function () { 3431 var $tr = $(this).closest('tr'); 3432 $(this).addClass('active'); 3433 $('td:first', $tr).addClass('active'); 3434 }) 3435 .on('mouseleave', '.size_content-wrap .tab-chart-size-wrap td', function () { 3436 var $tr = $(this).closest('tr'); 3437 $('td', $tr).removeClass('active'); 3438 }) 3439 3440 //inch-cm忢 3441 $(doc).on('click','.pull-right .js-shop-radio',function(e){ 3442 e.preventDefault(); 3443 var $this = $(this); 3444 var index = Number($this.attr('data-size')); 3445 if($this.find('.shop-radio').hasClass('shop-radio-checked')){ 3446 return false; 3447 } 3448 $('.shop-radio').removeClass('shop-radio-checked'); 3449 $this.find('.shop-radio').addClass('shop-radio-checked'); 3450 $('.tab-chart-size-wrap .tab-pane').eq(index).show().siblings().hide(); 3451 }) 3452 3453 //忢å½å®¶æ´æ¢å¯¹åºçsizeå¼ 3454 $(".size_list_box .list li").click(function(e) { 3455 e.stopPropagation(); 3456 _this.selConversion($(this)); 3457 }); 3458 }, 3459 getSizeData: function () { 3460 return window.size;//è·åsizeæ°æ® 3461 }, 3462 selConversion: function (o) { 3463 var data = this.getSizeData(); 3464 if (!data) {return;} 3465 var type = o.find('a').text(), 3466 objInches = { 3467 type: type, 3468 sizes: [o.find('a').text()] 3469 }; 3470 var data = JSON.parse(data) 3471 objInches.sizes =objInches.sizes.concat(data[type]); 3472 3473 $('.table-inches').each(function () { 3474 if ($('th.local-inches', this).length) { 3475 $('tr', this).each(function (i) { 3476 $(this).children().eq(1).text(objInches.sizes[i] || '-'); 3477 }); 3478 } else { 3479 $('tr', this).each(function (i) { 3480 $(this).children().eq(0).after(i === 0 ? '<th class="local-inches">' + objInches.sizes[i] + '</th>' : '<td>' + (objInches.sizes[i] || '-') + '</td>'); 3481 }); 3482 } 3483 }); 3484 $(".size_list_box .list").hide(); 3485 var type = o.find('a').attr('size'); 3486 $('.size_list_box .cy_title a').attr('size', type).html(o.find('a').html()); 3487 }, 3488 //è¡¡é产åè¯¦æ æ¥çgaæ°æ®çæµ 3489 judgeGaProductDetail:function(){ 3490 if(gaNo && gaNo != ''){ 3491 var product_SKU = productSKU ? productSKU : productID, 3492 product_name = '', 3493 product_category = ''; 3494 if(pointData != null){ 3495 product_name = pointData.pointData.products_name; 3496 product_category = pointData.pointData.cate_path; 3497 } 3498 ga('ec:addProduct', { 3499 'id': product_SKU, 3500 'name': product_name, 3501 'category':product_category, 3502 'brand': pointData.pointData.brand, 3503 }); 3504 ga('ec:setAction', 'detail'); 3505 ga('set', 'nonInteraction', true); //éäºå¨å¹é æ è®° 3506 ga('send', 'pageview'); 3507 } 3508 }, 3509 //è¡¡éè´ç©è½¦æ·»å åågaæ°æ®çæµ 3510 judgeGaAddToCart:function () { 3511 if(gaNo && gaNo != ''){ 3512 var product_SKU = productSKU ? productSKU : productID, 3513 product_name = '', 3514 product_category = ''; 3515 if(pointData != null){ 3516 product_name = pointData.pointData.products_name; 3517 product_category = pointData.pointData.cate_path; 3518 } 3519 3520 ga('ec:addProduct', { 3521 'id': product_SKU, 3522 'name': product_name, 3523 'category':product_category, 3524 'brand': pointData.pointData.brand, 3525 }); 3526 ga('ec:setAction', 'add'); 3527 ga('send', 'event', 'UX', 'click', 'add to cart'); 3528 } 3529 3530 3531 }, 3532 buyNow: function(e){ 3533 var _this = this, 3534 $this = $(e.currentTarget), 3535 isPayPal = $this.hasClass('js-paypal'); 3536 isBuyNow = $this.hasClass('js-buynow'); 3537 3538 if ($this.hasClass('gray')) return false;
3539 if ($this.hasClass('forbidGray')) return false;//ç¦å®å°åº 3540 if ($this.hasClass('loading_bg')) return false; 3541 3542 if (isPayPal) { 3543 this.recordPayVisit('1', '1', 'PayPal Express Checkout'); 3544 this.reportBingCustomEvent('click', 'product', 'middle_payPal_button'); // Bingå¢è®¾åç¹ 3545 this.sendGaProductData(); // è¥éåç¹ 3546 this.sendGAEvents('product', 'middle_payPal_button'); // GAåç¹ 3547 } else { 3548 this.recordPayVisit('1', '0'); 3549 this.reportBingCustomEvent('click', 'product', 'middle_buyNow_button'); // Bingå¢è®¾åç¹ 3550 this.sendGaProductData(); // è¥éåç¹ 3551 this.sendGAEvents('product', 'middle_buyNow_button'); // GAåç¹ 3552 } 3553 3554 //_this.judgeGaAddToCart(); 3555 /* 屿§æ°éä¸ä¸º0 */ 3556 if (this.poaLength !== 0) { 3557 /* PC端 */ 3558 if (!this.isPc) { 3559 /* M端 */ 3560 var wrapIsShow = this.$poaWrapper.find('.poa_list_wrap').css('display') === 'none' ? false : true;//å¼¹æ¡æ¾ç¤ºç¶æ 3561 if (wrapIsShow) { 3562 /* ç¹å»å¼¹æ¡çå è´æé® */ 3563 if (this.checkSelected(true)) { 3564 this.buyNowRequire(isPayPal); 3565 } 3566 } else { 3567 /* ç¹å»é¡µé¢ä¸æ¹çå è´æé® */ 3568 this.openModal(); 3569 this.$giftWrapper.removeClass('show').find('.gift_list_wrap').hide(); 3570 this.$poaWrapper.find('.poa_list_wrap').show().find('.submit_box .js-buynow').show().css({'margin-left': 0,'margin-right': 0}).siblings().hide();//poaçªå£æ¾ç¤º 3571 setTimeout(function () { 3572 _this.$poaWrapper.addClass('show'); 3573 }, 0); 3574 } 3575 3576 } else { 3577 /* PC端 */ 3578 if (this.checkSelected(true)) { 3579 this.buyNowRequire(isPayPal); 3580 } 3581 } 3582 } else { 3583 this.buyNowRequire(isPayPal); 3584 } 3585 3586 }, 3587 buyNowRequire: function(isPayPal){ 3588 this.showBtnLoading(isPayPal ? 3 : 2); 3589 3590 var _this = this, 3591 data = this.packAddData(), 3592 quantity = this.$qtyInput.val(); 3593 var checkoutData={currency:'USD', value: quantity * $('.js-product-info #usPrice').val()} 3594 if(isPayPal){ 3595 typeof fbq == 'function' && fbq('track','AddPaymentInfo',checkoutData); 3596 } 3597 $.ajax({ 3598 url: '/addProductBuyNow.html', 3599 type: 'post', 3600 dataType: 'json', 3601 data: data, 3602 cache: false, 3603 processData: false, 3604 contentType: false, 3605 success: function (data) { 3606 if (data.message == 'success') { 3607 if(!isPayPal){ 3608 window.location.href = '/checkout'; 3609 }else{ 3610 window.location.href = "/index.php?com=shopcart&t=checkoutPayPalExpressSubmit&payCode=paypal&isExpress=Y"; 3611 //_this.paypalRequire(); 3612 } 3613 3614 } else { 3615 _this.errorAlert(data.msg); 3616 } 3617 _this.shippingModalPositon(); 3618 _this.hideBtnLoading(); 3619 3620 //ç¹å»buy now æ pay palæé®å追踪æ¨è使°æ® 3621 var rmmds = _this.getQueryString('rmmds'); 3622 if (isPayPal){ 3623 var pidArr = [_this.pid]; 3624 var bidArr = []; 3625 var pid = ""; 3626 var loadData = Record.loadOntime('exp_rec_bid_' + _this.pid);
3627 bidArr.push( loadData ? loadData.bid : ""); 3628 bidArr = bidArr.filter(Boolean);//å é¤ç©ºå ç´ 3629 _this.recObj["ac"] = "checkout"; 3630 _this.recObj["products_id"] = pidArr.join(","); 3631 _this.recObj["basket_id"] = bidArr.join(","); 3632 Record.rec(_this.recObj); 3633 //åå ¥cookieå¼ç»å端读åï¼æ°æ®ä¿å15天 3634 _this.setCookie('rec_bid', bidArr.join(","), 15) 3635 }else{ 3636 _this.recObj["ac"] = "cart"; 3637 _this.recObj["products_id"] = _this.pid; 3638 Record.rec(_this.recObj); 3639 } 3640 if(rmmds === 'search'){ 3641 //æç´¢åç¹ 3642 nDC.RecordClick('buynow', [_this.pid]) 3643 } 3644 //FBäºä»¶çæµ 3645 _this.sendFbEvents('AddToCart') 3646 //buyNow追å çæµ 3647 if (!isPayPal) { 3648 try { 3649 fbq('track', 'InitiateCheckout'); 3650 } catch (error) { 3651 console.log(error); 3652 } 3653 } 3654 3655 }, 3656 error: function (data) { 3657 _this.hideBtnLoading(); 3658 } 3659 }) 3660 }, 3661 /* add to cart å buy now åstart group æäº¤çæ°æ® */ 3662 packAddData: function(){ 3663 var _this = this, 3664 data = new FormData(), 3665 quantity = this.$qtyInput.val(); 3666 3667 data.append('quantity', quantity); 3668 data.append('products_id', this.pid); 3669 data.append('warehouse', this.cur_warehouse); 3670 3671 this.$giftList.find('.gift_item.isChecked').each(function () { 3672 var gift_id = $(this).attr('data-giftid'), 3673 $attrs = $(this).find('.gift_info_wrap').find('.info_attr'), 3674 accesory_id = gift_id; 3675 3676 if ($attrs !== 0) { 3677 $attrs.each(function () { 3678 var $active = $(this).find('.gift_attr.active'); 3679 accesory_id += '{' + $active.attr('data-optionid') + '}' + $active.attr('data-valueid'); 3680 }); 3681 3682 } 3683 3684 data.append('accesory_id[]', accesory_id); 3685 }); 3686 3687 $.each(this.activeIndex, function (i, val) { 3688 data.append('id[' + _this.activeIndex2[i] + ']', val); 3689 }); 3690 3691 return data; 3692 }, 3693 paypalRequire: function(){ 3694 var _this = this; 3695 $.ajax({ 3696 url: '/index.php?com=shopcart&t=checkoutPayPalExpressSubmit&payCode=paypal&isExpress=Y', 3697 type: 'post', 3698 dataType: 'json', 3699 success: function (data) { 3700 // if (data.message == 'success') { 3701 // if(!isPayPal){ 3702 // headerInfoAjax.then(function (res) { 3703 // if (_this.checkLogin(res)) { 3704 // window.location.href = '/checkout'; 3705 // } else { 3706 // window.location.href = '/information'; 3707 // } 3708 // }); 3709 // }else{ 3710 // _this.paypalRequire(); 3711 // } 3712 3713 // } else { 3714 // _this.errorAlert(data.msg); 3715 // } 3716 // _this.shippingModalPositon(); 3717 // _this.hideBtnLoading(); 3718 // //FBäºä»¶çæµ 3719 // _this.sendFbEvents('AddToCart') 3720 }, 3721 error: function (data) { 3722 console.log(data); 3723 _this.hideBtnLoading(); 3724 } 3725 }) 3726 }, 3727 /* 3728 屿§å¼å°ºç 忢 3729 author: liuyinggui 3730 */ 3731 sizeChange: function() { 3732 var win_w = $(window).width(); 3733 var _this = this; 3734 // å½å®¶ä¸æ 3735 var $sizeCountryList = $('.js-size-slide .list'); 3736 if(win_w>768){ 3737 $('.js-size-slide').hover(function(){ 3738 $sizeCountryList.stop(true,true).slideDown(); 3739 },function(){
3740 $sizeCountryList.stop(true,true).slideUp(); 3741 }) 3742 }else{ 3743 $('.js-size-slide .cy_title').click(function(){ 3744 $sizeCountryList.stop(true,true).slideDown(); 3745 }); 3746 } 3747 //ç¹å»å忢屿§å¼ 3748 $('.js-size-item').on('click', function(){ 3749 var attrList = $(this).parents('.item_name').next('.attr_value_list'), 3750 items = JSON.parse($(this).children().attr('data-val')); 3751 var size = $(this).children().attr('size'); 3752 $.each(attrList.children(),function(){ 3753 var vid = $(this).attr('data-vid') 3754 $(this).text(items[vid]) 3755 }) 3756 _this.setCookie('_sizeType', size, 30) //å°ºç æ°æ®ä¿åcookie30天 3757 $sizeCountryList.stop(true,true).slideUp();//æ¶èµ·ä¸ææ¡ 3758 $('.js-size-slide').find('.default_size').text('Size('+size+')') 3759 }) 3760 }, 3761 setPromotion: function(){ 3762 var promotionFlagArr = this.headerInfo.products_items_list.promotion_flag, 3763 group_url = this.headerInfo.products_items_list.group_url, 3764 $wrap = $('<div class="promotion-reduction-wrap"></div>'); 3765 3766 if(promotionFlagArr !== null && promotionFlagArr.length){ 3767 3768 if(this.isPc){ 3769 var listHtml = ''; 3770 $.each(promotionFlagArr,function(index, value){ 3771 if(index !== 0){ 3772 listHtml += '<div class="reduction-item">' + value + '</div>'; 3773 }else{ 3774 listHtml += '<div class="reduction-item"> <i class="shopCart icon-M-mycoupons"></i> ' + value + '</div>'; 3775 } 3776 }); 3777 3778 $wrap.html('<div class="promotion-flex-box"><a href="'+ group_url +'" class="reduction-list"> ' + listHtml + ' </a></div>'); 3779 3780 if(promotionFlagArr.length > 1){ 3781 $wrap.find('.promotion-flex-box').append('<a href="javascript:void(0);" class="more">More Deals <i class="shopCart icon-pinpaizhangouwuche_down-copy"></i></a>'); 3782 } 3783 }else{ 3784 var text = promotionFlagArr.join(', '); 3785 $wrap.addClass('js-show-promotion').html('<div class="reduction-label">Discount:</div><div class="reduction-content"><div class="promotion-flag">'+ text +'</div><i class="icon shopCart icon-M-in"></i><img class="m-discount-loading" src="/templates/common/src/shopCart/images/loading.gif" /></div>'); 3786 //M端 3787 3788 } 3789 3790 $("#promotion-flag").html($wrap); 3791 } 3792 }, 3793 initDefaultClick: function(){ 3794 var _this = this; 3795 $(doc).ready(function () { 3796 if (_this.shopStatus) { 3797 if (_this.semData) { 3798 var key = Object.keys(_this.semData); 3799 if (key.length) { 3800 var defaultPoaArr = key[0].split('.'); 3801 _this.onClickHandler(defaultPoaArr); 3802 } 3803 } else { 3804 if (_this.poaLength) { 3805 /* é»è®¤å±æ§è·ååºå */ 3806 var defaultPoaArr = [];//屿§idæ°ç» 3807 Object.keys(_this.defaultPoaVid).forEach(function (key) { 3808 defaultPoaArr.push(String(_this.defaultPoaVid[key])); 3809 }); 3810 _this.onClickHandler(defaultPoaArr); 3811 } else { 3812 /* é»è®¤POAè·ååºå */ 3813 _this.getPoaData(); 3814 } 3815 } 3816 3817 /* 夿æ¹åä»·æ¯å¦ä¸ºç©º */ 3818 if (!_this.isWsdataNull) { 3819 _this.updateWsTable(true); 3820 _this.$wholesaleWrap.css('display', 'inline-block'); 3821 } 3822 } 3823 }); 3824 }, 3825 groupBuyRule_m:function(){ 3826 var $rulePop = $('#m-group-rule-pop'); 3827 $(doc).on('click','.js-show-rulePop',function(){ 3828 $rulePop.fadeIn(); 3829 }); 3830 $(doc).on('click','.js-close-rule',function(e){ 3831 e.stopPropagation(); 3832 $rulePop.fadeOut(); 3833 }) 3834 }, 3835 discountHandler_m: function () { 3836 var _this = this, 3837 hasPromotionModal = false;
3838 /* å¼¹åºpromotion modal */ 3839 $('#promotion-flag').on('click', '.js-show-promotion', function () { 3840 _this.$promotionModal = $('#promotion-modal'); 3841 if (hasPromotionModal) { 3842 _this.$promotionModal.show(); 3843 $('body').css({ 3844 "overflow": "hidden" 3845 }); 3846 _this.openModal(); 3847 setTimeout(function () { 3848 _this.$promotionModal.addClass('show'); 3849 }, 0); 3850 } else { 3851 var $promotionFlag_m = $('#js-promotion-flag'), 3852 $discountBtn = $('#js-discount-btn'), 3853 promotionFlagArr = _this.headerInfo.products_items_list.promotion_flag, 3854 group_url = _this.headerInfo.products_items_list.group_url; 3855 _this.group_id = _this.headerInfo.products_items_list.group_id; 3856 $('.m-discount-loading').fadeIn(); 3857 _this.loadMoreProducts_m().then(function (data) { 3858 $('.m-discount-loading').hide(); 3859 $promotionFlag_m.html(promotionFlagArr.join(', ')); 3860 $discountBtn.html('<a href="' + group_url + '" class="product_info_btn">View More</a>'); 3861 _this.$promotionModal.show(); 3862 $('body').css({ 3863 "overflow": "hidden" 3864 }); 3865 _this.openModal(); 3866 hasPromotionModal = true; 3867 setTimeout(function () { 3868 _this.$promotionModal.addClass('show'); 3869 }, 0); 3870 }) 3871 } 3872 3873 }); 3874 3875 $(doc).on('click', '#promotion-modal .closeBtn', function () { 3876 _this.$promotionModal.removeClass('show'); 3877 setTimeout(function () { 3878 _this.$promotionModal.hide(); 3879 }, 200); 3880 _this.closeModal(); 3881 $('body').css({ 3882 "overflow": "" 3883 }); 3884 }); 3885 }, 3886 scrollBind_m: function () { 3887 var _this = this; 3888 var numTime = _this.isPc ? 300 : 50;//ä¹æä»¥è¿æ ·å¤çï¼å 为M端æéè¿å¿«æ²¡æ³ç»§ç»å è½½æ´å¤æ°æ® 3889 var throttleFn = throttle(function () { 3890 var flagLoadType =!_this.pro_loading && !_this.pro_isLoadOver; 3891 if (flagLoadType) { 3892 var boxHeight = $(".box_wrap").height(), 3893 eleScrollHight = $('.discount-list')[0].scrollHeight; 3894 eleScrollTop = $('.discount-list')[0].scrollTop; 3895 outHeight = $('.discount-list').outerHeight(); 3896 //ç嬿»å¨å°åºé¨è¯·æ±æ°æ® 3897 if (eleScrollTop + boxHeight >= eleScrollHight - outHeight - 100){ 3898 _this.loadMoreProducts_m(); 3899 } 3900 } 3901 3902 }, numTime); 3903 $('#js-discount-list').scroll(throttleFn); 3904 }, 3905 loadMoreProducts_m: function () { 3906 var _this = this, 3907 $pro_loading = $('#js-more-pro_loading'); 3908 _this.pro_loading = true; 3909 var $discountListWrap = $('#js-discount-list'); 3910 return $.ajax({ 3911 url: '/Promotion_groupProducts.html', 3912 data: { 3913 group_id:_this.group_id, 3914 page: _this.promos_pager, 3915 order: '', 3916 }, 3917 type: 'post', 3918 dataType: 'json', 3919 beforeSend: function () { 3920 $pro_loading.show(); 3921 }, 3922 success: function (res) { 3923 $pro_loading.hide(); 3924 var pages = res.pages;//è¯è®ºæ»é¡µæ° 3925 if(res.code == 200){ 3926 _this.productItem = template("templatePromotionContent", res); 3927 $discountListWrap.append(_this.productItem); 3928 } 3929 if (_this.promos_pager === pages) { 3930 _this.pro_isLoadOver = true; 3931 } else { 3932 _this.promos_pager++; 3933 _this.pro_isLoadOver = false; 3934 } 3935 _this.pro_loading = false; 3936 3937 }, 3938 complete: function () { 3939 $pro_loading.hide(); 3940 } 3941 }); 3942 }, 3943 // æ¯ä»éç¹ 3944 recordPayVisit: function(step, isExpress, payCode) { 3945 var step = step || 1, 3946 isExpress = isExpress || '', 3947 payCode = payCode || ''; 3948 $.ajax({ 3949 url: '/index.php', 3950 type: 'get', 3951 data: { 3952 com: 'shopcart', 3953 t: 'ajaxRecordPayVisit', 3954 isExpress: isExpress, 3955 step: step, 3956 payCode: payCode 3957 } 3958 }) 3959 }, 3960 reportBingCustomEvent: function(action, category, label) { 3961 // Bingå¢è®¾åç¹ 3962 try { 3963 window.uetq = window.uetq || []; 3964 window.uetq.push('event', action, { 3965 'event_category': category, 3966 'event_label': label, 3967 }); 3968 } catch (err) { 3969 } 3970 }, 3971 // è¡¡éç»å¸é项æµç¨è®°å½ 3972 sendGaProductData:function(){ 3973 try{ 3974 var products_info = pointData.pointData; 3975 console.log(pointData.pointData); 3976 ga('ec:addProduct', { 3977 'id': products_info.sku, 3978 'name': products_info.products_name, 3979 'category': products_info.cate_path, 3980 'brand': products_info.brand_name, 3981 'price': products_info.final_price, 3982 'quantity': products_info.quantity 3983 }); 3984 3985 ga('ec:setAction', 'checkout', { 3986 'step': 1, 3987 }); 3988 3989 ga('send', 'pageview'); 3990 } catch(error){ 3991 console.log(error) 3992 } 3993 }, 3994 // åégaåç¹ 3995 sendGAEvents:function(category, label) { 3996 //GA idåå¨ååéäºä»¶ 3997 if (gaNo && gaNo != '') { 3998 gtag('event', 'click', { 3999 'event_category': category, 4000 'event_label': label, 4001 'value': 0 4002 }); 4003 } 4004 }, 4005 } 4006 4007 var pid = $('#product_name').attr('data-id'); 4008 var sel_poa = $('#selPoa').val(); 4009 4010 win.PoaHandler = new PoaHandler({ 4011 pid: pid, 4012 poaCodeList: poaCodeList, 4013 selPoa: sel_poa,//é»è®¤SKU 4014 wsData: wsData,//æ¹åä»·ä¿¡æ¯ 4015 defaultPoaVid: defaultPoaVid,//é»è®¤éä¸ 4016 semData: semData,//semä¿¡æ¯ 4017 cur_warehouse: cur_warehouse,//产åæå¨ä»åº 4018 defaultPoa:defaultPoa,//é»è®¤poa 4019 }); 4020 4021})(document, window, jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.