123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- var page = 10,
- pagesize = 10,
- reqInfo = [
- {url:"doctor/jkEdu/article/PC/fetchPatientArticlePushedList",page: 1,template: 'edu_tmpl'},
- {url:"doctor/health/guidance/list_by_team",page: 1,template: 'zhidao_tmpl'}
-
- ],
- patiCode = "",
- teamCode,
- activeIndex = 0;
- var eduObj, zhidaoObj;
- var noResultWrap = '<div id="no_result_wrap" style="width: 320px; height: 184px; margin: 60px auto 0px;">'+
- '<img src="../../../images/shujuweikong_img.png" /><div style="color:#666;font-size:16px;text-align:center;">暂无数据</div></div>';
-
- mui.init();
- (function($) {
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- $('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- $.plusReady(function() {
- //循环初始化所有下拉刷新,上拉加载。
- $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
- $(pullRefreshEl).pullRefresh({
- down: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- getList(pullRefreshEl, index, true, true);
- self.endPulldownToRefresh();
- }, 1000);
- }
- },
- up: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- getList(pullRefreshEl, index, false);
- self.endPullupToRefresh();
- }, 1000);
- }
- }
- });
- });
- var self = plus.webview.currentWebview();
- patiCode = self.patientCode;
- initTemplateHelper();
- getTeamInfo();
- bindEvents();
- });
- })(mui);
- function getTeamInfo(){
- plus.nativeUI.showWaiting();
- // TODO 团队选择
- return getReqPromise("doctor/family_contract/patient_doctor_teams",{
- patient: patiCode
- }).then(function(res) {
- if(res.status == 200) {
- var data = res.data,teams = [];
- // 是否有签约关系 1:有 0:无,此时jtTeam与ssTeam都没有
- if(data.hasSign=="1") {
- data.ssTeam && (function() {
- var team = data.ssTeam.team;
- team.hasSign = data.ssTeam.hasSign; // 医生与患者是否有签约关系
- team.isLeader = data.ssTeam.isLeader; // 是否是团队长
- teams.push(team)
- })();
- data.jtTeam && (function() {
- var team = data.jtTeam.team;
- team.hasSign = data.jtTeam.hasSign; // 医生与患者是否有签约关系
- team.isLeader = data.jtTeam.isLeader; // 是否是团队长
- teams.push(team)
- })();
- }
- }
- $('.lin-sel-group').html(template('teams_tmpl', {data:teams}));
- //初始默认选中第一个团队信息
- var $select = $(".lin-sel-group li").eq(0);
- var code = parseInt($select.attr("data-code"));
- $(".lin-sel-group li").removeClass("checked");
- $select.addClass("checked");
- teamCode = code;
- $("#Dtitle").html($select.find("label").html()).attr("data-index",code);
- }).then(function(){
- // plus.nativeUI.closeWaiting();
- getList(document.getElementsByClassName("mui-scroll-wrapper")[activeIndex], activeIndex, true);
- });
- }
- function getList(el, index, isInit, refresh){
- page = isInit? 1: page;
- var url = reqInfo[index].url,
- params = {
- patientCode: patiCode,
- patient: patiCode,
- teamCode: teamCode || "",
- page: page,
- pagesize: pagesize,
- };
- if(!refresh && ((index == 0 && eduObj) || (index == 1 && zhidaoObj))){
- return false;
- }
- plus.nativeUI.showWaiting();
- sendPost(url, params, null, function(res){
- if(res.status == 200){
- var list = res.list || res.data;
- if(index == 0){
- eduObj = list;
- }else{
- zhidaoObj = list;
- }
- if(list.length > 0){
- page++;
- var html = template(reqInfo[index].template, {list: list});
- if(isInit){
- $(el).find(".mui-scroll").empty().append(html);
- }else{
- $(el).find(".mui-scroll").append(html);
- }
- if(list.length < pagesize){
- mui(mui('.mui-scroll-wrapper')[activeIndex]).pullRefresh().endPullupToRefresh(true);
- }
- }else{
- //无数据
- if(isInit){
- $(el).find(".mui-scroll").append(noResultWrap);
- }
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, 'POST', '', true);
- }
- function bindEvents(){
- //切换菜单
- $('.mui-control-item a').on('tap',function(){
- var index = this.getAttribute('data-index'),
- el = document.getElementsByClassName("mui-scroll-wrapper")[index];
- page = 1;
- activeIndex = index;
- getList(el, index, true);
- var slider = mui('.mui-slider').slider();
- slider.gotoItem(index);
- });
-
- document.getElementById('slider').addEventListener('slide', function(event) {
- var idx = event.detail.slideNumber,
- el = document.getElementsByClassName("mui-scroll-wrapper")[idx];
- getList(el, idx, true);
- });
-
- $('body').on("tap", ".zd_detail", function(){
- chooseItem(this,"zhidao")
- }).on("tap", ".edu_detail", function(){
- chooseItem(this, "edu");
- });
-
- $(".demo-comtop").on("click","h1",function(){
- $(".lin-mask").show();
- $(".lin-sel-group").show();
- });
-
- $(".lin-mask").on("click",function(){
- $(".lin-mask").hide();
- $(".lin-sel-group").hide();
- });
-
- $(".lin-sel-group").on("click","li",function(){
- var index = parseInt($(this).attr("data-code"));
- $(".lin-sel-group li").removeClass("checked");
- $(this).addClass("checked");
- $(".lin-mask").trigger("click");
- $("#Dtitle").html($(this).find("label").html()).attr("data-index",index);
- teamCode = $(this).attr("data-code");
- //重新加载数据
- getList(document.getElementsByClassName("mui-scroll-wrapper")[activeIndex], activeIndex, true);
- });
- }
- function chooseItem(ele, type){
- var info = ele.getAttribute("data-info"),
- self = plus.webview.currentWebview();
- var questionaires = plus.webview.getWebviewById("questionaires");
- mui.fire(questionaires, "fillEdu", {info: info, type: type});
- questionaires.show();
- mui.later(function(){
- self.close('none');
- }, 300);
- }
- function initTemplateHelper(){
- template.helper('toInfo', function(v){
- return JSON.stringify(v);
- });
-
- template.helper("setSex", function(s) {
- if(s == 1) {
- return "男"
- } else if(s == 2) {
- return "女"
- }
- });
- template.helper("setPhoto", function(p) {
- if(!p || p.length == 0) {
- return "../../../images/p-default.png";
- } else {
- return getImgUrl(p);
- }
- });
-
- template.helper("setTime", function(p) {
- // 为了防止类似“2016-12-21 14:08:10.0”在IOS上无法识别问题
- if(p){
- p = p.split('.')[0];
- return new Date(Date.parse(p.replace(/-/g, "/"))).format("yyyy-MM-dd hh:mm:ss")
- }else{
- return "";
- }
-
- });
- }
|