<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>活动</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" type="text/css" href="//css.iamberry.com/tooth/css/mui.min.css?v=2016101701" />
		<link rel="stylesheet" type="text/css" href="//css.iamberry.com/tooth/css/style.css?v=2016101701" />
		<style>
			.mui-table-view-chevron .mui-table-view-cell{padding-right:10px;}
			.mui-table-view-chevron .mui-table-view-cell>a:not(.mui-btn) {margin-right: -10px;}
			p{font-size:12px;}
			.mui-pull-right{font-size: 12px;color:#d22c50;}
			.mui-table-view .mui-media-body{margin-top: 5px;}
			.mui-table-view .mui-media-object {line-height: 50px;max-width: 50px;height: 50px;}
			#whell-bar{background-color: #fff;height: 60px;-webkit-box-shadow: 0 0 1px rgba(0,0,0,.35);box-shadow: 0 0 1px rgba(0,0,0,.35);display:none;}
		</style>
		<script type="text/javascript">
			// 屏蔽分享
			window.hiddenAllWechatMenu = true;
		</script>
	</head>
	<body>
	<div class="loading-bg">
			<div class="mui-loading">
				<div class="mui-spinner">
				</div>
				&nbsp;&nbsp;加载中...
			</div>
	</div>
		<nav class="mui-bar mui-bar-tab" id="whell-bar">
			<a class="mui-tab-item mui-active">
				<div class="my-tab-label" style="font-size: 12px;color: #d22c50;">立即去下单，把奖品抱回家吧！</div>
				<button type="button" class="mui-btn my-btn-red" style="top: 0;width: 165px;background: #d22c50;">立即购买</button>
			</a>
		</nav>
		<!--下拉刷新容器开始-->
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<!--数据列表-->
				<ul class="mui-table-view mui-table-view-chevron my-tab-view-pull">
					
				</ul>
			</div>
		</div>
		<!--下拉刷新容器结束-->
	<script src="//s.iamberry.com/tooth/js/mui.min.js"></script>
	<script src="//s.iamberry.com/tooth/js/jquery-2.1.1.min.js"></script>
	<script src="//s.iamberry.com/tooth/js/shop/main.js"></script>
	<script src="//s.iamberry.com/tooth/js/shop/wechat-utils-1.0.js"></script>
	<script type="text/javascript">
	
	var pageNumber = 0,pagesize = 10;
	mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					down: {
//						callback: pulldownRefresh
					},
					up: {
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
	});
			/**
			 * 上拉加载具体业务实现
			 */
			function pullupRefresh() {
				/* setTimeout(function() {
					mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2)); //参数为true代表没有更多数据了。
					var table = document.body.querySelector('.my-tab-view-pull');
					var cells = document.body.querySelectorAll('.my-tab-view-pull .mui-table-view-cell');
					for (var i = cells.length, len = i + 10; i < len; i++) {
						var li = document.createElement('li');
						li.className = 'mui-table-view-cell';
						li.innerHTML = '<a href="javascript:;"><img class="mui-media-object mui-pull-left" src="images/image-12.jpg"><div class="mui-media-body">获得一等奖'+(i+1)+'<p class="mui-ellipsis">iPhone7 亮黑版 32G一台</p></div><span class="mui-btn mui-btn-link">2016.09.19 20:00</span></a>';
						table.appendChild(li);
					}
				}, 1500); */
				++pageNumber;
				var btnArray = ['否', '是'];
				var table = document.body.querySelector('.my-tab-view-pull');
				mui.ajax(base_path + '/game/get_prize_log?dates=' + new Date().getTime(), {
					data: {
						"pageSize": pagesize,
						"pageNO": pageNumber
					},
					dataType: 'json',
					type: 'post',
					timeout: 15000,
					success: function(dt) {
						console.log(dt);
						if (dt.status) {
							var data =dt.data;
							var wheel_data =[];
							if (null != data && data!="0") {
								wheel_data = data.winningList;
							}
							mui('#pullrefresh').pullRefresh().endPullupToRefresh((wheel_data.length < pagesize)); //参数为true代表没有更多数据了。
							mui(wheel_data).each(function(index) {
								var li = document.createElement('li');
								li.className = 'mui-table-view-cell';
								li.innerHTML = '<a href="javascript:;"><img class="mui-media-object mui-pull-left" src="'+this.logsPrizeImage+'"><div class="mui-media-body">'+ this.logsPrizeName +'<span class="mui-pull-right">' + this.logsGameName + '</span><p class="mui-ellipsis">' + this.logsDate + '<span class="mui-pull-right">x' + this.logsSum + '</span></p></div></a>';
								table.appendChild(li);
						});
					} else {
						mui.confirm(dt.message, '爱贝源-提示', btnArray, function(e) {
							if (e.index == 1) {
								location.reload(true);
							}
						});
					}
				},
				error: function(xhr, type, errorThrown) {
					//异常处理；
					errorfn(xhr);
				}
			});
			}
	mui.ready(function(){
		console.log("页面加载完毕");
		mui('#pullrefresh').pullRefresh().pullupLoading();
		$.ajax({
			type: 'post',
			url: base_path + '/game/buyOrder',
			data: {gameId:2},
			dataType: 'json',
			timeout: 15000,
			context: $('body'),
			success: function(data){
				if(data.status){
					if(!data.data){
						$("#whell-bar").show();
					}
				}
			},
			error: function(xhr, type){
				console.log('Ajax error!' + xhr)
				}
			});
		document.querySelector('.loading-bg').style.display='none';
	});	
	mui('body').on('tap', '#whell-bar .mui-btn', function() {
		mui.openWindow({
		url:'https://w.iamberry.com/tooth/wechat/index'
		});
	});
		</script>
	</body>
</html>
