mui.plusReady(function() {
//	mui(".c-list").on("tap", "li", function() {
//		openWebview("my-doctor-advice-detail.html");
//	});
	//查询列表
	//queryList();
});

function queryList() {
	plus.nativeUI.showWaiting();
	//拼请求内容
	var params = {};
	params.page = 1;
	params.pageSize = 10;
	//发送ajax请求
	sendPost("patient/doctor_orders/doctot_list", params, "json", "post", queryListFailed, queryListSuccesss);
}

function queryListFailed(res) {
	console.log(res.status);
	if (res && res.msg) {
		plus.nativeUI.toast(res.msg);
	} else {
		plus.nativeUI.toast("数据加载失败");
	}
	plus.nativeUI.closeWaiting();
}

function queryListSuccesss(res) {
	if (res.status == 200) {
		//成功
		showList(res.data.list);
	} else {
		//非200则为失败
		queryListFailed(res);
	}
	plus.nativeUI.closeWaiting();
}

/**
 * 显示查询结果
 * @param {Object} list
 */
function showList(list) {	
	var _html = "";
	for (var i = 0; i < list.length; i++) {
		var data = list[i];
		if (!data) {
			continue;
		}
		//addRow(data.content, data.czrq);
		_html+="<li class='c-list-cover' attr_content='"+data.doc_code+"'>";
		_html+="<div class='c-avatar-m'>";
		_html+="<img class='c-images-cycle' src='../../../images/d-default.png'>";
		_html+="</div>";
		_html+="<div class='c-list-info ptb10'>";
		_html+="<h4 class='c-nowrap'>";
		_html+=data.doc_name;
		_html+="<span class='title'>"+data.job+"</span>";
	    _html+="<span class='ml5 c-666 c-f12'>"+data.dept+"</span>";
		_html+="</h4>";
		_html+="<p>"+data.hospital+"</p>";
		_html+="</div>";
//		_html+="<div class='c-list-value' style='margin-right:10px; '>"+data.time.substring(0, 10)+"</div>";
		_html+="</li>";
	}
	$("#ul_order").html(_html);
	
	$("#ul_order").on("click","li",function(){
	 	var content = $(this).attr('attr_content');
	 	mui.openWindow({
			url: "my-doctor-advice_1.html",
			extras: {
				doctor: content
			},
		});
	})
}

function li_click(content){
	mui.openWindow({
			url: "my-doctor-advice-detail.html",
			extras: {
				content: content
			},
		});
}

function addRow(content, czrq) {
	var ul = document.querySelector("#item");
	var li = document.createElement("li");
	li.className = "c-list-text";
	li.onclick = function() {
		mui.openWindow({
			url: "my-doctor-advice-detail.html",
			extras: {
				content: content
			},
		});
	};

	var html = '<div class="c-list-info">';
	html += '<h4 class="c-nowrap">' + content + '</h4></div>'
	html += '<div class="c-list-value">' + czrq.substring(0, 10) + '</div>';

	li.innerHTML = html;
	ul.appendChild(li);
}