$('.saoyisao').css('display', 'none'); $('.getquan').css('display', 'none'); $('#hot_more').css('display', 'none'); $('#search').css('width', '80%'); $('#search').css('left', '5%'); $('.searchimg').css('left', '8%'); $('.time').css('display', 'none'); var page = 1; var pagesize = 10; var isjiazai = 1; function getRecommend(page, pagesize) { var recommenddata = { page: page ? page : 1, pagesize: pagesize ? pagesize : 10 } if(isjiazai == 0) { return; } else { isjiazai = 0; } mui.ajax(ectUrl('addon/shuff-Shuff-recommend'), { data: recommenddata, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // var data = toJson(data, 1); if(data.status == 1) { var html = ''; var data = data.data; if(data.Rows == '') { $('.mui-scroll').append('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;">没有更多商品</p>'); isjiazai = 0; return; } $.each(data.Rows, function() { html += '<div class="recommend_con_block shadown_wai" data-goodsId="' + this.goodsId + '"><img class="rcb_img" src="' + ectImgUrl(this.goodsImg) + '" alt="" /><div class="rcb_con"><div class="rcb_title"><span style="display:none;" data-shopId="' + this.shopId + '">自营</span>' + this.goodsName + '</div><div class="rcb_pay">¥' + this.shopPrice + ' <span style="display:none;">满减</span></div><div class="rcb_bottom"><span>可用木吉抵扣20%货款</span></div></div><img style="display:none;" class="icon_icon" src="../img/icon_sscl.png" alt="" /></div>'; }); if(page == 1) { $('#recommend_con').html(html); } else { $('#recommend_con').append(html); } isjiazai = 1; $('.rcb_title span').each(function() { if($(this).attr('data-goodsId') == 1) { $(this).css('display', 'none'); } }) $('.rcb_img').height($('.rcb_img').width()); } else { // console.log(2) } }, error: function(xhr, type, errorThrown) { //异常处理; // alert(errorThrown); } }); } function getNextDate(dayStr) { var dd = new Date(dayStr); dd.setDate(dd.getDate() + 1); var y = dd.getFullYear(); var m = dd.getMonth() + 1; //获取当前月份的日期 var d = dd.getDate(); return y + "/" + m + "/" + d + " 00:00:00"; }; function countTime() { //获取当前时间 var date = new Date(); var now = date.getTime(); //设置截止时间 var endDate = new Date(getNextDate(date)); var end = endDate.getTime(); //时间差 var leftTime = end - now; //定义变量 d,h,m,s保存倒计时的时间 var h, m, s; if(leftTime >= 0) { h = Math.floor(leftTime / 1000 / 60 / 60); m = Math.floor(leftTime / 1000 / 60 % 60); s = Math.floor(leftTime / 1000 % 60); //将倒计时赋值到div中 if(h < 10) { h = "0" + h; } if(m < 10) { m = "0" + m; } if(s < 10) { s = "0" + s; } document.getElementById("_h").innerHTML = h; document.getElementById("_m").innerHTML = m; document.getElementById("_s").innerHTML = s; } //递归每秒调用countTime方法,显示动态时间效果 setTimeout(countTime, 1000); } mui.plusReady(function() { var ua = navigator.userAgent.toLowerCase(); var issx = 0; //获取折扣 localStorage.removeItem('ectzhekou'); mui.ajax(llUrl('addon/shuff-Shuff-ectDiscount'), { dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // var data = toJson(data, 1); if(data.status == 1) { localStorage.setItem('ectzhekou',data.data); } else { // console.log(2) } }, error: function(xhr, type, errorThrown) { //异常处理; // alert(errorThrown); } }); //bannerTop mui.ajax(llUrl('addon/shuff-Shuff-homeCarousel'), { dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // var data = toJson(data, 1); if(data.status == 1) { var html = ''; var data = data.data; $.each(data, function() { html += '<div class="swiper-slide" data-adURL="' + this.adURL + '" data-targetType="' + this.targetType + '"><img src="' + ectImgUrl(this.adFile) + '" alt="" /></div>'; }); $('#top_banner .swiper-wrapper').html(html); var swiper = new Swiper('#top_banner', { pagination: '#top_banner_pagination', spaceBetween: 0, loop: true, autoplay: 3500, autoplayDisableOnInteraction: false }); $('#top_banner').height($('#top_banner').width() * 460 / 750); } else { // console.log(data.status) } }, error: function(xhr, type, errorThrown) { //异常处理; // alert(errorThrown); } }); //秒杀 mui.ajax(ectUrl('addon/hyhsale-Goods-appGoodsList'), { dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // var data = toJson(data, 1); if(data.status == 1) { var html = ''; var data = data.data; $.each(data, function() { html += '<div class="swiper-slide" data-goodsId="' + this.goodsId + '"><img src="' + ectImgUrl(this.goodsImg) + '" alt="" /><p>¥' + this.goodsPrice + '</p><del>¥' + this.marketPrice + '</del></div>'; }); $('#timer_swiper .swiper-wrapper').html(html); countTime() var swiper = new Swiper('#timer_swiper', { slidesPerView: 4.5, paginationClickable: true, spaceBetween: 0, freeMode: true }); $('#timer_swiper .swiper-slide img').height($('#timer_swiper .swiper-slide img').width()); $('#timer_swiper .swiper-slide').height($('#timer_swiper .swiper-slide').width() * 250 / 160); } else { // console.log(data.status) } }, error: function(xhr, type, errorThrown) { //异常处理; // alert(errorThrown); } }); //会员快报 mui.ajax(hyhUrl('app/Articles/getIndexNews'), { data: {}, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(news_data) { //服务器返回响应,根据响应结果,分析是否登录成功; var news_data = toJson(news_data); if(news_data.status == 1) { news_data = news_data.data; var news = ''; $.each(news_data, function() { // console.log(this.articleTitle) news += '<a href="#" data-articleId="' + this.articleId + '">' + this.articleTitle + '</a> '; }) $('#news').html(news); // $('#news_more').html(''); //console.log(news); } }, error: function(xhr, type, errorThrown) { //异常处理; // alert(type); } }); //热门品牌 mui.ajax(llUrl('addon/shuff-Shuff-shuff'), { data: { positionId: 392 }, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // var data = toJson(data, 1); if(data.status == 1) { var html = ''; var data = data.data; $.each(data, function() { html += '<div class="swiper-slide"><div class="hotimg" data-targetType="' + this.targetType + '" data-adURL="' + this.adURL + '"><img class="hotimg_" src="' + ectImgUrl(this.adFile) + '" /></div><div class="hot_con clearfix">'; if(this.list != '') { $.each(this.list, function(num) { if(num >= 3) { return; } var adGoodsStatus = ''; if(this.adGoodsStatus == 1) { adGoodsStatus = '精品'; } else if(this.adGoodsStatus == 2) { adGoodsStatus = '推荐'; } else if(this.adGoodsStatus == 3) { adGoodsStatus = '热卖'; } html += '<div class="hot_con_block" data-goodsId="' + this.goodsId + '"><img class="hot_con_block_img" src="' + ectImgUrl(this.adGoodsImg) + '" /><p class="hcb_name">' + this.goodsName + '</p><p class="hcb_pay">¥' + this.shopPrice + '</p><div class="hot_bottom_icon"><img class="icon_star" src="../img/icon_star.png" /><span>' + adGoodsStatus + '</span></div></div>' }) } html += '</div></div>'; }); $('#hot_banner .swiper-wrapper').html(html); var swiper = new Swiper('#hot_banner', { pagination: '#hot_banner_pageination', spaceBetween: 0, loop: true, autoplay: 5500, autoplayDisableOnInteraction: false }); $('#hot_banner .swiper-wrapper .swiper-slide ').height($('#hot_banner ').width() * 820 / 718); $('#hot_banner .swiper-wrapper .swiper-slide .hotimg').height($('#hot_banner .hotimg').width() * 320 / 662); $('.hot_con_block_img').height($('.hot_con_block_img').width()); } else { // console.log(2) } }, error: function(xhr, type, errorThrown) { //异常处理; // alert(errorThrown); } }); //广告位 mui.ajax(llUrl('addon/shuff-Shuff-active'), { dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // var data = toJson(data, 1); if(data.status == 1) { var data = data.data; if(data[0]) { $('.add_top_left').addClass('add_').attr('data-adURL', data[0].adURL).attr('data-targetType', data[0].targetType); $('.add_top_left .p1').html(data[0].adName.split('|')[0]); $('.add_top_left .p2').html(data[0].adName.split('|')[1]); $('.add_top_left img').attr('src', ectImgUrl(data[0].adFile)); } if(data[1]) { $('.add_top_right_con').eq(0).addClass('add_').attr('data-adURL', data[1].adURL).attr('data-targetType', data[1].targetType); $('.add_top_right_con .p1').eq(0).html(data[1].adName.split('|')[0]); $('.add_top_right_con .p2').eq(0).html(data[1].adName.split('|')[1]); $('.add_top_right_con img').eq(0).attr('src', ectImgUrl(data[1].adFile)); } if(data[2]) { $('.add_top_right_con').eq(1).addClass('add_').attr('data-adURL', data[2].adURL).attr('data-targetType', data[2].targetType); $('.add_top_right_con .p1').eq(1).html(data[2].adName.split('|')[0]); $('.add_top_right_con .p2').eq(1).html(data[2].adName.split('|')[1]); $('.add_top_right_con img').eq(1).attr('src', ectImgUrl(data[2].adFile)); } if(data[3]) { $('#abc_1').addClass('add_').attr('data-adURL', data[3].adURL).attr('data-targetType', data[3].targetType); $('#abc_1 .p1').html(data[3].adName.split('|')[0]); $('#abc_1 .p2').html(data[3].adName.split('|')[1]); $('#abc_1 img').attr('src', ectImgUrl(data[3].adFile)); } if(data[4]) { $('#abc_2').addClass('add_').attr('data-adURL', data[4].adURL).attr('data-targetType', data[4].targetType); $('#abc_2 .p1').html(data[4].adName.split('|')[0]); $('#abc_2 .p2').html(data[4].adName.split('|')[1]); $('#abc_2 img').attr('src', ectImgUrl(data[4].adFile)); } if(data[5]) { $('#abc_3').addClass('add_').attr('data-adURL', data[5].adURL).attr('data-targetType', data[5].targetType); $('#abc_3 .p1').html(data[5].adName.split('|')[0]); $('#abc_3 .p2').html(data[5].adName.split('|')[1]); $('#abc_3 img').attr('src', ectImgUrl(data[5].adFile)); } // var html1 = `<div class="add_top_left add_" data-adURL="` + data[0].adURL + `" data-targetType="` + data[0].targetType + `"> // <p class="p1">` + data[0].adName.split('|')[0] + `</p> // <p class="p2">` + data[0].adName.split('|')[1] + `</p> // <img src="` + ectImgUrl(data[0].adFile) + `" /> // </div> // <div class="add_top_right"> // <div class="add_top_right_con atrct add_" data-adURL="` + data[1].adURL + `" data-targetType="` + data[1].targetType + `"> // <p class="p1">` + data[1].adName.split('|')[0] + `</p> // <p class="p2">` + data[1].adName.split('|')[1] + `</p> // <img src="` + ectImgUrl(data[1].adFile) + `" /> // </div> // <div class="add_top_right_con add_" data-adURL="` + data[2].adURL + `" data-targetType="` + data[2].targetType + `"> // <p class="p1">` + data[2].adName.split('|')[0] + `</p> // <p class="p2">` + data[2].adName.split('|')[1] + `</p> // <img src="` + ectImgUrl(data[2].adFile) + `" /> // </div> // </div>`; // // $('.add_top').html(html1); // var html2 = `<div class="add_bottom_con add_" id="abc_1" data-adURL="` + data[3].adURL + `" data-targetType="` + data[3].targetType + `"> // <p class="p1">` + data[3].adName.split('|')[0] + `</p> // <p class="p2">` + data[3].adName.split('|')[1] + `</p> // <img src="` + ectImgUrl(data[3].adFile) + `" /> // </div> // <div class="add_bottom_con add_" id="abc_2" data-adURL="` + data[4].adURL + `" data-targetType="` + data[4].targetType + `"> // <p class="p1">` + data[4].adName.split('|')[0] + `</p> // <p class="p2">` + data[4].adName.split('|')[1] + `</p> // <img src="` + ectImgUrl(data[4].adFile) + `" /> // </div> // <div class="add_bottom_con add_" id="abc_3" data-adURL="` + data[5].adURL + `" data-targetType="` + data[5].targetType + `"> // <p class="p1">` + data[5].adName.split('|')[0] + `</p> // <p class="p2">` + data[5].adName.split('|')[1] + `</p> // <img src="` + ectImgUrl(data[5].adFile) + `" /> // </div>`; // $('.add_bottom').html(html2); } else { // console.log(2) } }, error: function(xhr, type, errorThrown) { //异常处理; // alert(errorThrown); } }); //为你推荐 getRecommend(page, pagesize); document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) { if(scroll.y == scroll.maxScrollY) { if(isjiazai == 1) { page++; getRecommend(page, pagesize); } } }) setInterval(function() { $('.add_top_left img').height($('.add_top_left img').width()); $('.add_top_right_con img').height($('.add_top_right_con img').width()); $('.add_bottom_con img').height($('.add_bottom_con img').width()); $('.rcb_img').height($('.rcb_img').width()); }, 100) document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) { if(-scroll.y < 0) { num = 0; } else if((-scroll.y > 0 || scroll.y == 0) && -scroll.y < 150) { num = -scroll.y / 150; } else { num = 1; } $('.header').css('background-color', 'rgba(255,255,255,' + num + ')') if(-scroll.y < 75) { $('.saoyisao').attr('src', '../img/saoyisao.png'); $('.msg').attr('src', '../img/icon_msg.png'); $('.search').attr('src', '../img/icon_search.png'); $('#search').css('background-color', 'white'); // $('#search').css('color', 'black'); // $('#keyword').css('color', 'black'); $('.header').removeClass('shadown_wai'); } else { $('.saoyisao').attr('src', '../img/saoyisao1.png'); $('.msg').attr('src', '../img/icon_msg1.png'); $('.search').attr('src', '../img/icon_search1.png'); $('#search').css('background-color', '#d8d8d8'); // $('#search').css('color', 'white'); // $('#keyword').css('color', 'white'); $('.header').addClass('shadown_wai'); } if(scroll.y > 80 && issx == 0) { issx = 1; setTimeout(function() { location.reload() }, 1000) } }) //轮播图跳转 $('#top_banner').on('tap', '.swiper-slide', function() { openAds($(this)); }) //秒杀跳转 $('#timer_swiper').on('tap', '.swiper-slide', function() { // openAds($(this)); }) //广告 $('.add').on('tap', '.add_', function() { openAds($(this)); }) //品牌跳转 $('#hot_banner').on('tap', '.hotimg', function() { openAds($(this)); }) var num = 0; mui('.time').on('tap', '#timer_more', function() { mui.openWindow({ url: 'time.html', id: 'time.html', styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 }, extras: { // data_keyword: searchName // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: {}, waiting: {} }) }) mui('.classify').on('tap', '.class_block', function() { var classifyId = $(this).attr('data-classifyId'); var url = 'orSupermarket.html'; if(classifyId == 5) { url = 'classify.html'; } mui.openWindow({ url: url, id: url, styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 }, extras: { classifyId: classifyId // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: {}, waiting: {} }) }) //跳新闻 mui('.con_nav').on('tap', '.news', function() { mui.openWindow({ url: 'journalism.html', id: 'journalism.html', styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 }, extras: { // data_keyword: searchName // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: {}, waiting: {} }) }) //跳消息 mui('.header').on('tap', '.msg', function() { mui.openWindow({ url: 'msg.html', id: 'msg.html', styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 }, extras: { // data_keyword: searchName // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: {}, waiting: {} }) }) mui('.hot_shop').on('tap', '#hot_more', function() { mui.openWindow({ url: 'activity4.html', id: 'activity4.html', styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 }, extras: { // data_keyword: searchName // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: {}, waiting: {} }) }) //搜索 $('#keyword').on('focus', function() { $(".search button").css('display', 'block'); }) $('#keyword').on('blur', function() { $(".search button").css('display', 'none'); }) $(".search button").on('tap', function() { var searchName = $('#keyword').val(); var url = ''; // e.preventDefault(); // console.log(searchName) //请求搜索接口 // console.log($('.search select').val()) if($('.search select').val() == 0) { url = 'goodsList.html'; } else if($('.search select').val() == 1) { url = 'shopsList.html'; } mui.openWindow({ url: url, id: url + searchName, styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 width: '100%', //新页面宽度,默认为100% height: '100%' //新页面高度,默认为100% }, extras: { data_keyword: searchName // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: true, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: { // autoShow: true, //页面loaded事件发生后自动显示,默认为true // aniShow: animationType, //页面显示动画,默认为”slide-in-right“; // duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒; // event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示 // extras: {} //窗口动画是否使用图片加速 }, waiting: { autoShow: true, //自动显示等待框,默认为true title: '正在加载...', //等待对话框上显示的提示内容 options: { // width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度 // height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度 // ...... } } }) }) $("#keyword").on('keypress', function(e) { var keycode = e.keyCode; var searchName = $(this).val(); var url = ''; if(keycode == '13') { // e.preventDefault(); // console.log(searchName) //请求搜索接口 // console.log($('.search select').val()) if($('.search select').val() == 0) { url = 'goodsList.html'; } else if($('.search select').val() == 1) { url = 'shopsList.html'; } mui.openWindow({ url: url, id: url + searchName, styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 width: '100%', //新页面宽度,默认为100% height: '100%' //新页面高度,默认为100% }, extras: { data_keyword: searchName // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: true, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: { // autoShow: true, //页面loaded事件发生后自动显示,默认为true // aniShow: animationType, //页面显示动画,默认为”slide-in-right“; // duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒; // event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示 // extras: {} //窗口动画是否使用图片加速 }, waiting: { autoShow: true, //自动显示等待框,默认为true title: '正在加载...', //等待对话框上显示的提示内容 options: { // width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度 // height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度 // ...... } } }) } }); mui("#hot_banner").on('tap', '.hot_con_block', function() { // var tj = plus.webview.create('search.html'); // tj.show(); // alert(e.target.attributes["data-id"].nodeValue); var data_id = this.attributes["data-goodsId"].nodeValue; // console.log(this.attributes["data-id"].nodeValue); mui.openWindow({ url: 'details.html', id: 'details.html' + data_id, styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 width: '100%', //新页面宽度,默认为100% height: '100%' //新页面高度,默认为100% }, extras: { data_id: data_id // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: { // autoShow: true, //页面loaded事件发生后自动显示,默认为true // aniShow: animationType, //页面显示动画,默认为”slide-in-right“; // duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒; // event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示 // extras: {} //窗口动画是否使用图片加速 }, waiting: { autoShow: true, //自动显示等待框,默认为true title: '正在加载...', //等待对话框上显示的提示内容 options: { // width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度 // height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度 // ...... } } }) }) })