123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- // 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/dept_group_list",
- params = {};
- plus.nativeUI.showWaiting();
- sendGet(url, params, null,function(res){
- if(res.status == 200){
- var html = template("pati_group_tmpl", {list: res.data});
- $("#groupList").empty().append(html);
- plus.nativeUI.closeWaiting();
- }else{
- plus.nativeUI.closeWaiting();
- mui.toast(res.msg);
- }
- });
- },
- // 滚动条分页实例初始化
- 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','.group-info li[data-code]',function(e) {
- var code = $(this).attr("data-code");
- var name = $(this).attr("data-name");
- mui.openWindow('../../mine/html/zuyuanziliao.html', 'zuyuanziliao', {
- extras: {
- docCode: code,
- docName:name,
- teamCode: docInfo.adminTeamCode,
- // isTeamOwner: isTeamOwner
- }
- });
- return false;
- });
-
- $("#groupList").on('tap', ".group-item", function(){
- var $el = $(this),
- code = $.trim($el.attr("data-group")),
- isOpen = $el.hasClass("current"),
- $groupInfo = $el.find('.group-info');
-
- if(isOpen) {
- $el.removeClass("current");
- $el.find(".ui-arrow").removeClass("ui-arrow-b");
- $el.find(".ui-arrow").addClass("ui-arrow-r");
- $groupInfo.hide();
- }else{
- var $opened = $(".group-item.current");
- $el.addClass("current");
- $el.find(".ui-arrow").removeClass("ui-arrow-r");
- $el.find(".ui-arrow").addClass("ui-arrow-b");
-
- if($opened.length > 0){
- $opened.removeClass('current').find(".group-info").hide();
- $opened.find(".ui-arrow").removeClass("ui-arrow-b");
- $opened.find(".ui-arrow").addClass("ui-arrow-r");
- }
- $groupInfo.show();
- }
- });
-
- $searchbarInput.on('tap',function() {
- mui.openWindow({
- id: "searchhuanzhe2",
- url: "../../tuandui/html/searchdoctor.html",
- extras: {}
- })
- });
-
- /*刷新事件*/
- 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();
- 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);
- })
|