var nowOrderId = null;
var isSpell=getParam('isSpell'),isSpellstr='';
if(isSpell==1){
	isSpellstr='&isSpell=1';
}
mui.ready(function() {
	var nowUrl = location.href;
	nowOrderId = getParam('orderId');
	selectUser(nowOrderId)
});


function selectUser(orderId) {
	var btnArray = ['否', '是'];
	$.ajax(base_path + '/cart/getShopOrderByOrderId', {
		data: {
			orderId: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;
					$("#check-order-desc").attr("value", order.salesOrderid);
					if(isSpell==1){
						isSpellstr+='&productId='+order.orderItemList[0].itemProductId+'&colorId='+order.orderItemList[0].itemColorId
						if(typeof(order.salesSpellOrderId)!="undefined"){
							$("#check-order-desc").attr("href", "order_details.html?orderId=" + nowOrderId+isSpellstr)
						}else{
							location.href='pay_add_group.html?orderId='+nowOrderId+isSpellstr
						}
					}else{
						$("#check-order-desc").attr("href", "order_details.html?orderId=" + nowOrderId)
					}
					
					$(document).on('tap', '#check-order-desc', function() {
						location.href=$(this).attr('href');
					});
					document.querySelector('.loading-bg').style.display = 'none';
				} else {
					mui.confirm(dt.message + '是否刷新页面?', '提示', btnArray, function(e) {
						if(e.index == 1) {
							location.reload(true)
						}
					})
				}
			}
		},
		error: function(xhr, type, errorThrown) {
			console.log(xhr)
		}
	})
};