//我的佣金
var toURL = 'apply_for.html?'+version;
window.onload = function() {
	ifLogin(function(flag){
		$('body').show();
		httpLoadInfo();
	},'my_commission.html')
}

function httpLoadInfo() {
	$.ajax({
		type: "post",
		url: base_api + 'user/fx-user/my-commission',
		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/my_commission.html';
					URL = encodeURI(URL);
					location.href = res_data['url'] + URL;
				} else if(codeNotRegister == res_data['code']) {
					location.href = 'register.html?toURL=my_commission.html';
				} else {
					alert(res_data['msg']);
				}
			} else {
				var data = res_data['data'];
                toURL = data['BindWxUrl'];
				var headimgurl = data['headimgurl']; //微信头像
				var nickname = data['nickname']; //微信昵称
				var phone = data['phone']; //手机号
				var total_commission = data['total_commission']; //累计佣金
				var available_commission = data['available_commission']; //可提佣金
				var remaining_sum = data['remaining_sum_s'];//预付款余额

				var apply_rule = data['apply_rule'];
				
				var my_obj = {
					balance:available_commission,
					nick_name:nickname,
					apply_rule:apply_rule,
					remaining_sum:remaining_sum
				}
				setStorJson('my_commission_20170315',my_obj);


				$('.header_image').attr('src', headimgurl);
				$('#nick_name').text(nickname);
				$('#phone').text(phone);
				$('#total_commission').text('¥' + total_commission);
				$('#balance').text('¥'+remaining_sum);
				$('#available_commission').text('¥' + available_commission);
			}
		},
		error: function() {
			alert(infoApiError);
		}
	});
}

$(document).ready(function() {

	//佣金明细
	$('#commission_detail').on('click', function() {
		location.href = 'commission_list.html?'+version;
	})

	//订单明细
	$('#order_detail').on('click', function() {
		location.href = 'order_list.html?'+version;
	})
	
	//收支明细
	$('#balance_detail').on('click',function(){
		location.href = 'balance_list.html?'+version;
	})

	//提现
	$('#apply_for').on('click', function() {
		location.href = toURL;
	})
	
	//充值
	$('.recharge').on('click',function() {
		location.href = 'recharge_money.html?'+version;
	})

})