mui.ready(function() {
	//springFestivalPop();
	marquee_Show();
	getCartNum();
	mui.ajax(base_path + '/indexData?dates=' + new Date().getTime(), {
		dataType: 'json',
		type: 'post',
		timeout: 15000,
		success: function(dt) {
			var bannerstr = "",
				prostr = "",
				dian = "",
				advsstr = "";
			if(dt.status) {
				var banner_data = dt.data.banners;
                var shareOpenid = dt.data.memberOpenid;
                var link = domanUrl + base_path + "/index?shareOpenid=" + shareOpenid;
                window.repleFlag = false;
                window.wxFriend = {
                    "appId": "",
                    "imgUrl": 'http://static.iamberry.com/wateroPF/images/logo_wateroPF.jpg',
                    "link": link,
                    "desc": "美国标准，4级净化，5档水温，水质TDS智能显示。",
                    "title": "WaterO，美国可移动智能净水机代表，4级净化，5档水温，净化饮水一体；",
                    "netError": "您的网络异常，请刷新重试!如多次刷新无效，请向我们反应 ~",
                    "shareTimeSuccess": "分享成功",
                    "shareTimeCancel": "已取消分享",
                    "shareAppSuccess": "分享成功!",
                    "shareAppCancel": "已取消分享"
                };
				mui(banner_data).each(function(index) {
					if(index == 0) {
						bannerstr += '<div class="mui-slider-item mui-slider-item-duplicate"><a href="' + banner_data[banner_data.length - 1].bannerImageCheckOutUrl + '"><img src="' + (banner_data[banner_data.length - 1].bannerImageUrl) + '"></a></div><div class="mui-slider-item mui-active"><a href="' + this.bannerImageCheckOutUrl + '"><img src="' + (this.bannerImageUrl) + '"></a></div>';
						dian += '<div class="mui-indicator mui-active"></div>'
					} else {
						bannerstr += '<div class="mui-slider-item"><a href="' + this.bannerImageCheckOutUrl + '"><img src="' + (this.bannerImageUrl) + '"></a></div>';
						dian += '<div class="mui-indicator"></div>'
					}
					if(index == (banner_data.length - 1) || (banner_data.length - 1) == 0) {
						bannerstr += '<div class="mui-slider-item mui-slider-item-duplicate"><a href="' + banner_data[0].bannerImageCheckOutUrl + '"><img src="' + (banner_data[0].bannerImageUrl) + '"></a></div>'
					}
				});
				dc('mui-slider-loop').innerHTML = bannerstr;
				dc('my-slider-indicator').innerHTML = dian;
				$("<div id='banner-slider' class='mui-slider'><div class='mui-slider-group mui-slider-loop' id='mui-slider-loop'>" + bannerstr + "</div><div id='my-slider-indicator' class='mui-slider-indicator my-slider-indicator'>" + dian + "</div></div>").insertBefore(".chanpin-box");
				var advs_data = dt.data.advs;
				mui(advs_data).each(function(index) {
					advsstr += '<a href="' + this.bannerImageCheckOutUrl + '"><img src="' + this.bannerImageUrl + '" /></a>'
				});
				dc('advs_banner').innerHTML = advsstr;
				dc('advs_banner').style.display = 'block';
				dc('banner-slider').style.display = 'block';
				var banner = mui('#banner-slider');
				banner.slider({
					interval: 5000
				});
				mui.each(document.querySelectorAll('#banner-slider a'), function(index, el) {
					el.addEventListener('tap', function() {
						//document.querySelector('.loading-bg').style.display = 'block';
						var str=this.getAttribute('href');
						console.log(this.getAttribute('href'));
						if(str!="#" && str!=''){
							location.href = this.getAttribute('href')
						}
					}, false)
				});
				mui.each(document.querySelectorAll('#advs_banner a'), function(index, el) {
					el.addEventListener('tap', function() {
						//document.querySelector('.loading-bg').style.display = 'block';
						location.href = this.getAttribute('href')
					}, false)
				});

				document.querySelector('.loading-bg').style.display = 'none'
			} else {
				mui.alert(dt.message, ' ', '朕知道了', function() {
					mui.openWindow({
						url: domanUrl + base_path + "/index?dates=" + new Date().getTime()
					})
				})
			}
		},
		error: function(xhr, type, errorThrown) {
			console.log(xhr)
		}
	});
	if(marquee != '') {
		$('body').append('<div class="marquee-show"><div></div></div>')
	}
	mui('body').on('tap', '.go_jifen_shop', function() {
		mui.alert('敬请期待', ' ', '朕知道了', function() {})
	});
	setTimeout(function() {
		$("#chanpin-slider .mui-slider-item").each(function() {
			if($(this).find('.opacity_0').length > 0) {
				$(this).find('img').prop('src', $(this).find('img').attr('val'));
				$(this).find('.opacity_0').removeClass('opacity_0')
			}
		})
	}, 1500)
});