window.onload = function() {
	ifLogin(function(flag) {
		$('body').show();
		httpLoadInfo();
	});
	
}

function httpLoadInfo() {

	$.ajax({
		type: "post",
		url: base_api + 'user/fx-user/order-list',
		dataType: 'json',
		success: function(res_data) {
			ZZLog(res_data);
			if(false == res_data['flag']) {
				if(codeNotLogin == res_data['code']) {
					//					alert(infoNotLogin)
					var URL = '/web/fx/commission_list.html';
					URL = encodeURI(URL);
					location.href = res_data['url'] + URL;
				} else if(codeNotRegister == res_data['code']) {
					location.href = 'register.html';
				} else {
					alert(res_data['msg']);
				}
			} else {
				//..
				var data = res_data['data'];
				var order_list = data['order_list'];
				var HTML = '';
				for(var i = 0, m = order_list.length; i < m; i++) {
					var dict = order_list[i];
					var tempHTML = getHTMLWithParam(dict);
					HTML += tempHTML;
				}
				$('.list_info').html(HTML);

				if(order_list.length == 0) {
					$('#no_info').show();
					return;
				} else {
					$('#no_info').hide();
				}

			}
		},
		error: function() {
			alert(infoApiError);
		}
	});
}

function getHTMLWithParam(dict) {

	var month = getMonthAndDayByDate(dict['start_date'], 'month');
	var day = getMonthAndDayByDate(dict['start_date'], 'day');
	var str = dict.status == '1' ? '<div class="ub-f2 li_font_dark" style="width: 1%;padding-left:0.4rem">' + dict['status_desc'] + '</div>' : '<div class="ub-f2 li_font_gray" style="width: 1%;padding-left:0.4rem">' + dict['status_desc'] + '</div>';

	var html = '<li class="ub ui_p_t13 ui_p_b13 " style="border-bottom:1px solid #e5e5e5;">' +
		'<div class="ub-f2 li_font_dark" style="width: 1%;padding-left:0.12rem">' + month + '月' + day + '日</div>' +
		'<div class="ub-f4 li_font_gray tx-l" style="width: 1%;">' + dict['pro_cate_name'] + '</div>' +
		'<div class="ub-f1 li_font_dark" style="width: 1%;padding-left:0.2rem">¥' + dict['commission_total_money'] + '</div>' + str +
		'</li>'
	return html;
}