/*var UserID = sessionStorage.getItem("MiaoMuUserID"); var userInfo = JSON.parse(sessionStorage.getItem("miaomuUserInfo"));*/ if (UserID != null && UserID != "") { var forShow = userInfo.name; if (forShow == null || forShow == "") { forShow = userInfo.mobile; } } var pics = 0; var pic; var pic2; var pic3; var pic4; var picNow = 1; var gsjj = ""; var spxq = ""; $(function () { showInfo(); $("#toLeft").click(function () { L(); }); $("#toRight").click(function () { R(); }); $(".detailInfo").css("left", $("#XS").outerWidth() + 110 + "px"); $("#XS").mouseenter(function () { $(".detailInfo").show(); }); $(".detailInfo").mouseenter(function () { $(".detailInfo").show(); }); $("#XS").mouseleave(function () { $(".detailInfo").hide(); }); $(".detailInfo").mouseleave(function () { $(".detailInfo").hide(); }); $("#searchAll").click(function () { var content = $("#Sou").val(); var type = $("#selectType").val(); if (content.trim().length < 2) { layer.tips("请至少输入两个字符", "#Sou"); } else { if (type == "供应") { window.location.href = "/spzs/?search=" + content; } else if (type == "采购") { window.location.href = "/syjh/qiugou.htm?search=" + content; } else if (type == "企业") { window.location.href = "/qyml/?search=" + content; } else if (type == "资讯") { window.location.href = "/hyxx/informationSearch.html?search=" + content; } else if (type == "百科") { window.location.href = "/qyfw/encyclopediaSearch.html?search=" + content; } } }); $("#spxq").click(function () { $(this).css("background-color", "#7aac4b"); $(this).css("color", "#ffffff"); $(this).siblings().css("background-color", "#FAFAFA"); $(this).siblings().css("color", "#000000"); $("#other-title").html('商品详情'); $("#other-text").html(spxq); }); $("#gysxx").click(function () { $(this).css("background-color", "#7aac4b"); $(this).css("color", "#ffffff"); $(this).siblings().css("background-color", "#FAFAFA"); $(this).siblings().css("color", "#000000"); $("#other-title").html('公司简介'); $("#other-text").html(gsjj.replace(/{{br}}/g,'')); }); }); function loadInfo() { var IDArr = window.location.href.split("?id="); var info = null; var IDs = 0; if (IDArr.length == 2) { IDs = window.location.href.split("?id=")[1]; } else { var weburl = window.location.href; IDs = weburl.substring(weburl.lastIndexOf('/') + 1).split(".")[0]; } if (parseInt(IDs)) { var id = parseInt(IDs); $.ajax({ url: url + "/info/supply/selectById", data: {"id": id}, type: "post", dateType: "json", async: false, success: function (response, status, xhr) { info = response[0]; }, error: function (e) { layer.msg("系统错误,请联系客服!", {icon: 5}); console.log("读取信息ajax错误"); console.log(e.status); console.log(e.responseText); } }); } addSeeTimes(id); return info; } function showInfo() { var info = loadInfo(); if (info != null) { getSwiper(info.gsid); $("#collect").click(function () { insertCollection(info.cpmc); }); $("#share").click(function () { var share = document.getElementById("share"); var clip = new ClipboardJS(share, { text: function () { return "我在苗木网看到出售:" + info.cpmc + ",点击链接或复制链接到浏览器查看→" + window.location.href; } }); clip.on('success', function (e) { console.log(e); clip.destroy();// 复制完毕删除,否则会有创建多个clipboard对象 layer.msg("链接已复制,去粘贴分享吧!", {icon: 1}); }); clip.on('error', function (e) { console.log(e); layer.msg("浏览器版本过低,请手动复制链接", {icon: 2}); }); share.click(); clip.destroy(); }); getSold(info.gsid); var gsid = info.gsid; var showName = info.cpmc; var hits = info.hits; var qd = info.less; var address = info.address; var content = info.bz; spxq = info.bz; var price = info.cpjg; var linkman = info.lxr; var phone = info.phone; var fb = info.idate; var gj1 = info.gj1; var gj2 = info.gj2; var gd1 = info.gd1; var gd2 = info.gd2; var gf1 = info.gf1; var gf2 = info.gf2; var fz1 = info.fz1; var fz2 = info.fz2; var zt1 = info.zt1; var zt2 = info.zt2; var dw = info.dw; var jg = info.jglx; if (jg == null || jg == "") { jg = "地头价"; } pic = PIC(info.picture); pic2 = PIC(info.picture2); pic3 = PIC(info.picture3); pic4 = PIC(info.picture4); //var gg = GG1("杆径",gj1,gj2,"cm")+GG1("高度",gd1,gd2,"cm")+GG1("冠幅",gf1,gf2,"cm")+GG1("分枝点",fz1,fz2,"cm")+GG1("枝条数",zt1,zt2,"")+GG2("备注",content); if (qd == null || qd == "") { qd = 1; } if (content == null || content == "") { content = "无详细内容"; } var gg = info.cpgg; if (gg == "") { gg = "无详细信息"; } if (price == null || price == "" || price == 0 || price == "0" || price == "无") { price = "面议"; } else { if (!isNaN(price)) { price = "¥" + price + "元" } } if (dw == null || dw == "") { dw = "株"; } $(".dw").html(dw); $("#showname").html(showName); $("#hits").html(hits); $("#qd").html(qd); $("#other-text").html(content); $("#price").html(price + " " + jg); $("#fb").html(fb.slice(0, 10)); $("#gg").html(gg); $("#pic").attr("src", pic); $("#pic2").attr("src", pic); $("#pic3").attr("src", pic2); $("#pic4").attr("src", pic3); $("#seeTimes").html(info.seeTimes + 1 + "次"); // 相关供应 var url1 = url + '/info/supply/selectForSupply0'; var datainfo = { "gd1": '', "gd2": '', "gj1": '', "gj2": '', "fz1": '', "fz2": '', "jg1": '-1', "jg2": '-1', "zt1": '', "zt2": '', "gf1": '', "gf2": '', "page": 0, "sf": '', "type": '', "cpmc": showName }; $.ajax({ url: url1, data: datainfo, type: "post", dateType: "json", async: false, success: function (res, status, xhr) { var result1 = ""; if (res.length > 1) { var temp = 0; $.each(res, function (i, list) { var img = "/images/无图片.jpg"; if (list.picture != null && list.picture != "") { img = list.picture; } if (temp < 8) { result1 += "<div style='margin-bottom: 20px;'><a href='/spzs/Show_product/" + list.id + ".html' target='_blank'><img src='" + formatImgUrl(img) + "'><br>" + list.cpmc + "</a></div>"; temp++; } else { return false; } }); } else { $(".D8").hide(); $(".D8-text").hide(); } $(".D8-text").html(result1); } }); if (gsid != null && gsid != "") { var companyInfo = loadCompany(gsid); if (companyInfo != null) { var qyjj = ''; if(companyInfo.qyjj){ qyjj = companyInfo.qyjj; } if (qyjj && qyjj.length > 100) { qyjj = qyjj.substring(0, 99); } var qymc = companyInfo.qymc; if (!qymc) { qymc = info.sf + info.city; } var show_gg = info.cpgg; if (show_gg.indexOf('cm') !== -1) { var temp_arr = show_gg.split('cm'); show_gg = temp_arr[0] + '公分'; } else { show_gg = ''; } document.title = info.sf + info.city + show_gg + info.cpmc + '|' + info.cpmc + '价格|' + info.cpmc + '图片-中国苗木网miaomu.com'; $("meta[name='keywords']").attr('content', info.sf + info.city + show_gg + info.cpmc + ',' + info.cpmc + '价格,' + info.cpmc + '图片,' + info.cpmc + '行情,' + info.cpmc + '报价'); $("meta[name='description']").attr('content', qymc + '为您提供最新' + show_gg + info.cpmc + '价格,' + qyjj.replace(/{{br}}/g, '')); gsjj = companyInfo.qyjj; if (companyInfo.qymc != null && companyInfo.qymc != "") { $("#company,#company2,#XS").html(companyInfo.qymc); $("#zygy").html("主要供应:" + companyInfo.zycp); $(".com-Top-nav>div:first-child>a").attr("href", "/company/vip/" + gsid + ".html"); $(".com-Top-nav>div:nth-child(2)>a").attr("href", "/company/vip/about/" + gsid + ".html"); $(".com-Top-nav>div:nth-child(3)>a").attr("href", "/company/vip/spzs/" + gsid + ".html"); $(".com-Top-nav>div:nth-child(4)>a").attr("href", "/company/vip/syjh/" + gsid + ".html"); //$(".com-Top-nav>div:nth-child(5)>a").attr("href","companyMessage.html?id="+gsid); $(".com-Top-nav>div:last-child>a").attr("href", "/company/vip/zzry/" + gsid + ".html"); $("#company2").attr("href", "/company/vip/" + gsid + ".html"); $("#company3").attr("href", "/company/vip/spzs/" + gsid + ".html"); $("#searchThis").click(function () { var content = $("#Sou").val(); var type = $("#selectType").val(); if (content.trim().length < 2) { layer.tips("请至少输入两个字符", "#Sou"); } else { if (type == "供应") { window.location.href = "/company/vip/spzs/" + gsid + ".html?search=" + content; } else if (type == "采购") { window.location.href = "/company/vip/syjh/" + gsid + ".html?search=" + content; } else if (type == "企业") { layer.tips("请选择供应或求购", "#selectType"); } else if (type == "资讯") { layer.tips("请选择供应或求购", "#selectType"); } else if (type == "百科") { layer.tips("请选择供应或求购", "#selectType"); } } }); var zz = ""; var zzsm = "无"; if (companyInfo.gs == 1) { zz = "<img src='/images/三级详情页供应改danbao_23.png' title='已通过执照认证'>"; zzsm = " 公司认证<br> "; } var hy = ""; var hysm = "无"; switch (companyInfo.hyjb) { case 5: hy = "<img src='/images/皇冠级别.png' title='皇冠VIP'>"; hysm = " 皇冠VIP"; break; case 4: hy = "<img src='/images/黄钻级别.png' title='黄钻VIP'>"; hysm = " 黄钻VIP"; break; case 3: hy = "<img src='/images/红钻级别.png' title='红钻VIP'>"; hysm = " 红钻VIP"; break; case 2: hy = "<img src='/images/绿钻级别.png' title='绿钻VIP'>"; hysm = " 绿钻VIP"; break; case 1: break; default: break; } var sm = ""; var smsm = ""; if (companyInfo.shiming == 1) { sm = "<img src='/images/三级详情页供应改身份验证.png' title='已通过实名认证'>"; smsm = " 实名认证<br> "; } var db = ""; var dbsm = ""; if (companyInfo.danbao == 1) { db = "<img src='/images/三级详情页供应改danbao_30.png' title='已缴费担保认证'>"; $(".db").html(db + "供应商已缴纳担保金,平台监督,防止上当受骗,公平公正。"); dbsm = " 担保认证"; } var clsj = "未知"; if (companyInfo.clsj != null && companyInfo.clsj != "") { clsj = companyInfo.clsj; } $("#tb").html(hy + sm + zz + db); $("#DE1").html(companyInfo.qymc); $("#DE2").html(companyInfo.phone); $("#DE3").html(hy + hysm); $("#DE4").html(countSold(gsid)); $("#DE5").html(companyInfo.sf + companyInfo.city); $("#DE6").html(clsj); $("#DE7").html(zz + zzsm + sm + smsm + db + dbsm); if (companyInfo.touxiang != null && companyInfo.touxiang != "") { $("#tx").attr("src", formatImgUrl(companyInfo.touxiang)); $("#tx").css("border-radius", "75px"); } } else if (companyInfo.name) { $("#company,#XS").html(companyInfo.name); $("#company2").html('首页'); $("#company3").html('供应大厅'); $("#company2").attr('href', '/'); $("#company3").attr('href', '/spzs'); $("#zygy").hide(); } else { $("#company,#XS").html(''); $("#company2").html('首页'); $("#company3").html('供应大厅'); $("#company2").attr('href', '/'); $("#company3").attr('href', '/spzs'); $("#zygy").hide(); } } } //if(user!=null&&user!=""&&userInfo!=null){ //if(userInfo.hyjb>1){ $(".dh-1").html("<img src='/images/三级详情页公司首页改g_10.png'>" + linkman + ":" + phone); $(".dh-2").html("<img src='/images/三级详情页公司首页改g_13.png'>" + address); $(".dh").css("background-color", "white"); /*}else{ $(".greenTexts").html("对不起,您不是正式会员,"); $(".dh-2").hide(); }*/ //} } else { window.location.href = "/spzs"; } } function loadCompany(gsid) { var companyInfo = null; $.ajax({ url: url + "/user2019/qyml/listchaxungongsi", data: {"id": gsid}, type: "post", dateType: "json", async: false, success: function (response, status, xhr) { companyInfo = response[0]; }, error: function (e) { layer.msg("系统错误,请联系客服!", {icon: 5}); console.log("读取公司信息ajax错误"); console.log(e.status); console.log(e.responseText); } }); return companyInfo; } function GG1(str, num1, num2, dw) { if ((num1 == null || num1 == "") && (num2 == null || num2 == "")) { return ""; } else { return str + ":" + num1 + "~" + num2 + dw + " "; } } function GG2(str, text) { if (text == null || text == "") { return ""; } else { return str + ":" + text; } } function PIC(pic) { if (pic == null || pic == "") { return "/images/无图片.jpg"; } else { pics++; pic = formatImgUrl(pic); return pic; } } function L() { var picArr = [pic, pic2, pic3, pic4]; if (pics == 0) { layer.msg("该商品无图片", {icon: 2}); } if (pics == 4 && picNow != 1) { $("#pic2").attr("src", pic); $("#pic3").attr("src", pic2); $("#pic4").attr("src", pic3); } if (picNow != 1) { $("#pic").attr("src", picArr[picNow - 2]); picNow--; } else { layer.msg("已经是第一张了", {icon: 0}); } } function R() { var picArr = [pic, pic2, pic3, pic4]; if (pics == 0) { layer.msg("该商品无图片", {icon: 2}); } if (pics == 4 && picNow == 1) { $("#pic2").attr("src", pic2); $("#pic3").attr("src", pic3); $("#pic4").attr("src", pic4); } if (picNow == pics) { layer.msg("已经是最后一张了", {icon: 0}); } else { $("#pic").attr("src", picArr[picNow]); picNow++; } } function insertCollection(showName) { if (UserID != null && UserID != "") { if (checkCollection()) { var IDArr = window.location.href.split("?info_id="); var IDs = 0; if (IDArr.length == 2) { IDs = window.location.href.split("?info_id=")[1]; } else { var weburl = window.location.href; IDs = weburl.substring(weburl.lastIndexOf('/') + 1).split(".")[0]; } if (parseInt(IDs)) { var id = parseInt(IDs); $.ajax({ url: url + "/user/collect/insertCollect", data: { "shopId": id, "userId": userInfo.id, "type": "供应", "time": new Date().toLocaleString(), "showName": showName }, type: "post", dateType: "json", async: false, success: function (response, status, xhr) { if (response == 1) { layer.msg("收藏成功!", {icon: 1}); } else { layer.msg("系统错误,请联系客服!", {icon: 5}); console.log("insertCollection!=1"); } }, error: function (e) { layer.msg("系统错误,请联系客服!", {icon: 5}); console.log("insertCollection"); console.log(e.status); console.log(e.responseText); } }); } } else { layer.msg("您已收藏该商品,不能重复收藏!", {icon: 2}); } } else { layer.confirm('您尚未登录,请前往登录或注册!', { btn: ['登录', '注册'] //按钮 }, function () { window.location.href = "/reg201206/login06.html"; }, function () { window.location.href = "/reg201206/register06.html"; }); } } function checkCollection() { var IDArr = window.location.href.split("?info_id="); var IDs = 0; if (IDArr.length == 2) { IDs = window.location.href.split("?info_id=")[1]; } else { var weburl = window.location.href; IDs = weburl.substring(weburl.lastIndexOf('/') + 1).split(".")[0]; } var flag = false; if (parseInt(IDs)) { var id = parseInt(IDs); $.ajax({ url: url + "/user/collect/checkCollect", data: {"shopId": id, "userId": userInfo.id}, type: "post", dateType: "json", async: false, success: function (response, status, xhr) { flag = response; }, error: function (e) { layer.msg("系统错误,请联系客服!", {icon: 5}); console.log("checkCollection"); console.log(e.status); console.log(e.responseText); } }); } return flag; } function ZZ(id) { var result = false; $.ajax({ url: url + "/user/qyzz/selectqyzz", data: {"userid": id}, type: "post", dateType: "json", async: false, success: function (response, status, xhr) { if (response.length != 0) { if (response[0].flag == 1) { result = true; } } }, error: function (e) { layer.msg("系统错误,请联系客服!", {icon: 5}); console.log("ZZ"); console.log(e.status); console.log(e.responseText); } }); return result; } function getSold(gsid) { var id = parseInt(window.location.href.split("?id=")[1]); var result1 = ""; $.ajax({ url: url + "/info/supply/selectForCompany", data: {"gsid": gsid, "page": 0}, type: "post", dateType: "json", async: false, success: function success(response, status, xhr) { if (response.length > 1) { var temp = 0; $.each(response, function (i, list) { var img = "/images/无图片.jpg"; if (list.picture != null && list.picture != "") { img = list.picture; } if (temp < 8) { if (list.id != id) { result1 += "<div style='margin-bottom: 20px;'><a href='/spzs/Show_product/" + list.id + ".html' target='_blank'><img src='" + formatImgUrl(img) + "'><br>" + list.idate.slice(0, 10) + "<br>" + list.cpmc + "</a></div>"; temp++; } } else { return false; } }); } else { result1 = "无内容"; } $(".D7").html(result1); }, error: function error(e) { layer.msg("系统错误,请联系客服!", {icon: 5}); console.log("getSold方法ajax错误"); console.log(e.status); console.log(e.responseText); } }); } function countSold(id) { var result = 0; $.ajax({ url: url + "/info/supply/countForCompany", data: {"gsid": id}, type: "post", dateType: "json", async: false, success: function success(response, status, xhr) { result = response; }, error: function error(e) { layer.msg("系统错误,请联系客服!", {icon: 5}); console.log("countSold方法ajax错误"); console.log(e.status); console.log(e.responseText); } }); return result; } function addSeeTimes(id) { $.ajax({ url: url + "/info/supply/addSeeTimes", data: {"id": id}, type: "get", dateType: "json", async: false, success: function (response, status, xhr) { if (response != 1) { console.log("addSeeTimes!=1 ===>" + response); } }, error: function (e) { console.log("addSeeTimes"); console.log(e.status); console.log(e.responseText); } }); } function getSwiper(id) { $.ajax({ url: url + "/gstp/gstp/selectByUser", data: {"gsid": id}, type: "get", dateType: "json", async: false, success: function (response, status, xhr) { if (response.length == 1 && response[0].flag == 1) { var arr = []; if (response[0].pic1) { arr.push(response[0].pic1); } if (response[0].pic2) { arr.push(response[0].pic2); } if (response[0].pic3) { arr.push(response[0].pic3); } if (response[0].pic4) { arr.push(response[0].pic4); } if (arr.length > 0) { var content = ""; for (var i = 0; i < arr.length; i++) { content += "<div class='swiper-slide'><img src='" + formatImgUrl(arr[i]) + "' style='width: 1200px;height: 400px'></div>"; } $(".swiper-wrapper").html(content); $(".upImg").hide(); $(".swiper-container").show(); var mySwiper = new Swiper('.swiper-container', { autoplay: true,//可选选项,自动滑动 loop: true, }); } } }, error: function (e) { console.log("addSeeTimes"); console.log(e.status); console.log(e.responseText); } }); }