123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- // TODO 临时构造plus对象,使得能够在浏览器中进行调试
- //var plus = null;
- // 登录者相关信息(包括userAgent)
- var loginerInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null;
-
- // 选项卡
- var $queryTab = $('#query_tab'),
- // 搜索无结果时显示
- $noResultWrap = $('#no_result_wrap'),
- $views = $('.dest-view'),
- $mingyiView = $('#mingyi_view'),
- $qitaView = $('#qita_view'),
- $mingyiList = $('#mingyi_list'),
- $qitaList = $('#qita_list'),
- $selectedNum = $('#selected_num'),
- $searchbar = $(".searchbar-input");
-
- // ”名医”列表分页查询最后一条记录Id
- var mingyiLastId = 1,
- // ”其他”列表分页查询最后一条记录Id
- qitaLastId = 1,
- // ”名医”列表iscroll 滚动条实例
- mingyiIscroller,
- // ”其他”列表iscroll 滚动条实例
- qitaIscroller;
-
- // 获取登录相关信息
- var getLoginerInfo = 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;
- });
- },
- // 初始化”名医”视图列表
- initMingYiViewList = function(data) {
- var list = data.list;
- var dataList = [];
- for(var i = 0; i < list.length; i++) {
- if (list[i].isworking == "1") {
- dataList.push(list[i]);
- }
- }
- var html = template("yisheng_li_tmpl", {list: dataList});
- $mingyiList.append(html)
- },
- // 初始化”其他”视图列表
- initQiTaViewList = function(data) {
- var list = data.list;
- var dataList = [];
- for(var i = 0; i < list.length; i++) {
- if (list[i].isworking == "1") {
- dataList.push(list[i]);
- }
- }
- var html = template("yisheng_other_tmpl", {list: dataList})
- $qitaList.append(html)
- },
- // "名医"分页查询列表
- searchMingYiByPaging = function () {
- // TODO 示例示例搜索参数
- // id: 上次搜索结果列表最后一条记录id,type:6(进行中),query:搜素关键字,pageSize:每页条数
- var url = "doctor/findFamousDoctor",
- params = { page:1, pagesize:15,type:1,level: 1 };
- getReqPromise(url,params).then(function(res){
- // TODO 为了测试先注释
- var data = res;
- mingyiLastId = mingyiLastId+1;
- if(!mingyiIscroller) {
- mingyiIscroller = initScroller($mingyiView,url,
- function() { // 传递分页参数
- return $.extend({},params,{page:mingyiLastId});
- },function(data) {
- // TODO 示例数据
- mingyiLastId = mingyiLastId+1;
- initMingYiViewList(data);
- mingyiIscroller.refresh();
- });
- }
- // TODO 示例数据data
- if(!data.list || !data.list.length) {
- $mingyiView.hide();
- $noResultWrap.show();
- } else {
- $noResultWrap.hide();
- $mingyiView.show();
- // TODO 示例数据data
- initMingYiViewList(data);
- }
-
- mingyiIscroller.refresh();
- }).catch(function(e) {
- console && console.error(e)
- });
- },
- // "其他"分页查询列表
- searchQiTaByPaging = function () {
- // TODO 示例示例搜索参数
- // id: 上次搜索结果列表最后一条记录id,type:0(其他),,pageSize:每页条数
- var url = "doctor/findFamousDoctor",
- params = { page:1, pagesize:15,type:0,level:1 };
- getReqPromise(url,params).then(function(res){
- // TODO 为了测试先注释
- var data = res;
- qitaLastId = qitaLastId+1;
- if(!qitaIscroller) {
- qitaIscroller = initScroller($qitaView,url,
- function() { // 传递分页参数
- return $.extend({},params,{page:qitaLastId});
- },function(data) {
- // TODO 示例数据
- qitaLastId = qitaLastId+1;
- initQiTaViewList(data);
- qitaIscroller.refresh();
- });
- }
- // TODO 示例数据data
- if(!data.list || !data.list.length) {
- $qitaView.hide();
- $noResultWrap.show();
- } else {
- $noResultWrap.hide();
- //$qitaView.show();
- // TODO 示例数据data
- initQiTaViewList(data);
- }
-
- qitaIscroller.refresh();
- }).catch(function(e) {
- console && console.error(e)
- });
- }
- // 滚动条分页实例初始化
- initScroller = function($el,url,getData,pullUpAction) {
- var scroller = $el.initScroll({pullDown: false,pullUpAction: function() {
- var data = getData();
- getReqPromise(url,data).then(function(data) {
- if(pullUpAction && $.isFunction(pullUpAction)) {
- pullUpAction(data);
- updatePullUpText(scroller,data.list);
- }
- })
- }});
-
- return scroller;
- },
- // 获取分页搜索返回的最后一条记录的id
- getLastId = function(data) {
- var lastObj = data.list && data.list.length && data.list[data.list.length-1];
- // 最后一条记录
- if(lastObj) {
- return lastObj.id;
- } else {
- return null
- }
- },
- // 更新分页上拉加载的提示文本
- updatePullUpText= function(scroller,list) {
- var $wrap = $(scroller.wrapper),
- $pullupLabel = $wrap.find('.pullUpLabel');
- if(!list || !list.length) {
- $pullupLabel.text('没有更多');
- } else {
- $pullupLabel.text('上拉加载更多');
- }
- scroller.on('refresh',function() {
-
- if(!list || !list.length) {
- $pullupLabel.text('没有更多');
- } else {
- $pullupLabel.text('上拉加载更多');
- }
- });
- },
- // 显示选中的人数
- showSelectedNum = function() {
- var num = $views.find('input[type="checkbox"]:checked').length;
- if(num) {
- $selectedNum.text('('+num+'人)')
- } else {
- $selectedNum.text('');
- }
- },
- // 点击“确定”按钮处理方法
- submit = function() {
- // TODO 这里需要补充处理逻辑
- var checklength = $views.find('input[type="checkbox"]:checked');
- if(checklength.length<=0){
- mui.toast("请至少选择一名医生!");
- return false;
- }
- var consultCode = localStorage.getItem("consult");
- var doctors = new Array();
- $views.find('input[type="checkbox"]:checked').each(function(){
- doctors.push($(this).val());
- })
- sendPost("doctor/consult/transfer", {
- consult: consultCode,
- doctor: doctors.join(","),
- type: 1 //无用
- }, null,
- function(res) {
- if(res.status == 200) {
- mui.toast("邀请成功");
- setTimeout(function(){
- plus.webview.currentWebview().close();
- openWebview("../../zdzx/html/jiankangzixunxiangqing.html");
- }, 1000);
- }
- });
- },
- // 绑定页面事件
- bindEvents = function () {
- $queryTab.on('click','.tab-item',function() {
- var type = $(this).attr('data-type');
- $queryTab.find('.tab-item').removeClass('curr');
- $views.hide();
- $(this).addClass('curr');
- switch(type) {
- case "mingyi_view":
- if($mingyiView.find('li').length) {
- $noResultWrap.hide();
- $mingyiView.show();
- } else {
- $mingyiView.hide();
- $noResultWrap.show();
- }
-
- break;
- case "qita_view":
- if($qitaView.find('li').length) {
- $noResultWrap.hide();
- $qitaView.show();
- } else {
- $qitaView.hide();
- $noResultWrap.show();
- }
- break;
- }
- });
- $views.on('click','li',function(e) {
- var $el = $(e.target);
- setTimeout(function() {
- showSelectedNum();
- },0);
- if($el.attr('type')=="checkbox") {
- return ;
- }
- var checkbox = $(this).find('input[type="checkbox"]')[0];
- if(checkbox.checked) {
- checkbox.checked = false;
- } else {
- checkbox.checked = true;
- }
- });
- $searchbar.on('click',function() {
- openWebview("sousuoyisheng.html");
- });
- };
- // 页面业务处理流程开始
- 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() {
- // 获取登录医生信息
- loginerInfo = getLoginerInfo();
- searchMingYiByPaging();
- searchQiTaByPaging();
- // 绑定页面事件
- bindEvents();
- })
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- });
|