当前位置: 首页 > news >正文

查询条件与查询数据的ajax拼装

下面我将介绍如何使用 AJAX 动态拼装查询条件和获取查询数据,包括前端和后端的完整实现方案。

一、前端实现方案

1. 基础 HTML 结构

html

复制

<div class="query-container"><!-- 查询条件表单 --><form id="queryForm"><div class="form-group"><label>用户名:</label><input type="text" name="username" class="form-control"></div><div class="form-group"><label>状态:</label><select name="status" class="form-control"><option value="">全部</option><option value="1">启用</option><option value="0">禁用</option></select></div><div class="form-group"><label>注册时间:</label><input type="date" name="startDate" class="form-control"><span>至</span><input type="date" name="endDate" class="form-control"></div><button type="button" id="queryBtn" class="btn btn-primary">查询</button><button type="reset" class="btn btn-default">重置</button></form><!-- 查询结果表格 --><table id="resultTable" class="table table-striped"><thead><tr><th>ID</th><th>用户名</th><th>状态</th><th>注册时间</th></tr></thead><tbody><!-- 数据将通过AJAX动态填充 --></tbody></table><div id="pagination"></div>
</div>

运行 HTML

2. jQuery AJAX 实现

javascript

复制

$(function() {// 查询按钮点击事件$('#queryBtn').click(function() {loadData(1); // 加载第一页数据});// 初始加载第一页数据loadData(1);// 加载数据函数function loadData(pageNum) {// 1. 收集表单数据var formData = $('#queryForm').serialize();// 2. 添加分页参数var queryParams = formData + '&pageNum=' + pageNum + '&pageSize=10';// 3. 显示加载中状态$('#resultTable tbody').html('<tr><td colspan="4" class="text-center">加载中...</td></tr>');// 4. 发送AJAX请求$.ajax({url: '/api/user/list',type: 'GET',data: queryParams,dataType: 'json',success: function(response) {if (response.success) {// 渲染表格数据renderTable(response.data.list);// 渲染分页renderPagination(pageNum, response.data.total, response.data.pages);} else {alert(response.message);}},error: function(xhr) {alert('请求失败: ' + xhr.statusText);}});}// 渲染表格数据function renderTable(data) {var $tbody = $('#resultTable tbody');$tbody.empty();if (data.length === 0) {$tbody.append('<tr><td colspan="4" class="text-center">暂无数据</td></tr>');return;}$.each(data, function(i, item) {var statusText = item.status === 1 ? '启用' : '禁用';var row = '<tr>' +'<td>' + item.id + '</td>' +'<td>' + item.username + '</td>' +'<td>' + statusText + '</td>' +'<td>' + new Date(item.createTime).toLocaleString() + '</td>' +'</tr>';$tbody.append(row);});}// 渲染分页function renderPagination(currentPage, total, totalPages) {var $pagination = $('#pagination');$pagination.empty();if (totalPages <= 1) return;// 上一页if (currentPage > 1) {$pagination.append('<button class="page-btn" data-page="' + (currentPage - 1) + '">上一页</button>');}// 页码for (var i = 1; i <= totalPages; i++) {var active = i === currentPage ? 'active' : '';$pagination.append('<button class="page-btn ' + active + '" data-page="' + i + '">' + i + '</button>');}// 下一页if (currentPage < totalPages) {$pagination.append('<button class="page-btn" data-page="' + (currentPage + 1) + '">下一页</button>');}// 分页按钮事件$('.page-btn').click(function() {var page = $(this).data('page');loadData(page);});}
});

3. 使用 Axios 实现 (现代推荐)

javascript

复制

document.addEventListener('DOMContentLoaded', function() {const queryBtn = document.getElementById('queryBtn');const queryForm = document.getElementById('queryForm');const resultTable = document.getElementById('resultTable').getElementsByTagName('tbody')[0];const pagination = document.getElementById('pagination');// 查询按钮点击事件queryBtn.addEventListener('click', () => loadData(1));// 初始加载loadData(1);async function loadData(pageNum) {try {// 1. 收集表单数据const formData = new FormData(queryForm);const params = new URLSearchParams();// 2. 添加表单数据到查询参数formData.forEach((value, key) => {if (value) params.append(key, value);});// 3. 添加分页参数params.append('pageNum', pageNum);params.append('pageSize', 10);// 4. 显示加载状态resultTable.innerHTML = '<tr><td colspan="4" class="text-center">加载中...</td></tr>';// 5. 发送请求const response = await axios.get('/api/user/list', { params });if (response.data.success) {renderTable(response.data.data.list);renderPagination(pageNum, response.data.data.total, response.data.data.pages);} else {alert(response.data.message);}} catch (error) {alert('请求失败: ' + error.message);}}function renderTable(data) {resultTable.innerHTML = '';if (data.length === 0) {resultTable.innerHTML = '<tr><td colspan="4" class="text-center">暂无数据</td></tr>';return;}data.forEach(item => {const statusText = item.status === 1 ? '启用' : '禁用';const row = document.createElement('tr');row.innerHTML = `<td>${item.id}</td><td>${item.username}</td><td>${statusText}</td><td>${new Date(item.createTime).toLocaleString()}</td>`;resultTable.appendChild(row);});}function renderPagination(currentPage, total, totalPages) {pagination.innerHTML = '';if (totalPages <= 1) return;// 上一页if (currentPage > 1) {const prevBtn = document.createElement('button');prevBtn.className = 'page-btn';prevBtn.textContent = '上一页';prevBtn.dataset.page = currentPage - 1;prevBtn.addEventListener('click', () => loadData(parseInt(prevBtn.dataset.page)));pagination.appendChild(prevBtn);}// 页码for (let i = 1; i <= totalPages; i++) {const pageBtn = document.createElement('button');pageBtn.className = i === currentPage ? 'page-btn active' : 'page-btn';pageBtn.textContent = i;pageBtn.dataset.page = i;pageBtn.addEventListener('click', () => loadData(parseInt(pageBtn.dataset.page)));pagination.appendChild(pageBtn);}// 下一页if (currentPage < totalPages) {const nextBtn = document.createElement('button');nextBtn.className = 'page-btn';nextBtn.textContent = '下一页';nextBtn.dataset.page = currentPage + 1;nextBtn.addEventListener('click', () => loadData(parseInt(nextBtn.dataset.page)));pagination.appendChild(nextBtn);}}
});

二、后端实现方案 (Spring Boot)

1. 控制器实现

java

复制

@RestController
@RequestMapping("/api/user")
public class UserController {@Autowiredprivate UserService userService;@GetMapping("/list")public Result listUsers(UserQuery query, @RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "10") Integer pageSize) {PageInfo<User> pageInfo = userService.queryUsers(query, pageNum, pageSize);return Result.success(pageInfo);}
}

2. 查询参数对象

java

复制

public class UserQuery {private String username;private Integer status;private Date startDate;private Date endDate;// getter 和 setter 方法// ...
}

3. 服务层实现

java

复制

@Service
public class UserServiceImpl implements UserService {@Autowiredprivate UserMapper userMapper;@Overridepublic PageInfo<User> queryUsers(UserQuery query, Integer pageNum, Integer pageSize) {PageHelper.startPage(pageNum, pageSize);List<User> users = userMapper.selectByQuery(query);return new PageInfo<>(users);}
}

4. MyBatis Mapper 示例

java

复制

public interface UserMapper {List<User> selectByQuery(UserQuery query);
}

xml

复制

<!-- mapper.xml -->
<select id="selectByQuery" resultType="User" parameterType="UserQuery">SELECT * FROM user<where><if test="username != null and username != ''">AND username LIKE CONCAT('%', #{username}, '%')</if><if test="status != null">AND status = #{status}</if><if test="startDate != null">AND create_time >= #{startDate}</if><if test="endDate != null">AND create_time <![CDATA[<=]]> #{endDate}</if></where>ORDER BY id DESC
</select>

运行 HTML

5. 统一返回结果封装

java

复制

public class Result implements Serializable {private boolean success;private String message;private Object data;public static Result success(Object data) {Result result = new Result();result.setSuccess(true);result.setData(data);return result;}public static Result error(String message) {Result result = new Result();result.setSuccess(false);result.setMessage(message);return result;}// getter 和 setter 方法// ...
}

三、高级功能扩展

1. 防抖处理 (优化频繁查询)

javascript

复制

// 使用 lodash 的防抖函数
$('#queryBtn').click(_.debounce(function() {loadData(1);
}, 500));

2. 查询条件本地存储

javascript

复制

// 保存查询条件
function saveQueryParams() {const formData = $('#queryForm').serializeArray();localStorage.setItem('lastQueryParams', JSON.stringify(formData));
}// 加载上次查询条件
function loadQueryParams() {const params = localStorage.getItem('lastQueryParams');if (params) {const formData = JSON.parse(params);formData.forEach(item => {$(`[name="${item.name}"]`).val(item.value);});}
}

3. 导出查询结果

javascript

复制

function exportData() {const formData = $('#queryForm').serialize();window.open('/api/user/export?' + formData, '_blank');
}

四、最佳实践建议

  1. 参数校验:前后端都要对查询参数进行校验

  2. 分页处理:大数据量时务必使用分页

  3. 性能优化:添加合适的数据库索引

  4. 错误处理:友好的错误提示和日志记录

  5. 安全性:防止SQL注入和XSS攻击

  6. API文档:使用Swagger等工具生成API文档

通过以上实现,您可以构建一个完整的、可维护的查询功能,满足大多数业务场景的需求。

/*** 按品种查询资源** @param breedId*            品名Id集,单个或多个*/
function searchMarket(breedId)
{var prBreedId=pi;$.ajax({url: "/resource/getMarketProperties.jsp",type:"post",async:false,data:{"breedId":breedId,"prBreedId":prBreedId},dataType:"text",success: function(message){var data = eval("(" + message + ")");var breed = eval("("+ data.breedJsonProperty +")");var material = eval("("+ data.materialJsonProperty +")");var spec = eval("("+ data.specJsonProperty +")");var brand = eval("("+ data.brandJsonProperty +")");// 刷新选择收索部分的数据changeHtml(breed,"breed",breedId);changeHtml(material,"material",breedId);changeHtml(spec,"spec",breedId);changeBrandHtml(brand);// 刷新输入框部分收索数据clickBreed(breed,material,spec,brand);// 品名的全部初值设置为当前大品名document.getElementById("breed_option_all").href = "javascript:searchMarket('"+ prBreedId +"');searchParams['breedNames']='';searchParams['breedIds']='';searchParams['breedInfos']='';searchByParams();";// 设置为全部$("#material_option_all").attr("class","option-all cur");$("#spec_option_all").attr("class","option-all cur");$("#brand_option_all").attr("class","option-all cur");}});
}/*** 单选查询品种** @param breedId* @param breedName*/
function searchBySingleBreed(breedId, breedName) {var breedInfo = {};breedInfo[breedId] = breedName;searchParams["breedInfos"] = breedInfo;searchByParams();
}
/*** 确认执行多选品种*/
function searchByMultiBreed() {$("#breedReset").click();var breedParams = {};var breedIds = "";$("[name='breedIds']:checked").each(function() {var breedId = $(this).val();var breedName = $("#label_breed_" + breedId).text();breedParams[breedId] = breedName;if (breedIds == "") {breedIds += breedId;} else {breedIds += "," + breedId;}});searchParams["breedInfos"] = breedParams;searchMarket(breedIds);searchByParams();
}/*** 确认执行多选材质*/
function searchByMultiMaterial() {$("#materialReset").click();var materials = "";$("[name='materialIds']:checked").each(function() {var material = $(this).val();if (materials == "") {materials += material;} else {materials += "," + material;}});searchParams["materials"] = materials;searchByParams();
}
/*** 确认执行多选规格*/
function searchByMultiSpec() {$("#specReset").click();var specs = "";$("[name='specIds']:checked").each(function() {var spec = $(this).val();if (specs == "") {specs += spec;} else {specs += "," + spec;}});searchParams["specs"] = specs;searchByParams();
}/*** 确认执行多选交货地*/
function searchByMultiCity() {$("#cityReset").click();var cities = "";var cityNameMutis = "";$("[name='cityIds']:checked").each(function() {var city = $(this).val().split(",")[0];var cityNameMuti = $(this).val().split(",")[1];if (cities == "") {cities += city;} else {cities += "," + city;}if (cityNameMutis == "") {cityNameMutis += cityNameMuti;} else {cityNameMutis += "," + cityNameMuti;}});searchParams["cityId"] = cities;searchParams["cityName"] = cityNameMutis;searchByParams();
}/*** 点击钢厂logo相应事件*/
function clickBrandLogo(brand) {var resetButton = $("#brandReset");if (resetButton.is(":hidden")) {searchParams["brands"] = brand;searchByParams();} else {var selectItem = document.getElementById("brandDiv_" + brand);selectItem.setAttribute("class", "selected");}
}/*** 确认执行钢厂多选*/
function searchByMultiBrand() {// 回到单选$("#brandReset").click();var brands = "";$("#show-logo-div .selected").each(function() {var id = $(this).attr("id");var brand = id.replace("brandDiv_", "");if (brands == "") {brands += brand;} else {brands += "," + brand;}});searchParams["brands"] = brands;searchByParams();
}
/*** 根据城市交货地进行搜索** @param obj*/
function searchByCity(obj){var cityName;searchParams["warehouses"]="";$("#warehouseDiv").remove();$("#whText").val("");if(obj.id == "quanguo"){cityName = "全国";ci="";searchParams["cityId"]="";searchParams["cityName"] = "";searchByParams();searchWarehouse("");}else{cityName=$("#"+obj.id).text();ci=obj.id;searchParams["cityName"] = cityName;searchParams["cityId"]=obj.id;searchByParams();searchWarehouse(obj.id);}
}
/*** 选择城市刷新仓库输入框** @param obj*/function searchWarehouse(obj){$.ajax({url: "/resource/getWarehouseProperties.jsp",type:"post",data:{"prBreedId":pi,"cityId":obj},dataType:"text",success: function(message){var data = eval("(" + message + ")");var warehouseDa = eval("("+ data.warehouseJsonProperty +")");$("#warehouseSelector").singleSelector("仓库", {"data" : warehouseDa,"defaultValue" : "","defaultText" : ""}, "whValue", "whText",afterSelectOthers,inputEnter,"down1");}});}
/*** 点击上方品名,下方收索框数据重新加载** @param breedData*            品名数据* @param materialData*            材质数据* @param specData*            规格数据* @param brandData*            钢厂数据*/
function clickBreed(breedData,materialData,specData,brandData)
{$("#breedSelector").singleSelector("品名", {"data" : breedData,"defaultValue" : "","defaultText" : ""}, "biValue", "bdText",afterSelectBreed,inputEnter,"down1");$("#materialSelector").singleSelector("材质", {"data" : materialData,"defaultValue": "","defaultText": ""}, "mlValue", "mlText",afterSelectOthers,inputEnter,"down2");$("#specSelector").singleSelector("规格", {"data" : specData,"defaultValue": "","defaultText": ""}, "spValue", "spText",afterSelectOthers,inputEnter,"down2");$("#brandSelector").singleSelector("钢厂", {"data" : brandData,"defaultValue": "","defaultText": ""}, "brValue", "brText",afterSelectOthers,inputEnter,"down2");
}
/*** 点击品种后更新资源信息** @param param*            参数对应信息* @param paramName*            参数名字* @param breedId*            品种Id*/
function changeHtml(param,paramName,breedId)
{var changeId = "change" + paramName;var html = "";for(var i=0; i<param.length;i++){var css = "";if(i>11){css = "class='more'";}var method = "";if(paramName == "material"){var paramNames ="materials";method+= "searchBySingleParam(\""+paramNames+"\",\""+ param[i].value +"\");";}    if(paramName == "spec"){var paramNames ="specs";method+= "searchBySingleParam(\""+paramNames+"\",\""+ param[i].value +"\");";}    if(paramName == "breed"){method = "searchMarket(\""+ param[i].value +"\");"+"searchBySingleBreed(\""+param[i].value+"\",\""+ param[i].name +"\");";}var check = "";var id = breedId.split(",");for(var j=0;j<id.length;j++){if(param[i].value == id[j]){check = "checked";}    }    html+="<li "+ css +">"+"<span class='block-choose-more'>" +"<input type='checkbox' "+ check +" class='check-choose' value='"+ param[i].value +"' name='"+ paramName +"Ids' id='checkItem_"+ paramName +"_"+ param[i].value +"' /><label id='label_"+paramName+"_"+param[i].value+"'>"+param[i].name +"</label>"+"</span>" +"<a href='javascript:"+ method +"' class='listitem-link' id='item_"+ paramName +"_" + param[i].value +"' >" + param[i].name +"</a>" +"</li>";}document.getElementById(changeId).innerHTML= html;
}/*** 单选动作,材质规格** @param paramName*            输入种类* @param paramvalue*            获取值*/
function searchBySingleParam(paramName,paramvalue)
{searchParams[paramName] = paramvalue;searchByParams();
}
/*** 选择品种后更新钢厂信息** @param paramBrand*            钢厂信息*/
function changeBrandHtml(paramBrand)
{var html = "";for(var i=0; i<paramBrand.length;i++){var count = i+1;var css = "";if(count>7){css = "class='more'";}var value = "";if(count>15){value = "more";}var html1 = "onMouseOver='this.style.cursor=\"pointer\";onMouseOver(this,"+ count +")'";var html2 = "onMouseOut='onMouseOut(this,"+ count +")'";html+="<div  id='brandDiv_"+ paramBrand[i].value+ "'" + css + html1 + html2 +" onclick='clickBrandLogo(\""+paramBrand[i].value+"\")"+"'> "+"<span  id='brandSpan_"+ count +"'>" +"<input  id='brandInput_"+ count + "'" +" type='hidden' value='"+ paramBrand[i].value +"' />" +"<input  id='checkItem_brand_"+ paramBrand[i].value +"' type='hidden'  value='"+ value +"' />" +"</span>" +"<a id='item_brand_"+ paramBrand[i].value +"'  href='#'  ><img src='../../../skin/images/factory/"+ paramBrand[i].image +".jpg' width='102' height='36' /></a>" +"</div>";}html+="<span class='clr'></span>";document.getElementById("show-logo-div").innerHTML= html;
}/*** 选择品种下拉输入框触发动作** @param value*            品名ID* @param text*/
function afterSelectBreed(value,text){$.post("/resource/getMarketProperties.jsp",{"breedId":value},function(result){if(result!=""){var data = eval("(" + result + ")");var materialData = eval("("+ data.materialJsonProperty +")");var specData = eval("("+ data.specJsonProperty +")");var brandData = eval("("+ data.brandJsonProperty +")");$("#materialSelector").singleSelector("材质", {"data" : materialData,"defaultValue" : "","defaultText" : ""}, "mlValue", "mlText",afterSelectOthers,inputEnter,"down2");$("#specSelector").singleSelector("规格", {"data" : specData,"defaultValue" : "","defaultText" : ""}, "spValue", "spText",afterSelectOthers,inputEnter,"down2");$("#brandSelector").singleSelector("钢厂", {"data" : brandData,"defaultValue" : "","defaultText" : ""}, "brValue", "brText",afterSelectOthers,inputEnter,"down2");var ids = data.ids;var jsonids = eval("("+ ids +")");if(jsonids.length == 1){searchRoolerMarket(jsonids[0].id);var breedName = $("#bdText").val();var breedInfo = {};breedInfo[jsonids[0].id] = breedName;searchParams["breedInfos"] = breedInfo;buttonSearch();}    }},"text");
}/*** 选择下拉框品名,重新刷新上方列表数据** @param breedId*/
function searchRoolerMarket(breedId)
{var prBreedId=pi;$.ajax({url: "resource/getMarketProperties.jsp",type:"post",async:false,data:{"breedId":breedId,"pi":prBreedId},dataType:"text",success: function(message){var data = eval("(" + message + ")");var breed = eval("("+ data.breedJsonProperty +")");var material = eval("("+ data.materialJsonProperty +")");var spec = eval("("+ data.specJsonProperty +")");var brand = eval("("+ data.brandJsonProperty +")");changeHtml(breed,"breed",breedId);changeHtml(material,"material",breedId);changeHtml(spec,"spec",breedId);changeBrandHtml(brand);document.getElementById("breed_option_all").href = "javascript:searchMarket('"+ prBreedId +"');searchParams['breedNames']='';searchParams['breedIds']='';searchParams['breedInfos']='';searchByParams();";$("#material_option_all").attr("class","option-all cur");$("#spec_option_all").attr("class","option-all cur");$("#brand_option_all").attr("class","option-all cur");}});
}
/*** 选择规格、材质、钢厂触发动作** @param value* @param text*/
function afterSelectOthers(value, text)
{buttonSearch();
}/*** 输入值按enter键进行收索** @param value* @param text*/
function inputEnter(value, text)
{var events = window.event || arguments.callee.caller.arguments[0];if (events.keyCode == 13){buttonSearch();}
}/*** 点击搜索按钮进行搜索*/
function buttonSearch() {var bi = $("#biValue").val();var breadInfos = {};if (bi != null && bi != "") {searchParams["breedIds"] = bi;breadInfos[bi] = $("#bdText").val() ;} else {searchParams["breedIds"] = "";breadInfos="";}var bd = escape($("#bdText").val());if (bd != null && bd != "") {searchParams["breedNames"] = bd;searchParams["breedInfos"] = breadInfos;searchParams["breedIds"] = "";} else {searchParams["breedNames"] = "";searchParams["breedIds"] = "";searchParams["breedInfos"] ="";}var ml = escape($("#mlText").val());if (ml != null && ml != "") {searchParams["materials"] = ml;} else {searchParams["materials"] = "";}var sp = escape($("#spText").val());if (sp != null && sp != "") {searchParams["specs"] = sp;} else {searchParams["specs"] = "";}var br = escape($("#brText").val());if (br != null && br != "") {searchParams["brands"] = br;} else {searchParams["brands"] = "";}var whs = escape($("#whText").val());if (whs != null && whs != "") {searchParams["warehouses"] = whs;} else {searchParams["warehouses"] = "";}var ts1 = $("#ts1").val();if (ts1 != null && ts1 != "") {searchParams["startThickness"] = ts1;} else {searchParams["startThickness"] = "";}var ts2 = $("#ts2").val();if (ts2 != null && ts2 != "") {searchParams["endThickness"] = ts2;} else {searchParams["endThickness"] = "";}var wi1 = $("#wi1").val();if (wi1 != null && wi1 != "") {searchParams["startWidth"] = wi1;} else {searchParams["startWidth"] = "";}var wi2 = escape($("#wi2").val());if (wi2 != null && wi2 != "") {searchParams["endWidth"] = wi2;} else {searchParams["endWidth"] = "";}var pr1 = $("#pr1").val();if (pr1 != null && pr1 != "") {if (!isNaN(pr1)) {searchParams["startPrice"] = pr1;}else{searchParams["startPrice"] = "";}} else {searchParams["startPrice"] = "";}var pr2 = $("#pr2").val();if (pr2 != null && pr2 != "") {if (!isNaN(pr2)) {searchParams["endPrice"] = pr2;}else{searchParams["endPrice"] = "";}} else {searchParams["endPrice"] = "";}searchParams["pageNum"] = 1;searchByParams();$("#pr1").val(pr1);$("#pr2").val(pr2);
}/*** 设置选中效果,并设值*/
function setAttrParams() {var cityName = searchParams["cityName"];// 当前城市展示if(cityName==null ||cityName=="undefined" ||cityName==""){$(".selects").text("交货地 :");$("#cityName").text("全国");}else{if(typeof(cityName) == "undefined"){$(".selects").text("交货地 :");$("#cityName").text("全国");}else{var cityNameMutiList = cityName.split(",");if(cityNameMutiList.length == 1){$(".selects").text("交货地 :"+searchParams["cityName"]);$("#cityName").text(searchParams["cityName"]);}else{$(".selects").text("交货地 :");$("#cityName").text("全国");}}    }$("#breed_option_all").attr("class", "option-all cur");$("#changebreed [class='listitem-link cur']").attr("class", "listitem-link");$("#changebreed [class='check-choose']").prop("checked", false);$("#bdText").val("");$("#biValue").val("");if (searchParams["breedInfos"] != null && searchParams["breedInfos"] != "") {$("#breed_option_all").attr("class", "option-all");var breedNames = "";var breedIds = "";var breedInfos = searchParams["breedInfos"];var i = 0;for ( var breedId in breedInfos) {i++;var breedName = breedInfos[breedId];if (breedName != "") {if (breedNames == "") {breedNames += breedName;} else {breedNames += "," + breedName;}}if (breedId != "") {if (breedIds == "") {breedIds += breedId;} else {breedIds += "," + breedId;}}$("#breed_option_all").attr("class", "option-all");$("#item_breed_" + breedId).attr("class", "listitem-link cur");$("#checkItem_breed_" + breedId).prop("checked", true);}if (i == 1) {$("#bdText").val(breedNames);$("#biValue").val(breedIds);}searchParams["breedNames"] = "";searchParams["breedIds"] = breedIds;} else {var breedNames = searchParams["breedNames"];if (breedNames != null && breedNames != "") {$("#breed_option_all").attr("class", "option-all");$("#bdText").val(unescape(breedNames));}}var specs = searchParams["specs"];$("#spec_option_all").attr("class", "option-all cur");$("#changespec [class='listitem-link cur']").attr("class", "listitem-link");$("#changespec [class='check-choose']").prop("checked", false);$("#spText").val("");if (specs != null && specs != "") {$("#spec_option_all").attr("class", "option-all");var specList = specs.split(",");for (var i = 0; i < specList.length; i++) {var selectItem = document.getElementById("item_spec_" + specList[i]);if (selectItem != null) {selectItem.setAttribute("class", "listitem-link cur");}var checkItem = document.getElementById("checkItem_spec_" + specList[i]);if (checkItem != null) {checkItem.checked = true;}}if (specList.length == 1) {$("#spText").val(unescape(specs));}}var materials = searchParams["materials"];$("#material_option_all").attr("class", "option-all cur");$("#changematerial [class='listitem-link cur']").attr("class", "listitem-link");$("#changematerial [class='check-choose']").prop("checked", false);$("#mlText").val("");$("#mlValue").val("");if (materials != null && materials != "") {$("#material_option_all").attr("class", "option-all");var materialList = materials.split(",");for (var i = 0; i < materialList.length; i++) {var selectItem = document.getElementById("item_material_" + materialList[i]);if (selectItem != null) {selectItem.setAttribute("class", "listitem-link cur");}var checkItem = document.getElementById("checkItem_material_" + materialList[i]);if (checkItem != null) {checkItem.checked = true;}}if (materialList.length == 1) {$("#mlText").val(unescape(materials));}}var brands = searchParams["brands"];$("#brand_option_all").attr("class", "option-all cur");$("#show-logo-div [class='selected']").attr("class", "");$("#brText").val("");$("#btValue").val("");if (brands != null && brands != "") {$("#brand_option_all").attr("class", "option-all");var brandList = brands.split(",");for (var i = 0; i < brandList.length; i++) {var selectItem = document.getElementById("brandDiv_" + brandList[i]);if (selectItem != null) {selectItem.setAttribute("class", "selected");}}if (brandList.length == 1) {$("#brText").val(unescape(brands));}}var cityName = searchParams["cityName"];if(typeof(cityName) != "undefined"){var cityiesList = cityName.split(",");if(cityiesList.length == 1){$(".selects").text("交货地 :"+cityiesList[0]);}else{$(".selects").text("交货地 :");}}    var cityIds = searchParams["cityId"];$("#city_option_all").attr("class", "option-all cur");$("#changecity [class='listitem-link cur']").attr("class", "listitem-link");$("#changecity [class='check-choose']").prop("checked", false);if (cityIds != null && cityIds != "") {$("#city_option_all").attr("class", "option-all");var cityList = cityIds.split(",");for (var i = 0; i < cityList.length; i++) {var selectItem = document.getElementById("item_city_" + cityList[i]);if (selectItem != null) {selectItem.setAttribute("class", "listitem-link cur");}var checkItem = document.getElementById("checkItem_city_" + cityList[i]);if (checkItem != null) {checkItem.checked = true;}}}var warehouses = searchParams["warehouses"];$("#whText").val("");if (warehouses != null && warehouses != "") {$("#whText").val(unescape(warehouses));}var startPrice = searchParams["startPrice"];var endPrice = searchParams["endPrice"];$("#pr1").val("¥最低价");$("#pr2").val("¥最高价");var i = 0;var j = 0;if (startPrice != null && startPrice != "") {i++;j = 1;}if (endPrice != null && endPrice != "") {i++;j = 2;}if (i == 2) {$("#pr1").val(startPrice);$("#pr2").val(endPrice);}if (i == 1 && j == 1) {$("#pr1").val(startPrice);}if (i == 1 && j == 2) {$("#pr2").val(endPrice);}i = 0;j = 0;$("#ts1").val("");$("#ts2").val("");var startThickness = searchParams["startThickness"];var endThickness = searchParams["endThickness"];if (startThickness != null && startThickness != "") {i++;j = 1;}if (endThickness != null && endThickness != "") {i++;j = 2;}if (i == 2) {$("#ts1").val(startThickness);$("#ts2").val(endThickness);}if (i == 1 && j == 1) {$("#ts1").val(startThickness);}if (i == 1 && j == 2) {$("#ts2").val(endThickness);}i = 0;j = 0;$("#wi1").val("");$("#wi2").val("");var startWidth = searchParams["startWidth"];var endWidth = searchParams["endWidth"];if (startWidth != null && startWidth != "") {i++;j = 1;}if (endWidth != null && endWidth != "") {i++;j = 2;}if (i == 2) {$("#wi1").val(startWidth);$("#wi2").val(endWidth);}if (i == 1 && j == 1) {$("#wi1").val(startWidth);}if (i == 1 && j == 2) {$("#wi2").val(endWidth);}
}/*** 清空输入价格*/
function clean(){searchParams["startPrice"]="";
searchParams["endPrice"]= "";
searchByParams();    
}
/*** 分页查询*/
function pageQuery(index){searchParams["pageNum"] = index;directSearchByParam();
}/*** 分页效果展示*/
function page() {var totalPages = $("#totalPages").val();var currPageNum = $("#currPageNum").val();if (totalPages < 10)for (var i = 1; i <= totalPages; i++) {if (i == currPageNum) {$("#pageSpan").append("<a class=\"current\">" + i + "</a>");} else {$("#pageSpan").append("<a href=\"javascript:void(0)\" id=\"page_" + i + "\">" + i + "</a>");$("#page_" + i).attr("onclick", "pageQuery("+i+")");}}else {if (currPageNum < 6) {for (var i = 1; i <= 10; i++) {if (i == currPageNum) {$("#pageSpan").append("<a class=\"current\">" + i + "</a>");} else {$("#pageSpan").append("<a href=\"javascript:void(0)\" id=\"page_" + i + "\">" + i + "</a>");$("#page_" + i).attr("onclick", "pageQuery("+i+")");}}} else {var cur = parseInt(currPageNum) + 5;if (cur <= totalPages) {var pre = parseInt(currPageNum) - 4;var last = parseInt(currPageNum) + 5;for (i = pre; i <= last; i++) {if (i == currPageNum) {$("#pageSpan").append("<a class=\"current\">" + i + "</a>");} else {$("#pageSpan").append("<a href=\"javascript:void(0)\" id=\"page_" + i + "\">" + i + "</a>");$("#page_" + i).attr("onclick", "pageQuery("+i+")");}}} else {var pre = parseInt(totalPages) - 9;for (i = pre; i <= parseInt(totalPages); i++) {if (i == currPageNum) {$("#pageSpan").append("<a class=\"current\">" + i + "</a>");} else {$("#pageSpan").append("<a href=\"javascript:void(0)\" id=\"page_" + i + "\">" + i + "</a>");$("#page_" + i).attr("onclick", "pageQuery("+i+")");}}}}}$("#totalSpan").append(totalPages);
}/*** 上一页*/
function prePage() {var currPageNum = parseInt($("#currPageNum").val());var tempPageNum = 1;if (currPageNum > 0) {tempPageNum = currPageNum - 1;}if (tempPageNum == 0) {tempPageNum = 1;}searchParams["pageNum"]=tempPageNum;directSearchByParam();
}/*** 跳转下一页*/
function nextPage() {var currPageNum = parseInt($("#currPageNum").val());var totalPages = parseInt($("#totalPages").val());var tempPageNum;if (currPageNum >= totalPages) {tempPageNum = totalPages;} else {tempPageNum = parseInt(currPageNum) + 1;}searchParams["pageNum"]=tempPageNum;directSearchByParam();
}/*** 转到*/
function goPage() {var totalPages = parseInt($("#totalPages").val());var pageNum = parseInt($("#pageNum").val());if (!isNaN(pageNum) && pageNum <= totalPages && pageNum > 0) {searchParams["pageNum"]=pageNum;directSearchByParam();} else {$("#pageNum").val("");}
}
/*** 首页*/
function firstPage() {searchParams["pageNum"]=1;directSearchByParam();
}/*** 尾页*/
function lastPage() {var totalPages = $("#totalPages").val();searchParams["pageNum"]= totalPages;directSearchByParam();
}
/*** 设置按照品种进行排序*/
function setSortBreed() {var sortBreedFlag = $("#sortBreedFlag").attr("class");if (sortBreedFlag == "basic") {$("#sortBreedFlag").attr("class", "up");searchParams["breedSort"] = "10";} else if (sortBreedFlag == "up") {$("#sortBreedFlag").attr("class", "down");searchParams["breedSort"] = "11";} else if (sortBreedFlag == "down") {$("#sortBreedFlag").attr("class", "basic");searchParams["breedSort"] = "";}directSearchByParam();
}/*** 设置按照规格进行排序*/
function setSortSpec() {var sortSpecFlag = $("#sortSpecFlag").attr("class");if (sortSpecFlag == "basic") {$("#sortSpecFlag").attr("class", "up");searchParams["specSort"] = "10";} else if (sortSpecFlag == "up") {$("#sortSpecFlag").attr("class", "down");searchParams["specSort"] = "11";} else if (sortSpecFlag == "down") {$("#sortSpecFlag").attr("class", "basic");searchParams["specSort"] = "";}directSearchByParam();
}/*** 设置按照材质进行排序*/
function setSortMaterial() {var sortMaterialFlag = $("#sortMaterialFlag").attr("class");if (sortMaterialFlag == "basic") {$("#sortMaterialFlag").attr("class", "up");searchParams["materialSort"] = "10";}if (sortMaterialFlag == "up") {$("#sortMaterialFlag").attr("class", "down");searchParams["materialSort"] = "11";}if (sortMaterialFlag == "down") {$("#sortMaterialFlag").attr("class", "basic");searchParams["materialSort"] = "";}directSearchByParam();
}/*** 设置按照钢厂排序*/
function setSortBrand() {var sortBrandFlag = $("#sortBrandFlag").attr("class");if (sortBrandFlag == "basic") {$("#sortBrandFlag").attr("class", "up");searchParams["brandSort"] = "10";} else if (sortBrandFlag == "up") {$("#sortBrandFlag").attr("class", "down");searchParams["brandSort"] = "11";} else if (sortBrandFlag == "down") {$("#sortBrandFlag").attr("class", "basic");searchParams["brandSort"] = "";}directSearchByParam();
}/*** 设置按照仓库排序*/
function setSortWarehouse() {var sortWarehouseFlag = $("#sortWarehouseFlag").attr("class");if (sortWarehouseFlag == "basic") {$("#sortWarehouseFlag").attr("class", "up");searchParams["warehouseSort"] = "10";} else if (sortWarehouseFlag == "up") {$("#sortWarehouseFlag").attr("class", "down");searchParams["warehouseSort"] = "11";} else if (sortWarehouseFlag == "down") {$("#sortWarehouseFlag").attr("class", "basic");searchParams["warehouseSort"] = "";}directSearchByParam();
}/*** 设置根据交货地排序*/
function setSortCity() {var sortCityFlag = $("#sortCityFlag").attr("class");if (sortCityFlag == "basic") {$("#sortCityFlag").attr("class", "up");searchParams["citySort"] = "10";} else if (sortCityFlag == "up") {$("#sortCityFlag").attr("class", "down");searchParams["citySort"] = "11";} else if (sortCityFlag == "down") {$("#sortCityFlag").attr("class", "basic");searchParams["citySort"] = "";}directSearchByParam();
}/*** 设置按照重量进行排序*/
function setSortAverageQty() {var sortAverageQtyFlag = $("#sortAverageQtyFlag").attr("class");if (sortAverageQtyFlag == "basic") {$("#sortAverageQtyFlag").attr("class", "up");searchParams["averageQtySort"] = "10";} else if (sortAverageQtyFlag == "up") {$("#sortAverageQtyFlag").attr("class", "down");searchParams["averageQtySort"] = "11";} else if (sortAverageQtyFlag == "down") {$("#sortAverageQtyFlag").attr("class", "basic");searchParams["averageQtySort"] = "";}directSearchByParam();
}/*** 设置按照价格进行排序*/
function setSortPrice() {var sortPriceFlag = $("#sortPriceFlag").attr("class");if (sortPriceFlag == "basic") {$("#sortPrice").attr("class", "sorton");$("#sortPriceFlag").attr("class", "up");searchParams["priceSort"] = "10";} else if (sortPriceFlag == "up") {$("#sortPrice").attr("class", "sortoff");$("#sortPriceFlag").attr("class", "down");searchParams["priceSort"] = "11";} else if (sortPriceFlag == "down") {$("#sortPrice").attr("class", "default");$("#sortPriceFlag").attr("class", "basic");searchParams["priceSort"] = "";}directSearchByParam();
}/*** 设置按照价格进行排序*/
function sortPrice() {var sortPriceFlag = $("#sortPrice").attr("class");if (sortPriceFlag == "default") {$("#sortPrice").attr("class", "sorton");$("#sortPriceFlag").attr("class", "up");searchParams["priceSort"] = "10";} else if (sortPriceFlag == "sorton") {$("#sortPrice").attr("class", "sortoff");$("#sortPriceFlag").attr("class", "down");searchParams["priceSort"] = "11";} else if (sortPriceFlag == "sortoff") {$("#sortPrice").attr("class", "default");$("#sortPriceFlag").attr("class", "basic");searchParams["priceSort"] = "";}directSearchByParam();
}/*** 设置按默认排序查找*/
function setDefaultSort() {$("#sortBreedFlag").attr("class", "basic");$("#sortSpecFlag").attr("class", "basic");$("#sortMaterialFlag").attr("class", "basic");$("#sortBrandFlag").attr("class", "basic");$("#sortWarehouseFlag").attr("class", "basic");$("#sortCityFlag").attr("class", "basic");$("#sortAverageQtyFlag").attr("class", "basic");$("#sortPriceFlag").attr("class", "basic");$("#sortPrice").attr("class","default");searchParams["breedSort"] = "";searchParams["specSort"] = "";searchParams["materialSort"] = "";searchParams["brandSort"] = "";searchParams["warehouseSort"] = "";searchParams["citySort"] = "";searchParams["averageQtySort"] = "";searchParams["priceSort"] = "";
}/*** 资源列表初始化*/
function resListInit()
{// 清空数据$("#thead").siblings().remove();$(".page").attr("style", "display:none");// 添加加载效果图片var table = $("#resList");var loadingTr = $("#loading");if (typeof (loadingTr) == "undefined" || loadingTr.length == 0) {var loadingTr = "<tr class='item-loading'><td colspan=\"11\" id=\"loading\"><img id=\"loadingImg\" width=\"100\" height=\"100\" src=\"//static.banksteel.com/v6/images/loading.gif\"></td></tr>";table.append(loadingTr);}// 加载动画$("#loadingImg").animate({left:"520px"},1000);
}/*** 展示资源列表(没有查询到资源)*/
function noRes(){var table = $("#resList");var breedNames = "";var breedNameTemp = "";var specs = "";var materials ="";var brands = "";var warehouses = "";var thickness = "";var width = "";var price = "";var prBreedName = "";var city = "";var keyword = "";if(searchParams["keyword"]){keyword = "【"+unescape(searchParams["keyword"])+"】";}if(searchParams["breedInfos"]){for(var key in searchParams["breedInfos"]){if(breedNameTemp==""){breedNameTemp = searchParams["breedInfos"][key];breedNames = "【"+breedNameTemp+"】";}else{breedNameTemp = breedNameTemp +"," + searchParams["breedInfos"][key];breedNames = "【"+breedNameTemp+"】";}}}if(searchParams["breedNames"]){breedNames = "【"+unescape(searchParams["breedNames"])+"】";}if(searchParams["specs"]){specs = "【"+unescape(searchParams["specs"])+"】";}if(searchParams["materials"]){materials = "【"+searchParams["materials"]+"】";}if(searchParams["brands"]){brands = "【"+searchParams["brands"]+"】";}if(searchParams["warehouses"]){warehouses = "【"+unescape(searchParams["warehouses"])+"】";}if(searchParams["startThickness"]){thickness = "【厚度大于等于"+searchParams["startThickness"]+"】";}if(searchParams["endThickness"]){thickness = "【厚度小于等于"+searchParams["endThickness"]+"】";}if(searchParams["startThickness"] && searchParams["endThickness"]){thickness = "【厚度"+searchParams["startThickness"]+"-"+searchParams["endThickness"]+"】";}if(searchParams["startWidth"]){width = "【宽度大于等于"+searchParams["startWidth"]+"】";}if(searchParams["endWidth"]){width = "【宽度小于等于"+searchParams["endWidth"]+"】";}if(searchParams["startWidth"] && searchParams["endWidth"]){width = "【宽度"+searchParams["startWidth"]+"-"+searchParams["endWidth"]+"】";}if(searchParams["startPrice"]){price = "【价格大于等于"+searchParams["startPrice"]+"】";}if(searchParams["endPrice"]){price = "【价格小于等于"+searchParams["endPrice"]+"】";}if(searchParams["startPrice"] && searchParams["endPrice"]){price = "【价格"+searchParams["startPrice"]+"-"+searchParams["endPrice"]+"】";}if(searchParams["cityName"]){city = "【"+searchParams["cityName"]+"】";}if(searchParams["prBreedName"]){prBreedName = searchParams["prBreedName"];}else{prBreedName = "全部";}var content1 = "<div class='conten1'>"+"您要找的<span class='blue' id='conditions'></span>"+"在当前大类<span class='orange' id='prBreedName'></span>中暂时没有相匹配的商品。" +"</div>";var content3 = "<div class='conten3 cl'>"+"<span>对不起,没有找到相关商品!</span>"+"<a class='goods_tips_btn' href='javascript:;' onclick='findRes()'>帮我找</a>"+"</div>";var content2 = "<div class='conten2'>钢银钢材超市具有海量真实现货资源,百家钢厂、贸易商在线直销,钢材价格。钢材库存实时更新,买卖钢材无忧。</div>";var tbody = "<tbody>"+"<tr class='hasno'>"+"<td align='center' colspan='11'>"+"<div class='goods_tips cl'>"+"<div class='fl goods_tips_img'></div>"+"<div class='goods_tips_inner fl' id='info'>"+"</div>" +"</div>" +"</td>" +"</tr>" +"</tbody>";setTimeout(function(){$("#resCount").text(0);$("#middlearrow_btn").html("");$("#middlearrow_btn").append("<span>0</span>/0");$("#loading").remove();table.append(tbody);$("#info").append(content3);$("#info").append(content1);$("#info").append(content2);$("#conditions").text(city+keyword+breedNames+specs+materials+unescape(brands)+warehouses+thickness+width+price);$("#prBreedName").text(prBreedName);sendFlag = "0";},400);}/*** 展示列表信息(查询到资源)** @param resData* @param onsell*/
function showResTable(resData, onsell) {var table = $("#resList");$("#pageSpan").html("");$("#totalSpan").html("");$("#middlearrow_btn").html("");$("#loading").remove();$.each(resData.pageData,function(index) {var i = index + 1;var tbody = "<tbody id=\"summaryRes_" + i + "\"></tbody>";table.append(tbody);var tr = "<tr id=\"resource_" + i + "\"></tr>";$("#summaryRes_" + i).append(tr);var td1 = "<td id=\"breed_" + i + "\"></td>";var td2 = "<td id=\"spec_" + i + "\">" + this.spec + "</td>";var td3 = "<td id=\"material_" + i + "\">" + this.material + "</td>";var td4 = "<td id=\"brand_" + i + "\">" + this.brand + "</td>";var td5 = "<td id=\"city_" + i + "\">" + this.city + "</td>";var td6 = "<td id=\"warehouse_" + i + "\"></td>";var td7 = "<td id=\"onboardItems_" + i + "\"></td>";var td8 = "<td id=\"averageQty_" + i + "\"></td>";var td9 = "<td id=\"onboardQty_" + i + "\">" + this.onboardQty + "</td>";var td10 = "<td id=\"price_" + i + "\"></td>";var td11 = "<td align=\"center\" id=\"operate_" + i + "\"></td>";$("#resource_" + i).append(td1);$("#resource_" + i).append(td2);$("#resource_" + i).append(td3);$("#resource_" + i).append(td4);$("#resource_" + i).append(td5);$("#resource_" + i).append(td6);$("#resource_" + i).append(td7);$("#resource_" + i).append(td8);$("#resource_" + i).append(td9);$("#resource_" + i).append(td10);$("#resource_" + i).append(td11);if (i % 2 == 0) {$("#resource_" + i).attr("class", "item-data-m");} else {$("#resource_" + i).attr("class", "alt");}// 封装第一列var div1 = "<div class=\"pad-l14 t-l blue\" id=\"div1_" + i + "\"></div>";$("#breed_" + i).append(div1);var label = "<a id=\"breed_" + this.resourceId + "\" href=\"javascript:void(0);\">" + this.breed + "</a>";$("#div1_" + i).append(label);if (this.offFlag == 1) {$("#div1_" + i).append("<span class=\"ico-b ico-b-yi\" title=\"可议价!\"></span>");}if (this.relationType == 1) {$("#div1_" + i).append("<span class=\"ico-b ico-b-cang\" title=\"仓\"></span> ");} else if (this.relationType == 3) {$("#div1_" + i).append("<span title=\"融\" class=\"ico-b ico-b-rong\"></span>");}if (this.resourceItems == 1) {$("#resource_" + i).attr("onmouseover","onMouseOverDetailTr(this.id)");$("#resource_" + i).attr("onmouseout","onMouseOutDetailTr(this.id)");// 展示备注信息事件添加$("#div1_" + i).attr("onmousemove", "showNote(this);");$("#div1_" + i).attr("onmouseout", "hideNote(this);");// 备注信息内容展示if(this.realBreedAlias && (this.realBreedAlias != this.breed || this.note || this.serialNo || this.qualityFatherRemark)){var pop_bname = "<div class=\"pop-bname\" style=\"display: none;\" id=\"pop_bname_" + i + "\"></div>";var pop_bname_arrow = "<div class=\"pop-bname-arrow\">";var pop_bname_col = "<div class=\"pop-bname-col\" id=\"pop_bname_col_" + i + "\"> </div>";$("#div1_" + i).append(pop_bname);$("#pop_bname_" + i).append(pop_bname_arrow);$("#pop_bname_" + i).append(pop_bname_col);if (this.realBreedAlias && this.realBreedAlias != this.breed) {$("#pop_bname_col_" + i).append("别名:" + this.realBreedAlias);}if (this.note) {$("#pop_bname_col_" + i).append("<span>备注:" + this.note + "</span>");}if (this.serialNo) {$("#pop_bname_col_" + i).append("捆包号:" + this.serialNo);}if(this.qualityFatherRemark){$("#pop_bname_col_" + i).append("协议品:" + this.qualityFatherRemark);}}$("#averageQty_" + i).html(this.averageQty);if (this.weightWay == 0) {$("#onboardQty_" + i).attr("title", "理重");} else if (this.weightWay == 1) {$("#onboardQty_" + i).attr("title", "过磅");} else {$("#onboardQty_" + i).attr("title", "抄码");}var div8 = "<div class=\"cl\" id=\"div8_" + i + "\"></div>";$("#operate_" + i).append(div8);var div9 = "<div class=\"operate\" id=\"div9_" + i + "\"></div>";$("#div8_" + i).append(div9);if (onsell=="true") {if (this.isOutDate == "1") {var span1 = "<span  class=\"btn-buy-gray\" >待挂牌</span>";$("#div9_" + i).append(span1);} else {var cart = "<a class=\"buy btnCart\" href=\"javascript:void(0);\" onclick=\"addCartv6('"+ this.resourceId+ "','0','1','"+ this.onboardPrice+ "','"+ this.onboardQty+ "','"+ this.averageQty+ "',1,this);\">购买</a>"+ "<div class=\"pop-addcart\">"+ "<div class=\"pop-addcart-arrow\"></div>"+ "<div class=\"pop-addcart-col\">"+ "<div class=\"tcon\">已成功添加到购物车</div>"+ "<div class=\"t\">共计<span class=\"orange\" id=\"averageQtyTotalTempPop\"></span>吨 <span class=\"orange\" id=\"itemTotalTempPop\"></span>件 <span class=\"orange\" id=\"priceTotalTempPop\"></span></div>"+ "<div class=\"pop-addcart-operate\">" + "<input type=\"button\" value=\"去结算\" class=\"btn-js\" name=\"\" onclick=\"goCar();\">"+ "<input type=\"button\" value=\"继续购物\" class=\"btn-gobuy\" name=\"\">" + "</div></div></div>";$("#div9_" + i).append(cart);$(".btn-gobuy").attr("onclick","goBuy()");}} else {$("#div9_" + i).append("<a href=\"javascript:void(0);\" class=\"buy-gray\">已闭市</a>");}// 当无明细时操作列展示元素添加var div10 = "<div class=\"chat f-fl\">"+ "<a class=\"img\" href=\"javascript:void(0);\" onclick=\"showAdmin(this);\"></a>"+ "<div class=\"pop-tel\" style=\"display: none;\">"+ this.marketAdminName+ "<a class=\"link\" href=\"http://b.qq.com/webc.htm?new=0&sid=4001618891&eid=218808P8z8p8y8Q8P8y8K&o=banksteel.com&q=7&ref=http://www.banksteel.com/\" target=\"_blank\">87325713</a>"+ "<br>电话:" + this.marketPhone + "<br>手机:" + this.marketMobile + "</div><div class=\"pop-tel-arrow\" style=\"display: none;\"></div></div>";$("#div8_" + i).append(div10);}if (this.resourceItems > 1) {// 添加点击展示明细事件$("#summaryRes_" + i).attr("class","item-data");$("#resource_" + i).attr("onmouseover","onMouseOverSummaryTr(this.id)");$("#resource_" + i).attr("onmouseout","onMouseOutSummaryTr(this.id)");$("#breed_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");$("#spec_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");$("#material_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");$("#brand_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");$("#city_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");$("#onboardItems_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");$("#averageQty_" + i).html("-");$("#onboardQty_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");$("#price_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");$("#operate_" + i).attr("onclick", "showDetail(this,'" + this.summaryCode + "'," + i + ");");// 当有明细时操作列元素添加var div7 = "<div class=\"cl\"><div class=\"operate\"><a class=\"btn-open btnoff\" href=\"javascript:void(0);\" id=\"btnopen\" >展开</a><div class=\"table_hover\" >"+ "<div class=\"table_hover_left\" style=\"display: none;\"></div>" + "<div class=\"table_hover_right\"  style=\"display: none;\"></div>"+ "<div class=\"table_hover_top\" style=\"display: none;\"></div>" + "<div class=\"table_hover_bottom\" style=\"display: none;\"></div>" + "</div></div></div>";$("#operate_" + i).append(div7);}// 价格列元素封装if (onsell=="true") {if (this.isOutDate == "1") {var b2 = "<b class=\"f14 gray\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-</b>";$("#price_" + i).append(b2);} else {var b3 = "<b class=\"f14 orange\">" + this.onboardPrice + "</b>";$("#price_" + i).append(b3);}}else {var b4 = "<b class=\"f14 orange\">" + this.onboardPrice + "</b>";$("#price_" + i).append(b4);}// 封装仓库列var div5 = "<div class=\"warehouse-name\" id=\"div5_" + i + "\"></div>";var href = "<a class=\"t-warehouse\" href=\"javascript:void(0);\" id=\"href_" + i + "\">" + this.warehouse + "</a>";$("#warehouse_" + i).append(div5);$("#div5_" + i).append(href);$("#href_" + i).attr("onclick", "showWarehouseInfo(this,'" + this.warehouseName + "'," + i + ");");$("#div5_" + i).attr("onmouseout", "hideWarehouse(this)");// 封装数量列var div6 = "<div class=\"pad-l7\">" + this.onboardItems + "</div>";$("#onboardItems_" + i).append(div6);var input = "<input type=\"hidden\" id=\"cityId_" + i + "\" value='" + this.cityId + "'/>";$("#resource_" + i).append(input);});// 分页$("#currPageNum").val(resData.currPageNum);$("#totalPages").val(resData.totalPages);$("#totalRows").val(resData.totalRows);$(".page").attr("style", "display:block");// 资源统计展示$("#resCount").text(resData.totalRows);$("#middlearrow_btn").append("<span>" + resData.currPageNum + "</span>/" + resData.totalPages);page();sendFlag = "0";
}/*** 使用searchParams直接进行查询*/
function directSearchByParam() {// 初始化resListInit();// 关键字中含城市keyWordIsCity();// 设置选中效果setAttrParams();// 展示当前查询条件showParams();// 有收索字段时添加记录if((searchParams["keyword"]!="" && typeof(searchParams["keyword"])!="undefined") || (searchParams["breedIds"]!="" && typeof(searchParams["breedIds"])!="undefined" )||(searchParams["breedNames"]!="" && typeof(searchParams["breedNames"])!="undefined")||(searchParams["specs"]!="" && typeof(searchParams["specs"])!="undefined") || (searchParams["materials"]!="" && typeof(searchParams["materials"])!="undefined" )||(searchParams["brands"]!="" && typeof(searchParams["brands"])!="undefined")|| (searchParams["warehouses"]!="" && typeof(searchParams["warehouses"])!="undefined")||(searchParams["cityId"]!="" && typeof(searchParams["cityId"])!="undefined")|| (searchParams["startPrice"]!="" && typeof(searchParams["startPrice"])!="undefined")||(searchParams["endPrice"]!=""&&typeof(searchParams["endPrice"])!="undefined")){addRecords(searchParams);}// 通过ajax请求超市资源(为防止ajax请求过于频繁,导致页面内容重叠,使用sendFlag,下一次请求只能在这次请求完成后继续进行)if(sendFlag == "0"){sendFlag = "1";$.ajax({type : "post",data : searchParams,url : "/resource/searchSuperMarketResource.jsp",timeout:60000,dataType : "text",success : function(message) {if (message != null && message != ""){var map = $.parseJSON(message);var onsell = $("#onSellValue").val();if (map["pageSet"] != null) {setTimeout(function(){showResTable(map["pageSet"], onsell);},300);}}else {noRes();}    },error : function() {alert("程序内部发生错误,请联系管理员");}});}
}/*** 查询方法(分页和排序自动回复默认)** @param params*/
function searchByParams() {searchParams["pageNum"] = 1;setDefaultSort();directSearchByParam();
}/*** 展示汇总下面的明细*/
function showDetail(obj,summaryCode,count){var btnOpenClass = $(obj).parent().find("#operate_"+count).find("#btnopen").attr("class");if(btnOpenClass == "btn-open btnoff"){$(obj).parent().find("#operate_"+count).find("#btnopen").text("收起");}else{$(obj).parent().find("#operate_"+count).find("#btnopen").text("展开");}var tableBody=$("#summaryRes_"+count);// 取得onSell的值var onSell=$("#onSellValue").val();// 判断如果旗下已经加载了明细则直接展示不增加var trLength=tableBody.children("tr").length;if(trLength>1){var hiddenRows = tableBody.children('tr:hidden').length;var fold_btn=$("#fold_btn_"+summaryCode);if(hiddenRows>0){// 展开的全部缩起来foldAllDetail();openDetail(fold_btn);configDetailEdage(count);}else{foldDetail(fold_btn);}}else{// 加载等待图标var showWait="<tr class='item-data-detail'  id='"+'showWait_'+count+"' style='display:table-row'> <td align='center'  colspan='11'><img height='24' width='24' src='/skin/images/loading.gif'></td></tr>";tableBody.append(showWait);$.ajax({     type: "Post",     url: "/resource/getMarketResourceDetail.jsp?callback=?",     // 查询该汇总下的明细列表// 方法传参的写法一定要对,str为形参的名字,str2为第二个形参的名字"data" : {"summaryId" : summaryCode},dataType: "jsonp",     success : function(json){// 展开的全部缩起来foldAllDetail();// 返回的数据列表在 json.returnStr中循环并展示var resArr=json.returnStr;var b='';for (var i=0;i<resArr.length;i++){var txt='';if(i%2==0){txt="<tr  class='item-data-detail'  onMouseOver='this.className=\"item-data-detail thover over\"' onMouseOut='this.className=\"item-data-detail\"'><td ><div class='pad-l14 t-l blue' onmousemove='showNote(this);' onmouseout='hideNote(this);'>" +resArr[i].breed  ;}else{txt="<tr  class='item-data-detail alt'  onMouseOver='this.className=\"item-data-detail thover over\"' onMouseOut='this.className=\"item-data-detail alt\"'><td ><div class='pad-l14 t-l blue' onmousemove='showNote(this);' onmouseout='hideNote(this);'>" +resArr[i].breed  ;}// 加载资源类型图片var pic1='';if(resArr[i].offFlag=="1"){pic1="<span class='ico-b ico-b-yi' title='可议价!'></span>";}var pic2='';if(resArr[i].relationType=="1"){pic2="<span class='ico-b ico-b-cang' title='仓'></span>";}if(resArr[i].relationType=="3"){pic2="<span title='融' class='ico-b ico-b-rong'></span>";}var detailPic=pic1+pic2;// 备注和别名的内容var aliasAndNote='';// 别名和备注domvar detailAlias='';if(resArr[i].realBreedAlias !=null && resArr[i].realBreedAlias!=''){aliasAndNote=aliasAndNote+"别名:"+resArr[i].realBreedAlias;}if(resArr[i].note !=null && resArr[i].note!=''){aliasAndNote=aliasAndNote+" 备注:"+resArr[i].note+"<br>";}if(resArr[i].serialNo !=null && resArr[i].serialNo!=''){aliasAndNote=aliasAndNote+" 捆包号:"+resArr[i].serialNo;}if(aliasAndNote!=''){detailAlias="<div class='pop-bname' style='display: none;'> <div class='pop-bname-arrow'></div> <div class='pop-bname-col'>" +aliasAndNote+"</div> </div> </div></td>";}// 规格var detailSpec="<td>"+resArr[i].spec+"</td>";// 材质var detailMaterial="<td>"+resArr[i].material+"</td>";// 钢厂var detailBrand="<td>"+resArr[i].brand+"</td>";// 交货地var detailCity="<td>"+resArr[i].city+"</td>";// 仓库var detailWarehouse="<td><div  class='warehouse-name'" +"><a class='t-warehouse'"+"onclick=\"showWarehouseInfo(this,'"+resArr[i].warehouseName+"',"+ count +");\"  "+"href='javascript:void(0);' >"+resArr[i].warehouse+"</a></div></td>";// 数量var detailNum="<td><div class='pad-l7'>"+resArr[i].onboardItems+"</div></td>";var detailQtyTitle='';if(resArr[i].weightWay==0){detailQtyTitle="title=理重";}else if(resArr[i].weightWay==1){detailQtyTitle="title=过磅";}else{detailQtyTitle="title=抄码";}// 重量var detailQty="<td "+detailQtyTitle+">"+resArr[i].onboardQty+"</td>";var detailAverageQty="<td>" + resArr[i].averageQty +"</td>";// 价格的内容var priceInfo='';if(onSell=='true'){if(resArr[i].status==null||resArr[i].status==0||resArr[i].status==""){priceInfo="<b class='f14 orange'>"+未挂牌+"</b>";}else{if(resArr[i].isOutDate==1){priceInfo="<b class='f14 gray'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-</b>";}else{priceInfo="<b class='f14 orange'>"+parseFloat(resArr[i].onboardPrice)+"</b>";}}}else{priceInfo="<b class='f14 orange'>"+parseFloat(resArr[i].onboardPrice)+"</b>";}var detailPrice="<td class='price'>"+priceInfo+"</td>";// 联系人和联系方式var detailCallWay="<div class='chat f-fl'><a  onclick='showAdmin(this);' class='img' href='javascript:void(0);'></a> <div class='pop-tel' style='display: none;'> "+ resArr[i].marketAdminName + " <a class='link' target='_blank' href='http://b.qq.com/webc.htm?new=0&sid=4001618891&eid=218808P8z8p8y8Q8P8y8K&o=banksteel.com&q=7&ref=http://www.banksteel.com/'>4001618891</a><br>电话:"+ resArr[i].marketPhone + "<br>手机:"+ resArr[i].marketMobile + "</div><div class='pop-tel-arrow' style='display: none;'></div> </div>";// 购买框显示的内容var buyValue='';if(onSell=='true'){if(resArr[i].isOutDate=='1'){buyValue="<span  class='btn-buy-gray'>待挂牌</span>";}else{buyValue="<a class='buy btnCart' href='javascript:void(0);'  onclick='addCartv6("+resArr[i].resId+","+resArr[i].shopId+","+resArr[i].channelType+","+resArr[i].onboardPrice+","+resArr[i].onboardQty+","+resArr[i].averageQty +",1,this);'>购买</a>" +"<div class='pop-addcart'>" +"<div class='pop-addcart-arrow'></div>" +"<div class='pop-addcart-col'>" +"<div class='tcon'>已成功添加到购物车</div>" +"<div class='t'>共计<span class='orange' id='averageQtyTotalTempPop'></span>吨 <span class='orange' id='itemTotalTempPop'></span>件 <span class='orange' id='priceTotalTempPop'></span></div>" +"<div class='pop-addcart-operate'>" +"<input type='button' value='去结算' class='btn-js' name='' onclick='goCar();'>" +"<input type='button' value='继续购物' class='btn-gobuy' name='' onclick='closePopCart(this);'>" +"</div>" +"</div>" +"</div>";}}else{buyValue="<a href='javascript:void(0);' class='buy-gray'>已闭市</a>";}// 购买domvar detailBuy="<td> <div class='cl'> <div class='operate'> "+buyValue+"</div>"+detailCallWay+"</div> </td>"+"</tr>";b=b+txt+detailPic+detailAlias+detailSpec+detailMaterial+detailBrand+detailCity+detailWarehouse+detailNum+detailAverageQty+detailQty+detailPrice+detailBuy;}$("#showWait_"+count).remove();tableBody.append(b);// 绑定子仓库移出后消失的事件$(".warehouse-name").mouseleave(function(){$(".pop-warehouse,.pop-warehouse-arrow").hide();});tableBody.children(".item-data-detail").mouseleave(function(){$(".pop-warehouse,.pop-warehouse-arrow").hide();});// 增加折叠行var fold=$("<tr class='item-data-detail' ><td align='center' colspan='11'> <span id='fold_btn_"+summaryCode+"' class='btn-blue-back140' onclick='foldDetail(this);' >点击折叠资源</span></td></tr>");tableBody.append(fold);openDetail(fold);configDetailEdage(count);},error :function(){$("#showWait_"+count).remove();// 增加暂无数据行var noData="<tr class='item-data-detail' ><td align='center' colspan='11'> <div class='pad-l14 blue'><label>资源下架或已售罄,请稍后...</label></div></td></tr>";// 增加折叠行var fold=$(noData+"<tr class='item-data-detail' ><td align='center' colspan='11'> <span id='fold_btn_"+summaryCode+"' class='btn-blue-back140' onclick='foldDetail(this);' >点击折叠资源</span></td></tr>");tableBody.append(fold);openDetail(fold);configDetailEdage(count);}   });   }
}function onMouseOverSummaryTr(id){$("#"+id).attr("class","item-data-m alt thover over");
}function onMouseOutSummaryTr(id){var index = id.split("_")[1];if (index % 2 == 0) {$("#resource_" + index).attr("class", "item-data-m");} else {$("#resource_" + index).attr("class", "alt");}
}function onMouseOverDetailTr(id){$("#"+id).attr("class","thover over");
}function onMouseOutDetailTr(id){var index = id.split("_")[1];if (index % 2 == 0) {$("#resource_" + index).attr("class", "item-data-m");} else {$("#resource_" + index).attr("class", "alt");}
}/*** 展示仓库信息*/
function showWarehouseInfo(obj,warehouseName,count){// 如果已经加载了仓库信息 则直接把旗下仓库信息展现出来即可if($(obj).parents(".warehouse-name").find(".pop-warehouse-arrow").length > 0 ){$(obj).parents(".warehouse-name").find(".pop-warehouse").show();$(obj).parents(".warehouse-name").find(".pop-warehouse-arrow").show();return}// 获取城市Idvar cityIdName="#cityId_"+count;var cityId=$(cityIdName).val();$.ajax({     type: "Post",     url: "/resource/getWarehouseInfo.jsp?callback=?",     // 查询该汇总下的明细列表// 方法传参的写法一定要对,str为形参的名字,str2为第二个形参的名字"data" : {"warehouse" : warehouseName,"cityId" : cityId},dataType: "jsonp",     success : function(json){var txt=json.returnStr;// 仓库名字var detailName= "<strong class='f14 orange'>"+txt.name+"</strong>";// 仓库地址var detailAdd="<br><strong>仓库地址:</strong>"+txt.address+"<br>";// 联系电话var detailPhone="<strong>联系电话:</strong>"+txt.phone;// 拼装仓库信息展示元素var warehouseInfo= "<div class='pop-warehouse' style='display: none;'>"+detailName+detailAdd+detailPhone+"</div> <div class='pop-warehouse-arrow' style='display: none;'></div>";$(obj).parents(".warehouse-name").append(warehouseInfo);// 展示出仓库信息$(obj).parents(".warehouse-name").find(".pop-warehouse").show();$(obj).parents(".warehouse-name").find(".pop-warehouse-arrow").show();},error:function(){}   });   
}/*** 隐藏仓库信息** @param obj*/
function hideWarehouse(obj){$(obj).children(".pop-warehouse,.pop-warehouse-arrow").hide();    
}/*** 展示备注等*/
function showNote(obj){$(obj).find(".pop-bname").show();
}
/*** 移开消失备注*/
function hideNote(obj){$(obj).find(".pop-bname").hide();
}function onMouseOver(obj,count){var aId=$(obj).attr("class");if(aId=="select"||aId=="more select"||aId=="selected"||aId=="more selected"){return;}$(obj).addClass("hover");var spanId="#brandSpan_"+count;$(spanId).addClass("border");
}function onMouseOut(obj,count){$(obj).removeClass("hover");var spanId="#brandSpan_"+count;$(spanId).removeClass("border");
}function foldAllDetail(){$('.item-data').find(".table_hover .table_hover_left").css("display","none");$('.item-data').find(".table_hover .table_hover_right").css("display","none");$('.item-data').find(".table_hover .table_hover_top").css("display","none");$('.item-data').find(".table_hover .table_hover_bottom").css("display","none");$('.item-data').removeClass("show");$('.item-data').find(".item-data-detail").hide();$('.item-data').find(".btn-open").text("展开");$('.item-data').find(".btn-open").addClass("btnoff");
}/*** 点击折叠*/
function foldDetail(obj){var index = $(obj).parents(".item-data").attr("id").split("_")[1];if (index % 2 == 0) {$(obj).parents(".item-data").find(".table_hover .table_hover_left").css("display","none");$(obj).parents(".item-data").find(".table_hover .table_hover_right").css("display","none");$(obj).parents(".item-data").find(".table_hover .table_hover_top").css("display","none");$(obj).parents(".item-data").find(".table_hover .table_hover_bottom").css("display","none");} else {$(obj).parents(".item-data").find(".alt .table_hover_left").css("display","none");$(obj).parents(".item-data").find(".alt .table_hover_right").css("display","none");$(obj).parents(".item-data").find(".alt .table_hover_top").css("display","none");$(obj).parents(".item-data").find(".alt .table_hover_bottom").css("display","none");}$(obj).parents(".item-data").removeClass("show");$(obj).parents(".item-data").find(".item-data-detail").hide();$(obj).parents(".item-data").find(".btn-open").text("展开");$(obj).parents(".item-data").find(".btn-open").addClass("btnoff");}function openDetail(obj){$(obj).parents(".item-data").find(".item-data-m .table_hover div").css("display","block");$(obj).parents(".item-data").addClass("show");$(obj).parents(".item-data").find(".item-data-detail").show();$(obj).parents(".item-data").find(".btn-open").text("收起");$(obj).parents(".item-data").find(".btn-open").removeClass("btnoff");$(obj).parents(".table_hover .table_hover_bottom").css("top","11px");$(obj).parents(".table_hover .table_hover_left").css("height","44px");$(obj).parents(".table_hover .table_hover_right").css("height","44px");
}function configDetailEdage(index){var edage=$("#summaryRes_"+index);edage.find('.table_hover div').css("display","block");var hbottom=edage.height()-38;var hlefet=edage.height();edage.find(".table_hover .table_hover_bottom").css("top",hbottom+"px");edage.find(".table_hover .table_hover_left").css("height",hlefet+"px");edage.find(".table_hover .table_hover_right").css("height",hlefet+"px");
}/*** 点击展示联系人等*/
function showAdmin(obj){// 先把打开的关掉if($(obj.target).attr('class')!='img'){$('.pop-tel,.pop-tel-arrow').hide();}$(obj).parents(".chat").find(".pop-tel").show();$(obj).parents(".chat").find(".pop-tel-arrow").show();
}/*** 点击其他地方消除联系方式*/
$(document).click(function(ee){if($(ee.target).attr('class')!='img'){$('.pop-tel,.pop-tel-arrow').hide();}});$('.pop-tel,.pop-tel-arrow').click(function(ee){if(ee && ee.stopPropagation()){ee.stopPropagation();}else{ee.cancelBubble=true;}});/*** 抛物线形式加入购物车以及弹出pop操作** @param currentObj*/
function goCart(currentObj){// 元素以及其他一些变量var eleFlyElement = $("#flyItem")[0], eleShopCart = $(".fc-cart-item")[0];// 抛物线运动var myParabola = funParabola(eleFlyElement, eleShopCart, {speed: 200,curvature: 0.002,    complete: function() {eleFlyElement.style.display = "none";}});// 绑定点击事件if (eleFlyElement && eleShopCart) {// 滚动大小eleFlyElement.style.display = "block";eleFlyElement.style.left = $(currentObj).offset().left + "px";eleFlyElement.style.top = $(currentObj).offset().top +"px";// 需要重定位myParabola.position().move();var fcl = document.getElementById('flyItem').offsetLeft - 10;document.getElementById('flyItem').style.left=fcl+'px';$(currentObj).removeAttr("onclick");$(currentObj).attr("class","buy-gray");$(currentObj).attr("class","buy-gray");$(currentObj).text("已购买");}
}/*** 传入参数拼装成cookie*/
function getCookieValue(resourceId, shopId, channelType, price, qty, averageQty , items)
{// 返回数据格式:资源ID+shopId+资源类型+价格+ 数量+件重return resourceId + "_" + shopId + "_" + channelType + "_" + price + "_" + qty + "_" + averageQty + "_" + items;
}/*** 将资源相关信息加入购物车** @param name* @param resourceId* @param shopId* @param price* @param qty* @param averageQty* @param channelType* @param currentObj*/
function SetCookiev6(name, resourceId, shopId, price, qty, averageQty, items, channelType,currentObj)
{var cookieValue = $.cookie(name);if (cookieValue != null && cookieValue != "")  // 如果存在 则累加{var uneacapeCookieValue = unescape(cookieValue);  // 解码if(uneacapeCookieValue.indexOf(resourceId)==-1){uneacapeCookieValue += "," + getCookieValue(resourceId, shopId, channelType, price, qty, averageQty,items);$.cookie(name, escape(uneacapeCookieValue), {expires: 30, domain:'banksteel.com', path: '/'});}changeShortCarListv6(uneacapeCookieValue);  // 更新购物车数据}else    // 如果不存在Cookie 创建{var values = getCookieValue(resourceId, shopId, channelType, price, qty, averageQty,items);$.cookie(name, escape(values), {expires: 30, domain:'banksteel.com', path: '/'});var cookieValue = $.cookie(name);changeShortCarListv6(unescape(cookieValue));  // 更新购物车数据}
}// 关闭该窗体
function closePopCart(currentObj)
{$(currentObj).parent().parent().parent(".pop-addcart").css("display","none");
}// 更新购物车数据 参数为未加密的Cookie
function changeShortCarListv6(cookieValue)
{var qtySum = 0;var priceSum = 0;var averageQtySum = 0;var priceTotal = 0;var itemTotal = 0;if(!cookieValue){$('#rcart_top').html(0);$('#rcart').html(0);$('#cartCountNav').html(0);$('#cartCountNav1').html(0);$('#itemTotalTemp').html(0);$('#averageQtyTotalTemp').html(0.0000);$('#priceTotalTemp').html(0.00);return;}var values = cookieValue.split(',');for (var i = 0; i < values.length; i++){var averageQty1 = parseFloat(values[i].split("_")[5]);var qty1 =  parseFloat(values[i].split("_")[4]);var price1 = parseFloat(values[i].split("_")[3]);var items = parseInt(values[i].split("_")[6]);var oneResourcePrice = MyNumber.precision(MyNumber.mul(averageQty1,price1),4);priceTotal = MyNumber.add(MyNumber.precision(parseFloat(priceTotal),2),MyNumber.precision(parseFloat(MyNumber.mul(oneResourcePrice,items)),2),2);averageQtySum = MyNumber.add(MyNumber.precision(parseFloat(averageQtySum),4),MyNumber.precision(parseFloat(MyNumber.mul(averageQty1,items)),4),4);qtySum = MyNumber.add(MyNumber.precision(parseFloat(qtySum),4),MyNumber.precision(parseFloat(qty1),4),4);priceSum = MyNumber.add(MyNumber.precision(parseFloat(priceSum),2),MyNumber.precision(parseFloat(price1),2),2);itemTotal = items + itemTotal;}$('#rcart_top').html(itemTotal);$('#rcart').html(itemTotal);$('#cartCountNav').html(itemTotal);$('#cartCountNav1').html(itemTotal);$('#itemTotalTemp').html(itemTotal);$('#averageQtyTotalTemp').html(averageQtySum);$('#priceTotalTemp').html(priceTotal);
}function orFade(currentObj)
{$(currentObj).siblings(".pop-addcart").show();
}/*** 如果关键词是交货地,则按交货地查询*/
function keyWordIsCity(){if(searchParams["keyword"] != null && searchParams["keyword"] != ""  && searchParams["keyword"] != "undefiend" && typeof(searchParams["keyword"])!="undefiend"){var keyword = searchParams["keyword"];var cityMap = $.parseJSON(cities);var cityId = "";var cityName = "";for(var key in cityMap){if(unescape(keyword).indexOf(cityMap[key])>= 0){if (cityId == "") {cityId += key;cityName += cityMap[key];} else {cityId += "," + key;cityName += "," + cityMap[key];}}}searchParams["cityId"]=cityId;searchParams["cityName"]=cityName;}
}// 展示查询条件
function showParams() {var cityName = searchParams["cityName"];// 当前城市展示if(cityName==null || cityName==""){$(".selects").text("交货地 :  ");$("#cityName").text("全国");}else{if(typeof(cityName) == "undefined"){$(".selects").text("交货地 :  ");$("#cityName").text("全国");}else{var cityNameMutiList = cityName.split(",");if(cityNameMutiList.length == 1){$(".selects").text("交货地 :"+searchParams["cityName"]);$("#cityName").text(searchParams["cityName"]);}else{$(".selects").text("交货地 : ");$("#cityName").text("全国");}}    }var flagRight = false;$("#cityDiv").remove();if (cityName != null && cityName != "" && typeof(cityName) != "undefined") {flagRight = true;var cityDiv = "<div class=\"filter\"  id=\"cityDiv\"><div class=\"fl\">城市:</div><div class=\"fl\">" + unescape(cityName) + "<span id=\"citySpan\"></span></div>";$("#searchCondition").append(cityDiv);$("#citySpan").attr("onclick", "setSearchParams('cityName');setSearchParams('cityId');searchByParams()");}$("#breedDiv").remove();if (searchParams["breedInfos"] != null && searchParams["breedInfos"] != "") {var breedNames = "";var breedIds = "";var breedInfos = searchParams["breedInfos"];for ( var breedId in breedInfos) {var breedName = breedInfos[breedId];if (breedName != "") {if (breedNames == "") {breedNames += breedName;} else {breedNames += "," + breedName;}}if (breedId != "") {if (breedIds == "") {breedIds += breedId;} else {breedIds += "," + breedId;}}}searchParams["breedNames"] = "";searchParams["breedIds"] = breedIds;var breedDiv = "<div class=\"filter\" id=\"breedDiv\"><div class=\"fl\">品种:</div><div class=\"fl\">" + unescape(breedNames) + "<span id=\"breedSpan\"></span></div>";flagRight = true;$("#searchCondition").append(breedDiv);$("#breedSpan").attr("onclick", "setSearchParams('breedNames');setSearchParams('breedIds');setSearchParams('breedInfos');searchByParams()");} else {var breedNames = searchParams["breedNames"];if (breedNames != null && breedNames != "" && typeof(breedNames) != "undefined") {var breedDiv = "<div class=\"filter\" id=\"breedDiv\"><div class=\"fl\">品种:</div><div class=\"fl\">" + unescape(breedNames) + "<span id=\"breedSpan\"></span></div>";flagRight = true;$("#searchCondition").append(breedDiv);$("#breedSpan").attr("onclick", "setSearchParams('breedNames');setSearchParams('breedIds');setSearchParams('breedInfos');searchByParams()");}}$("#specDiv").remove();var specs = searchParams["specs"];if (specs != null && specs != "" && typeof(specs) != "undefined") {flagRight = true;var specDiv = "<div class=\"filter\" id=\"specDiv\"><div class=\"fl\">规格:</div><div class=\"fl\">" + unescape(specs) + "<span id=\"specSpan\"></span></div>";$("#searchCondition").append(specDiv);$("#specSpan").attr("onclick", "setSearchParams('specs');searchByParams()");}$("#materialDiv").remove();var materials = searchParams["materials"];if (materials != null && materials != "" && typeof(materials) != "undefined") {flagRight = true;var materialDiv = "<div class=\"filter\" id=\"materialDiv\"><div class=\"fl\">材质:</div><div class=\"fl\">" + unescape(materials) + "<span id=\"materialSpan\"></span></div>";$("#searchCondition").append(materialDiv);$("#materialSpan").attr("onclick", "setSearchParams('materials');searchByParams()");}$("#brandDiv").remove();var brands = searchParams["brands"];if (brands != null && brands != ""  && typeof(brands) != "undefined") {flagRight = true;var brandDiv = "<div class=\"filter\" id=\"brandDiv\"><div class=\"fl\">钢厂:</div><div class=\"fl\">" + unescape(brands) + "<span id=\"brandSpan\"></span></div>";$("#searchCondition").append(brandDiv);$("#brandSpan").attr("onclick", "setSearchParams('brands');searchByParams()");}$("#keywordDiv").remove();var keyword = searchParams["keyword"];if (keyword != null && keyword != "" && typeof(keyword) != "undefined") {flagRight = true;var keywordDiv = "<div class=\"filter\" id=\"keywordDiv\"><div class=\"fl\">关键字:</div><div class=\"fl\">" + unescape(keyword) + "<span id=\"keywordSpan\"></span></div>";$("#searchCondition").append(keywordDiv);$("#keywordSpan").attr("onclick", "setSearchParams('keyword');searchByParams();cleanKeyword();");}$("#warehouseDiv").remove();var warehouses = searchParams["warehouses"];if (warehouses != null && warehouses != "") {var warehouseDiv = "<div class=\"filter\" id=\"warehouseDiv\"><div class=\"fl\">仓库:</div><div class=\"fl\">" + unescape(warehouses) + "<span id=\"warehouseSpan\"></span></div>";flagRight = true;$("#searchCondition").append(warehouseDiv);$("#warehouseSpan").attr("onclick", "setSearchParams('warehouses');searchByParams()");}$("#priceRangeDiv").remove();var startPrice = searchParams["startPrice"];var endPrice = searchParams["endPrice"];var i = 0;var j = 0;if (startPrice != null && startPrice != "") {i++;j = 1;}if (endPrice != null && endPrice != "") {i++;j = 2;}if (i == 2) {var priceRangeDiv = "<div class=\"filter\" id=\"priceRangeDiv\"><div class=\"fl\">价格:</div><div class=\"fl\">" + startPrice + "-" + endPrice+ "</div><span id=\"priceRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(priceRangeDiv);$("#priceRangeSpan").attr("onclick", "setSearchParams('startPrice');setSearchParams('endPrice');searchByParams()");}if (i == 1 && j == 1) {$("#pr1").val(startPrice);var priceRangeDiv = "<div class=\"filter\" id=\"priceRangeDiv\"><div class=\"fl\">价格:</div><div class=\"fl\">大于等于" + startPrice + "</div><span id=\"priceRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(priceRangeDiv);$("#priceRangeSpan").attr("onclick", "setSearchParams('startPrice');setSearchParams('endPrice');searchByParams()");}if (i == 1 && j == 2) {$("#pr2").val(endPrice);var priceRangeDiv = "<div class=\"filter\" id=\"priceRangeDiv\"><div class=\"fl\">价格:</div><div class=\"fl\">小于等于" + endPrice + "</div><span id=\"priceRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(priceRangeDiv);$("#priceRangeSpan").attr("onclick", "setSearchParams('startPrice');setSearchParams('endPrice');searchByParams()");}i = 0;j = 0;$("#thicknessRangeDiv").remove();var startThickness = searchParams["startThickness"];var endThickness = searchParams["endThickness"];if (startThickness != null && startThickness != "") {i++;j = 1;}if (endThickness != null && endThickness != "") {i++;j = 2;}if (i == 2) {var thicknessRangeDiv = "<div class=\"filter\" id=\"thicknessRangeDiv\"><div class=\"fl\">厚度:</div><div class=\"fl\">" + startThickness + "-" + endThickness+ "</div><span id=\"thicknessRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(thicknessRangeDiv);$("#thicknessRangeSpan").attr("onclick", "setSearchParams('startThickness');setSearchParams('endThickness');searchByParams()");}if (i == 1 && j == 1) {var thicknessRangeDiv = "<div class=\"filter\" id=\"thicknessRangeDiv\"><div class=\"fl\">厚度:</div><div class=\"fl\">大于等于" + startThickness+ "</div><span id=\"thicknessRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(thicknessRangeDiv);$("#thicknessRangeSpan").attr("onclick", "setSearchParams('startThickness');setSearchParams('endThickness');searchByParams()");}if (i == 1 && j == 2) {var thicknessRangeDiv = "<div class=\"filter\" id=\"thicknessRangeDiv\"><div class=\"fl\">厚度:</div><div class=\"fl\">小于等于" + endThickness+ "</div><span id=\"thicknessRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(thicknessRangeDiv);$("#thicknessRangeSpan").attr("onclick", "setSearchParams('startThickness');setSearchParams('endThickness');searchByParams()");}i = 0;j = 0;$("#widthRangeDiv").remove();var startWidth = searchParams["startWidth"];var endWidth = searchParams["endWidth"];if (startWidth != null && startWidth != "") {i++;j = 1;}if (endWidth != null && endWidth != "") {i++;j = 2;}if (i == 2) {var widthRangeDiv = "<div class=\"filter\" id=\"widthRangeDiv\"><div class=\"fl\">宽度:</div><div class=\"fl\">" + startWidth + "-" + endWidth+ "</div><span id=\"widthRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(widthRangeDiv);$("#widthRangeSpan").attr("onclick", "setSearchParams('startWidth');setSearchParams('endWidth');searchByParams()");}if (i == 1 && j == 1) {var widthRangeDiv = "<div class=\"filter\" id=\"widthRangeDiv\"><div class=\"fl\">宽度:</div><div class=\"fl\">大于等于" + startWidth + "</div><span id=\"widthRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(widthRangeDiv);$("#widthRangeSpan").attr("onclick", "setSearchParams('startWidth');setSearchParams('endWidth');searchByParams()");}if (i == 1 && j == 2) {var widthRangeDiv = "<div class=\"filter\" id=\"widthRangeDiv\"><div class=\"fl\">宽度:</div><div class=\"fl\">小于等于" + endWidth + "</div><span id=\"widthRangeSpan\"></span></div>";flagRight = true;$("#searchCondition").append(widthRangeDiv);$("#widthRangeSpan").attr("onclick", "setSearchParams('startWidth');setSearchParams('endWidth');searchByParams()");}$("#cleanDiv").remove();if (searchParams !=null && searchParams != "" && typeof(searchParams) != "undefined"){if (flagRight == true) {var cleanDiv = "<div class=\"btn-filter-clear\" style=\"display:block;\" id=\"cleanDiv\">清除全部</div>";$("#searchCondition").append(cleanDiv);$(".btn-filter-clear").attr("onclick", "searchParams={};ci='';searchByParams({});cleanKeyword()");}}if(flagRight == true){$("#leftspn").show();}else{$("#leftspn").hide();}
}/*** 清除关键字*/
function cleanKeyword()
{$("input[name='kw']").val("");$("#kwInput1").val("");
}/*** 重设查询参数*/
function setSearchParams(field)
{searchParams[field] = "";
}/*** 帮我找*/
function findRes(){goodsBtn = dialog({id: 'goods_tips_btn',title: '钢银找货',url: '/shop/market/v6/hasno_dialog.html',width:'400',height:'230',fixed:true});Autofixed('#goods_tips_btn',goodsBtn) ;goodsBtn.showModal();return false;
}/*** 大类名跳转要带交货地* @param url*/
function redirect(url){var ci = searchParams["cityId"];if(!ci){ci="";ct="quangguo";url = url+"?ct="+ct;}else{url = url+"?ci="+ci;}window.location.href=url;
}

http://www.mrgr.cn/news/96903.html

相关文章:

  • whisper 语音识别的安装与使用
  • LeetCode 解题思路 30(Hot 100)
  • GitHub高级筛选小白使用手册
  • Spring AI MCP Server + Cline 快速搭建一个数据库 ChatBi 助手
  • React-01React创建第一个项目(npm install -g create-react-app)
  • 【Unity】 HTFramework框架(六十四)SaveDataRuntime运行时保存组件参数、预制体
  • Transformer
  • Flinksql--订单宽表
  • [高级数据结构]线段树SegmentTree
  • React PDF 预览终极优化:30 页大文件不卡,加载快如闪电!
  • python操作es
  • UniApp集成极光推送详细教程
  • Python实现 MCP 客户端调用(高德地图 MCP 服务)查询天气工具示例
  • Laravel 中使用 JWT 作用户登录,身份认证
  • 【硬件视界9】网络硬件入门:从网卡到路由器
  • IO 端口与 IO 内存
  • Description of STM32F1xx HAL drivers用户手册
  • Mysql的安装
  • ControlNet-Tile详解
  • 3D意识(3D Awareness)浅析