From bff6584b7d73a5774551eda31aff30f06b39cc41 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Fri, 6 Sep 2019 16:31:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A9=E8=B4=AD=E5=90=A7=E9=A1=B5=E9=9D=A2JS?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 +- js/common.js | 7 +- js/index.js | 5 +- js/start.js | 21 +-- js/zhugouba.js | 331 ++++++++++++++++++++++++++++++++++ templete/zhugouba.html | 85 +++++++++ templete/zhugouba_remend.html | 88 +++++++++ 7 files changed, 522 insertions(+), 19 deletions(-) create mode 100644 js/zhugouba.js create mode 100644 templete/zhugouba.html create mode 100644 templete/zhugouba_remend.html diff --git a/index.html b/index.html index fa5e149..23bd546 100644 --- a/index.html +++ b/index.html @@ -47,9 +47,9 @@ - - + diff --git a/js/common.js b/js/common.js index e1c9f9b..34a4221 100644 --- a/js/common.js +++ b/js/common.js @@ -1,7 +1,10 @@ var is_app = 1; var imgUrl = 'http://img.zgqlg.com.cn/'; -var webUrl = 'http://www.zgqlg.com.cn/'; -var webUrl1 = 'http://www.zgqlg.com.cn/'; +// var webUrl = 'http://www.zgqlg.com.cn/'; +// var webUrl1 = 'http://www.zgqlg.com.cn/'; +// var imgUrl = 'http://qlg.tsgz.moe:233/'; +var webUrl = 'http://qlg.tsgz.moe:233/'; +var webUrl1 = 'http://qlg.tsgz.moe:233/'; var cssUrl = localStorage.getItem("cssUrl"); var jsUrl = localStorage.getItem("jsUrl"); var version = localStorage.getItem("version"); diff --git a/js/index.js b/js/index.js index 6111c8c..5b7dae4 100644 --- a/js/index.js +++ b/js/index.js @@ -45,7 +45,7 @@ mui.back = function() { }; //获取cid用于推送 mui.plusReady(function() { - // var cid = plus.push.getClientInfo().clientid; + var cid = plus.push.getClientInfo().clientid; var timer = 0; timer = setInterval(function() { getData(); @@ -66,7 +66,8 @@ mui.plusReady(function() { var ipxSizeBottom = 0; localStorage.setItem('ipxSizeTop', ipxSizeTop); localStorage.setItem('ipxSizeBottom', ipxSizeBottom); - init(data); + // TODO: 这个就是检测新版本的方法 -> init@start.js 先注释了,避免打不开 + // init(data); jumpPage(ipxSizeBottom); nav(0); } diff --git a/js/start.js b/js/start.js index 2ae9c0e..9053ad6 100644 --- a/js/start.js +++ b/js/start.js @@ -87,7 +87,7 @@ function jumpPage(ipxSizeBottom) { //跳转页面 var bSize = 50 + (+ipxSizeBottom) + 'px'; - var subpages = ['templete/home.html', 'templete/shops.html', '', 'templete/zhuweiba.html', + var subpages = ['templete/home.html', 'templete/shops.html', 'templete/zhugouba.html', 'templete/zhuweiba.html', 'templete/my.html' ]; var subpage_style = { @@ -161,6 +161,10 @@ function jumpPage(ipxSizeBottom) { var targetTab = plus.webview.getWebviewById(targetTab); mui.fire(targetTab, 'refresh'); } + if (targetTab == 'templete/zhugouba.html') { + var targetTab = plus.webview.getWebviewById(targetTab); + mui.fire(targetTab, 'refresh'); + } if (targetTab == 'templete/my.html') { var targetTab = plus.webview.getWebviewById(targetTab); mui.fire(targetTab, 'refresh'); @@ -192,11 +196,7 @@ function jumpPage(ipxSizeBottom) { function nav(num) { //console.log(num); $('.mui-tab-item span .img').each(function(a) { - - if (a == 2) { - - } else if (num == a && a != 2) { - // //console.log(a); + if (num == a) { $(this).attr('src', 'http://img.zgqlg.com.cn/static/app2/img/nav_' + a + '_1.png?version='+localStorage.getItem('version')); } else { $(this).attr('src', 'http://img.zgqlg.com.cn/static/app2/img/nav_' + a + '_0.png?version='+localStorage.getItem('version')); @@ -207,13 +207,8 @@ function nav(num) { $('.mui-bar').on('tap', '.mui-tab-item', function(e) { var num = $(this).attr('data-num'); - if (num == 2) { - $('.nav_in').addClass('shun'); - $('.nav_out').addClass('ni'); - } else { - $('.nav_in').removeClass('shun'); - $('.nav_out').removeClass('ni'); - } + $('.nav_in').removeClass('shun'); + $('.nav_out').removeClass('ni'); nav(num); }) diff --git a/js/zhugouba.js b/js/zhugouba.js new file mode 100644 index 0000000..92aa99c --- /dev/null +++ b/js/zhugouba.js @@ -0,0 +1,331 @@ +$('.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() { + 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/getHelpShopCarousel'), { + 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}); + }) + function getShopList(nowPage, pageSize) { + + lat = localStorage.getItem('lat'); + lng = localStorage.getItem('lng'); + + if (null == lat) { + lat = 36.659565; + lng = 117.125824; + } + var recommenddata = { + shopType: 3, + 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/getHelpSaleShops'), recommenddata, function(data) { + var html = ''; + var shopLevel + 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) { + shopLevel = this.shopLevel + if(0==shopLevel){ + shopLevel ='' + } + html += + '
' + + this.shopName + ''+ shopLevel + '
进店逛逛
' + 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}); + }) +}) + +//获取推荐页 +function getRecommend(page, pagesize) { + var recommenddata = { + type : 3 , + 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}); +}) + +//为你推荐 +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('shopsList.html', 'shopsList.html', {data_keyword: searchName,goodsType:2}); + JZL.openWindow('goodslist.html', 'goodslist.html', {data_keyword: searchName,goodsType :2}); + $('#keyword').val("") +}); +//跳转商品详情页 +mui("body").on('tap', '.bc_img', function() { + var goodsId = $(this).attr('data-goodsId'); + var shopId = $(this).parent().parent().attr('data-shopId'); + var goodsType=$(this).attr('data-goodsType') + JZL.openWindow('details.html', 'details.html' + goodsId, {data_id: goodsId,shopId: shopId,goodsType : goodsType}); +}) diff --git a/templete/zhugouba.html b/templete/zhugouba.html new file mode 100644 index 0000000..768feda --- /dev/null +++ b/templete/zhugouba.html @@ -0,0 +1,85 @@ + + + + + + + + + + +
+
+ + + +
+ +
+
+ +
+
刷新
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+ + + + + + + + diff --git a/templete/zhugouba_remend.html b/templete/zhugouba_remend.html new file mode 100644 index 0000000..a2e0779 --- /dev/null +++ b/templete/zhugouba_remend.html @@ -0,0 +1,88 @@ + + + + + + + + + + +
+
+ + + +
+ +
+
+
+
刷新
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ + + + + + +