var openid = helper.cookies.get("openid");
mui.plusReady(function() {})
Ajax();
//获取数据
function Ajax() {
	$.ajax({
		url: huayi.config.callcenter_url + '/WxLogin/GetProCustomerList',
		data: {
			openid: openid, //微信openid,
		},
		async: true,
		dataType: 'json',
		type: 'get', //HTTP请求类型
		success: function(data) {
			if(data.state.toLowerCase() == "success") {

				if(data.rows && data.rows.length > 0) {
					var arr = [];
					$(data.rows).each(function(i, n) {
						if(n.ParentId == 0) {
							//alert(n.F_CustomerName);
							$('<div class="mui-card mui_contail order"  index="'+n.ParentId+'" data-index="'+n.F_CustomerId+'"><div class="List_top">' +
								'<div class="mui-card-header abc" style="background: #2cc6a7;" data-index="' + n.F_CustomerId + '">' +
								'<li class="mui-table-view-cell mui-media mui-col-xs-2">' +
								'<a class="Seach" data-index="0">' +
								'<div class="Icon icon-1"><img src="../img/house_icon.png"></div>' +
								'<div class="mui-media-body">房屋</div></a>' +
								'</li>' +
								'<div class="mui-height"></div>' +
								'<li class="mui-table-view-cell mui-media mui-col-xs-10 font1">'+n.areaname+n.ProName+n.buldingname+n.F_BusinessLicenseID+
								'</li>' +
								'</div>' +
								'</div>' +
								'<div class="mui-card-content">' +
								'<ul id="house_' + n.F_CustomerId + '">'+
								'<li><span class="font-color3">' + n.CustomerTypeName +
								'</span><span class="font-color2 houses_line">' + n.F_CustomerName +
								'</span></li>'+
								'</ul></div></div>').appendTo('#userList');
							console.log(n.F_CustomerId);
						} else {
							arr.push(n);
						}
						$.each(arr, function(i, v) {
							//alert(n.F_CustomerId);
							//alert(v.ParentId);
							if(n.F_CustomerId == v.ParentId) {
								console.log(v);
								if(v) {
									$('<li><span class="font-color3">' + v.CustomerTypeName +
										'</span><span class="font-color2 houses_line">' + v.F_CustomerName +
										'</span></li>').appendTo('#house_' + n.F_CustomerId);
								}
							}
						});
					});
					//工单跳转
					$('.order').on('tap', function() {
						var index = $(this).attr('index');
						var custome= $(this).attr('data-index');
						// + '&itype=' + itype
						window.location.href = "tenant_edit.html?id=" + index+ '&custome=' + custome;
					});
				}
			}
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；

		}
	})
}