new Vue({
	el: "#app",
	data: {
		records: [],
		historyrecords: [],
		recodestype: '101',
		historytype: '100',
		ishomeNull: false,
		ishistoryNull: false,
	},
	mounted: function() {
		var vm = this
		vm.getlist(1)
		vm.gethistory(1)
	},
	methods: {
		getlist: function(pageNo) {
			var vm = this
			var oauthInfo = JSON.parse(sessionStorage.getItem("oauthInfo"));
			var filters = "userId=" + oauthInfo.id+";state=2;orderId<>null"
			var param = {
				fields: '',
				filters: filters,
				sort: '+registerDate',
				page: pageNo,
				size: 5
			}
			jiuzhenAPI.queryRegOrderInfos(param).then(function(res) {
				vm.records = res.detailModelList
				if(res.totalCount == 0) {
					vm.ishomeNull = true
				} else {
					vm.inithomePage(pageNo, res.totalPage, res.totalCount)
				}
			})
		},
		gethistory: function(pageNo) {
			var vm = this
			var oauthInfo = JSON.parse(sessionStorage.getItem("oauthInfo"));
			var param = {
				type: 100,
				appId: httpRequest.client_id,
				toUserId: oauthInfo.id,
				page: pageNo,
				size: 5,
				typeId: 7,
			}
			jiuzhenAPI.getRemind(param).then(function(res) {
				vm.historyrecords = res.detailModelList
				vm.historyrecords = res.detailModelList.map(function(v) {
					var content = JSON.parse(v.content);
					for(var i = 0; i < content.length; i++) {
						var aaa = content[i].code
						if(content[i].code == 'registerDate') {
							v.registerDate = content[i].value
						} else if(content[i].code == 'deptName') {
							v.deptName = content[i].value
						} else if(content[i].code == 'doctorName') {
							v.doctorName = content[i].value
						} else if(content[i].code == 'hospitalName') {
							v.hospitalName = content[i].value
						}
					}
					return v
				})
				if(res.totalCount == 0) {
					vm.ishomeNull = true
				} else {
					vm.inithistoryPage(pageNo, res.totalPage, res.totalCount)
				}
			})
		},
		inithomePage: function(pageNo, total, size) {
			var vm = this
			//分页初始化
			$("#homepage").paging({
				pageNo: pageNo,
				totalPage: total,
				totalSize: size,
				callback: function(num) {
					//回调的页数
					vm.getlist(1)
				}
			})
		},
		inithistoryPage: function(pageNo, total, size) {
			var vm = this
			//分页初始化
			$("#historypage").paging({
				pageNo: pageNo,
				totalPage: total,
				totalSize: size,
				callback: function(num) {
					//回调的页数
					vm.gethistory(1)
				}
			})
		},
		cancelbtn: function(orderid, thirdorderid) {
			mineJiuZhenDialogForm.cancelAppointment(orderid, thirdorderid)
		},
		satisfactionbtn: function(id) {
			mineJiuZhenDialogForm.satisfaction(id)
		},
	}
});