|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- window.onload = function() {
-
- httpBaseInfo();
- $('#div_body').removeClass('ui_hide');
- }
-
- function httpBaseInfo() {
- $.ajax({
- type: "post",
- url: $$.base_api + 'home/home/home-list',
- dataType: 'json',
- success: function(res_data) {
- $$.ZZLog(res_data);
- if(res_data.flag == false) {
- $$.alert(res_data.msg);
- } else {
- replaceBaseInfo(res_data.data);
- }
- },
- error: function() {
- alert($$.infoApiError);
- }
- });
-
- // var temp_lunbo = "";
- //轮播
- // for(var i = 0, j = 3; i < j; i++) {
- // // var str = data.recomList[i].toUrl;
- // temp_lunbo += '<div class="swiper-slide"><img to_url="https://m.simpletour.com/mobile/gateway/wechat/line/detail/2" style="width: 100%;" src="images/banner.png"; /></div>'
- // }
- // $(".swiper-wrapper").html(temp_lunbo);
- //轮播空间swiper
- // var swiper = new Swiper('.swiper-container', {
- // pagination: '.swiper-pagination',
- // loop: true,
- // paginationClickable: true,
- // centeredSlides: true,
- // autoplay: 2000,
- // autoplayDisableOnInteraction: false,
- // onTouchEnd: function(swiper) {
- // if(Math.abs(swiper.touches.currentX - swiper.touches.startX) < 3) {
- // location.href = $('.swiper-container img').eq(swiper.activeIndex).attr('to_url');
- // }
- // }
- // updateFormElements : true,//当内嵌图像加载完成之后 会重新初始化对象
- // followFinger: false
- // });
-
- // $("img.lazy-load").lazyload({
- // threshold: -120,
- // effect: "fadeIn"
- // });
-
- // $(".lazy-load").lazyload({
- // threshold: -70,
- // effect: "fadeIn"
- // })
-
- window.tabbar.init({ index: 0, }, function(n) {
- console.log(n);
- });
-
- }
-
- //替换数据
- function replaceBaseInfo(data) {
- //轮播
- var banner_list = data.banner_list;
- var temp_banner = '';
- banner_list.forEach(function(dict, index) {
- temp_banner += '<div class="swiper-slide"><img to_url="' + dict.toUrl + '" style="height:1.48rem" src="' + dict.img + '"; /></div>'
- });
- $(".swiper-wrapper").html(temp_banner);
- var swiper = new Swiper('.swiper-container', {
- pagination: '.swiper-pagination',
- loop: true,
- paginationClickable: true,
- centeredSlides: true,
- autoplay: 2000,
- autoplayDisableOnInteraction: false,
- onTouchEnd: function(swiper) {
- if(Math.abs(swiper.touches.currentX - swiper.touches.startX) < 3) {
- location.href = $('.swiper-container img').eq(swiper.activeIndex).attr('to_url');
- }
- }
- });
-
- //热门目的地
- var hot_area_list = data.hot_area;
- var temp_hot_area = '';
- hot_area_list.forEach(function(dict, index) {
- temp_hot_area += '<div class="ub-f1 tx-c hot_area" area_id=' + dict.area_id + '>' + dict.area_name + '</div>';
- })
- $('.hot_area_info').html(temp_hot_area);
- $('.hot_area').on('click', function() {
- var area_id = $(this).attr('area_id');
- $$.ZZLog(area_id);
- });
-
- //主分类
- $('.sigle_cms').on('click', function() {
- var cms_id = $(this).attr('cms_id');
- $$.ZZLog(cms_id);
- });
-
- //广告
- $('.ad').attr('data-original', data.ad.img);
- $('.ad').attr('to_url', data.ad.toUrl);
- $('.ad').on('click', function() {
- var to_url = $(this).attr('to_url');
- $$.ZZLog(to_url);
- });
-
- //猜你喜欢
- var like_list = data.like.like_list;
- var temp_like = '';
- like_list.forEach(function(dict, index) {
- // if (index == 1) {
- // dict.show_img = 'http://img.zhizhuchuxing.cn/wechat/ad1.jpg';
- // }else if(index == 2){
- // dict.show_img = 'http://h5.sztoda.cn/static/img/loveLetter/teacher/teacher4.jpg';
- // }else{
- // dict.show_img = 'http://h5.sztoda.cn/static/img/loveLetter/teacher/teacher3.jpg';
- // }
- var t_star = dict.star;
- var star = parseFloat(t_star).toFixed(1);
- var star_integer = parseInt(star);
- var star_flt = star - star_integer;
- //全星
- var star_o_s = '';
- for (var i = 0; i < star_integer; i++) {
- star_o_s+='<div class="ub-f1 star" style="width: 0.1rem;height: 0.1rem;background-image: url(images/home/staro.png);margin: 0.01rem;background-repeat:no-repeat;background-size:100% 100%"></div>';
- }
- //判断是否填充半星
- if (star_integer<5 && star_flt > 0) {
- star_o_s+='<div class="ub-f1 star" style="width: 0.1rem;height: 0.1rem;background-image: url(images/home/starh.png);margin: 0.01rem;background-repeat:no-repeat;background-size:100% 100%"></div>'
- }
- //判断是否还要填充空星
- var star_e = 5 - star;
- if(star_e >= 1){
- star_o_s += '<div class="ub-f1 star" style="width: 0.1rem;height: 0.1rem;background-image: url(images/home/stare.png);margin: 0.01rem;background-repeat:no-repeat;background-size:100% 100%"></div>'
- }
-
-
- // '<div class="ub-f1 star" style="width: 0.1rem;height: 0.1rem;background-image: url(images/home/stare.png);margin: 0.01rem;background-repeat:no-repeat;background-size:100% 100%"></div>' +
- // '<div class="ub-f1 star" style="width: 0.1rem;height: 0.1rem;background-image: url(images/home/stare.png);margin: 0.01rem;background-repeat:no-repeat;background-size:100% 100%"></div>' +
- // '<div class="ub-f1 star" style="width: 0.1rem;height: 0.1rem;background-image: url(images/home/stare.png);margin: 0.01rem;background-repeat:no-repeat;background-size:100% 100%"></div>' +
- // '<div class="ub-f1 star" style="width: 0.1rem;height: 0.1rem;background-image: url(images/home/stare.png);margin: 0.01rem;background-repeat:no-repeat;background-size:100% 100%"></div>' +
- // '<div class="ub-f1 star" style="width: 0.1rem;height: 0.1rem;background-image: url(images/home/stare.png);margin: 0.01rem;background-repeat:no-repeat;background-size:100% 100%"></div>' +
- temp_like += '<div style="background-color: #ffffff;margin-bottom: 0.05rem;" pro_cate_id=' + dict.pro_cate_id + '>' +
- '<div style="padding: 0.08rem;" class="ub">' +
- '<img class="lazy-load" src="images/home/productloading.png" data-original="' + dict.show_img + '" style="width: 1rem;height: 1rem;"/>' +
- '<div class="ub-f1 ub ub-ver" style="padding-left: 0.08rem;">' +
- '<div class="ulev1" style="color: #2d2e3a;">' + dict.pro_cate_name + '</div>' +
- '<div style="padding: 0.08rem 0;">' +
- '<span style="padding: 0.04rem 0.15rem;background-color: #e9ebee;border-radius: 0.5rem;color: #2d2e3a;">' + dict.category_name + '</span><span></span>' +
- '</div>' +
- '<div class="ub ub-ae ub-f1">' +
- '<div class="ub ub-ver">' +
- '<div class="ub">' +
- '<div class="ulev0" style="line-height: 1.0;color: #686872;">评分' + dict.star + '</div>' +
- '<div class="ub-f1 ub ub-ac star_ary" style="padding-left: 0.03rem;" star=' + dict.star + '>' +
- star_o_s +
- '</div>' +
- '</div>' +
- '<div style="color: #686872;">月销' + dict.sales_count + '单</div> ' +
- '</div>' +
- '<div class="ub-f1 tx-r ub ub-ver ub-ae">' +
- '<div class="ub ub-ae" style="line-height: 1;text-decoration: line-through;text-decoration-color:#96969c;color: #96969c;">原价' + dict.original_price + '元</div>' +
- '<div style="color: #686872;"><span class="ulev3" style=" color: #cc3333;">¥' + dict.show_price + '</span>起</div>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>';
-
- })
- $('.like_list').html(temp_like);
-
- // var t_star = $('.star_ary').attr('star');
- // var star = parseFloat(t_star).toFixed(1);
- // var star_integer = parseInt(star);
- // var star_flt = star - star_integer;
- // for(var i = 0; i < star_integer; i++) {
- // console.log($('.star_ary').children().eq(i).c);
- // $('.star_ary').children().eq(i).css('background-image', 'url(images/home/staro.png)');
- // }
-
- //精品推荐
- var recommon_list = data.recommon.recommon_list;
- var temp_recommon = '';
- var one = '';
- recommon_list.forEach(function(dict, index) {
- if(index % 2 == 0) {
- var left_html = getHtmlByDict(dict);
- one += '<div class="ub" style="margin-bottom: 0.05rem;">';
- one += left_html;
- one += '<div style="width: 0.05rem;"></div>';
- } else {
- var right_html = getHtmlByDict(dict);
- one += right_html;
- one += '</div>';
- temp_recommon += one;
- one = '';
- }
- });
- $('.recommon_info').html(temp_recommon);
-
- $(".lazy-load").lazyload({
- threshold: -70,
- effect: "fadeIn"
- })
- }
-
- function getHtmlByDict(dict) {
- if(dict.show_img == '') {
- dict.show_img = 'images/home/product02loading.png';
- }
- var html = '<div class="ub-f1 ub" style="background-color: #FFFFFF;width: 1%;" pro_cate_id=' + dict.pro_cate_id + '>' +
- '<div class="ub ub-ver ub-f1" style="padding: 0.08rem;">' +
- '<img class="lazy-load" src="images/home/product02loading.png" data-original=' + dict.show_img + ' style="width: 1.69rem;height: 0.9rem;" />' +
- '<div class="ulev1" style="padding-top: 0.08rem;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;color: #2d2e3a;">' + dict.pro_cate_name + '</div>' +
- '<div class="ub ub-ae ub-f1 ui_p_t10">' +
- '<div style="color: #96969c;text-decoration: line-through;text-decoration-color:#96969c;">原价' + dict.original_price + '元</div>' +
- '<div class="ub-f1 tx-r" style="color: #686872;">' +
- '<span class="ulev3" style="color: #cc3333;">¥' + dict.show_price + '</span>起' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>'
- return html;
- }
-
- //查询产品
- function goToSearch() {
- window.location.href = './prod_search.html';
- }
|