return; } } }); } else { alert("请输入数量"); return false; } }); // 判断值是否属于该区间 /**获取元素位置***/ var test = function(arr,num) { // console.log(arr,num,'staring OK',arr[arr.length-1]); for(var i=0;iparseInt(num)) { return i-1; } else if(parseInt(num)>=parseInt(arr[arr.length-1])) { return arr.length-1; } } } } else { if(parseInt(arr[i])>parseInt(num)) { return i-1; } else if(parseInt(num)>=arr[arr.length-1]) { return arr.length-1; } } } } $('.el-input__inner').change(function(){ var par_num = $(this).parent().parent(); var tr = $(".cps-price"); console.log(tr); var cur_unit = $(this).next().find('.cur-unit').text(); // var moq = tr.find(".spq_num").text().trim(); var moq = $(this).attr("spq"); var spq_num = moq; var num = parseInt($(this).val()); var moq_zx = parseInt($(this).attr("data_min")); var stock = parseInt($(this).attr("data_max")); var price_arr = []; var num_arr = []; $(".cps-price").find("div").find("span[class*='moq_']").each(function(k,v){ num_arr.push($(v).text().trim().replace("+:",'')); }) $(".cps-price").find("div").find('i').each(function(k,v){ price_arr.push($(v).text().trim()); }) console.log(num,num_arr,price_arr,num_arr[0]); var len = price_arr.length; if(len>0) { var index = test(num_arr,num); tr.find("div").eq(index).addClass("ff7900").siblings().removeClass("ff7900"); var price = tr.find(".ff7900").find("i[class^='priceS_']").text().trim(); console.log(index,'ing OK',price); } else { if(tr.find(".priceS_6").text().trim()>0) { var price = tr.find(".priceS_6").text().trim(); } } // console.log(price,'price','end'); // var dj = $(tr).find(".price_new").find(".box").find("div:last()").find("i").text(); // console.log(num,moq_zx); if(isNaN(num)) { if(parseInt(moq_zx)>1) { console.log("1-2"); $(tr).find(".add-cart-modal-toast").replaceWith(""); $(tr).find(".add-cart-modal-toast").show().delay(2250).fadeOut(); $(tr).find(".addCartNumS").val(moq_zx); } else { console.log("1-3"); $(tr).find(".add-cart-modal-toast").replaceWith(""); $(tr).find(".add-cart-modal-toast").show().delay(2250).fadeOut(); $(tr).find(this).val(1); } } if(moq_zx>0) { if(numstock) { console.log("1-4"); $(tr).find(".add-cart-modal-toast").replaceWith(""); $(tr).find(".add-cart-modal-toast").show().delay(2250).fadeOut(); $(this).val(stock); } else if(isNaN(num)) { $(this).val(1); } else { $(tr).find(".add-cart-modal-toast").replaceWith(""); $(tr).find(".add-cart-modal-toast").show().delay(2250).fadeOut(); $(this).val(moq_zx*xs); } } } if(num0) { $(".price_tj").show(); } else { $(".price_tj").hide(); } }); // $('.edit').on('click',function(){ $(document).on('click','.edit', function(){ var td = $(this).parent(); var bt = $(this).attr('bt'); var mpn_bm = $(this).attr('mpn_bm'); $.ajax({ type : "POST" , url : "/goods/checkcs", data : {"mpn_bm":mpn_bm,"bt":bt}, dataType : "json" , success : function(data) { if (data.ok=='1') { var html = ''; var _html = ''; var _html = " "; html +=""; if(bt=='spq'||bt=='gysqjfz'||bt=='tag') { td.find('.check').replaceWith(_html); } else { td.find('.check').replaceWith(html); } var htmls = "保存取消"; td.find('a').replaceWith(htmls); } } }); }); // $('.check_cs').on("click",".save",function(){ // var td = $(this).parent(); // // console.log(td); // // console.log(td.find("select").find("option:selected")); // var is_cz = td.find("select").length; // if(is_cz==1) // { // var z = td.find("select").find('option:selected').val(); // }else // { // var z = td.find("input").val(); // } // var mpn_bm = $(this).attr('mpn_bm'); // var bt = $(this).attr('bt'); // var zzsbh = td.attr('zzsbh'); // $.ajax({ // type : "POST" , // url : "/goods/checkcssave", // data : {"mpn_bm":mpn_bm,"bt":bt,"z":z,"zzsbh":zzsbh}, // dataType : "json" , // success : function(data) // { // if (data.ok=='1') // { // // td.find('.checkcs').find("input").replaceWith(z); // td.find(".checkcs").html(z); // var htmls = "编辑"; // td.find('a').replaceWith(htmls); // } // } // }); // }); // $('.check_cs').on("click",".qxsave",function(){ // var td = $(this).parent(); // var is_cz = td.find("select").length; // var html = ''; // td.find(".save").remove(); // // if(is_cz==1) // // { // // var z = td.find("select").find('option:selected').val(); // // }else // // { // // var z = td.find("input").val(); // // } // var mpn_bm = $(this).attr('mpn_bm'); // var bt = $(this).attr('bt'); // var zzsbh = td.attr('zzsbh'); // var edit_html = "编辑"; // td.find(".checkcs").replaceWith(html); // $(this).replaceWith(edit_html); // }); function copy(a) { var text = $(a).attr('title'); var str = $(a).prev().text().trim(); var $temp = $(''); $('body').append($temp); $temp.val(str).select(); document.execCommand('copy'); $temp.remove(); $(".ant-message").show().delay(3000).fadeOut(); } $(".lb_hot").on('click',function() { var urll= $(this).attr('url'); console.log("https://www.chenkeiot.com"+urll); window.location.href="https://www.chenkeiot.com"+urll; })