123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- // TODO 临时构造plus对象,使得能够在浏览器中进行调试
- // var plus = null;
- // 基本信息(包括userAgent、上个页面传递的数据)
- var baseInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null,
- pages = {}, //记录个分组内数据页数
- docInfo,
- content,
- modelCode,
- images;
- var $searchbarInput = $('.searchbar .search-input'),
- // 搜索无结果时显示
- $noResultWrap = $('#no_result_wrap'),
- 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: 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: 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 () {
- var acTiveId='activeId';//选中的ID
- $("#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");
- var isCheck = $(this).attr("check");
- var id = $(this).attr('id');
- if(id != acTiveId ){ //如果点击的不是之前选中的
- $('#'+acTiveId).find('.checboxImg').find('img').attr('src','../images/checbox-false.png');
- $('#'+acTiveId).removeAttr('id');
- $(this).find('.checboxImg').find('img').attr('src','../images/checbox-true.png');
- $(this).attr('check','yes');
- $(this).attr('id',acTiveId);
- }
- else { //如果点击的是自己的话
- if(isCheck == 'no'){
- $(this).find('.checboxImg').find('img').attr('src','../images/checbox-true.png');
- $(this).attr('check','yes');
- }
- else {
- $(this).find('.checboxImg').find('img').attr('src','../images/checbox-false.png');
- $(this).attr('check','no');
- $(this).removeAttr('id',acTiveId);
- }
- }
-
- // 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;
- });
-
- $(".send_btn").on('tap', function(){
- var patiCode =$('#'+acTiveId).attr('data-patient-code');
- if(!patiCode) {mui.toast("请选择居民再进行发送");return};
- dialog({
- content: "发出后无法变更,是否确认发送给居民?",
- okValue: "继续发送",
- ok: function(){
- var url = "doctor/health/guidance/add",
- params = {
- patient: patiCode,
- content: content,
- modelCode: modelCode,
- images: images
- };
- console.log(params)
- plus.nativeUI.showWaiting();
- sendPost(url, params, null, function(res){
- if (res.status == 200) {
- mui.toast("发送成功!");
- var main =plus.webview.getWebviewById('guidance_list');
- mui.fire(main,'refresh');
- var self = plus.webview.currentWebview(),
- opener = self.opener(),
- pre_opener = self.opener().opener();
-
- if(opener.id == "jkzd"){ //自己的模板详情
- if(pre_opener.id == "guidance_info"){
- mui.fire(pre_opener.opener(), "update");
- pre_opener.opener().show();
- mui.later(function(){
- pre_opener.close('none');
- opener.close('none');
- self.close('none');
- }, 300);
- }else{
- mui.fire(pre_opener, "update");
- pre_opener.show();
- mui.later(function(){
- opener.close('none');
- self.close('none');
- }, 300);
- }
- }else{ //系统模板详情
- var pre_pre_opener = pre_opener.opener();
- if(pre_pre_opener.id == "guidance_info"){
- mui.fire(pre_pre_opener.opener(), "update");
- pre_pre_opener.opener().show();
- mui.later(function(){
- pre_pre_opener.close('none');
- opener.close('none');
- pre_opener.close('none');
- self.close('none');
- }, 300);
- }else{
- mui.fire(pre_pre_opener, "update");
- pre_pre_opener.show();
- mui.later(function(){
- opener.close('none');
- pre_opener.close('none');
- self.close('none');
- }, 300);
- }
-
- }
- }else{
- mui.toast(res.msg)
- }
- plus.nativeUI.closeWaiting();
- }, 'POST', '', true);
- },
- cancelValue: "不了,谢谢",
- cancel: function(){}
- }).showModal();
- });
- $("#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);
- });
-
- $searchbarInput.on('tap',function() {
- openWebview('guidance_searchhuanzhe.html',{
- content: content,
- modelCode: modelCode,
- images: images
- });
- // mui.openWindow({
- // id: "searchhuanzhe2",
- // url: "../../huanzhe/html/searchhuanzhe.html?isIndex=true",
- // 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() {
- // 获取登录医生信息
- var self = plus.webview.currentWebview();
- content =self.content;
- modelCode =self.modelCode;
- images =self.images;
- console.log(content)
- console.log(modelCode)
- console.log(images)
- 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);
- })
|