123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- mui.init();
- var scrollers = [],
- page = [1,1], //主要存储个人和系统的模板分页信息
- page1 = [], //存储团队模板中,各个团队对应的模板分页信息
- loaded = [],
- patient = null,
- docInfo = null,
- reference,
- pagesize = 20,
- pagesize2 = 10,
- selectedTab = 0; //默认选中第一个tab
- isIndex=null;
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
- var opener = self.opener();
- if(opener.id == "home2.html"){
- reference = "home2";
- }
- patient = self.code;
- isIndex = self.isIndex;
- initScroller();
- getList(true);
- bindEvents();
- });
- function getList(isInit){
-
- if(isInit){
- page[selectedTab] = 1;
- }
- var url = "doctor/guidance_temp/list",
- params = {
- type: selectedTab == 0 ? 2 : 1, //模板类型 1:系统 2:自定义 为空:所有
- pageNo: page[selectedTab],
- pageSize: pagesize
- },
- filter = '';
- if(selectedTab == 0){
- filter = $("#item1 .search-input").val();
- }else{
- filter = $("#item2 .search-input").val();
- }
- params.filter = filter;
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- loaded[selectedTab] = true;
- var $controlPanel = $("#item"+(selectedTab + 1)),
- $ul = $controlPanel.find("ul"),
- $noResult = $controlPanel.find(".no-result");
- if(isInit){
- if(res.data.length == 0){
- $ul.hide();
- $noResult.show();
- }else{
- $ul.show();
- $noResult.hide();
- var html = template("guidance_tmp", {list: res.data});
- $ul.empty().append(html);
- }
- }else{
- var html = template("guidance_tmp", {list: res.data});
- $ul.append(html);
- }
- if(res.data.length < pagesize){
- scrollers[selectedTab].endPullupToRefresh(true);
- }else{
- scrollers[selectedTab].endPullupToRefresh(false);
- page[selectedTab] ++;
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- function bindEvents(){
- document.querySelector('.mui-slider').addEventListener('slide', function(event) {
- selectedTab = event.detail.slideNumber;
- if(loaded[selectedTab] == "false"){
- getList(true);
- loaded[selectedTab] = "true";
- }
- });
-
- //新增按钮
- $(".add-icon").on("tap", function(){
- var $this = $(this),
- type = $this.attr("data-val");
- openWebview('edit_guidance.html',{
- action: "add",
- reference: reference,
- patiCode: patient
- });
- });
-
- //查看文章详情
- $("#item1").on('tap', 'li', function(){
- var code = $(this).attr("data-code");
- openWebview("guidance_detail.html",{
- code: code,
- reference: reference,
- patiCode: patient,
- isIndex:isIndex
- });
- });
-
- $("#item2").on('tap', 'li', function(){
- var code = $(this).attr("data-code");
- openWebview("guidance_detail.html", {
- code: code,
- reference: reference,
- patiCode: patient,
- is_sys: true,
- isIndex:isIndex
- });
- });
-
- //搜索功能
- $(".search-input").on('keydown', function(e){
- if (e.which === 13) {
- e.preventDefault();
- getList(true);
- }
- });
-
- //设置页面监听
- window.addEventListener("refresh", function(e){
- getList(true);
- })
- }
- function initScroller(){
- $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
- page.push(1);
- loaded.push("false");
- var pullRefresh = mui(pullRefreshEl).pullRefresh({
- down:{
- callback: function(){
- var self = this;
- setTimeout(function(){
- if(selectedTab == 0){
- $("#item1 .search-input").blur();
- }else{
- $("#item2 .search-input").blur();
- }
- getList(true);
- self.endPulldownToRefresh();
- }, 300);
- }
- },
- up: {
- callback: function(){
- var self = this;
- if(selectedTab == 0){
- $("#item1 .search-input").blur();
- }else{
- $("#item2 .search-input").blur();
- }
- setTimeout(function(){
- getList(false);
- }, 300);
- }
- }
- });
- scrollers.push(pullRefresh);
- })
- }
|