123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- // TODO 列表示例数据
- //var data = {"msg":"查询成功","list":[
- //{"id":"3502050100","consult":"",patient:"P123",photo:"",title:"",name:"张敏敏",jobName:"主任医师",expertise:"中医内科疾病,糖尿病慢性并发症;肿瘤手术后及放、化疗后中医药调理;脾肿瘤手术后及放、化疗中医药调理。",introduce:"无",deptName:"骨科",hospitalName:"厦门市第一医院",age:23,comment:"激光治疗红血丝治疗部位保持清洁,避免感染和摩擦;部位有痂皮的会自行脱落,不要手动进行抠除。",star:3,type:5,time:"2016-09-12 16:49:17",status:"",sex:0,doctorRead:""},
- //{"id":"3502050101","consult":"",patient:"P124",photo:"",title:"",name:"李佳佳",jobName:"主任医师",expertise:"中医内科疾病,糖尿病慢性并发症;肿瘤手术后及放、化疗后中医药调理;脾肿瘤手术后及放、化疗中医药调理。",introduce:"无",deptName:"骨科",hospitalName:"厦门市第一医院",age:23,age:23,comment:"激光治疗红血丝治疗部位保持清洁,避免感染和摩擦;部位有痂皮的会自行脱落,不要手动进行抠除。",star:3,type:5,time:"2016-09-13 16:49:17",status:"",sex:0,doctorRead:""},
- //{"id":"3502050102","consult":"",patient:"P124",photo:"",title:"",name:"李佳敏",jobName:"主任医师",expertise:"中医内科疾病,糖尿病慢性并发症;肿瘤手术后及放、化疗后中医药调理;脾肿瘤手术后及放、化疗中医药调理。",introduce:"无",deptName:"骨科",hospitalName:"厦门市第一医院",age:23,age:23,comment:"激光治疗红血丝治疗部位保持清洁,避免感染和摩擦;部位有痂皮的会自行脱落,不要手动进行抠除。",star:3,type:5,time:"2016-09-13 16:49:17",status:"",sex:0,doctorRead:""},
- //{"id":"3502050103","consult":"",patient:"P124",photo:"",title:"",name:"赵六",jobName:"主任医师",expertise:"中医内科疾病,糖尿病慢性并发症;肿瘤手术后及放、化疗后中医药调理;脾肿瘤手术后及放、化疗中医药调理。",introduce:"无",deptName:"骨科",hospitalName:"厦门市第一医院",age:23,age:23,comment:"激光治疗红血丝治疗部位保持清洁,避免感染和摩擦;部位有痂皮的会自行脱落,不要手动进行抠除。",star:3,type:5,time:"2016-09-13 16:49:17",status:"",sex:0,doctorRead:""}],"status":200};
- // TODO 临时构造plus对象,使得能够在浏览器中进行调试
- // var plus = null;
- // 基本信息(包括userAgent、上个页面传递的数据)
- var baseInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null;
- var $doctorListWrapper = $('#doctor_list_wrap'),
- $doctorList = $('#doctor_list'),
- $addMingyiBtn = $('#addMingyi_btn'),
- // 搜索无结果时显示
- $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 html = template("yisheng_li_tmpl", {list: data.list})
- $doctorList.append(html);
- ellipsisText($doctorList.find('.c-dest-content'))
- },
- // 分页查询列表
- searchByPaging = function () {
- // TODO 示例示例搜索参数
- // id: 上次搜索结果列表最后一条记录id,type:1(1:名医,0:非名医,key:搜素关键字,pagesize:每页条数
- var url = "doctor/findFamousDoctor",
- params = { type:1,page:curPage,pagesize:15};
- getReqPromise(url,params).then(function(res){
- var data = res;
- if(!iscroller) {
- iscroller = initScroller($doctorListWrapper,url,
- function() { // 传递分页参数
- return $.extend({},params,{page:curPage+1});
- },function(data) {
- if(data.list && data.list.length) {
- curPage++;
- }
- initDoctorList(data);
- iscroller.refresh();
- });
- }
- if(!data.list || !data.list.length) {
- $doctorListWrapper.hide();
- $noResultWrap.show();
- } else {
- $noResultWrap.hide();
- $doctorListWrapper.show();
- initDoctorList(data);
- }
-
- iscroller.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;
- },
- // 更新分页上拉加载的提示文本
- 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('上拉加载更多');
- }
- });
- },
- // 绑定页面事件
- bindEvents = function () {
- $doctorList.on('click','.list-item',function() {
- var code = $(this).attr('data-code')||"";
- mui.openWindow({
- url: "doctor-homepage.html",
- id:"doctor-homepage",
- // 跳转页面传参
- extras: {
- accessData:{ // 传递数据
- doctor: code
- }
- }
- });
- });
- $addMingyiBtn.on('tap',function() {
- mui.openWindow({
- url: "xinzengmingyi.html",
- id:"xinzengmingyi"
- });
- });
-
- /*刷新事件*/
- 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();
- // 绑定页面事件
- bindEvents();
- })
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- });
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|