// $('.saoyisao').css('display', 'none');
$('#search').css('width', '80%');
$('#search').css('left', '5%');
$('.searchimg').css('left', '8%');
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(qlgUrl('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('
没有更多商品
');
isjiazai = 0;
return;
}
$.each(data.Rows, function() {
html += ' +
')
自营' + this.goodsName + '
¥' + this.shopPrice +
' 满减
可用木吉抵扣20%货款

';
});
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)
// //console.log(2)
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(errorThrown);
}
});
}
mui.plusReady(function() {
var ua = navigator.userAgent.toLowerCase();
var issx = 0;
//bannerTop
mui.ajax(qlgUrl('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 += '';
});
$('#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 {
mui.alert(data.msg)
// //console.log(data.status)
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.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));
})
var num = 0;
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: {
from_id,
classifyId: classifyId
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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,
from_id,
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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: {
from_id,
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
}
});
})