unjcdtd.com
Open in
urlscan Pro
52.220.181.11
Public Scan
URL:
https://unjcdtd.com/V3/common/assets/js/public.js
Submission: On December 15 via api from US — Scanned from SG
Submission: On December 15 via api from US — Scanned from SG
Form analysis
0 forms found in the DOMText Content
function addProductLogo(val, pos, logo) { if (!val.length || !logo) return; val.each(function (v) { var img = '<img data-original="' + logo + '" src="' + logo + '" class="lazy product-logo">'; if ($(this).find(pos).length) { $(this).find(pos).css({ position: 'relative', 'z-index': '1' }); $(this).find(pos).append(img); } }); } function multiCurrency(curId, curSymbolPos, curSymbol, currencyTo, cartProm, isMultiCurrency) { var remark = { fromCurrencyId: curId, toCurrencyId: curId, curSymbolPos: curSymbolPos, symbol: curSymbol }; if(!isMultiCurrency){ return remark; } require(['currencyNew'], function ({ winCurrency }) { var currencyFrom = store.get('_gk_currencyFrom'); if (currencyFrom != null) { remark.fromCurrencyId = currencyFrom; } if (currencyTo != null) { remark.toCurrencyId = currencyTo; } if ('undefined' != typeof cartProm) { cartProm = winCurrency.cartPromFun({ data: JSON.parse(JSON.stringify(cartProm)), remark: remark, lang: cartLang['addcart_prom_desc'] }); } var href = location.href; if (href.indexOf('detail') > -1) { var sinfo = store.get('sinfo'); if ('undefined' != typeof sinfo) { sinfo = JSON.parse(sinfo); sinfo.currencyId = remark.toCurrencyId; sinfo = winCurrency.sinfoFun({ data: sinfo, remark: remark, lang: cartLang['addcart_prom_desc'] }); } } }); return remark; } function publicFormatPrice(price) { var str = price + ''; var newStr = ''; var count = 0; for (var i = str.length - 1; i >= 0; i--) { if (count % 3 == 0 && count != 0) { newStr = str.charAt(i) + ',' + newStr; } else { newStr = str.charAt(i) + newStr; } count++; } return newStr; } function publiceFormatCurrency(money, curSymbol) { if (!money) { return money; } curSymbol = curSymbol || symbol; // ä¿ç•™ä¸¤ä½å°æ•°çš„å¸ç§ç¬¦å· var symbolKeepTwoDecimals = ['$']; money = money.toString().replace(/\$|\,/g, ''); if (isNaN(money)) { money = '0'; } if (symbolKeepTwoDecimals.includes(curSymbol)) { money = String(Number(money).toFixed(2)); } else { money = Math.floor(money * 10 + 0.50000000001); money = Math.floor(money / 10).toString(); } if (curSymbol == 'zÅ‚') { for (var i = 0; i < Math.floor((money.length - (1 + i)) / 3); i++) { money = money.substring(0, money.length - (4 * i + 3)) + ' ' + money.substring(money.length - (4 * i + 3)); } money = money + `<small>,00</small>`; } else if (curSymbol == 'Ft') { for (var i = 0; i < Math.floor((money.length - (1 + i)) / 3); i++) { money = money.substring(0, money.length - (4 * i + 3)) + ' ' + money.substring(money.length - (4 * i + 3)); } } else if (symbolKeepTwoDecimals.includes(curSymbol)) { var moneyFixed = money.split('.'); money = moneyFixed[0]; for (var i = 0; i < Math.floor((money.length - (1 + i)) / 3); i++) { money = money.substring(0, money.length - (4 * i + 3)) + ' ' + money.substring(money.length - (4 * i + 3)); } money = money + '.' + moneyFixed[1]; } else { for (var i = 0; i < Math.floor((money.length - (1 + i)) / 3); i++) { money = money.substring(0, money.length - (4 * i + 3)) + ',' + money.substring(money.length - (4 * i + 3)); } } return money; } $.fn.priceFormatCurrency = function () { switch (currencyId) { case '18': this.each(function () { var price = $(this).text(); if (price.length > 0) { price = Number(price.trim().replace(/[^\d.]/g, '')).toFixed(2); currencyPos ? $(this).html(symbol + separationSpace(price)) : $(this).html(separationSpace(price) + symbol); } }); break; case '29': // 波兰 this.each(function () { let price = $(this).text(); if (price.length > 0 && price.indexOf(',00') == -1) { if (price.indexOf(',') > -1) { price = price.trim().replace(/,/g, ''); } if (price.indexOf('.00') > -1) { price = price.trim().replace(/\.00/g, ''); } price = parseInt(price.trim().replace(/\D/g, '')); $(this).html(separationSpace(price) + `<small>,00 ${symbol}</small>`); } }); break; case '36': // 匈牙利 this.each(function () { let price = $(this).text(); if (price.length > 0 && price.indexOf(',00') == -1) { if (price.indexOf(',') > -1) { price = price.trim().replace(/,/g, ''); } if (price.indexOf('.00') > -1) { price = price.trim().replace(/\.00/g, ''); } price = parseInt(price.trim().replace(/\D/g, '')); $(this).html(separationSpace(price) + `<small>${symbol}</small>`); } }); break; } }; function separationSpace(num) { //å—符串æ¯ä¸‰ä½åŠ ç©ºæ ¼ var numpart = String(num).split('.'); numpart[0] = numpart[0].replace(new RegExp('(\\d)(?=(\\d{3})+$)', 'ig'), '$1 '); return numpart.join('.'); } function backHint(cb, pushHistory = 0) { var pathname = window.location.pathname; if (typeof publicConfirm != 'undefined') { var hint = pageBackHint; var confirm = backContinueBuy; if (pageBackCoupon) { confirm = confirmOk; var price = currencyPos ? symbol + publiceFormatCurrency(pageBackCoupon, symbol) : publiceFormatCurrency(pageBackCoupon, symbol) + symbol; hint = pageBackHintCoupon.replace('$P', "<span class='red'>" + price + '</span>'); } initConfirm( hint, confirm, cancal, cancelBack, function () { confirmBack(cb); }, 'page-back' ); } else { cb(); } function confirmBack(cb) { window.removeEventListener('popstate', function () { backHint(function () { history.go(-1); }, 1); }); cb(); store.set('active_page_back', 2); } function cancelBack() { if (typeof pageBackCoupon != 'undefined' && pageBackCoupon) { if (pathname.indexOf('/detail') > -1) { store.set('is_back_coupon', pageBackCoupon); } if (pathname.indexOf('/checkout') > -1) { window.Account.backCoupon(pageBackCoupon); } } store.set('active_page_back', 1); if (pushHistory) { window.history.pushState( { title: 'title', url: '' }, null, location.href ); } } } function initConfirm(text, ok, cancal, confirmCb, cancalCb, className, cancelSmall) { var gkMask; if ($('.new-mask').length < 1) { gkMask = $("<div class='new-mask'></div>"); } else { gkMask = $('.new-mask'); } if (className) { gkMask.addClass(className); } gkMask.addClass('gui-show'); var gkModel = $( '<div class="confirm"><div class="confirm-t al-c">' + text + '</div><div class="confirm-btn flex-btw"><span id="confirm-ok">' + ok + '</span><span id="confirm-cancle">' + cancal + '</span></div>' + (cancelSmall ? '<div class="cancel-small">' + cancelSmall + '</div>' :'') + '</div>' ); if (className && className == 'page-back') { var pathname = window.location.pathname; var page = 'detail'; if (pathname.indexOf('/checkout') > -1) page = 'checkout'; gkModel.find('#confirm-ok').addClass('ga-event').attr({ 'ga-src': page, 'ga-type': 'page-ok' }); gkModel .find('#confirm-cancle') .addClass('ga-event') .attr({ 'ga-src': page, 'ga-type': 'page-cancle' }); } gkMask.html(gkModel); var bgMask = $('<div class="bg-mask"></div>'); gkMask.append(bgMask); $('.body-box').length ? $('.body-box').eq(0).append(gkMask) : $('body').append(gkMask); var width = -($('.confirm').width() / 2), height = -($('.confirm').height() / 2); $('.confirm').css({ 'margin-left': width + 'px', 'margin-top': height + 'px' }); gkModel.on('click', '#confirm-ok', function () { $('.new-mask').removeClass('gui-show'); confirmCb(); setTimeout(function () { $('.new-mask').removeClass(className); }, 300); }); gkModel.on('click', '#confirm-cancle, .cancel-small, .bg-mask', function () { $('.new-mask').removeClass('gui-show'); cancalCb(); setTimeout(function () { $('.new-mask').removeClass(className); }, 300); }); bgMask.on('click', function () { $('.new-mask').removeClass('gui-show'); cancalCb(); setTimeout(function () { $('.new-mask').removeClass(className); }, 300); }); } function isDetailPage() { var pathname = window.location.pathname; return pathname.indexOf('/detail') > -1; } function isCheckoutPage() { var pathname = window.location.pathname; var path = [ '/checkout/orderSuccess', '/checkout/paysuccess', '/checkout/orderFail', '/checkout/fail', '/checkout/loading' ]; var flag = path.indexOf(pathname) > -1; if (pathname.indexOf('/checkout') > -1 && !flag) { return true; } else { return false; } } function historyBack() { try { if (isDetailPage()) { store.remove('is_back_coupon'); } if (!isCheckoutPage()) return; if (typeof pageBack != 'undefined' && pageBack / 1) { // var isUpdate = location.href.slice(-1) == "#"; if (window.performance.navigation.type != 1) { // 0 : 页é¢é¦–æ¬¡åŠ è½½ // 1 : 页é¢è¢«åˆ·æ–° // 2 : 页é¢æ˜¯é€šè¿‡å…¶ä»–页é¢è¿”回的 window.history.pushState( { title: 'title', url: '' }, null, location.href ); } console.log(window.performance.navigation.type); window.addEventListener('popstate', function () { backHint(function () { history.go(-1); }, 1); }); } } catch (err) { console.log(err); } } // 在线支付æˆåŠŸé¡µ function onlinePaySucess() { var pathname = window.location.pathname; var flag = store.get('pay_loading'); if (pathname.indexOf('/checkout/paysuccess') > -1) { if (flag) { toast(loadingPayHint, 2000); store.remove('pay_loading'); } if (typeof amountTaxExclusive != 'undefined' && typeof langId != 'undefined' && langId == 3) { $('.amount-hint').html(amountTaxExclusive); } return true; } else { return false; } } // 货到付款支付æˆåŠŸé¡µ function orderSucessPage() { var pathname = window.location.pathname; if (pathname.indexOf('/checkout/orderSuccess') > -1) { if (typeof amountTaxInclusive != 'undefined' && typeof langId != 'undefined' && langId == 3) { $('.amount-hint').html(amountTaxInclusive); } return true; } else { return false; } } $(document).ready(function () { onlinePaySucess(); orderSucessPage(); // 当å‰é¡µé¢æ˜¯è¯¦æƒ…页,ä¸æ˜¯ç»“账页使用php缓å˜è·³è½¬åˆ°è¯¦æƒ…é¡µçš„ï¼Œåˆ é™¤æœ¬åœ°å˜å‚¨æ•°æ®useTplData if (location.href.includes('/index/detail') && (!document.referrer || !document.referrer.includes('/checkout?'))) { store.remove('useTplData'); } }); // 生æˆäºŒç»´ç function createQrCode(codeText, cb) { var gkMask; if ($('.new-mask').length < 1) { gkMask = $('<div class="new-mask"></div>'); $('body').append(gkMask); } else { gkMask = $('.new-mask'); } gkMask.addClass('gui-show'); var gkModel = $('<div class="qr-code"></div>'); var gkQr = $('<div id="QRCodeNone"></div>'); gkMask.html(gkQr); gkMask.append(gkModel); gkQr.qrcode({ text: codeText, width: '200', // 二维ç 的宽度 height: '200' }); // 二维ç 长按识别 var myCanvas = document.querySelector('#QRCodeNone canvas'); var img = new Image(); img.src = myCanvas.toDataURL('image/png'); gkModel.append(img); $('#QRCodeNone').hide(); if (typeof qrcodeHint != 'undefined') { gkModel.append(`<p class="hint">${qrcodeHint}</p>`); } if (typeof updateHint != 'undefined') { gkModel.append(`<p class="hint qr-update" style="cursor: pointer;">${updateHint}</p>`); } $('.qr-update').on('click', function () { createQrCode(codeText, cb); }); cb(); } // å›¾ç‰‡æ·»åŠ å°ºå¯¸ function addImgSize(url, width, height) { if (url.indexOf('static.compgoo.com') < 0) { return url }; var path = url.split('?')[0]; var arr = path.split('.'); var suffix = '.' + arr[arr.length - 1]; var suffixArr = ['.png', '.jpg', '.jpeg']; if (suffixArr.indexOf(suffix) < 0) { return url; } var newWidth = width > 100 ? width : 100; var newHeight = height > 100 ? height : 100; var sizeStr = '.' + newWidth + 'x' + newHeight + suffix; return url.replace(suffix, sizeStr); } // æ ¼å¼åŒ–日期 function formatDate(date) { date = new Date(date); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); month = month < 10 ? "0" + month : month; day = day < 10 ? "0" + day : day; return `${year}-${month}-${day}`; } // 东八区指定时间æ¢ç®—时区 function formatTimeZone(time){ if (!time) return ''; const actualTime = new Date(time * 1000); const year = actualTime.getFullYear(); const month = actualTime.getMonth() + 1 > 9 ? actualTime.getMonth() + 1 : `0${actualTime.getMonth() + 1}`; const day = actualTime.getDate() > 9 ? actualTime.getDate() : `0${actualTime.getDate()}`; const hour = actualTime.getHours() > 9 ? actualTime.getHours() : `0${actualTime.getHours()}`; const minute = actualTime.getMinutes() > 9 ? actualTime.getMinutes() : `0${actualTime.getMinutes()}`; const second = actualTime.getSeconds() > 9 ? actualTime.getSeconds() : `0${actualTime.getSeconds()}`; return `${year}-${month}-${day} ${hour}:${minute}:${second}`; }; // æå–å—符串ä¸ä¸åŒ…å«JSON的内容 function extractNonJsonString(inputStr) { let jsonStart = inputStr.indexOf('{'); let jsonEnd = inputStr.lastIndexOf('}') + 1; let result = ''; let nonJsonStringFront = inputStr.substring(0, jsonStart); let nonJsonStringBehind = inputStr.substring(jsonEnd); if (jsonStart === -1 && jsonEnd === 0) { return '未检测到jsonå—符串' + inputStr; } result = nonJsonStringFront && ('JSONå‰å—符:' + nonJsonStringFront.trim()) || ''; result += nonJsonStringBehind && ((result ? ', ' : '') + 'JSONåŽå—符:' + nonJsonStringBehind.trim()) || ''; return result; } templateCache = true; // 防抖 function debounce(fn, delay) { let timer = null; return function () { let that = this; let args = arguments; clearTimeout(timer); timer = setTimeout(function () { fn.apply(that, args) }, delay) } }