| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 | 
							- var d = dialog({contentType: 'load',skin: 'bk-popup'})
 
- //var iscrollState = ""//判断拉取方向
 
- var page = 0;
 
- var pagesize = 10;
 
- var firstLevelCategoryId = ""
 
- var hospital = "" // 医生所属社区Code
 
- var pageData = {}
 
- var doctor = null
 
- function toast(msg){
 
- 	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
 
- }
 
- function getCategoryByNamePromise(){
 
- 	return new Promise(function(resolve, reject) {
 
- 		sendPost("third/jkEdu/Article/getCategoryByName",{name:'健康文章'},"JSON","GET",function(){
 
- 			toast('请求失败')
 
- 		},function(res){
 
- 			resolve(res)
 
- 		})
 
- 	})
 
- }
 
- function jimeiHomepagePromise(){
 
- 	return new Promise(function(resolve, reject) {
 
- 		sendPost("patient/family_contract/jimeiHomepage",{doctor:doctor,pageIndex:1,pageSize:3},"JSON","GET",function(){
 
- 			toast('请求失败')
 
- 		},function(res){
 
- 			resolve(res)
 
- 		})
 
- 	})
 
- }
 
- function queryArticleAPPListPromise(){
 
- 	return new Promise(function(resolve, reject) {
 
- 		sendPost("patient/jkEdu/article/queryArticlePcList",{
 
- 			doctor: doctor,
 
- 			firstLevelCategoryId: firstLevelCategoryId, // 文章一级分类
 
- 			isMyArticle: true,
 
- 			currentUserRole: hospital,
 
- 			currentUserRoleLevel: 4,
 
- 			iDisplayStart: page,
 
- 			iDisplayLength: 10
 
- 		},"JSON","GET",function(){
 
- 			toast('请求失败')
 
- 		},function(res){
 
- 			resolve(res)
 
- 		})
 
- 	})
 
- }
 
- $(function(){
 
- 	// 判断是否登录
 
- 	checkUserAgent();
 
- 	//轮播图
 
-     mui("#slider").slider({
 
-         interval: 2000
 
-     })
 
-     
 
- })
 
- function queryInit(){
 
- 	d.show();
 
- 	sendPost("patient/family_contract/getSignDoctors",{}, 'json', 'get',function(){
 
- 		d.close();
 
- 		toast('请求失败')
 
- 	},function(res){
 
- 		d.close();
 
- 		if(res.status == 200){
 
- 			var html = template('doctor_tmp',{data:res.list[0]})
 
- 			doctor = res.list[0] && res.list[0].code
 
- 			$('#doctor_msg').html(html).show();
 
- 			mui.init({
 
- 				pullRefresh : {
 
- 				    container:'#wrapper',
 
- 				    up : {
 
- 					    height:50,
 
- 					    contentinit: '',
 
- 						contentdown: '',
 
- 					    contentrefresh : "正在加载...",
 
- 					    contentnomore:'没有更多数据了',
 
- 					    auto: true,
 
- 					    callback: function() {
 
- 					    	var self = this;
 
- 					    	page++;
 
- 					    	queryArticle(function(val){
 
- 					    		setTimeout(function(){
 
- 						    		self.endPullupToRefresh(val);
 
- 						    	},500)
 
- 					    	})
 
- 						}
 
- 				    }
 
- 				}
 
- 			})
 
- 		}else{
 
- 			toast('获取医生信息失败')
 
- 		}
 
- 	})
 
- 	
 
- }
 
- function queryArticle(fun){
 
- 	Promise.all([getCategoryByNamePromise(),jimeiHomepagePromise()]).then(function(responses) {
 
- 		var res0 = responses[0]
 
- 		var res1 = responses[1]
 
- 		if(res0.status == 200 && res1.status == 200) {
 
- 			firstLevelCategoryId = res0.data.cid
 
- 			hospital = res1.data.hospital
 
- 			pageData = res1.data
 
- 		} else {
 
- 			d.close()
 
- 			toast('获取数据失败')
 
- 			return Promise.reject()
 
- 		}
 
- 	}).then(function() {
 
- 		return queryArticleAPPListPromise().then(function(res) {
 
- 			d.close()
 
- 			if(res.status == 200){
 
- 				if(res.data.length>0){
 
- 					if(res.data.length < pagesize){
 
- 						fun&&fun.call(this,true)
 
- 					}else{
 
- 						fun&&fun.call(this,false)
 
- 					}
 
- 				}else{
 
- 					fun&&fun.call(this,true)
 
- 				}
 
- 				var list = res.data.aaData
 
- 				var data = $.extend({},pageData, {
 
- 					healthEduArticles: list
 
- 				})
 
- 				var html = template('article_tmp',{data: data})
 
- 				$('.xj-ul').append(html);
 
- 				$('.xj-main').show()
 
- 				bindEvents()
 
- 			}else{
 
- 				fun&&fun.call(this,false)
 
- 				toast('获取健康文章失败')
 
- 			}
 
- 			
 
- 		})
 
- 	}).catch(function(e) {
 
- 		d.close()
 
- 		console && console.error(e)
 
- 	})
 
- }
 
- function bindEvents(){
 
- 	$('#doctor_msg').on('tap',function(){
 
- 		window.location.href="doctor-index.html?docCode="+$(this).find('.xj-nav-foot').attr('data-id')
 
- 	})
 
- 	$('.xj-main').on('tap','.xj-li',function(){
 
- 		d.show()
 
- 		window.location.href=articleUrl+"/jkeduweb/web/jkEdu/articleDetail.html?behavior=4&articleId="+$(this).attr('data-id')
 
- 	})
 
- }
 
- template.helper("setPhoto", function(p) {
 
- 	return getImgUrl(p);
 
- })
 
- template.helper("setTimeFormat", function(p) {
 
- 	var now = new Date()
 
- 	var old = new Date(p.replace(/\-/g,'/'))
 
- 	if(now.getFullYear() == old.getFullYear()){
 
- 		if(now.getMonth() == old.getMonth()){
 
- 			if(now.getDate() == old.getDate()){
 
- 				if(now.getHours() == old.getHours()){
 
- 					if(now.getMinutes() == old.getMinutes()){
 
- 						return '1分钟前'
 
- 					}else{
 
- 						var a = now.getMinutes() - old.getMinutes()
 
- 						return a+'分钟前'
 
- 					}
 
- 				}else{
 
- 					var b = now.getHours() - old.getHours()
 
- 					return b+'小时前'
 
- 				}
 
- 			}else{
 
- 				var c = now.getDate() - old.getDate()
 
- 				if(c>7){
 
- 					return p.substr(5,5)
 
- 				}else{
 
- 					return c+'天前'
 
- 				}
 
- 			}
 
- 		}else{
 
- 			return p.substr(5,5)
 
- 		}
 
- 	}else{
 
- 		return p.substr(0,10)
 
- 	}
 
- })
 
- template.helper("setTime", function(p) {
 
- 	if(p && p.length>0){
 
- 		return p.substr(0,16)
 
- 	}else{
 
- 		return ''
 
- 	}
 
- })
 
 
  |