$('.getquan').css('display', 'none'); // $('#search').css('width', '80%'); $('.saoyisao').hide(); $('.class_block').eq(0).attr('data-classifyId', 5); $('.class_block').eq(1).attr('data-classifyId', 6); $('.class_block').eq(2).attr('data-classifyId', 7); $('.class_block').eq(3).attr('data-classifyId', 8); $('.class_block').eq(4).attr('data-classifyId', ''); $('.zya_block').addClass('add_'); mui.init({ beforeback: function() { //获得父页面的webview var list = plus.webview.currentWebview().opener(); //触发父页面的自定义事件(refresh),从而进行刷新 mui.fire(list, 'refresh'); //返回true,继续页面关闭逻辑 return true; }, }); var data = ''; var addr = ''; var lat = '', lat1 = '', lng = ''; var page = 1; var pageSize = 5; var count = 1; var isjiazai = 1; var nowPage = 1; var isLoading = false; mui.plusReady(function() { from_id=1; getLocation(); function getLocation() { if (navigator.geolocation) { plus.geolocation.getCurrentPosition(showPosition, showError); } else { mui.alert("手机不支持定位") } } function showPosition(position) { lat = position.coords.latitude; lng = position.coords.longitude; localStorage.setItem('lat', lat); localStorage.setItem('lng', lng); getShopList(nowPage, pageSize); addr = position.address.city; localStorage.setItem('addr', addr); $('#location').html(addr); $('#location-r').html(addr); } function showError(error) { switch (error.code) { case error.TIMEOUT: mui.alert('请求超时,请重试') break; case error.POSITION_UNAVAILABLE: mui.alert('定位不到你的地址') break; case error.PERMISSION_DENIED: // case 22: mui.alert('您拒绝了地理位置请求') break; case error.UNKNOWN_ERROR: mui.alert('未知错误') break; default: mui.alert(error.message) break; } getShopList(nowPage, pageSize); } //bannerTop mui.ajax(qlgUrl('app/shopping/getCarousel'), { dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; if (data.status == 1) { var html = ''; var data = data.data; $.each(data, function() { html += '
'; }); $('#top_banner .swiper-wrapper').html(html); var swiper = new Swiper('#top_banner', { pagination: '#top_banner_pagination', spaceBetween: 0, loop: true, autoplay: 3500, autoplayDisableOnInteraction: false }); var topBannerheight = localStorage.getItem('topBannerheight') $('#top_banner').height(topBannerheight) // $('#top_banner').height(($('#top_banner').width() )* 460 / 750); } else { mui.alert(data.msg) } }, error: function(xhr, type, errorThrown) { //异常处理; // mui.alert(errorThrown); } }); mui('.con').on('tap', '.bc_img', function() { var goodsId = $(this).attr('data-goodsId'); JZL.openWindow('details.html', 'details.html' + goodsId, {data_id: goodsId, from_id:1}); }) function getShopList(nowPage, pageSize) { lat = localStorage.getItem('lat'); lng = localStorage.getItem('lng'); if (null == lat) { lat = 36.659565; lng = 117.125824; } var recommenddata = { shopType: 1, page: nowPage ? nowPage : 1, perPage: pageSize ? pageSize : 10, lat: lat, lng: lng } if (true == isLoading) return; isLoading = true; //console.log(lat); JZL.ajax(hyhUrl('app/shopping/getShops'), recommenddata, function(data) { var html = ''; if (1 == data.status) { var data = data.data; // console.log(data); if ('' == data.Rows) { $('.shoplist').append( '

没有更多数据

'); // isLoading = false; return; } $.each(data.Rows, function(index, element) { html += '
' + this.shopName + '进店逛逛
' if (0 != this.goods.length) { $.each(this.goods, function(idx, ele) { html += '
¥' + this.shopPrice + '
' }) } html += '
距离:' + this.distance / 1000 + '公里
' }) if (nowPage == 1) { $('.shoplist').html(html); } else { $('.shoplist').append(html); } isLoading = false; } else { mui.alert(data.msg) } }) } //加载 document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) { if (scroll.y == scroll.maxScrollY) { if (isLoading == false) { nowPage++; // getShops(nowPage, pageSize); getShopList(nowPage, pageSize) } } }) mui('.shoplist').on('tap', '.shops-content1-title', function() { // var goodsId = $(this).attr('data-goodsId'); var shopName = $(this).attr("data-shopName"); var shopId = $(this).attr("data-shopId"); JZL.openWindow('storeout.html', 'storeout.html', {shopName: shopName,shopId: shopId, from_id: 1}); }) }) //获取推荐页 function getRecommend(page, pagesize) { var recommenddata = { type:1, page: page ? page : 1, pagesize: pageSize ? pageSize : 10 } if (isjiazai == 0) { return; } else { isjiazai = 0; } JZL.ajax(qlgUrl('app/shopping/getGoods'), recommenddata, function(data) { // console.log(data); // if (data.status == 1) { var html = ''; // var data = data.data; if (data.Rows == '') { $('.self_shop_rem').append( '

没有更多商品

'); isjiazai = 0; return; } $.each(data.Rows, function() { html += '
' + this.goodsName + '
¥' + this.shopPrice + ' 满减
' + this.saleNum + '人购买
优惠率  ' + this.discountRate + '
'; }); 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 { // mui.alert(data.msg) // } }) } $('.bcon_left').height($('.bcon_left').width() * 345 / 185); $('.bcon_left img').height($('.bcon_left img').width() * 345 / 185); $('.bcr_block').height($('.bcr_block').width()); $('.addsct_block').height($('.addsct_block').width() * 225 / 355); $('.addscb_block').height($('.addscb_block').width() * 260 / 180); $('.zya_block').height($('.zya_block').width() * 185 / 355); var issx = 0; // 轮播图跳转 $('#slider').on('tap', '.swiper-slide', function() { openAds($(this)); }) //导航栏 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'); $('.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'); $('.header').addClass('shadown_wai'); } if (scroll.y > 80 && issx == 0) { issx = 1; setTimeout(function() { location.reload() }, 1000) } }) mui('.classify').on('tap', '.class_block', function() { var classifyId = $(this).attr('data-classifyId'); var url = 'orSupermarket.html'; if (classifyId == '') { url = 'ac3.html'; } JZL.openWindow(url, url, {classifyId: classifyId, from_id: 1}); }) //为你推荐 getRecommend(page, pageSize); document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) { if (scroll.y == scroll.maxScrollY) { if (isjiazai == 1) { page++; getRecommend(page, pageSize); } } }) //搜索 $('.header').on('focus', '#keyword', function() { $(".search button").css('display', 'block'); }) $('.header').on('blur', '#keyword', function() { $(".search button").css('display', 'none'); }) $(".header").on('tap', '.search button', function(e) { var searchName = $('#keyword').val(); JZL.openWindow('goodslist.html', 'goodslist.html', {data_keyword: searchName, from_id: 1}); $('#keyword').val("") // JZL.openWindow('shopsList.html', 'shopsList.html', {data_keyword: searchName}); //JZL.openWindow('shopgoodList.html', 'shopgoodList.html', {data_keyword: searchName}); }); //跳转商品详情页 mui("body").on('tap', '.bc_img', function() { var goodsId = $(this).attr('data-goodsId'); var shopId = $(this).parent().parent().attr('data-shopId'); JZL.openWindow('details.html', 'details.html' + goodsId, {data_id: goodsId,shopId: shopId, from_id:1}); })