//var myDate = new Date();
//myDate.setFullYear(2018, 9, 14);
//var today = new Date();
var activity7 = ''
var timestamp1 = Date.parse( new Date());
if(timestamp1 >=1536854400000) {
$('.nav_block p').eq(3).html('ECT专区');
$('.nav_block').eq(3).attr('id', 'activity7.html');
$('.nav_block img').eq(3).attr('src', 'http://img.juzi199.com/static/app/img/ect.png');
$('.ssbd').attr('src', 'http://img.juzi199.com/Upload/app/banner/ectbanner.png');
activity7 = 'activity7.html';
}else{
activity7 = 'newuser.html';
}
function getCNXH(pageNum, pagesizeNum) {
var data_cnxh = {
page: pageNum ? pageNum : 1,
pagesize : pagesizeNum ? pagesizeNum : 10
}
mui.ajax(hyhUrl('app/Index/guess_like'), {
data: data_cnxh,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
var data = toJson(data);
if(data.status == 1) {
data = data.data;
var html = '';
$.each(data.Rows, function() {
// console.log(hyhImgUrl(this.goodsImg))
html += '
 + ')
推荐' + this.goodsName + '
¥' + Math.round(this.shopPrice * 0.8 * 100) / 100 + '到手价¥' + this.shopPrice + '
可用惠宝抵扣20%货款
'
});
if(pageNum == 1) {
$('.cnxh_con').html(html);
} else if(pageNum > 1) {
$('.cnxh_con').append(html);
}
$('.cnxh_block img').height($('.cnxh_block img').width())
} else {
alert(data.msg);
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// alert(type);
}
});
}
/**
* 下拉刷新具体业务实现
*/
function pulldownRefresh() {
setTimeout(function() {
window.location.reload();
mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
}, 1000);
}
var count = 1;
/**
* 上拉加载具体业务实现
*/
function pullupRefresh() {
setTimeout(function() {
mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 50)); //参数为true代表没有更多数据了。
getCNXH(count, 10)
}, 500);
}
mui.init({
pullRefresh: {
container: "#pullrefresh", //下拉刷新容器标识,querySelector能定位的css选择器均可,比如:id、.class等
down: {
style: 'circle', //必选,下拉刷新样式,目前支持原生5+ ‘circle’ 样式
color: '#2BD009', //可选,默认“#2BD009” 下拉刷新控件颜色
height: '50px', //可选,默认50px.下拉刷新控件的高度,
range: '100px', //可选 默认100px,控件可下拉拖拽的范围
offset: '0px', //可选 默认0px,下拉刷新控件的起始位置
// auto: true, //可选,默认false.首次加载自动上拉刷新一次
contentdown: "下拉可以刷新", //可选,在下拉可刷新状态时,下拉刷新控件上显示的标题内容
contentover: "释放立即刷新", //可选,在释放可刷新状态时,下拉刷新控件上显示的标题内容
contentrefresh: "正在刷新...", //可选,正在刷新状态时,下拉刷新控件上显示的标题内容
callback: pulldownRefresh //必选,刷新函数,根据具体业务来编写,比如通过ajax从服务器获取新数据;
},
up: {
contentrefresh: '正在加载...',
callback: pullupRefresh
}
}
});
mui.plusReady(function() {
window.addEventListener('mask', function(e) { //执行刷新
var mask = mui.createMask(); //callback为用户点击蒙版时自动执行的回调;
mask.show(); //显示遮罩
});
function openAds(item) {
if(item.attr('data-adURL') == '' || item.attr('data-targetType') == 0) {
return;
}
var adURL = item.attr('data-adURL');
var targetType = '';
var data_set = {};
if(item.attr('data-targetType') == 1) {
//商品
targetType = 'details.html';
data_set = {
data_id: adURL
}
} else if(item.attr('data-targetType') == 2) {
//商家
targetType = 'storeout.html';
if(adURL == 1) {
targetType = 'self_shop.html'
}
data_set = {
shopId: adURL
}
} else if(item.attr('data-targetType') == 3) {
//活动
targetType = adURL + '.html';
}
mui.openWindow({
url: targetType,
id: targetType + adURL,
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: data_set,
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
}
getCNXH(1, 10);
mui('.mui-bar-transparent').transparent({
scroller: "#pullrefresh",
offset: 150,
});
//秒杀
var swiper = new Swiper('.time_con .swiper-container', {
pagination: '.time_con .swiper-container .swiper-pagination',
slidesPerView: 4,
paginationClickable: true,
spaceBetween: 6,
freeMode: true
});
$('#news').html(''); //先把惠员快讯清空
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 += '' + this.articleTitle + ' ';
})
$('#news').html(news);
// $('#news_more').html('');
//console.log(news);
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// alert(type);
}
});
//广告数据
var arr1 = ["../img/faxianhaohuo1.png", "../img/huiyuanzhuanhui1.png", "../img/paihangbang.png", "../img/huigou.png", "../img/xinpinshoufa.png", "../img/shangxin.png"]
mui.ajax(hyhUrl('app/Index/getIndexAds'), {
data: {},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
var data = toJson(data);
var banner1 = '';
var banner2 = '';
var html1 = '';
var html2 = '';
var html3 = '';
var o = 0;
//顶部轮播图
if(data.top_img.length != 0) {
var topBanner1 = '';
var topBanner2 = '
';
$.each(data.top_img, function() {
topBanner1 += '
'
topBanner2 += '
'
})
topBanner2 += '
'
topBanner1 += '
'
topBanner1 += topBanner2;
$('#slider').html(topBanner1);
$('.mui-slider-item a img').height($('.mui-slider-item a img').width() * 188 / 375)
$('#slider').height($('.mui-slider-item a img').width() * 188 / 375)
mui("#slider").slider({
interval: 5000
});
document.getElementsByClassName('mui-indicator')[0].className += ' mui-active';
}
//广告区banner
$.each(data.cross_img.cross_top, function() {
banner1 += '';
});
$('.banner .swiper-container .swiper-wrapper').html(banner1);
//banner1
var swiper = new Swiper('.banner .swiper-container', {
pagination: '.banner .swiper-container .swiper-pagination',
slidesPerView: 1,
centeredSlides: true,
paginationClickable: true,
spaceBetween: 6,
grabCursor: true
});
$.each(data.cross_img.cross_bottom, function() {
banner2 += '';
});
$('.banner1 .swiper-container .swiper-wrapper').html(banner2);
//banner2
var swiper = new Swiper('.banner1 .swiper-container', {
pagination: '.banner1 .swiper-container .swiper-pagination',
slidesPerView: 1,
centeredSlides: true,
paginationClickable: true,
spaceBetween: 6,
grabCursor: true
});
$('.banner .swiper-container .swiper-wrapper .swiper-slide img').height($('.banner .swiper-container .swiper-wrapper .swiper-slide img').width() * 162 / 600);
$('.banner1 .swiper-container .swiper-wrapper .swiper-slide img').height($('.banner .swiper-container .swiper-wrapper .swiper-slide img').width() * 162 / 600);
var adsArr = [];
for(var i in data.ads) {
adsArr.push(data.ads[i]);
}
$('.box_1').each(function(num) {
$(this).children('p').html(adsArr[num].name);
$(this).children('.boxcon').children('img').eq(0).attr('src', hyhImgUrl(adsArr[num].list[0].adFile ? adsArr[num].list[0].adFile : ''));
$(this).children('.boxcon').children('img').eq(0).attr('data-adURL', adsArr[num].list[0].adURL ? adsArr[num].list[0].adURL : '');
$(this).children('.boxcon').children('img').eq(0).attr('data-targetType', adsArr[num].list[0].targetType ? adsArr[num].list[0].targetType : '');
$(this).children('.boxcon').children('img').eq(1).attr('src', hyhImgUrl(adsArr[num].list[1].adFile ? adsArr[num].list[1].adFile : ''));
$(this).children('.boxcon').children('img').eq(1).attr('data-adURL', adsArr[num].list[1].adURL ? adsArr[num].list[1].adURL : '');
$(this).children('.boxcon').children('img').eq(1).attr('data-targetType', adsArr[num].list[1].targetType ? adsArr[num].list[1].targetType : '');
})
$('.pzss1').each(function(num) {
$(this).children('.p1').html(adsArr[num + 6].name.slice(0, 4));
$(this).children('.p2').html(adsArr[num + 6].name.slice(4));
var adsList = adsArr[num + 6].list;
if(adsList.length == 0) {
adsList.push({
"adFile": "",
"adURL": "",
"targetType": 0
});
adsList.push({
"adFile": "",
"adURL": "",
"targetType": 0
});
} else if(adsList.length == 1) {
adsList.push({
"adFile": "",
"adURL": "",
"targetType": 0
});
}
$(this).children('.boxcon').children('img').eq(0).attr('src', hyhImgUrl(adsList[0].adFile));
$(this).children('.boxcon').children('img').eq(0).attr('data-adURL', adsList[0].adURL);
$(this).children('.boxcon').children('img').eq(0).attr('data-targetType', adsList[0].targetType);
$(this).children('.boxcon').children('img').eq(1).attr('src', hyhImgUrl(adsList[1].adFile));
$(this).children('.boxcon').children('img').eq(1).attr('data-adURL', adsList[1].adURL);
$(this).children('.boxcon').children('img').eq(1).attr('data-targetType', adsList[1].targetType);
})
},
error: function(xhr, type, errorThrown) { //异常处理;
// alert(type);
}
});
$('.msg').on('tap', function() {
mui.openWindow({
url: 'journalism.html',
id: 'journalism.html',
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
})
mui(".cnxh_con").on('tap', '.cnxh_block', function() {
// var tj = plus.webview.create('search.html');
// tj.show();
// alert(e.target.attributes["data-id"].nodeValue);
var data_id = this.attributes["data-id"].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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
})
mui(".nav").on('tap', '.nav_block', function() {
// var tj = plus.webview.create('search.html');
// tj.show();
// alert(e.target.attributes["data-id"].nodeValue);
var url = this.attributes["id"].nodeValue;
//品牌街跳转
if(url == 'activity4.html') {
mui.openWindow({
url: 'self_shop.html',
id: 'self_shop.html' + 1,
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
shopId: 1
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
return;
}
// console.log(this.attributes["data-id"].nodeValue);
mui.openWindow({
url: url,
id: url,
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
})
$('#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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
}
});
$("body").on('tap', '.ssbd', function() {
mui.openWindow({
url: activity7,
id: activity7,
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
// data_keyword: searchName
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
});
//首页广告跳转
$('.boxcon').on('tap', 'img', function() {
openAds($(this));
})
//轮播图跳转
$('#slider').on('tap', '.mui-slider-item', function() {
openAds($(this));
})
//banner跳转
$('.banner').on('tap', '.swiper-slide', function() {
openAds($(this));
})
$('.banner1').on('tap', '.swiper-slide', function() {
openAds($(this));
})
//3.8活动页
// var btnArray = ['否', '是'];
// mui.confirm('跳转到3.8女神节活动页?', '合源惠商城', btnArray, function(e) {
// if(e.index == 1) {
// mui.openWindow({
// url: 'activity7.html',
// id: 'activity7.html',
// show: {
// aniShow: 'none'
// },
// waiting: {
// autoShow: false
// }
// })
// } else {
//
// }
// })
var isZz = localStorage.getItem('isZz') ? localStorage.getItem('isZz') : 1;
if(isZz == 1) {
localStorage.setItem('isZz', 0);
$('body').append('');
}
$('body').on('tap', '.mui-backdrop', function() {
$(this).css('display', 'none');
mui.openWindow({
url: 'newuser.html',
id: 'newuser.html',
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
// data_keyword: searchName
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
})
})