define(['zepto','medtap'],function($,medtap){
	var detail = {
		remindId:medtap.getRequest('remindId'),
		init:function(){
			detail.getDetail();
			detail.bindEve()
		},
		bindEve:function(){
			$('#no').unbind().bind('click',function(){
				var status = 2;
				detail.confirmMsg(status)
			});
			$('#yes').unbind().bind('click',function(){
				var status = 1;
				detail.confirmMsg(status)
			})
		},
		getDetail:function(){
			medtap.loading(1);
			medtap.submitAjax({
				url:'https://testdevgw.medtap.cn/operation/notify/getNotifyMessage',
				type:"post",
				contentType: 'application/json',
				async:false,
				data:{
					id:parseInt(detail.remindId)
				},
				success:function(res){
					medtap.loading(0);
					if(res.success == true){
						var info = res.content.uerNotifyDTO.messageInfo;
						if(res.content.uerNotifyDTO.confirmStatus == 0){
							//待确认
							$('.btn_warp').show();
						}else if(res.content.uerNotifyDTO.confirmStatus == 1){
							$('.remind_flag img').attr('src','../images/remind_my_result_yes_png@2x.png');
							$('.remind_flag').show();
							$('.btn_warp').hide();
						}else if(res.content.uerNotifyDTO.confirmStatus == 2){
							$('.remind_flag img').attr('src','../images/remind_my_result_no_png@2x.png');
							$('.remind_flag').show();
							$('.btn_warp').hide();
						}
						if(info.notifyType == 3){
							//就诊
							$('.remind_title').text('- 就诊提醒 -');
							$('.item .left_title').text('就诊类型:');
							$('.item .right_content').text(info.medicalTypeName)
							$('.remind_content').text(info.content);
						}else if(info.notifyType == 2){
							//检查
							$('.remind_title').text('- 检查提醒 -');
							$('.item .left_title').text('检查项目:');
							$('.item .right_content').text(info.checkItemName)
							$('.remind_content').text(info.content)
						}else if(info.notifyType == 1){
							//用药
							$('.remind_title').text('- 用药提醒 -');
							$('.item .left_title').text('药品名称:');
							$('.item .right_content').text(info.drugName)
							$('.remind_content').text(info.content)
						}
					}
				}
			})
		},
		confirmMsg:function(status){
			medtap.loading(1);
			medtap.submitAjax({
				url:'https://testdevgw.medtap.cn/operation/notify/confirmMessage',
				type:"post",
				contentType: 'application/json',
				async:false,
				data:{
					confirmStatus:status,
					remark:'',
					id:detail.remindId
				},
				success:function(res){
					medtap.loading(0);
					if(res.success == true){
						medtap.toast({
							message:'确认成功',
							time:1500
						})
						setTimeout(function(){
							window.location.reload();
						})
					}
				}
			})
		}
	}
	detail.init();
})