123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- // TODO 医生示例数据
- //var doctorData = {"msg":"查询成功",data:{"id":"3502050100","consult":"",patient:"P123",photo:"",jobName:"主任医师",expertise:"中医内科疾病",introduce:"无",deptName:"骨科",hospitalName:"厦门市第一医院",title:"",name:"张敏敏",age:23,comment:"激光治疗红血丝治疗部位保持清洁,避免感染和摩擦;部位有痂皮的会自行脱落,不要手动进行抠除。",star:3,type:5,time:"2016-09-12 16:49:17",status:"",sex:0,doctorRead:""},"status":200};
- var doctorData = null;
- // 基本信息(包括userAgent、上个页面传递的数据)
- var baseInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null;
- // 医生code
- var doctorCode = "";
- var $baseInfoWrapper = $('#base_info_wrap');
- // 获取基本信息(包括userAgent、上个页面传递的数据)
- var getBaseInfoPromise = function() {
- // 登录的相关信息
- var userAgent = plus && JSON.parse(plus.storage.getItem("userAgent"))
- return {
- userAgent: userAgent,
- // 上一个页面传递的数据
- accessData: baseEnv.webview.accessData
- }
- },
- // 获取基础环境信息
- getBaseEnvPromise = function () {
- var webview = plus.webview.currentWebview();
- var env = {
- webview: webview,
- // 点击“返回”的webveiw的id(由上一个页面传递)
- backTo: webview.backTo
- };
- return Promise.resolve().then(function(res) {
- return env;
- });
- },
- showBaseInfo = function(){
-
- var url = server+"/doctor/baseinfo";
- var data={code:doctorCode};
- getReqPromise(url,data).then(function(res) {
- // TODO 示例后台返回医生数据
- //res = doctorData;
- doctorData = res;
-
- if(res.status == 200) {
- return res.data;
- } else {
- mui.toast(res.msg);
- return null;
- }
- }).then(function(data) {
- if(data) {
- var html = template("base_info_tmpl", data);
- $baseInfoWrapper.html(html);
- }
- }).catch(function(e) {
- console && console.error(e);
- });
-
-
- },
- // 点击“立即咨询”按钮的处理
- zixun = function() {
- service.hasUnfinishedConsult(doctorCode, function(res){
- if(res.data.consult){
- var doc = doctorData.data;
- mui.confirm("您与"+ doc.name +"医生当前有进行中咨询,不可发起求助,您可直接进入咨询提问",
- "提示", ["查看咨询", "我知道了"], function(e){
- if(e.index==0){
- var wv = mui.openWindow({
- url:"../../message/html/p2p.html",
- id: "p2p",
- extras: {
- otherCode: doctorCode,
- otherName: doc.name,
- otherSex: doc.sex,
- otherPhoto: doc.photo,
- consultData: res.data
- }
- })
- }
- })
- } else
- checkWorking()
- })
- },
- checkWorking= function(){
- var url = server+"/doctor/work_scheduling/is_doctor_working";
- var data={doctor:doctorCode};
- getReqPromise(url,data).then(function(res) {
- if(res.status == 200) {
- return res.data;
- } else {
- mui.toast(res.msg);
- return null;
- }
- }).then(function(data) {
- var status = data.status;
- if(status) {//0:医生不接受咨询 1:医生接受咨询 2:医生当前不在工作时间
- if(status=="0"){
- dialog({
- content: '对不起,该医生已暂停接受咨询,您可选择其他医生进行咨询',
- cancelValue: '我知道了',
- cancel: function () {
- return;
- }
- }).showModal();
- return false;
- }else if(status=="1"){
- openWebview("faqizixun.html",{accessData: $.extend({},doctorData.data,{doctor:doctorCode})});
- }else if(status=="2"){
- dialog({
- content: '医生不在工作时间内哦,请在医生咨询计划时间段内咨询',
- cancelValue: '我知道了',
- cancel: function () {
- return;
- }
- }).showModal();
- }
- }
- }).catch(function(e) {
- console && console.error(e);
- });
- }
- // 绑定页面事件
- bindEvents = function () {
-
- };
- // 页面业务处理流程开始
- new Promise(function(resolve, reject) {
- mui.plusReady(function() {
- var old_back = mui.back;
- mui.back = function() {
- var webview = plus.webview.getWebviewById("zixun-xuanzeyisheng");
- if(webview) {
- mui.fire(webview,"refreshPage");
- }
- old_back();
- }
- // plus已经准备好,可以往下执行
- resolve(true);
- });
-
- }).then(function() {
-
- // 获取基础环境信息
- return getBaseEnvPromise().then(function(env) {
- baseEnv = env;
- if(baseEnv.backTo) {
- backToWebviewById(baseEnv.backTo);
- }
- }).then(function() {
- // 获取登录医生信息
- baseInfo = getBaseInfoPromise();
- doctorCode = baseInfo.accessData.doctor;
- // 显示医生基本信息
- showBaseInfo();
- // 绑定页面事件
- bindEvents();
- })
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- });
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|