var colorArray = ['#9c0010','#fea262','#fbecc5','#780b06','#f8c78f']; var bannerImag = ['https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgBanner01.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgBanner02.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgBanner03.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgBanner04.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgBanner05.png']; var titleImag = ['https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/title01.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/title02.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/title03.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/title04.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/title05.png']; var bgImage = ['https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bg01.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bg02.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bg03.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bg04.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bg05.png']; var bgTopImage = ['https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgTop01.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgTop02.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgTop03.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgTop04.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bgTop05.png']; var commodityBgImage = ['https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/conBg01.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/conBg02.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/conBg03.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/conBg04.png','https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/conBg05.png'] var day = '';//国庆第几天 var page = 1;//页数 var qs = parseQueryString(window.location.href); $().ready(function() { if (qs.day) { day = qs.day; } getData();//获取数据 }) //页面初始化 function init () { $('body').css('background',colorArray[day-1]) $('.banner img').attr('src',bannerImag[day-1]) $('.activityList').css({'background':'url(' + bgImage[day-1] + ') no-repeat','background-size':'100% 100%'}) $('.activityList .title').css({'background':'url(' + titleImag[day-1] + ') no-repeat','background-size':'100% 100%'}) $('.activityList').eq(0).css({'background':'url(' + bgTopImage[day-1] + ') no-repeat','background-size':'100%','background-position': '0 0.5rem'}) $('.commodityListCon').css({'background':'url(' + commodityBgImage[day-1] + ') no-repeat','background-size':'100%'}) //根据天数改变样式 if(day == 1){ $('.tab li .img').css({'border-radius':'0','background':'none'}) $('.tab li .img img').css({'width':'0.55rem','height':'0.55rem'}) }else if(day == 2){ $('.title').css({'height': '0.45rem','color':'#7B1F00'}) $('.tab li .img').css({'border-radius':'0','background':'none'}) $('.tab li .img img').css({'width':'0.55rem','height':'0.55rem'}) $('.tab li span').css({'color':'#E6250D'}) $('.con').css({'width': '3.35rem','padding-top': '0.29rem'}) $('.commodityList ul li').css({'margin-left': '0.01rem'}) $('.con li p').css({'color':'#FE3967'}) $('.nowPrice').css({'color':'#FE3967'}) $('.oldPrice').css({'color':'#FF6D7E'}) }else if(day == 3){ $('.title').css({'height': '0.45rem','color':'#FFFFFF'}) $('.tab li .img').css({'border-radius':'0','background':'none'}) $('.tab li .img img').css({'width':'0.55rem','height':'0.55rem'}) $('.tab li span').css({'color':'#000000'}) $('.con li p').css({'color':'#FFF4C4'}) $('.nowPrice').css({'color':'#FFFFFF'}) $('.oldPrice').css({'color':'#FFFFFF'}) }else if(day == 4){ $('.title').css({'width': '100%','color': '#FFFFFF','line-height': '0.48rem'}) $('.con').css({'width': '3.5rem','padding-top': '0.35rem'}) }else if(day == 5){ $('.title').css({'color': '#FD5E25','line-height': '0.55rem'}) $('.con').css({'width': '3.75rem'}) $('.con .img').css({'border': '0.01rem solid #FCB502'}) } } //获取地址栏参数 function parseQueryString(url) { var urlObj = {}; var reg = /([^?=&]+)=([^?=&]+)/g; url.replace(reg, ($0, $1, $2) => { urlObj[$1] = decodeURIComponent($2); }) return urlObj; } //获取数据 function getData(){ $.ajax({ type: "POST", url: "/api/v2/goods/nationalDayActive", data:{ day : day }, success:function(res){ if(res.errno == "0" && res.rst){ var data = res.rst.data; var html = ''; html = template_Strategy (data) } } }) } //攻略模板 function template_Strategy(data) { var html = ''; var img = '' ; data.forEach(function (item, index) { var grouplist = item.grouplist; //tab列表 var goodslist = item.goodslist; //6个商品 html += '
' + item.name + '
    '; //每个分类下的6个商品 for(var i in goodslist){ var goods_id = goodslist[i].goods_id; //商品id var is_coupon = goodslist[i].is_coupon; //有没有券 var price = goodslist[i].price; //原价 var coupon_price = goodslist[i].coupon_price; //券价格 var discount_price = goodslist[i].discount_price; //折扣价 var itemUrl = "'"+encodeURIComponent(goodslist[i].item_url)+"'"; //去淘宝 // console.log(itemUrl) html +='
  • ¥'+ goodslist[i].coupon_price +'

    '+ goodslist[i].title +'

    ¥'+ goodslist[i].discount_price +'¥'+ goodslist[i].price +'
  • '; } html += '
'; }) $("#activity").html(html); init();//初始化 } //点击跳转到list页面 function toList(parent_id,son_id,page){ window.location.href = "list.html?parent_id="+ parent_id +"&son_id="+ son_id +"&page="+ page } //点击跳转到详情页面 function toDetails(goods_id,coupon_price,is_coupon,price,discount_price,itemUrl){ window.location.href = "details.html?goods_id="+ goods_id +"&coupon_price="+ coupon_price +"&is_coupon="+ is_coupon +"&price="+ price +"&discount_price="+ discount_price + "&itemUrl="+ itemUrl }