123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- // 基本信息(包括userAgent、上个页面传递的数据)
- var baseInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null;
- var $doctorListWrapper = $('#doctor_list_wrap'),
- $doctorList = $('#doctor_list'),
- // 搜索无结果时显示
- $noResultWrap = $('#no_result_wrap');
- // 分页查询当前页数
- var curPage = 1,
- // iscroll 滚动条实例
- iscroller;
-
- // 获取基本信息(包括userAgent、上个页面传递的数据)
- var getBaseInfoPromise = function() {
- // 登录的相关信息
- var userAgent = plus && JSON.parse(plus.storage.getItem("userAgent"))
- return {
- userAgent: userAgent
- }
- },
- // 获取基础环境信息
- getBaseEnvPromise = function () {
-
- var env = {
- webview: plus&&plus.webview.currentWebview()
- };
- return Promise.resolve().then(function(res) {
- return env;
- });
- },
- ellipsisText = function ($el) {
- $el.ellipsis({ row: 2 });
- },
- // 初始化医生列表
- initDoctorList = function(data) {
- var list = _.filter(data.list,function(d) {
- return d.code != baseInfo.userAgent.uid
- });
- var html = template("yisheng_li_tmpl", {list: list})
- $doctorList.empty().append(html);
- ellipsisText($doctorList.find('.c-dest-content'))
- },
- // 分页查询列表
- searchByPaging = function () {
- // TODO 示例示例搜索参数
- // id: 上次搜索结果列表最后一条记录id,type:1(1:名医,0:非名医,key:搜素关键字,pagesize:每页条数
- var url = "doctor/consult/famousDoctorList",
- params = { type:1,page:curPage,pagesize:15};
- plus.nativeUI.showWaiting();
- getReqPromise(url,params,'POST',true).then(function(res){
- var data = res;
- plus.nativeUI.closeWaiting();
- if(!data.list || !data.list.length) {
- $doctorListWrapper.hide();
- $noResultWrap.show();
- } else {
- $noResultWrap.hide();
- $doctorListWrapper.show();
- initDoctorList(data);
- }
-
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e)
- });
- },
- // 滚动条分页实例初始化
- initScroller = function() {
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
-
- mui(".mui-scroll").pullToRefresh({
- down: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- searchByPaging();
- self.endPullDownToRefresh();
- }, 1000);
- }
- }
- });
- },
- // 绑定页面事件
- bindEvents = function () {
- $doctorList.on('tap','.list-item .c-list',function() {
- var code = $(this).closest("li").attr('data-code')||"";
- mui.openWindow({
- url: "zixun-doctor-homepage.html",
- id:"zixun-doctor-homepage",
- // 跳转页面传参
- extras: {
- accessData:{ // 传递数据
- doctor: code
- }
- }
- });
- return false;
- });
-
- var doctorData = null;
- $doctorList.on("tap",".list-item .div-lijizixun-btn",function(){
- var $li = $(this).closest("li");
- var doctorCode = $li.attr("data-code");
- var docName = $li.attr("data-name");
- service.hasUnfinishedConsult(doctorCode, function(res){
- if(res.data.consult){
- mui.confirm("您与"+ docName +"医生当前有进行中咨询,不可发起求助,您可直接进入咨询提问",
- "提示", ["查看咨询", "我知道了"], function(e){
- if(e.index==0){
- var wv = mui.openWindow({
- url:"../../message/html/p2p.html",
- id: "p2p",
- extras: {
- otherCode: doctorCode,
- otherName: docName,
- otherSex: $li.attr('data-sex'),
- otherPhoto: $li.attr('data-photo'),
- consultData: res.data
- }
- })
- }
- })
- } else
- checkWorking(doctorCode)
- })
- return false;
- })
- function checkWorking(doctorCode){
- var url1 = server+"/doctor/work_scheduling/is_doctor_working";
- var data1={doctor:doctorCode};
- var url2 = server+"/doctor/baseinfo";
- var data2={code:doctorCode};
- promise = getReqPromises([{url:url1,data:data1},{url:url2,data:data2}])
- return promise.then(function(datas){
-
- var isWorkData = datas[0].data.status,
- doctorData = datas[1];
-
- if(isWorkData=="0"){//0:医生不接受咨询 1:医生接受咨询 2:医生当前不在工作时间
- dialog({
- content: '对不起,该医生已暂停接受咨询,您可选择其他医生进行咨询',
- cancelValue: '我知道了',
- cancel: function () {
- return;
- }
- }).showModal();
- return false;
- }else if(isWorkData=="1"){
- openWebview("faqizixun.html",{accessData: $.extend({},doctorData.data,{doctor:doctorCode})});
- }else if(isWorkData=="2"){
- dialog({
- content: '医生不在工作时间内哦,请在医生咨询计划时间段内咨询',
- cancelValue: '我知道了',
- cancel: function () {
- return;
- }
- }).showModal();
- }
- })
- }
-
- /*刷新事件*/
- window.addEventListener("refreshPage", function group(e) {
- $doctorList.empty();
- curPage = 1;
- searchByPaging();
- });
- };
- // 页面业务处理流程开始
- new Promise(function(resolve, reject) {
- // TODO 临时放开
- //resolve(true);
- mui.plusReady(function() {
- // plus已经准备好,可以往下执行
- resolve(true);
- });
- }).then(function() {
- // 获取基础环境信息
- return getBaseEnvPromise().then(function(env) {
- baseEnv = env;
- }).then(function() {
- // 获取登录医生信息
- baseInfo = getBaseInfoPromise();
- searchByPaging();
- initScroller();
- // 绑定页面事件
- bindEvents();
- })
- }).catch(function(e) {
- console && console.error(e);
- });
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|