ijÁÖ¾ó ¿ÊÀåÀ»À§ÇÑ ¼¼·ÃµÇ°í Æí¾ÈÇÑ ³²¼º ¼¼Æ®¸¦ ã°í °è½Ê´Ï±î? ÆмÇÀ» Ãß±¸ÇÏ´Â ½Å»çµé¿¡°Ô ¿Ïº®ÇÑ ¼±ÅÃÀÎ ³²¼º¿ë ¹ÙÁö ¼¼Æ® Ä÷º¼Ç ¸¸ÇÑ Á¦Ç°ÀÌ ¾ø½À´Ï´Ù. °í±Þ ¼ÒÀç¿Í µðÀÚÀÌ³Ê ½ºÅ¸Àϸµ¿¡ ÁßÁ¡À» µÐ ³²¼º¿ë ¼¼Æ®´Â ½ºÆ÷Ã÷¿þ¾î ¹× ijÁÖ¾ó ÀÇ·ù¿¡¼ ÃÖ°íÀÔ´Ï´Ù.
ÀÌ ½ºÆ÷Ã÷ ¿îµ¿º¹ ÀÇ·ù ¿îµ¿º¹Àº Áý¿¡¼ ÈÞ½ÄÀ» ÃëÇϰųª Ä£±¸µé°ú üÀ°°üÀ» Ä¡´Â µ¥ ÀÌ»óÀûÀÌ¸ç ´Ù¾çÇÑ ½ºÅ¸ÀÏ·Î ¾î¶² °æ¿ì¿¡µµ ÁÁ½À´Ï´Ù. ÇÁ¸®¹Ì¾ö ¼ÒÀç·Î Á¦À۵Ǿî Æí¾ÈÇÑ Âø¿ë°¨À» Ư¡À¸·Î ÇÏ´Â ÀÌ ¼¼Æ®´Â Ź¿ùÇÑ Æí¾ÈÇÔ°ú ½ºÅ¸ÀÏÀ» Á¦°øÇϵµ·Ï ¼³°èµÇ¾ú½À´Ï´Ù.
À¯ÇàÇÏ´Â Èĵð¿Í ¾î¿ï¸®´Â ÆÒÆ®¿Í ÇÔ²², ÀÌ ³²¼º¿ë ½º¿þÆ® ¼ÅÃ÷ ¼¼Æ®´Â ÃÖ°íÀÇ ¸ð½À°ú ´À³¦À» ¿øÇÏ´Â ¸ðµç ³²¼º¿¡°Ô ¿Ïº®ÇÑ ¼±ÅÃÀÔ´Ï´Ù. ´ç½ÅÀÌ ´Þ¸®±â¸¦ ÇÏ´øÁö ¾Æ´Ï¸é ±×³É Áý ÁÖº¯À» ¾î½½··°Å¸®´øÁö, ÀÌ ¼¼Æ®´Â Ʋ¸²¾øÀÌ ´ç½ÅÀÇ ¿ÊÀå¿¡¼ ÇØ°á»ç°¡ µÉ °ÍÀÌ´Ù.
¿Ö ±â´Ù·Á? ¿À´Ã ³²¼º µðÀÚÀÌ³Ê ÀÇ·ù Ä÷º¼ÇÀ» ¼îÇÎÇÏ°í ijÁÖ¾ó ¿ÊÀå¿¡ ¿Ïº®ÇÑ ¸¶¹«¸® ÅÍÄ¡¸¦ Ãß°¡ÇϽʽÿÀ. ½ºÅ¸ÀÏ°ú Æí¾ÈÇÔÀÇ Å¹¿ùÇÑ Á¶È·Î, ³õÄ¡°í ½ÍÁö ¾ÊÀº ÇϳªÀÇ ¼¼Æ®ÀÔ´Ï´Ù!
`; skuObjList.map(function(item,index){ myhtml+=`
`; }); myhtml+=`
`; $(`#popSkuCon`).length>0&&$(`.showSweetAlert #popSkuCon`).remove(); $(`.showSweetAlert .pop2Smt .popContent`).prepend(myhtml); } //??skuîÜîï?äÎ?ÞÀËì $(`body`).on(`click`,`#popSkuCon label`,function(e){ var tarObj=$(e.target); if (tarObj.is(`input`)) { if (tarObj.parent().parent().is(`p`)) { if (tarObj.parent().hasClass(`all`)) { //îï? var childInput=tarObj.closest(`div`).siblings().find(`input`); tarObj.is(`:checked`)?childInput.prop(`checked`,`checked`):childInput.removeAttr(`checked`); } else { //í?úþîï? var childInput=tarObj.closest(`div`).find(`ul input`); tarObj.is(`:checked`)?childInput.prop(`checked`,`checked`):childInput.removeAttr(`checked`); } } if (!tarObj.is(`:checked`)) { tarObj.closest(`#popSkuCon`).children("div").eq(0).find("input").removeAttr("checked"); if (tarObj.parent().parent().is("li")) { tarObj.closest(`ul`).siblings("p").find("input").removeAttr("checked"); } } } }); //???æ´ïÒËÀ?Ê«îÜîï?äÎ?ÞÀËì $(`body`).on(`click`,`#popCountry label`,function(e){ var tarObj=$(e.target); if (tarObj.is(`input`)) { if (tarObj.parent().hasClass(`all`)) { //îï? var childInput=tarObj.closest(`div`).find(`ul`).find(`input`); tarObj.is(`:checked`)?childInput.prop(`checked`,`checked`):childInput.removeAttr(`checked`); } if (!tarObj.is(`:checked`)) { tarObj.closest(`div`).children("p").find("input").removeAttr("checked"); } } }); function getSelectSkus(){ // ?ö¢??ñéá¶êó??îÜSKU var selectSkulist=[]; if ($(`.showSweetAlert #popSkuCon > div`).eq(0).find("input").is(`:checked`)) { return selectSkulist; } $(`.showSweetAlert #popSkuCon > div`).map(function(index,item){ if(index>0){ var skulist=[];//áÜ?÷×ê«ã·Ù£?,éÄéÍ?õöïÒËÀ var skuNameList=[];//ñì٤٣ý¨îÜÙ£?,éÄéÍÜÁò¥?ù¡ $(item).find(`li`).map(function(index2,item2){ if($(item2).find(`input`).is(`:checked`)){ var itemValue = $(item2).find(`input`).val(); skulist.push(itemValue.replace("@", "\"")); skuNameList.push($(item2).text()); } }); selectSkulist.push({ title:$(item).find(`p label`).text(), skulist:skulist, skuNameList:skuNameList }); } }); return selectSkulist; } $(`body`).on(`click`,`#btnpop2cancel,#pop2cancelSmt`,function(){ $(`.showSweetAlert .pop2con,.showSweetAlert .pop2freeNotice,.showSweetAlert .pop2Smt,.showSweetAlert .colorNotice,.showSweetAlert .pop2overlay`).hide(); }); $(`body`).on(`click`,`#btnpop2ok`,function(e){ hideHint(); if($(e.target).attr(`data-type`)!=`error`){ // åýÍýà÷Íí,ö¦?????? $(`.showSweetAlert`).hide(); $(`.sweet-overlay`).hide(); var currentUrl = location.href; if (currentUrl.indexOf("mangoerp.com") > -1) { $(`body`).attr(`class`,`no-skin modal-open`); } else { $(`body`).attr(`class`,`aside-expanded-true pace-done`); } } }); function showHint(type, msg) { if (type == "error") $(`.showSweetAlert .pop2Hint .sa-error`).show(); else $(`.showSweetAlert .pop2Hint .sa-success`).show(); $(`.showSweetAlert .pop2Hint p`).html(msg); $(`.showSweetAlert .pop2Hint,.showSweetAlert .pop2overlay`).show(); if (type == "sync") { type = "error"; //?ÖõÔÒÜÆÙ¼÷ùù»ÕÃ?à÷Ííý¨,Üô???ß©Ðï?? } $(`.showSweetAlert .pop2Hint #btnpop2ok`).attr(`data-type`,type); } function hideHint() { $(`.showSweetAlert .pop2Hint .sa-error`).hide(); $(`.showSweetAlert .pop2Hint .sa-success`).hide(); $(`.showSweetAlert .pop2Hint,.showSweetAlert .pop2overlay`).hide(); $(`.showSweetAlert .pop2con,.showSweetAlert .pop2Smt,.showSweetAlert .pop2overlay`).hide(); } $(`body`).on(`change`, `#selectRegionPercentTemplate`, function () { var templateId = $(this).children(`option:selected`).val(); if (templateId == "") { for (var i = 2; i < 33; i++) { percentSheet.setRowData(i, ["","","","","","","","","","","","","","","",""]); } return; } var param={ method:`ajax`, params: { url: domain + `/seller/getTeamplateById?templateId=` + templateId, xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param,function(t){ ($(`.showSweetAlert #percentSheet`)[0]).jexcel = null; $(`.showSweetAlert #percentSheet`).html(""); percentSheet = jexcel($(`.showSweetAlert #percentSheet`)[0], regionOptions(regionDataPercen)); if (!t.message && t.result) { //ôøã·ûùúèâ?ù»ÕÃ? initOverseasCountries(t.result, percentSheet); logisticsDiscount = t.result.logisticsDiscount; var template = JSON.parse(t.result.data); template.type = t.result.templateType; template.shippingCountry = "CN"; template.volumeSize = t.result.volumeSize; templateData = template; initOptions(template); jisuan(template.fee ? template.fee : "0"); $($(`.showSweetAlert #nav span`)[0]).click(); //?êó???,?ãÆ??table if (templateData.volumeSize) { var threeSide = templateData.volumeSize.split("x"); $(".showSweetAlert #txtLength").val(threeSide[0]); $(".showSweetAlert #txtWidth").val(threeSide[1]); $(".showSweetAlert #txtHeight").val(threeSide[2]); $(".showSweetAlert #divVolumeSize").css("display", "flex"); } else { $(".showSweetAlert #divVolumeSize").hide(); } //ñþêóêóøÐ??Ê«?î¦âÍé©ôøã·ûù??table if (template.fee) { $(`.showSweetAlert #nav`).show(); initDataTable(template); } else { $(`.showSweetAlert #nav`).hide(); } var inputValues = getInputValues(); hotCountries = sortCountrys(template.countrys); for (var j = 0; j < 31; j++) { var rowData = ["","","","","","","","","","","","","","",""]; if (j < hotCountries.length) { rowData = createLogistis(hotCountries[j], j + 3,"percent", "CN"); } if (j == 0) { rowData.push(inputValues.hl); } else if (j == 1) { rowData.push(inputValues.fwf); } else if (j == 2) { rowData.push(inputValues.cb); } else if (j == 3) { rowData.push(inputValues.zl); } else if (j == 4) { rowData.push(inputValues.zk); } else if (j == 5) { rowData.push(inputValues.zhzs); } else { rowData.push(""); } percentSheet.setRowData(j + 2, rowData); } // $(`.showSweetAlert #nineNineSwitch`).trigger("change"); } else { swal("", t.message, "error"); } }); }); //product_save button ïÒËÀ?ß©Ðïß¾îÜ?ù¡Î·×âÜÁðíäÎ? window.isGetRetailOK = false;//??ÖÃ?ËÀãÀÜú?ö¢èÇà÷ window.isGetRegionOK = false;//???æ´ïÒËÀãÀÜú?ö¢èÇà÷ function saveProduct() { $("#saveProductBtn").prop("disabled", true); var currentUrls = location.search ? location.search.substr(1) : ""; if (currentUrls) { $(`.sweetAlert`).removeClass(`zndjpop`).removeClass(`qydjlre`).removeClass(`qydjlrl`).removeClass(`diy100`); var baseSkuDatas = $("input[name=`baseSkuDatas`]"); if (baseSkuDatas.length == 0) { swal({ title: "", text: "ñþêóïÃ?ïÒËÀ?ß©Ðï×ìîÜ?õöïÒËÀäÎ?ý¨î¦ÒöÞÅéÄó®ÍíÒö,?à»ïÃ?ïÒËÀ?ß©Ðï×ìîÜ?õöïÒËÀäÎ?!", type: "error", customClass: "sweetAlertNormal", allowOutsideClick: true }); return; } var productId = ""; var queryParams = currentUrls.split(`&`); for (var idi = 0; idi < queryParams.length; idi++) { var arr = queryParams[idi].split("="); if (arr[0] == "productId" || arr[0] == "switchId" || arr[0] == "draftId") { productId = arr[1]; break; } } var title = $("#struct-content #base-card #struct-title #title").val(); var uploader = $("#struct-content #base-card #struct-mainImage .info-content .image-upload-wrap .image-uploader"); var imgUrl = ""; if (uploader.length > 0) { var imgs = $(uploader[0]).find(".sell-o-image-item-preview img"); if (imgs.length > 0) { for (var ii = 0; ii < imgs.length; ii++) { var src = $(imgs[ii]).attr("src"); if (src.indexOf("http") == 0 && src.indexOf("XXXX") == -1) { imgUrl = src; break; } } } } var skuPrices = []; var skuNamesSet = []; //ÖÃ?ËÀ // Øßó?õöËÀÌ«îñ,ìéïÒé©÷ê???üÞÓð?Ý» var prictmainobj = $("table.sell-sku-inner-table.sell-sku-body-table").eq(0); var scrollobj=prictmainobj.closest(`.ver-scroll-wrap`); scrollobj.animate({ scrollTop: "0" }, 0,function(){ setTimeout(function(){ getRetailPrice(skuPrices, skuNamesSet); },200) }); // ?æ´ïÒËÀ // Øßó?õöËÀÌ«îñ,ìéïÒé©÷ê???üÞÓð?Ý» // ?ñ¬:?×ìüÁ?Óð?Ý»,ñþî¤õÌ?ã·?ú¼ìéó var regionPrices = {}; var skutableobj = $("table.sell-sku-inner-table.sell-sku-body-table").eq(1); if (skutableobj.find(`tr`).length > 0) { var regionTimer = setInterval(function () { if (window.isGetRetailOK) { clearInterval(regionTimer); var regionscrollobj = skutableobj.closest(`.ver-scroll-wrap`); regionscrollobj.animate({ scrollTop: "0" }, 0,function(){ setTimeout(function(){ getRegionPrice(regionPrices) },200) }); } }, 100); } else { window.isGetRegionOK = true; } var timer = setInterval(function () { if (window.isGetRetailOK && window.isGetRegionOK) { clearInterval(timer); window.isGetRetailOK = false; window.isGetRegionOK = false; if (JSON.stringify(regionPrices) != "{}") { for (var skuI = 0; skuI < skuPrices.length; skuI++) { if (regionPrices[skuPrices[skuI]["skuName"]]){ skuPrices[skuI]["regionPrices"] = regionPrices[skuPrices[skuI]["skuName"]]; } } } var product = {"aeId":productId, "title":title, "imgUrl":imgUrl, "skus":skuPrices}; //?õöà÷Üâ,ñìÕá,??Ù¼÷ùÔõãáãÓ for (var m = 0; m < baseSkuDatas.length; m++) { var baseData = JSON.parse($(baseSkuDatas[m]).val()); var selectSkus = baseData.selectSkus; if (selectSkus && selectSkus.length > 0) { for (var j = 0; j < skuPrices.length; j++) { var skuNameList = skuPrices[j]["skuNameList"]; if (skuNameList.length == selectSkus.length) { var tempFlag = true; for (var n = 0; n < selectSkus.length; n++) { var tempSkus = selectSkus[n]["skuNameList"]; var skuName = skuNameList[n]; if (tempSkus && tempSkus.length > 0 && tempSkus.indexOf(skuName) == -1) { tempFlag = false; break; } } if (tempFlag) { skuPrices[j]["cost"] = baseData.cost; skuPrices[j]["weight"] = baseData.weight; } } else { skuPrices[j]["cost"] = baseData.cost; skuPrices[j]["weight"] = baseData.weight; } } } else { for (var o = 0; o < skuPrices.length; o++) { skuPrices[o]["cost"] = baseData.cost; skuPrices[o]["weight"] = baseData.weight; } } if (baseData.templateName) { product.templateName = baseData.templateName; } if (baseData.serviceRate) { product.serviceRate = baseData.serviceRate; } if (baseData.wreckRate) { product.wreckRate = baseData.wreckRate; } if (baseData.discountRate) { product.discountRate = baseData.discountRate; } } var param={ method:`ajax`, params: { url: domain + `/seller/product/saveProduct`, data: JSON.stringify(product), type: "POST", contentType: "application/json", xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param, function(response) { $(`.showSweetAlert`).removeClass("aezsmain"); if (response.status == "FAIL") { swal({ title: "", text: response.message, type: "error", customClass: "sweetAlertNormal", allowOutsideClick: true }, function () { $("div[data-custom-class=`sweetAlertNormal`]").remove(); }); } else { swal({ title: "", text: "ÜÁðíà÷Íí", type: "success", customClass: "sweetAlertNormal", allowOutsideClick: true }, function () { $("div[data-custom-class=`sweetAlertNormal`]").remove(); }); } $("#saveProductBtn").prop("disabled", false); }); } }, 100); } else { $("#saveProductBtn").prop("disabled", false); } } function saveProductDxm() { $("#saveProductBtn").prop("disabled", true); // $(`.sweetAlert`).removeClass(`zndjpop`).removeClass(`qydjlre`).removeClass(`qydjlrl`).removeClass(`diy100`); var baseSkuDatas = $("input[name=`baseSkuDatas`]"); if (baseSkuDatas.length == 0) { swal({ title: "", text: "ñþêóïÃ?ïÒËÀ?ß©Ðï×ìîÜ?õöïÒËÀäÎ?ý¨î¦ÒöÞÅéÄó®ÍíÒö,?à»ïÃ?ïÒËÀ?ß©Ðï×ìîÜ?õöïÒËÀäÎ?!", type: "error", customClass: "sweetAlertNormal", allowOutsideClick: true }); return; } var productId = "temp" + new Date().getTime(); var title = $("#subject").val(); var imgEle = $("#img_show").find("img").first(); var imgUrl = ""; if (imgEle.length > 0) { imgUrl = imgEle.attr("src"); } var purchaseUrl = $("#sourceUrl11").val(); var skuPrices = []; //îïϹÖÃ?ËÀ if ($("#skuVariantList tr[trcid]").length > 0) { $("#skuVariantList tr[trcid]").each(function () { var skuPrice = {}; skuPrice.originalPrice = $(this).find("input").first().val(); skuPrice.sku = $(this).find("input").last().val();//ßÂù¡?? var skuNames = []; $(this).find("td[data-names=`property`]").each(function (index, elem) { var property = $(elem).html(); if (property.indexOf("(") > -1 && property.indexOf(")") > -1) { skuNames.push(property.match(/\(.+\)/g)[0].replace(/\(|\)/g, "")); } else { skuNames.push(property); } }); skuPrice.skuName = skuNames.join("-"); skuPrice.skuNameList = skuNames.slice(); skuPrices.push(skuPrice); }); } else if ($("#retail #skuPrice:visible").length > 0) { var skuPrice = {}; skuPrice.originalPrice = $("#retail #skuPrice:visible").val(); skuPrice.sku = ""; skuPrice.skuName = ""; skuPrice.skuNameList = []; skuPrices.push(skuPrice); } // ?æ´ïÒËÀ // Øßó?õöËÀÌ«îñ,ìéïÒé©÷ê???üÞÓð?Ý» // ?ñ¬:?×ìüÁ?Óð?Ý»,ñþî¤õÌ?ã·?ú¼ìéó var regionPrices = {}; var skuTrs = $("#setNationalProductPrice table tbody tr"); if (skuTrs.length > 0) { skuTrs.each(function () { var countriesTds = $(this).find("td[data-coun]"); if (countriesTds.length > 0) { var skuNames = []; $(this).find("td[cid]").each(function (index, elem) { var property = $(elem).html(); if (property.indexOf("(") > -1 && property.indexOf(")") > -1) { skuNames.push(property.match(/\(.+\)/g)[0].replace(/\(|\)/g, "")); } else { skuNames.push(property); } }); var nationalPrice = {}; countriesTds.each(function (index, elem) { var country =$(elem).attr("data-coun").toLowerCase(); nationalPrice[country == "id" ? "idd" : country] = $(elem).find("input").val(); }); regionPrices[skuNames.join("-")] = nationalPrice; } }); } if (JSON.stringify(regionPrices) != "{}") { for (var skuI = 0; skuI < skuPrices.length; skuI++) { if (regionPrices[skuPrices[skuI]["skuName"]]){ skuPrices[skuI]["regionPrices"] = regionPrices[skuPrices[skuI]["skuName"]]; } } } var product = {"aeId":productId, "title":title, "imgUrl":imgUrl, "skus":skuPrices,"purchaseUrl":purchaseUrl}; //?õöà÷Üâ,ñìÕá,??Ù¼÷ùÔõãáãÓ for (var m = 0; m < baseSkuDatas.length; m++) { var baseData = JSON.parse($(baseSkuDatas[m]).val()); var selectSkus = baseData.selectSkus; if (selectSkus && selectSkus.length > 0) { for (var j = 0; j < skuPrices.length; j++) { var skuNameList = skuPrices[j]["skuNameList"]; if (skuNameList.length == selectSkus.length) { var tempFlag = true; for (var n = 0; n < selectSkus.length; n++) { var tempSkus = selectSkus[n]["skuNameList"]; var skuName = skuNameList[n]; if (tempSkus && tempSkus.length > 0 && tempSkus.indexOf(skuName) == -1) { tempFlag = false; break; } } if (tempFlag) { skuPrices[j]["cost"] = baseData.cost; skuPrices[j]["weight"] = baseData.weight; } } else { skuPrices[j]["cost"] = baseData.cost; skuPrices[j]["weight"] = baseData.weight; } } } else { for (var o = 0; o < skuPrices.length; o++) { skuPrices[o]["cost"] = baseData.cost; skuPrices[o]["weight"] = baseData.weight; } } if (baseData.templateName) { product.templateName = baseData.templateName; } if (baseData.serviceRate) { product.serviceRate = baseData.serviceRate; } if (baseData.wreckRate) { product.wreckRate = baseData.wreckRate; } if (baseData.discountRate) { product.discountRate = baseData.discountRate; } } var param={ method:`ajax`, params: { url: domain + `/seller/product/saveProduct`, data: JSON.stringify(product), type: "POST", contentType: "application/json", xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param, function(response) { $(`.showSweetAlert`).removeClass("aezsmain"); if (response.status == "FAIL") { swal({ title: "", text: response.message, type: "error", customClass: "sweetAlertNormal", allowOutsideClick: true }, function () { $("div[data-custom-class=`sweetAlertNormal`]").remove(); }); } else { swal({ title: "", text: "ÜÁðíà÷Íí", type: "success", customClass: "sweetAlertNormal", allowOutsideClick: true }, function () { $("div[data-custom-class=`sweetAlertNormal`]").remove(); }); } $("#saveProductBtn").prop("disabled", false); }); } // function getCustomedColorMap() { // var colorMap = {}; // var colorDiv = $("#struct-saleProp>div>div").eq(0); // var label = colorDiv.children("div").eq(0).text(); // // var colorDiv = $("#struct-saleProp").children("div").eq(0); // // var label = colorDiv.children("div").eq(0).text(); // if (label == "?ßä") { // var items = colorDiv.children("div").eq(1).find(".info-content").find(".item"); // for (var i = 0; i < items.length; i++) { // var colorSpans = $(items[i]).find(".posting-feild-color-item").children("span"); // var value = colorSpans.eq(0).find("em").text(); // var key = colorSpans.eq(1).find("input").val(); // if (key && key != "" && value && value != "") { // colorMap[key] = value; // } // } // } // return colorMap; // } function getRetailPrice(skuPrices, skuNamesSet) { var prictmainobj = $("table.sell-sku-inner-table.sell-sku-body-table").eq(0); var trs = prictmainobj.find("tr"); if (trs.length > 0) { var skuNames = []; for (var j = 0; j < trs.length; j++) { var tds = $(trs[j]).find("td"); var tdSpCount = tds.length - 3; if ($(trs[j]).find("td.col-buyerPrice").length > 0) { tdSpCount = tds.length - 4; } var skuPrice = {}; for (var k = 0; k < tds.length; k++) { if (k < tdSpCount) { if (j == 0) { if($(tds[k]).find("p").length>0) skuNames.push($(tds[k]).find("p").text()); else skuNames.push($(tds[k]).find(".ae-sku-cell-text-content").text()); } else { if($(tds[k]).find("p").length>0) skuNames.splice(skuNames.length - tdSpCount + k, 1, $(tds[k]).find("p").text()); else skuNames.splice(skuNames.length - tdSpCount + k, 1, $(tds[k]).find(".ae-sku-cell-text-content").text()); } } else { if (k == (tdSpCount)) { skuPrice.originalPrice = $(tds[k]).find("input").val(); } else if ($(tds[k]).find("input[name=`skuOuterId`]").length != 0) { skuPrice.sku = $(tds[k]).find("input[name=`skuOuterId`]").val(); } } } if (skuNamesSet.indexOf(skuNames.join("-")) == -1) { skuPrice.skuName = skuNames.join("-"); skuPrice.skuNameList = skuNames.slice(); skuPrices.push(skuPrice); skuNamesSet.push(skuPrice.skuName); } } } // ??Óðù»ìé? var scrollobj = prictmainobj.closest(`.ver-scroll-wrap`); if (scrollobj.scrollTop() + scrollobj.height() >= scrollobj[0].scrollHeight) { window.isGetRetailOK = true; return; } scrollobj.animate({ scrollTop: "+="+190 }, 0,function(){ setTimeout(function(){ getRetailPrice(skuPrices, skuNamesSet); },200); }); } function getRegionPrice(regionPrices) { var tables = $("table.sell-sku-inner-table.sell-sku-body-table").eq(1); var trs = tables.find("tr"); if (trs.length > 0) { var skuNames = []; var inputSize = $(trs[0]).find(".sell-sku-cell-money").length; for (var j = 0; j < trs.length; j++) { var tds = $(trs[j]).find("td"); var nationalPrice = {}; for (var k = 0; k < tds.length; k++) { if ($(tds[k]).hasClass("sell-sku-cell-money")) { var priceInput = $(tds[k]).find("input"); if (priceInput.length != 0) { var tdClass = $(tds[k]).attr("class").match(/col-price-\w{2}/); if (tdClass != null && tdClass.length > 0) { var country = tdClass[0].replace("col-price-","").toLowerCase(); nationalPrice[country == "id" ? "idd" : country] = priceInput.val(); } } } else { if (j == 0) { if($(tds[k]).find("p").length>0) skuNames.push($(tds[k]).find("p").text()); else skuNames.push($(tds[k]).find(".ae-sku-cell-text-content").text()); } else { if($(tds[k]).find("p").length>0) skuNames.splice(skuNames.length - (tds.length - inputSize) + k, 1, $(tds[k]).find("p").text()); else skuNames.splice(skuNames.length - (tds.length - inputSize) + k, 1, $(tds[k]).find(".ae-sku-cell-text-content").text()); } } } var skuName = skuNames.join("-"); regionPrices[skuName] = nationalPrice; } } // ??Óðù»ìé? var scrollobj = tables.closest(`.ver-scroll-wrap`); if (scrollobj.scrollTop() + scrollobj.height() >= scrollobj[0].scrollHeight) { window.isGetRegionOK = true; return; } scrollobj.animate({ scrollTop: "+="+190 }, 0,function(){ setTimeout(function(){ getRegionPrice(regionPrices); },200); }); } //?ßäûú?ßäÓÛøúä§?ëòÞÖ? $("body").on("click", ".colorTip", function () { $(`.showSweetAlert .colorNotice,.showSweetAlert .pop2overlay`).show(); }); function convertPrice(exchangeRate, price) { if (exchangeRate == 1) { if (price <= 13.1=""> -1) { var shopId = $(this).children(`option:selected`).val(); if (shopId != "") { syncTemplates(`?dxmId=` + shopId); } } else if (location.href.indexOf("mangoerp.com/erp") > -1) { var shopId = $(this).children(`option:selected`).attr("data-shopid"); if (shopId != "" && shopId != undefined) { syncTemplates(`?wdtId=` + shopId); } } }); //------------------------èÚïÁ÷×??ïÁ?ï·?Ù¼?---------------------- $(`body`).on(`click`, `#shopCn .el-radio__label`, function () { var shopId = $(this).parent().attr("data-shopcn"); if (shopId != "" && shopId != undefined) { syncTemplates(`?wdtId=` + shopId); } }); //------------------------÷×Ô²âÍâ£?Ù¼?---------------------- //?Íó÷×Ô²?øÖ?ù¡?ØüïÁ?ù»ÕÃ??ÌÚÞÀËì,áìãæÙ¼÷ùù»ÕÃ? $(function() { storeChange(); }); function storeChange(){ var currentVal=getStoreId(); setInterval(function() { var nowVal=getStoreId(); if(nowVal != currentVal && nowVal !== "") { syncTemplates(`?ttId=` + nowVal); currentVal=nowVal; } },1000); } function getStoreId(){ return $("#baseInfoDiv .bg-title:contains(`ÐñÜâãáãÓ`)").next().find(`.left label:contains("ÇØ¿ÜïÁ?")`) .siblings(`span.textbox.combo`).find(`input[type=hidden].textbox-value`).val(); } //------------------------÷×Ô²âÍâ£?Ù¼?-------------------end //?ß©Ðï?ØüÔÒÜÆäÎ?ÞÀËì $("body").on("click", ".syncTemplates", function () { if (chrome.runtime.getManifest().version < "1.1.4") { showHint("error", "ó®ÍíÒöâÍé©ÌÚãæ?ËìÓð1.1.4Ðàì¤ß¾÷úÜâî¦ÒöÞÅéÄ.ã®??ïï:https://www.yuque.com/helps/aeoptools/tquc69"); return; } var currentUrl = location.href; if (currentUrl.indexOf("mabangerp.com") > -1) { var value = $(`input[name="shopId"]:checked`).val(); if (value != "") { syncTemplates(`?mbId=` + value); } } else if (currentUrl.indexOf("dianxiaomi.com") > -1) { var shopId = $(`#shopId`).children(`option:selected`).val(); if (shopId != "") { syncTemplates(`?dxmId=` + shopId); } } else if (currentUrl.indexOf("tongtool.com") > -1) { $("#rootEle tr:first .pdtb5").each(function (i) { if ($(this).text().indexOf("ÇØ¿ÜïÁ?") > -1) { var shopId = $(this).find(".textbox-value").val(); if (shopId !== "") { syncTemplates(`?ttId=` + shopId); } return false; } }); } else if (currentUrl.indexOf("qizhishangke.com") > -1) { var value = $("#shopCn").attr("data-cn"); if (value != "") { syncTemplates(`?wdtId=` + value); } } else if (currentUrl.indexOf("mangoerp.com") > -1) { var shopId = $(`#shopId`).children(`option:selected`).attr("data-shopid"); if (shopId != "" && shopId != undefined) { syncTemplates(`?wdtId=` + shopId); } } else if (currentUrl.indexOf("v3.wxwerp.com") > -1 || location.href.indexOf("ae-pub.wxwerp.com") > -1) { var shopId = $(`#v3-ÇØ¿Ü-shop`).attr("cnid"); if (shopId != "" && shopId != undefined) { syncTemplates(`?wdtId=` + shopId); } } else { syncTemplates(``); } }); //êó???õöò¢Û°,?ìé?î¤price_menu.html function syncTemplates(params) { var param={ method:`ajax`, params: { url: domain + `/seller/querySampleTemplates` + params, xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param,function(t){ if (!t.message && t.result) { if (t.result["NORMAL"] && t.result["NORMAL"].length > 0) { $("#selectNormalTemplate").empty(); $("#selectNormalTemplate").append("
"); for (var i = 0; i < t.result["NORMAL"].length; i++) { var template = t.result["NORMAL"][i]; $("#selectNormalTemplate").append("
"); } //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectNormalTemplate`).empty(); $(`.showSweetAlert #selectNormalTemplate`).append("
"); for (var i = 0; i < t.result["NORMAL"].length; i++) { var template = t.result["NORMAL"][i]; $(`.showSweetAlert #selectNormalTemplate`).append("
"); } $(`.showSweetAlert #selectNormalTemplate`).trigger("chosen:updated"); $(`.showSweetAlert #selectNormalTemplate`).chosen(); } else { $("#selectNormalTemplate").empty(); $("#selectNormalTemplate").append("
"); //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectNormalTemplate`).empty(); $(`.showSweetAlert #selectNormalTemplate`).append("
"); $(`.showSweetAlert #selectNormalTemplate`).trigger("chosen:updated"); $(`.showSweetAlert #selectNormalTemplate`).chosen(); } if (t.result["REGION"] && t.result["REGION"].length > 0) { $("#selectRegionAmountTemplate").empty(); $("#selectRegionPercentTemplate").empty(); $("#selectRegionAmountTemplate").append("
"); $("#selectRegionPercentTemplate").append("
"); for (var j = 0; j < t.result["REGION"].length; j++) { var template = t.result["REGION"][j]; $("#selectRegionAmountTemplate").append("
"); $("#selectRegionPercentTemplate").append("
"); } //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectRegionAmountTemplate`).empty(); $(".showSweetAlert #selectRegionPercentTemplate").empty(); $(".showSweetAlert #selectRegionAmountTemplate").append("
"); $(".showSweetAlert #selectRegionPercentTemplate").append("
"); for (var j = 0; j < t.result["REGION"].length; j++) { var template = t.result["REGION"][j]; $(".showSweetAlert #selectRegionAmountTemplate").append("
"); $(".showSweetAlert #selectRegionPercentTemplate").append("
"); } $(".showSweetAlert #selectRegionAmountTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionAmountTemplate").chosen(); $(".showSweetAlert #selectRegionPercentTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionPercentTemplate").chosen(); } else { $("#selectRegionAmountTemplate").empty(); $("#selectRegionPercentTemplate").empty(); $("#selectRegionAmountTemplate").append("
"); $("#selectRegionPercentTemplate").append("
"); //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectRegionAmountTemplate`).empty(); $(".showSweetAlert #selectRegionPercentTemplate").empty(); $(".showSweetAlert #selectRegionAmountTemplate").append("
"); $(".showSweetAlert #selectRegionPercentTemplate").append("
"); $(".showSweetAlert #selectRegionAmountTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionAmountTemplate").chosen(); $(".showSweetAlert #selectRegionPercentTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionPercentTemplate").chosen(); } $(".syncTemplates").show(); $(".authorizeBtn").hide(); $(".buyStore").hide(); //ñ«?ïÃ?ÔÒÜÆ?î¦âÍé©ð«ãÆ if (params == ``) { showHint("sync", "ÔÒÜÆà÷Íí"); } } else if (t.message) { $("#selectNormalTemplate").empty(); $("#selectNormalTemplate").append("
"); //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectNormalTemplate`).empty(); $(`.showSweetAlert #selectNormalTemplate`).append("
"); $(`.showSweetAlert #selectNormalTemplate`).trigger("chosen:updated"); $(`.showSweetAlert #selectNormalTemplate`).chosen(); $("#selectRegionAmountTemplate").empty(); $("#selectRegionPercentTemplate").empty(); $("#selectRegionAmountTemplate").append("
"); $("#selectRegionPercentTemplate").append("
"); //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectRegionAmountTemplate`).empty(); $(".showSweetAlert #selectRegionPercentTemplate").empty(); $(".showSweetAlert #selectRegionAmountTemplate").append("
"); $(".showSweetAlert #selectRegionPercentTemplate").append("
"); $(".showSweetAlert #selectRegionAmountTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionAmountTemplate").chosen(); $(".showSweetAlert #selectRegionPercentTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionPercentTemplate").chosen(); if (t.message.indexOf("â£?") > -1) { $(".syncTemplates").hide(); $(".buyStore").hide(); if (params.indexOf("dxmId") > -1) { $(".authorizeBtn").attr("href", "https://www.dianxiaomi.com/sys/index.htm?go=m407"); } else if (params.indexOf("mbId") > -1) { $(".authorizeBtn").attr("href", "https://www.mabangerp.com/index.php?mod=shop.list"); } else { $(".authorizeBtn").attr("href", "https://listing.tongtool.com/listing/account/index.htm"); } $(".authorizeBtn").show(); } else { //??ì«?Ñ¢ $(".syncTemplates").hide(); $(".authorizeBtn").hide(); $(".buyStore").show(); } } else { console.log(t.message); } }); } //------------------------ïÒð¤100g?ß©ÐïÙ¼?start---------------------- //ïÒð¤100g?ß©Ðïóø?ÞÀËì,?õó??? $("body").on("click", "#btnDiy100", function () { if($(".diy100").length){ $(".diy100").show(); $(`.sweet-overlay`).show(); $(`body`).attr(`class`,`aside-expanded-true pace-done stop-scrolling`); }else{ $(`.sweetAlert`).removeClass(`zndjpop`).removeClass(`qydjlre`).removeClass(`qydjlrl`).removeClass(`diy100`); $(`.aeplgcon ul li.nav`).removeClass(`now`); $(`#btnDiy100`).parent().addClass(`now`); swal({ title: "ïÒð¤?ß©Ðï", showConfirmButton: false, text: $(`#region_diy_div`).html(), html: true, customClass: "sweetAlert aezsmain diy100", allowOutsideClick: false }); if ($(".showSweetAlert select[name=`selectTemplate`]").chosen) { $(".showSweetAlert select[name=`selectTemplate`]").chosen(); } if ($(".showSweetAlert .locationCountry #locationSelect").chosen) { $(".showSweetAlert .locationCountry #locationSelect").chosen(); } } }); //??Ù¼÷ùù»ÕÃ?ý¨îÜÞÀËì $(`body`).on(`change`, `#selectDiyTemplate`, function () { var templateId = $(this).children(`option:selected`).val(); diySheet.setValue("G2", "", true); for (var i = 3; i < 34; i++) { diySheet.setRowData(i, ["","","","","","","","","","","",""]); } if (templateId == "") { return; } var param={ method:`ajax`, params: { url: domain + `/seller/getTeamplateById?templateId=` + templateId, xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param,function(t){ ($(`.showSweetAlert #diySheet`)[0]).jexcel = null; $(`.showSweetAlert #diySheet`).html(""); diySheet = jexcel($(`.showSweetAlert #diySheet`)[0], diyOptions()); if (!t.message && t.result) { var template = JSON.parse(t.result.data); //ùê?á¶êó??ò¢îÜ???Ê«,éÄ?Îþ??æ´ïÒËÀîÜ?Ê« getPriceHotCountry(t.result); //ôøã·ûùúèâ?ù»ÕÃ? var html = "
"; if (t.result.overseasData) { var overseas = JSON.parse(t.result.overseasData); for (var key in overseas) { html += "
"; } } $(".showSweetAlert .locationCountry #locationSelect").html(html); $(".showSweetAlert .locationCountry #locationSelect").trigger("chosen:updated"); $(".showSweetAlert .locationCountry #locationSelect").off("change").on(`change`, function (e, params) { if (params.selected == "CN") { template.shippingCountry = "CN"; template.type = t.result.templateType; template.volumeSize = t.result.volumeSize; templateData = template; } else { var tempOverseasAll = JSON.parse(t.result.overseasData); var temp = tempOverseasAll[params.selected]; temp.type = t.result.templateType; temp.shippingCountry = params.selected; templateData = temp; } if(templateData){ initDiyData(templateData, templateData.shippingCountry); } }); logisticsDiscount = t.result.logisticsDiscount; template.type = t.result.templateType; template.shippingCountry = "CN"; templateData = template; initDiyData(template, "CN"); } else { swal("", t.message, "error"); } }); }); function initDiyData(template, shippingCountry) { var exchangeRate = template.exchangeRate; var serviceRate = localStorage.getItem("serviceRate"); var wreckRate = localStorage.getItem("wreckRate"); if (exchangeRate == undefined || exchangeRate == "") { exchangeRate = localStorage.getItem("exchangeRate"); exchangeRate = exchangeRate ? exchangeRate : 6.6; } if (serviceRate == undefined || serviceRate == "" || serviceRate == "undefined") { serviceRate = 5; } if (wreckRate == undefined || wreckRate == "" || wreckRate == "undefined") { wreckRate = 2; } diySheet.setValue("A2", exchangeRate, true); diySheet.setValue("B2", serviceRate, true); diySheet.setValue("C2", 0, true); diySheet.setValue("D2", template.goodsWeight, true); diySheet.setValue("F2", wreckRate, true); diySheet.setValue("G2", template.fee, true); diySheet.setValue("H2", `=ROUNDUP(C2/A2+G2+E2*(B2+F2)/100, 2)`, true); diySheet.setValue("I2", `=ROUNDUP(J2/A2/E2*100,2)`, true); diySheet.setValue("J2", `=ROUNDUP((E2-H2)*A2,2)`, true); diySheet.setValue("K2", `=E2`, true); for (var i = 3; i < 34; i++) { diySheet.setRowData(i, ["","","","","","","","","","","",""]); } if (template.type != "NORMAL" && template.type != "NORMAL_100") { hotCountries = sortCountrys(template.countrys); for (var j = 0; j < hotCountries.length; j++) { var row = j + 4; var countryLogis = []; var countryLogistic = hotCountries[j]; countryLogis.push(countryLogistic.countryName); //A countryLogis.push(countryLogistic.country); //B countryLogis.push(countryLogistic.logisName); //C countryLogis.push(countryLogistic.firstWeight); //D countryLogis.push(countryLogistic.firstWeightFee); //E if (countryLogistic.overWeight == undefined || countryLogistic.overWeight == "") { countryLogis.push(1); //F countryLogis.push((countryLogistic.overWeightFee/1000).toFixed(4));//G } else { countryLogis.push(countryLogistic.overWeight); //F countryLogis.push(countryLogistic.overWeightFee); //G } countryLogis.push(countryLogistic.registrationFee); //H countryLogis.push("=ROUNDUP(E" + row + "+H" + row + "+ROUNDUP((D2-D" + row + ">0 ? D2-D" + row + ":0)/F" + row + ",0)*G" + row + ",2)");//I countryLogis.push("=ROUNDUP(I" + row + "/A2-G2>0.01 ? I" + row + "/A2-G2:0,2)"); countryLogis.push(""); diySheet.setRowData(j + 3, countryLogis); } } } // ?õö?ËÀÞÅéÄ function assemblePricesForDiy() { var prices = {}; prices.templateName = $(".showSweetAlert [name=`selectTemplate`]").children(`option:selected`).html(); prices.global = diySheet.getValue("K2"); prices.serviceRate = diySheet.getValue("B2"); prices.cost = diySheet.getValue("C2"); prices.weight = diySheet.getValue("D2"); prices.discountRate = 0; prices.wreckRate = diySheet.getValue("F2"); prices.globalSwitch = true; for (var i = 4; i < 35; i++) { var country = diySheet.getValue("B" + i); if (country) { prices["price-" + country] = diySheet.getValue("J" + i); } } return prices; } // ?áóËÇñìÕáý¨ñìãæ?ß©øÐ??éÄ function recomputeFreeFee(el, records) { var skip = true; for (var ri = 0; ri < records.length; ri++) { if (records[ri].row == 1 && records[ri].col == 3) { skip = false; break; } } if (skip) return; var weight = diySheet.getValue("D2"); var exchangeRate = diySheet.getValue("A2"); if (templateData.otherCountrys && templateData.otherCountrys.length > 0) { for (var i = 0; i < templateData.otherCountrys.length; i++) { var otherCountry = templateData.otherCountrys[i]; if (otherCountry.countryName == templateData.feeFreeCountry) { var fee; var firstWeight = otherCountry.firstWeight; var firstWeightFee = otherCountry.firstWeightFee; var registrationFee = otherCountry.registrationFee; var overWeight = otherCountry.overWeight; var overWeightFee = otherCountry.overWeightFee; if (overWeight == undefined || overWeight == "") { var size = maltose.complexEval((weight - firstWeight > 0 ? weight - firstWeight : 0),0); fee = maltose.complexEval((firstWeightFee + registrationFee + size * overWeightFee / 1000) / exchangeRate, 2); } else { var size = Math.ceil(maltose.complexEval((weight - firstWeight > 0 ? weight - firstWeight : 0) + `/` + overWeight,2), 0); fee = maltose.complexEval((firstWeightFee + registrationFee + size * overWeightFee) / exchangeRate, 2); } diySheet.setValue("G2", fee, true); return; } } } } //------------------------ïÒð¤100g?ß©ÐïÙ¼?end------------------------
`; skuObjList.map(function(item,index){ myhtml+=`
`; }); myhtml+=`
`; $(`#popSkuCon`).length>0&&$(`.showSweetAlert #popSkuCon`).remove(); $(`.showSweetAlert .pop2Smt .popContent`).prepend(myhtml); } //??skuîÜîï?äÎ?ÞÀËì $(`body`).on(`click`,`#popSkuCon label`,function(e){ var tarObj=$(e.target); if (tarObj.is(`input`)) { if (tarObj.parent().parent().is(`p`)) { if (tarObj.parent().hasClass(`all`)) { //îï? var childInput=tarObj.closest(`div`).siblings().find(`input`); tarObj.is(`:checked`)?childInput.prop(`checked`,`checked`):childInput.removeAttr(`checked`); } else { //í?úþîï? var childInput=tarObj.closest(`div`).find(`ul input`); tarObj.is(`:checked`)?childInput.prop(`checked`,`checked`):childInput.removeAttr(`checked`); } } if (!tarObj.is(`:checked`)) { tarObj.closest(`#popSkuCon`).children("div").eq(0).find("input").removeAttr("checked"); if (tarObj.parent().parent().is("li")) { tarObj.closest(`ul`).siblings("p").find("input").removeAttr("checked"); } } } }); //???æ´ïÒËÀ?Ê«îÜîï?äÎ?ÞÀËì $(`body`).on(`click`,`#popCountry label`,function(e){ var tarObj=$(e.target); if (tarObj.is(`input`)) { if (tarObj.parent().hasClass(`all`)) { //îï? var childInput=tarObj.closest(`div`).find(`ul`).find(`input`); tarObj.is(`:checked`)?childInput.prop(`checked`,`checked`):childInput.removeAttr(`checked`); } if (!tarObj.is(`:checked`)) { tarObj.closest(`div`).children("p").find("input").removeAttr("checked"); } } }); function getSelectSkus(){ // ?ö¢??ñéá¶êó??îÜSKU var selectSkulist=[]; if ($(`.showSweetAlert #popSkuCon > div`).eq(0).find("input").is(`:checked`)) { return selectSkulist; } $(`.showSweetAlert #popSkuCon > div`).map(function(index,item){ if(index>0){ var skulist=[];//áÜ?÷×ê«ã·Ù£?,éÄéÍ?õöïÒËÀ var skuNameList=[];//ñì٤٣ý¨îÜÙ£?,éÄéÍÜÁò¥?ù¡ $(item).find(`li`).map(function(index2,item2){ if($(item2).find(`input`).is(`:checked`)){ var itemValue = $(item2).find(`input`).val(); skulist.push(itemValue.replace("@", "\"")); skuNameList.push($(item2).text()); } }); selectSkulist.push({ title:$(item).find(`p label`).text(), skulist:skulist, skuNameList:skuNameList }); } }); return selectSkulist; } $(`body`).on(`click`,`#btnpop2cancel,#pop2cancelSmt`,function(){ $(`.showSweetAlert .pop2con,.showSweetAlert .pop2freeNotice,.showSweetAlert .pop2Smt,.showSweetAlert .colorNotice,.showSweetAlert .pop2overlay`).hide(); }); $(`body`).on(`click`,`#btnpop2ok`,function(e){ hideHint(); if($(e.target).attr(`data-type`)!=`error`){ // åýÍýà÷Íí,ö¦?????? $(`.showSweetAlert`).hide(); $(`.sweet-overlay`).hide(); var currentUrl = location.href; if (currentUrl.indexOf("mangoerp.com") > -1) { $(`body`).attr(`class`,`no-skin modal-open`); } else { $(`body`).attr(`class`,`aside-expanded-true pace-done`); } } }); function showHint(type, msg) { if (type == "error") $(`.showSweetAlert .pop2Hint .sa-error`).show(); else $(`.showSweetAlert .pop2Hint .sa-success`).show(); $(`.showSweetAlert .pop2Hint p`).html(msg); $(`.showSweetAlert .pop2Hint,.showSweetAlert .pop2overlay`).show(); if (type == "sync") { type = "error"; //?ÖõÔÒÜÆÙ¼÷ùù»ÕÃ?à÷Ííý¨,Üô???ß©Ðï?? } $(`.showSweetAlert .pop2Hint #btnpop2ok`).attr(`data-type`,type); } function hideHint() { $(`.showSweetAlert .pop2Hint .sa-error`).hide(); $(`.showSweetAlert .pop2Hint .sa-success`).hide(); $(`.showSweetAlert .pop2Hint,.showSweetAlert .pop2overlay`).hide(); $(`.showSweetAlert .pop2con,.showSweetAlert .pop2Smt,.showSweetAlert .pop2overlay`).hide(); } $(`body`).on(`change`, `#selectRegionPercentTemplate`, function () { var templateId = $(this).children(`option:selected`).val(); if (templateId == "") { for (var i = 2; i < 33; i++) { percentSheet.setRowData(i, ["","","","","","","","","","","","","","","",""]); } return; } var param={ method:`ajax`, params: { url: domain + `/seller/getTeamplateById?templateId=` + templateId, xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param,function(t){ ($(`.showSweetAlert #percentSheet`)[0]).jexcel = null; $(`.showSweetAlert #percentSheet`).html(""); percentSheet = jexcel($(`.showSweetAlert #percentSheet`)[0], regionOptions(regionDataPercen)); if (!t.message && t.result) { //ôøã·ûùúèâ?ù»ÕÃ? initOverseasCountries(t.result, percentSheet); logisticsDiscount = t.result.logisticsDiscount; var template = JSON.parse(t.result.data); template.type = t.result.templateType; template.shippingCountry = "CN"; template.volumeSize = t.result.volumeSize; templateData = template; initOptions(template); jisuan(template.fee ? template.fee : "0"); $($(`.showSweetAlert #nav span`)[0]).click(); //?êó???,?ãÆ??table if (templateData.volumeSize) { var threeSide = templateData.volumeSize.split("x"); $(".showSweetAlert #txtLength").val(threeSide[0]); $(".showSweetAlert #txtWidth").val(threeSide[1]); $(".showSweetAlert #txtHeight").val(threeSide[2]); $(".showSweetAlert #divVolumeSize").css("display", "flex"); } else { $(".showSweetAlert #divVolumeSize").hide(); } //ñþêóêóøÐ??Ê«?î¦âÍé©ôøã·ûù??table if (template.fee) { $(`.showSweetAlert #nav`).show(); initDataTable(template); } else { $(`.showSweetAlert #nav`).hide(); } var inputValues = getInputValues(); hotCountries = sortCountrys(template.countrys); for (var j = 0; j < 31; j++) { var rowData = ["","","","","","","","","","","","","","",""]; if (j < hotCountries.length) { rowData = createLogistis(hotCountries[j], j + 3,"percent", "CN"); } if (j == 0) { rowData.push(inputValues.hl); } else if (j == 1) { rowData.push(inputValues.fwf); } else if (j == 2) { rowData.push(inputValues.cb); } else if (j == 3) { rowData.push(inputValues.zl); } else if (j == 4) { rowData.push(inputValues.zk); } else if (j == 5) { rowData.push(inputValues.zhzs); } else { rowData.push(""); } percentSheet.setRowData(j + 2, rowData); } // $(`.showSweetAlert #nineNineSwitch`).trigger("change"); } else { swal("", t.message, "error"); } }); }); //product_save button ïÒËÀ?ß©Ðïß¾îÜ?ù¡Î·×âÜÁðíäÎ? window.isGetRetailOK = false;//??ÖÃ?ËÀãÀÜú?ö¢èÇà÷ window.isGetRegionOK = false;//???æ´ïÒËÀãÀÜú?ö¢èÇà÷ function saveProduct() { $("#saveProductBtn").prop("disabled", true); var currentUrls = location.search ? location.search.substr(1) : ""; if (currentUrls) { $(`.sweetAlert`).removeClass(`zndjpop`).removeClass(`qydjlre`).removeClass(`qydjlrl`).removeClass(`diy100`); var baseSkuDatas = $("input[name=`baseSkuDatas`]"); if (baseSkuDatas.length == 0) { swal({ title: "", text: "ñþêóïÃ?ïÒËÀ?ß©Ðï×ìîÜ?õöïÒËÀäÎ?ý¨î¦ÒöÞÅéÄó®ÍíÒö,?à»ïÃ?ïÒËÀ?ß©Ðï×ìîÜ?õöïÒËÀäÎ?!", type: "error", customClass: "sweetAlertNormal", allowOutsideClick: true }); return; } var productId = ""; var queryParams = currentUrls.split(`&`); for (var idi = 0; idi < queryParams.length; idi++) { var arr = queryParams[idi].split("="); if (arr[0] == "productId" || arr[0] == "switchId" || arr[0] == "draftId") { productId = arr[1]; break; } } var title = $("#struct-content #base-card #struct-title #title").val(); var uploader = $("#struct-content #base-card #struct-mainImage .info-content .image-upload-wrap .image-uploader"); var imgUrl = ""; if (uploader.length > 0) { var imgs = $(uploader[0]).find(".sell-o-image-item-preview img"); if (imgs.length > 0) { for (var ii = 0; ii < imgs.length; ii++) { var src = $(imgs[ii]).attr("src"); if (src.indexOf("http") == 0 && src.indexOf("XXXX") == -1) { imgUrl = src; break; } } } } var skuPrices = []; var skuNamesSet = []; //ÖÃ?ËÀ // Øßó?õöËÀÌ«îñ,ìéïÒé©÷ê???üÞÓð?Ý» var prictmainobj = $("table.sell-sku-inner-table.sell-sku-body-table").eq(0); var scrollobj=prictmainobj.closest(`.ver-scroll-wrap`); scrollobj.animate({ scrollTop: "0" }, 0,function(){ setTimeout(function(){ getRetailPrice(skuPrices, skuNamesSet); },200) }); // ?æ´ïÒËÀ // Øßó?õöËÀÌ«îñ,ìéïÒé©÷ê???üÞÓð?Ý» // ?ñ¬:?×ìüÁ?Óð?Ý»,ñþî¤õÌ?ã·?ú¼ìéó var regionPrices = {}; var skutableobj = $("table.sell-sku-inner-table.sell-sku-body-table").eq(1); if (skutableobj.find(`tr`).length > 0) { var regionTimer = setInterval(function () { if (window.isGetRetailOK) { clearInterval(regionTimer); var regionscrollobj = skutableobj.closest(`.ver-scroll-wrap`); regionscrollobj.animate({ scrollTop: "0" }, 0,function(){ setTimeout(function(){ getRegionPrice(regionPrices) },200) }); } }, 100); } else { window.isGetRegionOK = true; } var timer = setInterval(function () { if (window.isGetRetailOK && window.isGetRegionOK) { clearInterval(timer); window.isGetRetailOK = false; window.isGetRegionOK = false; if (JSON.stringify(regionPrices) != "{}") { for (var skuI = 0; skuI < skuPrices.length; skuI++) { if (regionPrices[skuPrices[skuI]["skuName"]]){ skuPrices[skuI]["regionPrices"] = regionPrices[skuPrices[skuI]["skuName"]]; } } } var product = {"aeId":productId, "title":title, "imgUrl":imgUrl, "skus":skuPrices}; //?õöà÷Üâ,ñìÕá,??Ù¼÷ùÔõãáãÓ for (var m = 0; m < baseSkuDatas.length; m++) { var baseData = JSON.parse($(baseSkuDatas[m]).val()); var selectSkus = baseData.selectSkus; if (selectSkus && selectSkus.length > 0) { for (var j = 0; j < skuPrices.length; j++) { var skuNameList = skuPrices[j]["skuNameList"]; if (skuNameList.length == selectSkus.length) { var tempFlag = true; for (var n = 0; n < selectSkus.length; n++) { var tempSkus = selectSkus[n]["skuNameList"]; var skuName = skuNameList[n]; if (tempSkus && tempSkus.length > 0 && tempSkus.indexOf(skuName) == -1) { tempFlag = false; break; } } if (tempFlag) { skuPrices[j]["cost"] = baseData.cost; skuPrices[j]["weight"] = baseData.weight; } } else { skuPrices[j]["cost"] = baseData.cost; skuPrices[j]["weight"] = baseData.weight; } } } else { for (var o = 0; o < skuPrices.length; o++) { skuPrices[o]["cost"] = baseData.cost; skuPrices[o]["weight"] = baseData.weight; } } if (baseData.templateName) { product.templateName = baseData.templateName; } if (baseData.serviceRate) { product.serviceRate = baseData.serviceRate; } if (baseData.wreckRate) { product.wreckRate = baseData.wreckRate; } if (baseData.discountRate) { product.discountRate = baseData.discountRate; } } var param={ method:`ajax`, params: { url: domain + `/seller/product/saveProduct`, data: JSON.stringify(product), type: "POST", contentType: "application/json", xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param, function(response) { $(`.showSweetAlert`).removeClass("aezsmain"); if (response.status == "FAIL") { swal({ title: "", text: response.message, type: "error", customClass: "sweetAlertNormal", allowOutsideClick: true }, function () { $("div[data-custom-class=`sweetAlertNormal`]").remove(); }); } else { swal({ title: "", text: "ÜÁðíà÷Íí", type: "success", customClass: "sweetAlertNormal", allowOutsideClick: true }, function () { $("div[data-custom-class=`sweetAlertNormal`]").remove(); }); } $("#saveProductBtn").prop("disabled", false); }); } }, 100); } else { $("#saveProductBtn").prop("disabled", false); } } function saveProductDxm() { $("#saveProductBtn").prop("disabled", true); // $(`.sweetAlert`).removeClass(`zndjpop`).removeClass(`qydjlre`).removeClass(`qydjlrl`).removeClass(`diy100`); var baseSkuDatas = $("input[name=`baseSkuDatas`]"); if (baseSkuDatas.length == 0) { swal({ title: "", text: "ñþêóïÃ?ïÒËÀ?ß©Ðï×ìîÜ?õöïÒËÀäÎ?ý¨î¦ÒöÞÅéÄó®ÍíÒö,?à»ïÃ?ïÒËÀ?ß©Ðï×ìîÜ?õöïÒËÀäÎ?!", type: "error", customClass: "sweetAlertNormal", allowOutsideClick: true }); return; } var productId = "temp" + new Date().getTime(); var title = $("#subject").val(); var imgEle = $("#img_show").find("img").first(); var imgUrl = ""; if (imgEle.length > 0) { imgUrl = imgEle.attr("src"); } var purchaseUrl = $("#sourceUrl11").val(); var skuPrices = []; //îïϹÖÃ?ËÀ if ($("#skuVariantList tr[trcid]").length > 0) { $("#skuVariantList tr[trcid]").each(function () { var skuPrice = {}; skuPrice.originalPrice = $(this).find("input").first().val(); skuPrice.sku = $(this).find("input").last().val();//ßÂù¡?? var skuNames = []; $(this).find("td[data-names=`property`]").each(function (index, elem) { var property = $(elem).html(); if (property.indexOf("(") > -1 && property.indexOf(")") > -1) { skuNames.push(property.match(/\(.+\)/g)[0].replace(/\(|\)/g, "")); } else { skuNames.push(property); } }); skuPrice.skuName = skuNames.join("-"); skuPrice.skuNameList = skuNames.slice(); skuPrices.push(skuPrice); }); } else if ($("#retail #skuPrice:visible").length > 0) { var skuPrice = {}; skuPrice.originalPrice = $("#retail #skuPrice:visible").val(); skuPrice.sku = ""; skuPrice.skuName = ""; skuPrice.skuNameList = []; skuPrices.push(skuPrice); } // ?æ´ïÒËÀ // Øßó?õöËÀÌ«îñ,ìéïÒé©÷ê???üÞÓð?Ý» // ?ñ¬:?×ìüÁ?Óð?Ý»,ñþî¤õÌ?ã·?ú¼ìéó var regionPrices = {}; var skuTrs = $("#setNationalProductPrice table tbody tr"); if (skuTrs.length > 0) { skuTrs.each(function () { var countriesTds = $(this).find("td[data-coun]"); if (countriesTds.length > 0) { var skuNames = []; $(this).find("td[cid]").each(function (index, elem) { var property = $(elem).html(); if (property.indexOf("(") > -1 && property.indexOf(")") > -1) { skuNames.push(property.match(/\(.+\)/g)[0].replace(/\(|\)/g, "")); } else { skuNames.push(property); } }); var nationalPrice = {}; countriesTds.each(function (index, elem) { var country =$(elem).attr("data-coun").toLowerCase(); nationalPrice[country == "id" ? "idd" : country] = $(elem).find("input").val(); }); regionPrices[skuNames.join("-")] = nationalPrice; } }); } if (JSON.stringify(regionPrices) != "{}") { for (var skuI = 0; skuI < skuPrices.length; skuI++) { if (regionPrices[skuPrices[skuI]["skuName"]]){ skuPrices[skuI]["regionPrices"] = regionPrices[skuPrices[skuI]["skuName"]]; } } } var product = {"aeId":productId, "title":title, "imgUrl":imgUrl, "skus":skuPrices,"purchaseUrl":purchaseUrl}; //?õöà÷Üâ,ñìÕá,??Ù¼÷ùÔõãáãÓ for (var m = 0; m < baseSkuDatas.length; m++) { var baseData = JSON.parse($(baseSkuDatas[m]).val()); var selectSkus = baseData.selectSkus; if (selectSkus && selectSkus.length > 0) { for (var j = 0; j < skuPrices.length; j++) { var skuNameList = skuPrices[j]["skuNameList"]; if (skuNameList.length == selectSkus.length) { var tempFlag = true; for (var n = 0; n < selectSkus.length; n++) { var tempSkus = selectSkus[n]["skuNameList"]; var skuName = skuNameList[n]; if (tempSkus && tempSkus.length > 0 && tempSkus.indexOf(skuName) == -1) { tempFlag = false; break; } } if (tempFlag) { skuPrices[j]["cost"] = baseData.cost; skuPrices[j]["weight"] = baseData.weight; } } else { skuPrices[j]["cost"] = baseData.cost; skuPrices[j]["weight"] = baseData.weight; } } } else { for (var o = 0; o < skuPrices.length; o++) { skuPrices[o]["cost"] = baseData.cost; skuPrices[o]["weight"] = baseData.weight; } } if (baseData.templateName) { product.templateName = baseData.templateName; } if (baseData.serviceRate) { product.serviceRate = baseData.serviceRate; } if (baseData.wreckRate) { product.wreckRate = baseData.wreckRate; } if (baseData.discountRate) { product.discountRate = baseData.discountRate; } } var param={ method:`ajax`, params: { url: domain + `/seller/product/saveProduct`, data: JSON.stringify(product), type: "POST", contentType: "application/json", xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param, function(response) { $(`.showSweetAlert`).removeClass("aezsmain"); if (response.status == "FAIL") { swal({ title: "", text: response.message, type: "error", customClass: "sweetAlertNormal", allowOutsideClick: true }, function () { $("div[data-custom-class=`sweetAlertNormal`]").remove(); }); } else { swal({ title: "", text: "ÜÁðíà÷Íí", type: "success", customClass: "sweetAlertNormal", allowOutsideClick: true }, function () { $("div[data-custom-class=`sweetAlertNormal`]").remove(); }); } $("#saveProductBtn").prop("disabled", false); }); } // function getCustomedColorMap() { // var colorMap = {}; // var colorDiv = $("#struct-saleProp>div>div").eq(0); // var label = colorDiv.children("div").eq(0).text(); // // var colorDiv = $("#struct-saleProp").children("div").eq(0); // // var label = colorDiv.children("div").eq(0).text(); // if (label == "?ßä") { // var items = colorDiv.children("div").eq(1).find(".info-content").find(".item"); // for (var i = 0; i < items.length; i++) { // var colorSpans = $(items[i]).find(".posting-feild-color-item").children("span"); // var value = colorSpans.eq(0).find("em").text(); // var key = colorSpans.eq(1).find("input").val(); // if (key && key != "" && value && value != "") { // colorMap[key] = value; // } // } // } // return colorMap; // } function getRetailPrice(skuPrices, skuNamesSet) { var prictmainobj = $("table.sell-sku-inner-table.sell-sku-body-table").eq(0); var trs = prictmainobj.find("tr"); if (trs.length > 0) { var skuNames = []; for (var j = 0; j < trs.length; j++) { var tds = $(trs[j]).find("td"); var tdSpCount = tds.length - 3; if ($(trs[j]).find("td.col-buyerPrice").length > 0) { tdSpCount = tds.length - 4; } var skuPrice = {}; for (var k = 0; k < tds.length; k++) { if (k < tdSpCount) { if (j == 0) { if($(tds[k]).find("p").length>0) skuNames.push($(tds[k]).find("p").text()); else skuNames.push($(tds[k]).find(".ae-sku-cell-text-content").text()); } else { if($(tds[k]).find("p").length>0) skuNames.splice(skuNames.length - tdSpCount + k, 1, $(tds[k]).find("p").text()); else skuNames.splice(skuNames.length - tdSpCount + k, 1, $(tds[k]).find(".ae-sku-cell-text-content").text()); } } else { if (k == (tdSpCount)) { skuPrice.originalPrice = $(tds[k]).find("input").val(); } else if ($(tds[k]).find("input[name=`skuOuterId`]").length != 0) { skuPrice.sku = $(tds[k]).find("input[name=`skuOuterId`]").val(); } } } if (skuNamesSet.indexOf(skuNames.join("-")) == -1) { skuPrice.skuName = skuNames.join("-"); skuPrice.skuNameList = skuNames.slice(); skuPrices.push(skuPrice); skuNamesSet.push(skuPrice.skuName); } } } // ??Óðù»ìé? var scrollobj = prictmainobj.closest(`.ver-scroll-wrap`); if (scrollobj.scrollTop() + scrollobj.height() >= scrollobj[0].scrollHeight) { window.isGetRetailOK = true; return; } scrollobj.animate({ scrollTop: "+="+190 }, 0,function(){ setTimeout(function(){ getRetailPrice(skuPrices, skuNamesSet); },200); }); } function getRegionPrice(regionPrices) { var tables = $("table.sell-sku-inner-table.sell-sku-body-table").eq(1); var trs = tables.find("tr"); if (trs.length > 0) { var skuNames = []; var inputSize = $(trs[0]).find(".sell-sku-cell-money").length; for (var j = 0; j < trs.length; j++) { var tds = $(trs[j]).find("td"); var nationalPrice = {}; for (var k = 0; k < tds.length; k++) { if ($(tds[k]).hasClass("sell-sku-cell-money")) { var priceInput = $(tds[k]).find("input"); if (priceInput.length != 0) { var tdClass = $(tds[k]).attr("class").match(/col-price-\w{2}/); if (tdClass != null && tdClass.length > 0) { var country = tdClass[0].replace("col-price-","").toLowerCase(); nationalPrice[country == "id" ? "idd" : country] = priceInput.val(); } } } else { if (j == 0) { if($(tds[k]).find("p").length>0) skuNames.push($(tds[k]).find("p").text()); else skuNames.push($(tds[k]).find(".ae-sku-cell-text-content").text()); } else { if($(tds[k]).find("p").length>0) skuNames.splice(skuNames.length - (tds.length - inputSize) + k, 1, $(tds[k]).find("p").text()); else skuNames.splice(skuNames.length - (tds.length - inputSize) + k, 1, $(tds[k]).find(".ae-sku-cell-text-content").text()); } } } var skuName = skuNames.join("-"); regionPrices[skuName] = nationalPrice; } } // ??Óðù»ìé? var scrollobj = tables.closest(`.ver-scroll-wrap`); if (scrollobj.scrollTop() + scrollobj.height() >= scrollobj[0].scrollHeight) { window.isGetRegionOK = true; return; } scrollobj.animate({ scrollTop: "+="+190 }, 0,function(){ setTimeout(function(){ getRegionPrice(regionPrices); },200); }); } //?ßäûú?ßäÓÛøúä§?ëòÞÖ? $("body").on("click", ".colorTip", function () { $(`.showSweetAlert .colorNotice,.showSweetAlert .pop2overlay`).show(); }); function convertPrice(exchangeRate, price) { if (exchangeRate == 1) { if (price <= 13.1=""> -1) { var shopId = $(this).children(`option:selected`).val(); if (shopId != "") { syncTemplates(`?dxmId=` + shopId); } } else if (location.href.indexOf("mangoerp.com/erp") > -1) { var shopId = $(this).children(`option:selected`).attr("data-shopid"); if (shopId != "" && shopId != undefined) { syncTemplates(`?wdtId=` + shopId); } } }); //------------------------èÚïÁ÷×??ïÁ?ï·?Ù¼?---------------------- $(`body`).on(`click`, `#shopCn .el-radio__label`, function () { var shopId = $(this).parent().attr("data-shopcn"); if (shopId != "" && shopId != undefined) { syncTemplates(`?wdtId=` + shopId); } }); //------------------------÷×Ô²âÍâ£?Ù¼?---------------------- //?Íó÷×Ô²?øÖ?ù¡?ØüïÁ?ù»ÕÃ??ÌÚÞÀËì,áìãæÙ¼÷ùù»ÕÃ? $(function() { storeChange(); }); function storeChange(){ var currentVal=getStoreId(); setInterval(function() { var nowVal=getStoreId(); if(nowVal != currentVal && nowVal !== "") { syncTemplates(`?ttId=` + nowVal); currentVal=nowVal; } },1000); } function getStoreId(){ return $("#baseInfoDiv .bg-title:contains(`ÐñÜâãáãÓ`)").next().find(`.left label:contains("ÇØ¿ÜïÁ?")`) .siblings(`span.textbox.combo`).find(`input[type=hidden].textbox-value`).val(); } //------------------------÷×Ô²âÍâ£?Ù¼?-------------------end //?ß©Ðï?ØüÔÒÜÆäÎ?ÞÀËì $("body").on("click", ".syncTemplates", function () { if (chrome.runtime.getManifest().version < "1.1.4") { showHint("error", "ó®ÍíÒöâÍé©ÌÚãæ?ËìÓð1.1.4Ðàì¤ß¾÷úÜâî¦ÒöÞÅéÄ.ã®??ïï:https://www.yuque.com/helps/aeoptools/tquc69"); return; } var currentUrl = location.href; if (currentUrl.indexOf("mabangerp.com") > -1) { var value = $(`input[name="shopId"]:checked`).val(); if (value != "") { syncTemplates(`?mbId=` + value); } } else if (currentUrl.indexOf("dianxiaomi.com") > -1) { var shopId = $(`#shopId`).children(`option:selected`).val(); if (shopId != "") { syncTemplates(`?dxmId=` + shopId); } } else if (currentUrl.indexOf("tongtool.com") > -1) { $("#rootEle tr:first .pdtb5").each(function (i) { if ($(this).text().indexOf("ÇØ¿ÜïÁ?") > -1) { var shopId = $(this).find(".textbox-value").val(); if (shopId !== "") { syncTemplates(`?ttId=` + shopId); } return false; } }); } else if (currentUrl.indexOf("qizhishangke.com") > -1) { var value = $("#shopCn").attr("data-cn"); if (value != "") { syncTemplates(`?wdtId=` + value); } } else if (currentUrl.indexOf("mangoerp.com") > -1) { var shopId = $(`#shopId`).children(`option:selected`).attr("data-shopid"); if (shopId != "" && shopId != undefined) { syncTemplates(`?wdtId=` + shopId); } } else if (currentUrl.indexOf("v3.wxwerp.com") > -1 || location.href.indexOf("ae-pub.wxwerp.com") > -1) { var shopId = $(`#v3-ÇØ¿Ü-shop`).attr("cnid"); if (shopId != "" && shopId != undefined) { syncTemplates(`?wdtId=` + shopId); } } else { syncTemplates(``); } }); //êó???õöò¢Û°,?ìé?î¤price_menu.html function syncTemplates(params) { var param={ method:`ajax`, params: { url: domain + `/seller/querySampleTemplates` + params, xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param,function(t){ if (!t.message && t.result) { if (t.result["NORMAL"] && t.result["NORMAL"].length > 0) { $("#selectNormalTemplate").empty(); $("#selectNormalTemplate").append("
"); for (var i = 0; i < t.result["NORMAL"].length; i++) { var template = t.result["NORMAL"][i]; $("#selectNormalTemplate").append("
"); } //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectNormalTemplate`).empty(); $(`.showSweetAlert #selectNormalTemplate`).append("
"); for (var i = 0; i < t.result["NORMAL"].length; i++) { var template = t.result["NORMAL"][i]; $(`.showSweetAlert #selectNormalTemplate`).append("
"); } $(`.showSweetAlert #selectNormalTemplate`).trigger("chosen:updated"); $(`.showSweetAlert #selectNormalTemplate`).chosen(); } else { $("#selectNormalTemplate").empty(); $("#selectNormalTemplate").append("
"); //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectNormalTemplate`).empty(); $(`.showSweetAlert #selectNormalTemplate`).append("
"); $(`.showSweetAlert #selectNormalTemplate`).trigger("chosen:updated"); $(`.showSweetAlert #selectNormalTemplate`).chosen(); } if (t.result["REGION"] && t.result["REGION"].length > 0) { $("#selectRegionAmountTemplate").empty(); $("#selectRegionPercentTemplate").empty(); $("#selectRegionAmountTemplate").append("
"); $("#selectRegionPercentTemplate").append("
"); for (var j = 0; j < t.result["REGION"].length; j++) { var template = t.result["REGION"][j]; $("#selectRegionAmountTemplate").append("
"); $("#selectRegionPercentTemplate").append("
"); } //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectRegionAmountTemplate`).empty(); $(".showSweetAlert #selectRegionPercentTemplate").empty(); $(".showSweetAlert #selectRegionAmountTemplate").append("
"); $(".showSweetAlert #selectRegionPercentTemplate").append("
"); for (var j = 0; j < t.result["REGION"].length; j++) { var template = t.result["REGION"][j]; $(".showSweetAlert #selectRegionAmountTemplate").append("
"); $(".showSweetAlert #selectRegionPercentTemplate").append("
"); } $(".showSweetAlert #selectRegionAmountTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionAmountTemplate").chosen(); $(".showSweetAlert #selectRegionPercentTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionPercentTemplate").chosen(); } else { $("#selectRegionAmountTemplate").empty(); $("#selectRegionPercentTemplate").empty(); $("#selectRegionAmountTemplate").append("
"); $("#selectRegionPercentTemplate").append("
"); //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectRegionAmountTemplate`).empty(); $(".showSweetAlert #selectRegionPercentTemplate").empty(); $(".showSweetAlert #selectRegionAmountTemplate").append("
"); $(".showSweetAlert #selectRegionPercentTemplate").append("
"); $(".showSweetAlert #selectRegionAmountTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionAmountTemplate").chosen(); $(".showSweetAlert #selectRegionPercentTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionPercentTemplate").chosen(); } $(".syncTemplates").show(); $(".authorizeBtn").hide(); $(".buyStore").hide(); //ñ«?ïÃ?ÔÒÜÆ?î¦âÍé©ð«ãÆ if (params == ``) { showHint("sync", "ÔÒÜÆà÷Íí"); } } else if (t.message) { $("#selectNormalTemplate").empty(); $("#selectNormalTemplate").append("
"); //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectNormalTemplate`).empty(); $(`.showSweetAlert #selectNormalTemplate`).append("
"); $(`.showSweetAlert #selectNormalTemplate`).trigger("chosen:updated"); $(`.showSweetAlert #selectNormalTemplate`).chosen(); $("#selectRegionAmountTemplate").empty(); $("#selectRegionPercentTemplate").empty(); $("#selectRegionAmountTemplate").append("
"); $("#selectRegionPercentTemplate").append("
"); //ò¸á´??ìéó?ß©Ðï?? $(`.showSweetAlert #selectRegionAmountTemplate`).empty(); $(".showSweetAlert #selectRegionPercentTemplate").empty(); $(".showSweetAlert #selectRegionAmountTemplate").append("
"); $(".showSweetAlert #selectRegionPercentTemplate").append("
"); $(".showSweetAlert #selectRegionAmountTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionAmountTemplate").chosen(); $(".showSweetAlert #selectRegionPercentTemplate").trigger("chosen:updated"); $(".showSweetAlert #selectRegionPercentTemplate").chosen(); if (t.message.indexOf("â£?") > -1) { $(".syncTemplates").hide(); $(".buyStore").hide(); if (params.indexOf("dxmId") > -1) { $(".authorizeBtn").attr("href", "https://www.dianxiaomi.com/sys/index.htm?go=m407"); } else if (params.indexOf("mbId") > -1) { $(".authorizeBtn").attr("href", "https://www.mabangerp.com/index.php?mod=shop.list"); } else { $(".authorizeBtn").attr("href", "https://listing.tongtool.com/listing/account/index.htm"); } $(".authorizeBtn").show(); } else { //??ì«?Ñ¢ $(".syncTemplates").hide(); $(".authorizeBtn").hide(); $(".buyStore").show(); } } else { console.log(t.message); } }); } //------------------------ïÒð¤100g?ß©ÐïÙ¼?start---------------------- //ïÒð¤100g?ß©Ðïóø?ÞÀËì,?õó??? $("body").on("click", "#btnDiy100", function () { if($(".diy100").length){ $(".diy100").show(); $(`.sweet-overlay`).show(); $(`body`).attr(`class`,`aside-expanded-true pace-done stop-scrolling`); }else{ $(`.sweetAlert`).removeClass(`zndjpop`).removeClass(`qydjlre`).removeClass(`qydjlrl`).removeClass(`diy100`); $(`.aeplgcon ul li.nav`).removeClass(`now`); $(`#btnDiy100`).parent().addClass(`now`); swal({ title: "ïÒð¤?ß©Ðï", showConfirmButton: false, text: $(`#region_diy_div`).html(), html: true, customClass: "sweetAlert aezsmain diy100", allowOutsideClick: false }); if ($(".showSweetAlert select[name=`selectTemplate`]").chosen) { $(".showSweetAlert select[name=`selectTemplate`]").chosen(); } if ($(".showSweetAlert .locationCountry #locationSelect").chosen) { $(".showSweetAlert .locationCountry #locationSelect").chosen(); } } }); //??Ù¼÷ùù»ÕÃ?ý¨îÜÞÀËì $(`body`).on(`change`, `#selectDiyTemplate`, function () { var templateId = $(this).children(`option:selected`).val(); diySheet.setValue("G2", "", true); for (var i = 3; i < 34; i++) { diySheet.setRowData(i, ["","","","","","","","","","","",""]); } if (templateId == "") { return; } var param={ method:`ajax`, params: { url: domain + `/seller/getTeamplateById?templateId=` + templateId, xhrFields: {withCredentials: true} } }; chrome.runtime.sendMessage(param,function(t){ ($(`.showSweetAlert #diySheet`)[0]).jexcel = null; $(`.showSweetAlert #diySheet`).html(""); diySheet = jexcel($(`.showSweetAlert #diySheet`)[0], diyOptions()); if (!t.message && t.result) { var template = JSON.parse(t.result.data); //ùê?á¶êó??ò¢îÜ???Ê«,éÄ?Îþ??æ´ïÒËÀîÜ?Ê« getPriceHotCountry(t.result); //ôøã·ûùúèâ?ù»ÕÃ? var html = "
"; if (t.result.overseasData) { var overseas = JSON.parse(t.result.overseasData); for (var key in overseas) { html += "
"; } } $(".showSweetAlert .locationCountry #locationSelect").html(html); $(".showSweetAlert .locationCountry #locationSelect").trigger("chosen:updated"); $(".showSweetAlert .locationCountry #locationSelect").off("change").on(`change`, function (e, params) { if (params.selected == "CN") { template.shippingCountry = "CN"; template.type = t.result.templateType; template.volumeSize = t.result.volumeSize; templateData = template; } else { var tempOverseasAll = JSON.parse(t.result.overseasData); var temp = tempOverseasAll[params.selected]; temp.type = t.result.templateType; temp.shippingCountry = params.selected; templateData = temp; } if(templateData){ initDiyData(templateData, templateData.shippingCountry); } }); logisticsDiscount = t.result.logisticsDiscount; template.type = t.result.templateType; template.shippingCountry = "CN"; templateData = template; initDiyData(template, "CN"); } else { swal("", t.message, "error"); } }); }); function initDiyData(template, shippingCountry) { var exchangeRate = template.exchangeRate; var serviceRate = localStorage.getItem("serviceRate"); var wreckRate = localStorage.getItem("wreckRate"); if (exchangeRate == undefined || exchangeRate == "") { exchangeRate = localStorage.getItem("exchangeRate"); exchangeRate = exchangeRate ? exchangeRate : 6.6; } if (serviceRate == undefined || serviceRate == "" || serviceRate == "undefined") { serviceRate = 5; } if (wreckRate == undefined || wreckRate == "" || wreckRate == "undefined") { wreckRate = 2; } diySheet.setValue("A2", exchangeRate, true); diySheet.setValue("B2", serviceRate, true); diySheet.setValue("C2", 0, true); diySheet.setValue("D2", template.goodsWeight, true); diySheet.setValue("F2", wreckRate, true); diySheet.setValue("G2", template.fee, true); diySheet.setValue("H2", `=ROUNDUP(C2/A2+G2+E2*(B2+F2)/100, 2)`, true); diySheet.setValue("I2", `=ROUNDUP(J2/A2/E2*100,2)`, true); diySheet.setValue("J2", `=ROUNDUP((E2-H2)*A2,2)`, true); diySheet.setValue("K2", `=E2`, true); for (var i = 3; i < 34; i++) { diySheet.setRowData(i, ["","","","","","","","","","","",""]); } if (template.type != "NORMAL" && template.type != "NORMAL_100") { hotCountries = sortCountrys(template.countrys); for (var j = 0; j < hotCountries.length; j++) { var row = j + 4; var countryLogis = []; var countryLogistic = hotCountries[j]; countryLogis.push(countryLogistic.countryName); //A countryLogis.push(countryLogistic.country); //B countryLogis.push(countryLogistic.logisName); //C countryLogis.push(countryLogistic.firstWeight); //D countryLogis.push(countryLogistic.firstWeightFee); //E if (countryLogistic.overWeight == undefined || countryLogistic.overWeight == "") { countryLogis.push(1); //F countryLogis.push((countryLogistic.overWeightFee/1000).toFixed(4));//G } else { countryLogis.push(countryLogistic.overWeight); //F countryLogis.push(countryLogistic.overWeightFee); //G } countryLogis.push(countryLogistic.registrationFee); //H countryLogis.push("=ROUNDUP(E" + row + "+H" + row + "+ROUNDUP((D2-D" + row + ">0 ? D2-D" + row + ":0)/F" + row + ",0)*G" + row + ",2)");//I countryLogis.push("=ROUNDUP(I" + row + "/A2-G2>0.01 ? I" + row + "/A2-G2:0,2)"); countryLogis.push(""); diySheet.setRowData(j + 3, countryLogis); } } } // ?õö?ËÀÞÅéÄ function assemblePricesForDiy() { var prices = {}; prices.templateName = $(".showSweetAlert [name=`selectTemplate`]").children(`option:selected`).html(); prices.global = diySheet.getValue("K2"); prices.serviceRate = diySheet.getValue("B2"); prices.cost = diySheet.getValue("C2"); prices.weight = diySheet.getValue("D2"); prices.discountRate = 0; prices.wreckRate = diySheet.getValue("F2"); prices.globalSwitch = true; for (var i = 4; i < 35; i++) { var country = diySheet.getValue("B" + i); if (country) { prices["price-" + country] = diySheet.getValue("J" + i); } } return prices; } // ?áóËÇñìÕáý¨ñìãæ?ß©øÐ??éÄ function recomputeFreeFee(el, records) { var skip = true; for (var ri = 0; ri < records.length; ri++) { if (records[ri].row == 1 && records[ri].col == 3) { skip = false; break; } } if (skip) return; var weight = diySheet.getValue("D2"); var exchangeRate = diySheet.getValue("A2"); if (templateData.otherCountrys && templateData.otherCountrys.length > 0) { for (var i = 0; i < templateData.otherCountrys.length; i++) { var otherCountry = templateData.otherCountrys[i]; if (otherCountry.countryName == templateData.feeFreeCountry) { var fee; var firstWeight = otherCountry.firstWeight; var firstWeightFee = otherCountry.firstWeightFee; var registrationFee = otherCountry.registrationFee; var overWeight = otherCountry.overWeight; var overWeightFee = otherCountry.overWeightFee; if (overWeight == undefined || overWeight == "") { var size = maltose.complexEval((weight - firstWeight > 0 ? weight - firstWeight : 0),0); fee = maltose.complexEval((firstWeightFee + registrationFee + size * overWeightFee / 1000) / exchangeRate, 2); } else { var size = Math.ceil(maltose.complexEval((weight - firstWeight > 0 ? weight - firstWeight : 0) + `/` + overWeight,2), 0); fee = maltose.complexEval((firstWeightFee + registrationFee + size * overWeightFee) / exchangeRate, 2); } diySheet.setValue("G2", fee, true); return; } } } } //------------------------ïÒð¤100g?ß©ÐïÙ¼?end------------------------