var nowOrderId = null;
mui.ready(function() {
	var nowUrl = location.href;
	var orderId = nowUrl.split("?")[1].split("&")[0].split("=")[1];
	nowOrderId = orderId;
//	selectUser({
//		"orderId": orderId
//	});
	//getCartNum();
	$(document).on('tap', '#check-order-desc', function() {
		location.href='order_details.html?orderId='+nowOrderId
	});
	document.querySelector('.loading-bg').style.display = 'none'
});


function selectUser(orderId) {
	var btnArray = ['否', '是'];
	$.ajax(base_path + '/order/getOrderInfo', {
		data: orderId,
		dataType: 'json',
		type: 'post',
		timeout: 15000,
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		success: function(dt) {
			if(dt.isRedirect) {
				location.href = dt.redirectURL;
			} else {
				if(dt.status) {
					var order = dt.data;
					$("#pay-money-total").html((order.salesYetAmount / 100).toFixed(2));
					$("#orderid-span").html(order.salesOrderid);
					$("#check-order-desc").attr("value", order.salesOrderid);
					$('#check-luck-draw').attr("value", order.salesOrderid);
					var date = new Date(order.salesTransactionDate);
					var str = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + "  " + date.getHours() + ":" + date.getMinutes() + ":" + (date.getSeconds() + 1);
					$("#pay-date-span").html(str);
					$("#show-div-data").show();
					$("#now-load-data-div-bg").hide();
					$("#check-order-desc").attr("href", "order_details.html?orderId=" + nowOrderId)
				} else {
					mui.confirm(dt.message + '是否刷新页面?', '提示', btnArray, function(e) {
						if(e.index == 1) {
							location.reload(true)
						}
					})
				}
			}
		},
		error: function(xhr, type, errorThrown) {
			console.log(xhr)
		}
	})
};