助购吧页面JS接口等

This commit is contained in:
Jerry Yan 2019-09-06 16:31:23 +08:00
parent c64195c218
commit bff6584b7d
7 changed files with 522 additions and 19 deletions

View File

@ -47,9 +47,9 @@
<span class="mui-icon"><img class="img" src="" /></span>
<!-- <span>逛商都</span> -->
</a>
<a class="mui-tab-item" href="" data-num='2' style="display: none;">
<a class="mui-tab-item" href="templete/zhugouba.html" data-num='2'>
<span class="mui-icon"><img class="nav_out img" src="" /><img class="nav_in" src="" /></span>
<!-- <span>助吧</span> -->
<!-- <span>助吧</span> -->
</a>
<a class="mui-tab-item" href="templete/zhuweiba.html" data-num='3'>
<span class="mui-icon"><img class="img" src="" /></span>

View File

@ -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");

View File

@ -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);
}

View File

@ -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);
})

331
js/zhugouba.js Normal file
View File

@ -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 += '<div class="swiper-slide add_" data-adURL="' + this.adURL + '" data-targetType="' + this.targetType +
'"><img src="' + hyhImgUrl(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
});
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(
'<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;">没有更多数据</p>');
// isLoading = false;
return;
}
$.each(data.Rows, function(index, element) {
shopLevel = this.shopLevel
if(0==shopLevel){
shopLevel =''
}
html +=
'<div class="con shadown_wai" data-shopId="' + this.shopId +
'"><div class="shops-content1-title" data-shopId="' + this.shopId +
'" data-shopName="'+this.shopName +'" ><span class="logoimg"><img src="' + hyhImgUrl(this.shopImg) +
'"alt=""></span><div class="shop-name">' +
this.shopName + '<img class ="aixinImg" src = "../img/aixin.png"><span class="aixinlevel">'+ shopLevel + '</span> </div><span class="gogogo">进店逛逛</span></div><div class="t_con">'
if (0 != this.goods.length) {
$.each(this.goods, function(idx, ele) {
html += '<div class="t_con_ bc_img" data-goodsId="' + this.goodsId +
'" data-goodsType = 2 ><div class="t_con_img"><img src="' + hyhImgUrl(this.goodsImg) + '" data-goodsId="' + this.goodsId +
'" alt=""></div><span>¥' + this.shopPrice + '</span></div>'
})
}
html += '</div><div class="pos clearfix"><img src="../img/dingwei1.png"><span>距离:' + this.distance / 1000 +
'公里</span></div></div>'
})
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(
'<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 +
'" data-goodsType = 2><img class="rcb_img" src="' + ectImgUrl(this.goodsImg) +
'" alt="" /><div class="rcb_con"><div class="rcb_title"><span style="display:inline-block;" data-shopId="' +
this.shopId + '"></span>' + this.goodsName + '</div><div class="rcb_pay">¥' + this.shopPrice +
' <span style="display:none;">满减</span></div><div class="rcb_bottom"><div><span>' + this.saleNum +
'人购买</span></div><div style="display:none"><span>优惠率&nbsp;&nbsp;' + this.discountRate +
'</span></div></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 {
// 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});
})

85
templete/zhugouba.html Normal file
View File

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title></title>
<link rel="stylesheet" type="text/css" href="../css/mui.css" />
<link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
</head>
<body style="visibility:hidden;">
<div class="header">
<div class="header_con">
<a href="javascript:;" id="location"></a>
<div class="search clearfix" id="search">
<select name="" style="display: none;">
<option value="0">商品</option>
<option value="1">店铺</option>
</select>
<input type="search" name="" id="keyword" value="" placeholder="请输入搜索内容" />
<button style="display: none;">搜索</button>
</div>
<img class="saoyisao" src="../img/saoyisao.png" />
</div>
</div>
<div class="mui-scroll-wrapper selfshop scroll_out" id="pullrefresh">
<div class="mui-scroll self_shops clearfix">
<div class="sx">刷新</div>
<div class="swiper-container" id="top_banner" style="margin:0;">
<div class="swiper-wrapper">
<div class="swiper-slide"><img src="../img/kong.png" /></div>
</div>
<div id="top_banner_pagination" class="swiper-pagination"></div>
</div>
<div class="recommend ">
<div class="recommend_title">
<div class="shops-nav">
<a class="shops-nav1 s-shops on" href="zhugouba.html">助购吧</a>
<a class="shops-nav1 s-remend" href="zhugouba_remend.html">推 荐</a>
</div>
<!-- <img src="../img/recommend_title3.png" /> -->
</div>
<div class="shops-content">
<div class="shops-content1 shoplist">
<div class=" con shadown_wai">
</div>
</div>
<div class="shops-content1" style="display:none">
<div class="recommend_con clearfix">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
mui.plusReady(function() {
var element;
var parent = document.body;
element = document.createElement('script');
element.src = localStorage.getItem("jsUrl") + 'common.js?ver=' + localStorage.getItem('version');
parent.appendChild(element);
element.onload = function() {
var style = [JZL.getCssUrl('global.css'), JZL.getCssUrl('dynamic.css'), JZL.getCssUrl('recommend.css'), JZL.getCssUrl("home_new.css"), JZL.getCssUrl("self_shop.css")];
JZL.css_init(style);
var script = [JZL.getJsUrl("zhugouba.js")];
JZL.js_init(script);
setTimeout(function() {
parent.style.visibility = "visible";
}, 100);
};
mui.init();
mui('body').on('tap', 'a', function() {
window.top.location.href = this.href;
});
})
</script>
</html>

View File

@ -0,0 +1,88 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title></title>
<link rel="stylesheet" type="text/css" href="../css/mui.css" />
<link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
</head>
<body style="visibility:hidden;">
<div class="header">
<div class="header_con">
<a href="javascript:;" id="location-r"></a>
<div class="search clearfix" id="search">
<select name="" style="display: none;">
<option value="0">商品</option>
<option value="1">店铺</option>
</select>
<input type="search" name="" id="keyword" value="" placeholder="请输入搜索内容" />
<button style="display: none;">搜索</button>
</div>
<img class="saoyisao" src="../img/saoyisao.png" />
</div>
</div>
<div class="mui-scroll-wrapper scroll_out" id="pullrefresh">
<div class="mui-scroll self_shop_rem clearfix">
<div class="sx">刷新</div>
<div class="con">
<div class="swiper-container" id="top_banner" style="margin:0;">
<div class="swiper-wrapper">
<div class="swiper-slide"><img src="../img/kong.png" /></div>
</div>
<div id="top_banner_pagination" class="swiper-pagination"></div>
</div>
</div>
<div class="recommend ">
<div class="recommend_title">
<div class="shops-nav">
<a class="shops-nav1 s-shops " href="zhugouba.html">助购吧</a>
<a class="shops-nav1 s-remend on" href="zhugouba_remend.html">推 荐</a>
</div>
</div>
<div class="shops-content">
<div class="shops-content1 ">
<div id="pullrefresh">
<div class=" con shadown_wai" style="display: none;">
<div class="shops-content1-content">
</div>
</div>
</div>
</div>
<div class="shops-content1">
<div class="recommend_con clearfix">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
mui.plusReady(function() {
var element;
var parent = document.body;
element = document.createElement('script');
element.src = localStorage.getItem("jsUrl") + 'common.js?ver=' + localStorage.getItem('version');
parent.appendChild(element);
element.onload = function() {
var style = [JZL.getCssUrl('global.css'), JZL.getCssUrl('dynamic.css'),JZL.getCssUrl('recommend.css'), JZL.getCssUrl("home_new.css"), JZL.getCssUrl("self_shop.css")];
JZL.css_init(style);
var script = [JZL.getJsUrl('recommend.js'), JZL.getJsUrl("zhugouba.js")];
JZL.js_init(script);
setTimeout(function() {
parent.style.visibility = "visible";
}, 100);
};
mui.init();
mui('body').on('tap','a',function(){
window.top.location.href=this.href;
});
})
</script>
</html>