123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- // TODO 临时构造plus对象,使得能够在浏览器中进行调试
- // var plus = null;
- // 基本信息(包括userAgent、上个页面传递的数据)
- var baseInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null,
- pages = {}, //记录个分组内数据页数
- docInfo;
- var $searchbarInput = $('.searchbar .search-input'),
- // 搜索无结果时显示
- $noResultWrap = $('#no_result_wrap'),
- // 页面顶部分类标签列表(四个列表项)
- $groupLabelList = $('#group_label_list'),
- patientInfo = null;
- // 获取基本信息(包括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;
- });
- },
- //获取分组信息
- getGroupData = function(){
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- var url = "doctor/patient_label_info/label_patient_amount",
- params = {
- labelType: 1, //labelType:1是服务类型,3是疾病类型 4自定义标签
- teamCode: docInfo.adminTeamCode
- };
- plus.nativeUI.showWaiting();
- sendPost(url, params, null,function(res){
- if(res.status == 200){
- for(i=0; i<res.data.length; i++){
- var item = res.data[i];
- pages[item.labelCode] = 1;
- }
- var html = template("pati_group_tmpl", {list: res.data});
- $("#groupList").empty().append(html);
- plus.nativeUI.closeWaiting();
- }else{
- plus.nativeUI.closeWaiting();
- mui.toast(res.msg);
- }
- });
- },
- // 分页查询列表
- initPatientListByGroup = function(code, isInit) {
- if(isInit){
- pages[code] = 1;
- }
- var url = "doctor/patient_label_info/patients_by_label",
- params = {
- labelType: 1, //labelType:1是服务类型,3是疾病类型 4自定义标签
- labelCode: code,
- teamCode: docInfo.adminTeamCode,
- page: pages[code],
- pagesize: 20
- };
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- var list = res.data;
- if(list.length == 0){
- $(".group-item[data-group="+code+"]").find(".load-more").hide();
- }else{
- var html = template("pati_list_tmpl", {list: list});
- if(isInit){
- $(".n-list[data-group="+code+"]").empty().append(html);
- }else{
- $(".n-list[data-group="+code+"]").append(html);
- }
-
- if(list.length < 20){
- $(".group-item[data-group="+code+"]").find(".load-more").hide();
- }else{
- pages[code] ++;
- $(".group-item[data-group="+code+"]").find(".load-more").show();
- }
- }
- }else{
- mui.toast(res.msg);
- }
- }, true)
- },
- // 滚动条分页实例初始化
- 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() {
- getGroupData();
- self.endPullDownToRefresh();
- }, 1000);
- }
- }
- });
- },
- // 绑定页面事件
- bindEvents = function () {
- $("#groupList").on('tap','li[data-patient-code]',function(e) {
- var code = $(this).attr("data-patient-code");
- var mobile = $(this).attr("data-patient-phone");
- var address = $(this).attr("data-patient-address");
- if(baseEnv.webview.origin=="suifang") {//“随访”功能
- if(baseEnv.webview.follow_type == 1){
- openWebview("../../suifang/html/add_plan.html",{patientInfo: {code:code,mobile:mobile,address:address},chooseDate:baseEnv.webview.chooseDate});
- return false;
- }
- if(baseEnv.webview.follow_type == 2){
- openWebview("../../suifang/html/follow_way.html",{patientInfo: {code:code,mobile:mobile,address:address}});
- return false;
- }
- }else{
- openWebview("../../huanzhe/html/huanzhexinxi.html",{
- patiCode: code
- });
- }
- return false;
- });
-
- $("#groupList").on('tap', ".group-item", function(){
- var $el = $(this),
- code = $.trim($el.attr("data-group")),
- amount = parseInt($el.attr("data-amount")),
- isOpen = $el.hasClass("current"),
- $groupInfo = $el.find('.group-info'),
- $siblings = $el.siblings();
-
- if(isOpen) {
- $el.removeClass("current");
- $el.find(".ui-arrow").removeClass("ui-arrow-t");
- $el.find(".ui-arrow").addClass("ui-arrow-b");
- $groupInfo.hide();
- }else{
- var $opened = $(".group-item.current");
- $el.addClass("current");
- $el.find(".ui-arrow").removeClass("ui-arrow-b");
- $el.find(".ui-arrow").addClass("ui-arrow-t");
-
- if($opened.length > 0){
- $opened.removeClass('current').find(".group-info").hide();
- $opened.find(".ui-arrow").removeClass("ui-arrow-t");
- $opened.find(".ui-arrow").addClass("ui-arrow-b");
- }
-
- if(amount > 0){
- $groupInfo.show();
- var liLen = $el.find('ul.n-list li').length;
- if(liLen == 0){
- initPatientListByGroup(code, true);
- }
- }
- }
- });
-
- $("#groupList").on('tap', ".load-more", function(e){
- e.stopPropagation();
- var $this = $(this),
- code = $this.attr("data-group");
- // mui('.mui-scroll-wrapper').refresh();
- initPatientListByGroup(code, false);
- });
-
- $groupLabelList.on('tap',"li.group-item",function() {
- openWebview("../../huanzhe/html/huanzhe-by-type.html",{
- type: self.type,
- accessData: {
- labelType: $(this).attr("data-type"),
- typeName: $(this).find(".item-label").text(),
- teamCode: docInfo.adminTeamCode
- },
- });
- })
-
- $searchbarInput.on('tap',function() {
- mui.openWindow({
- id: "searchhuanzhe2",
- url: "../../huanzhe/html/searchhuanzhe.html",
- extras: {}
- })
- });
-
- $(".header-link").on('click', function(){
- openWebview("../../huanzhe/html/biaoqianguanli.html",{
- teamCode: docInfo.adminTeamCode
- });
- })
- /*刷新事件*/
- window.addEventListener("refresh", function group(e) {
- getGroupData();
- });
- };
- // 页面业务处理流程开始
- 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();
- initScroller();
- // searchByPaging(true);
- getGroupData();
- // 绑定页面事件
- bindEvents();
- if(baseEnv.webview.origin){//“随访”功能,需要返回按钮
- $(".mui-action-back").show();
- }
- })
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- });
- function setAge(age) {
- if(age == 0) {
- return "<1";
- }
- if(age == -1)
- return "未知";
- return age;
- }
- template.helper("setAge", setAge);
- function setSex(s) {
- if(s == 1) {
- return "男";
- } else if(s == 2) {
- return "女";
- }
- }
- template.helper("setSex", setSex);
- template.helper("getPhoto", function(str){
- return getImgUrl(str);
- })
|