123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- mui.init();
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
- var id = self.dataId;
- if(id == "null"){
- id = "";
- }
- var xtCode = self.xtCode;
- var doctorCode = "";
- var orgCode = "";
- var deptCode = "";
- var patient = "";
-
- var details; //记录预约详情内容
- //注册事件
- bindEvents();
-
- //初始化数据
- initData();
-
- function initData(){
- var data={};
- data.orderId = id;
- sendPost('third/guahao/GetPatientReservation', data, getListFail, successFun);
- }
-
- function getCanceler(data) {
- var name = data.cancelerName;
- if(!name) return "";
-
- if(data.cancelerType=='1') {
- return name+'(专科医生)';
- } else if(data.cancelerType=='2') {
- return name+'(全科医生)';
- } else if(data.cancelerType=='3') {
- return name+'(健康管理师)';
- } else if(data.cancelerType=='4') {
- return name+'(临时专科)';
- } else if(data.cancelerType=='5') {
- return name;
- }
- return name;
- }
-
- function successFun(res){
- if(res.status==200){
- var data = res.data;
- details = data;
- //status:0 已撤销 1 预约成功 2 已就诊 3已停诊
- var clazz1 = "cb-47ABEF";
- var clazz2 = "c-47ABEF";
- var statusNm = "预约成功";
- //保存 协同数据
- if(xtCode){
- var params = {
- type:1,//1.预约成功,2.预约失败
- code:xtCode,
- orderHospital:details.orgCode,
- orderHospitalName:details.orgName,
- orderDept:details.deptCode,
- orderDeptName:details.deptName,
- orderDoctor :details.doctorCode,
- orderDoctorName:details.doctorName,
- orderTime:details.startTime,
- registerTime:details.czrq
- }
- plus.nativeUI.showWaiting();
- sendPost("doctor/pcCustomer/dealAppointCallService",params, function(){
- plus.nativeUI.closeWaiting();
- mui.toast("请求失败");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- var page = plus.webview.getWebviewById("xietongfuwu-management");
- if(page){ mui.fire(page, "refreshXietong") }
- var page1 = plus.webview.getWebviewById("xietongfuwu-message");
- if(page1){ mui.fire(page1, "refreshXTmsg") }
- mui.toast("协同任务已完成");
- sendGet("doctor/pcCustomer/getCallServiceInfo",{code:xtCode}, function(){
- plus.nativeUI.closeWaiting();
- mui.toast("请求失败");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- $('.xt-time').text(res.data.callService.createTime)
- $('.xt-text').text(res.data.callService.serverContent)
- $('.div-xietong').show();
- }else{
- mui.toast("获取数据失败");
- }
- })
- closePage()
- }else{
- mui.toast("协同任务保存失败");
- }
- })
- }
-
- if(data.status=="0"){
- clazz1 = "cb-FF6A56";
- clazz2 = "c-FF6A56";
- statusNm = "已撤销";
- var operator = getCanceler(data);
- if(operator) {
- $('.div-operator').show();
- $('#operator_name').text(operator);
- }
- $(".div-cancel-btn").hide();
- $(".div-tongkeshi-btn").removeClass("c-24").addClass("c-50");
- $(".div-again-yuyue").removeClass("c-38").addClass("c-50");
-
- }else if(data.status=="1"){
- // $(".div-cancel-btn").show();
- // TODO 如果预约开始时间早于当前时间,则不显示”取消预约“按钮
- var jzStartTimeStr = data.startTime.replace(/-/g,'/');
- var jsStartTime = new Date(jzStartTimeStr).getTime();
- var curTime = new Date().getTime();
- if(curTime>jsStartTime) {
- $(".div-cancel-btn").hide();
- } else {
- $(".div-cancel-btn").show();
- $(".div-tongkeshi-btn").removeClass("c-50").addClass("c-24");
- $(".div-again-yuyue").removeClass("c-50").addClass("c-38");
- }
- }else if(data.status=="2"){
- clazz1 = "cb-74BF00";
- clazz2 = "c-74BF00";
- statusNm = "已就诊";
- }else if(data.status=="3"){
- clazz1 = "cb-909090";
- clazz2 = "c-909090";
- statusNm = "已停诊";
- }
- var jiuzhenTime = data.startTime.replace(/\//g,'-').substring(0);//就诊时间
- if(data.endTime){
- jiuzhenTime = jiuzhenTime + "~"+data.endTime.replace(/\//g,'-').substring(9);
- }
- $(".left-yuan").addClass(clazz1);
- $(".left-status").addClass(clazz2).html(statusNm);
- $(".daiyuyue").html(data.dname);
- $(".guahao-time").html(data.czrq.substring(0,16));
- $(".jiuzheng-time").html(jiuzhenTime);
- $(".hospital-name").html(data.orgName);
- $(".users-name").html(data.name);
- $(".dept-name").html(data.deptName);
- $(".doctor-name").html(data.doctorName);
- $(".idcard").html(data.idcard);
- $(".yibao-num").html(data.ssc);
- $(".iphone-num").html(data.phone);
-
- doctorCode = data.doctorCode;
- orgCode = data.orgCode;
- deptCode = data.deptCode;
- patient = data.patient;
- }else{
- getListFail(res);
- }
-
- $(".main").show();
- $("#footer").show();
- }
-
- function getListFail(res){
- if (res && res.msg) {
- mui.toast(res.msg);
- } else {
- mui.toast("加载失败");
- }
- }
-
-
- function bindEvents(){
- //同科室医生
- $(".div-tongkeshi-btn").on("click",function(){
- var params ={};
- params.patient = patient;
- params.hospitalId = orgCode;
- params.deptId = deptCode;
- openWebviewExtras("select-doctor.html",params)
- });
-
- //再次预约
- $(".div-again-yuyue").on("click",function(){
- var params = {};
- params.id=id;
- params.doctorId=doctorCode;
- params.hospitalId=orgCode;
- params.deptId = deptCode;
- params.type=2;
- params.patient = patient;
- openWebviewExtras("doctor-detail.html",params);
- });
-
- //撤销预约
- $(".div-cancel-btn").on("click",function(){
- sendPost('doctor/guahao/isCancelOrder',{orderId:id},function(res) {
- mui.toast("操作失败");
- },function (res) {
- if(res.status == '0') {
- mui.toast('对不起,您本月已取消过该居民预约,如需继续撤销,请让居民自行处理。');
- } else {
- dialog({
- content: '取消预约次数将计入居民取消次数,居民每月取消超过3次将纳入黑名单。是否继续撤销?',
- okValue:'确认',
- ok: function (){
- plus.nativeUI.showWaiting();
- sendPost('doctor/guahao/CancelOrder', {orderId:id, code: details.code, ssc:details.ssc}, function() {
- plus.nativeUI.closeWaiting();
- mui.toast("操作失败");
- }, function(res) {
- plus.nativeUI.closeWaiting();
- if(res.status==200) {
- mui.toast("撤销成功");
- mui.fire(self.opener(),'update');
- initData();
- } else {
- mui.toast(res.msg);
- }
-
- },'post','',true);
- },
- cancelValue: '取消',
- cancel: function () {
- return ;
- }
- }).showModal();
- }
- },'post','',true)
-
-
- });
- }
- //关闭页面
- function closePage(){
- var page = plus.webview.getWebviewById("xietongfuwu-detail");
- if(page){ page.close('none') }
- var page1 = plus.webview.getWebviewById("appointment-register");
- if(page1){ page1.close('none') }
- var page2 = plus.webview.getWebviewById("hospital-dept");
- if(page2){ page2.close('none') }
- var page3 = plus.webview.getWebviewById("xietongfuwu-yy");
- if(page3){ page3.close('none') }
- var page4 = plus.webview.getWebviewById("select-doctor");
- if(page4){ page4.close('none') }
- var page5 = plus.webview.getWebviewById("doctor-detail");
- if(page5){ page5.close('none') }
- var page6 = plus.webview.getWebviewById("info-confirm");
- if(page6){ page6.close('none') }
- var page7 = plus.webview.getWebviewById("detail-appointment");
- if(page7){ page7.close('none') }
- }
-
- });
|