123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- var page = 0,
- pagesize = 10;
- var $tabs = $('#tabs'),
- $panels = $('.c-panels'),//切换选项卡
- $list = $('#dest_list'),//选项卡内容
- $notext = $('#no_result_wrap'),//没有样式
- $scroll = $('#iScroll');//内容展示
-
- var teamInfo,
- docInfo,
- teamCode,//团队code
- categoryLevel="",//级别id
- categoryId="",//类别id
- isAuthentication="",
- startDate="",
- firstLevelCategoryId ="",
- endDate="",
- hospitalName="",
- currentUserRole="";
-
- // 获取登录相关信息
- var getBaseInfo = function() {
- // 登录的相关信息
- currentUserRole = JSON.parse(plus.storage.getItem('docInfo')).hospital
- return currentUserRole;
- }
- var getHospitalName = function() {
- // 登录的相关信息
- hospitalName = JSON.parse(plus.storage.getItem('docInfo')).hospitalName
- return hospitalName;
- }
- /*刷新事件*/
- window.addEventListener("reloadPage", function refresh(e) {
- refreshPage();
- });
- function refreshPage(){
- $('#dest_list').empty();
- categoryId = ""; //类别id
- isAuthentication = "";
- startDate = "";
- endDate = "";
- //将所有顶部的选项置为默认置
- $("#showHeader li").removeClass("list-selected");
- $("#showHeader ul li:first-child").addClass("list-selected");
- $("#tabs .j-tag:eq(0)").text("全部分类");
- $("#tabs .j-tag:eq(1)").text("认证状态");
- $("#tabs .j-tag:eq(2)").text("全部时间");
- queryListData(true);
- }
- function queryHeaderData(){
- sendPost("/third/jkEdu/Article/getCategoryByName",{name:'健康文章'}, null, function(res){
- if(res.status == 200){
- var html = template('tag_tmpl',{data:res.data})
- $('#showHeader').html(html)
- firstLevelCategoryId = res.data.cid;
- console.log(firstLevelCategoryId);
- queryListData(true);
- }
- },'get')
- }
- function queryListData(isInit){
- if(isInit){
- page = 0;
- }
- var params ={
- firstLevelCategoryId: firstLevelCategoryId,
- secondLevelCategoryId: categoryId,
- isAuthentication: isAuthentication,//文章是否认证
- insertTimeStart: startDate,
- insertTimeEnd: endDate,
- currentUserRole: currentUserRole,
- iDisplayStart: page,
- iDisplayLength: pagesize,
- currentUserRoleLevel: 4,
- roleType:1,
- isMyArticle: true
- }
- console.log(JSON.stringify(params));
- sendPost("/doctor/jkEdu/article/queryArticleAPPList",params, function(){
- plus.nativeUI.closeWaiting();
- fun&&fun.call(this,false)
- mui.toast("获取数据失败!");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- if(isInit && res.data.aaData.length == 0){
- $notext.show();
- $scroll.hide();
- return;
- }else{
- $notext.hide();
- $scroll.show();
- var html = template('li_tmpl',{list:res.data.aaData});
- if(isInit){
- mui('.mui-scroll-wrapper').scroll().scrollTo(0,0,300);
- $("#dest_list").empty().append(html);
- }else{
- $("#dest_list").append(html);
- }
-
- if(res.data.aaData.length < pagesize){
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }else{
- page ++;
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false);
- }
- }
- }else{
- mui.toast(res.msg);
- }
- },'get')
- }
- template.helper('setSex',function(item){
- if(item == 1){
- return '男'
- }else{
- return '女'
- }
- })
- //该上月份最后一天
- function lastDate(date){
- var arr = date.split('-');
- var year = arr[0];
- var month = arr[1]*1-1;
- if(month<1){
- month = 12;
- year = year - 1;
- }
- var day = new Date(year,month,0).getDate();
- return day;
- }
- //近一周
- function beforeWeek(date,num){
- var d = new Date();
- d.setDate(date.getDate() - num);
- return d.format('yyyy-MM-dd');
- }
- //近几个月前
- function beforeMonth(date,num){
- var d = new Date();
- d.setMonth(date.getMonth() - num);
- return d.format('yyyy-MM-dd');
- }
- function bindEvents() {
- $tabs.on('click','.sanp-flex',function() {
- var index = $(this).index(),
- $panel = $panels.find('.c-panel').eq(index);
- $panel.siblings().hide();
- if($panel.css('display')=='none') {
- $panel.show();
- } else {
- $panel.hide();
- }
- })
-
- template.helper("getImgUrl", function(str){
- if(str){
- return getImgUrl(str);
- }else{
- return "";
- }
- });
-
- template.helper("formatDate", function(updateTime){
- if(updateTime){
- return updateTime.substr(0,19)
- }else{
- return "";
- }
- });
-
- $panels.on('click','li',function() {
- var $panel = $(this).closest('.c-panel');
- $(this).siblings().removeClass('list-selected');
- $(this).addClass('list-selected');
- $panel.hide();
- $('.j-tag').eq($panel.index()).text($(this).find('a').text())
-
- if($panel.index() ==0){ categoryId = $(this).attr('category-id');categoryLevel = $(this).attr('category-level') }
- if($panel.index() ==1){ isAuthentication = $(this).attr('data-id') }
- if($panel.index() ==2){
- var num = $(this).attr('data-id'),
- now = new Date();
- endDate = now.format('yyyy-MM-dd')+" 23:59:59";
- if(num == 1){
- startDate = beforeWeek(now,7) + " 00:00:00";
- }else if(num == 2){
- startDate = beforeMonth(now,1) + " 00:00:00";
- }else if(num == 3){
- startDate = beforeMonth(now,6) + " 00:00:00";
- }else if(num == 4){
- startDate = beforeMonth(now,12) + " 00:00:00";
- }else{
- startDate = '';
- endDate = '';
- }
- }
- queryListData(true);
- })
-
-
- $('#dest_list').on('tap','li.article-li',function(){
- var articleId = $(this).attr('data-id');
- mui.openWindow({
- id: "articleDetail",
- url: "articleDetail.html",
- extras: {
- articleId:articleId
- }
- })
- })
- //点击跳转
- $('#dest_list').on('tap','.tuisong-common',function(e){
- e.stopPropagation();
- var $this = $(this);
- var articleId = $this.attr("data-code");
- var articleTitle = $this.attr("data-title");
- mui.openWindow({
- id: "xuanzejumin_more",
- url: "xuanzejumin_more.html",
- extras: {
- article:articleId,origin:'jiaoyu',articleTitle:articleTitle
- }
- })
- })
- $('#dest_list').on('tap','.edit-common',function(e){
- e.stopPropagation();
- var $this = $(this);
- var articleId = $this.attr("data-id");
- mui.openWindow({
- id: "article-edit",
- url: "article-edit.html",
- extras: {
- articleId:articleId
- }
- })
- })
-
- $('#search_btn').click(function(){
- mui.openWindow({
- id: "articleSearch",
- url: "articleSearch.html",
- extras: {
- //必需的数据
- firstLevelCategoryId:firstLevelCategoryId,
- currentUserRole:currentUserRole,
- currentUserRoleLevel:4
- //非必需数据 加上有测试数据
- // currentUserRole:'350200',
- }
- })
- })
- //新增按钮事件
- $(".div-add-btn").on("click",function(){
- //现在固定显示咨询可以选择类型,不做三师等的判断
- mui.openWindow({
- id: "addArticle",
- url: "addArticle.html",
- extras: {
- firstLevelCategoryId:firstLevelCategoryId,//文章一级分类id
- currentUserRole:currentUserRole,
- hospitalName:hospitalName
-
- }
- })
- });
- }
- function initscroller(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- mui('.mui-scroll-wrapper').pullRefresh({
- down: {
- callback: function(){
- queryListData(true);
- this.endPulldownToRefresh();
- }
- },
- up: {
- callback: function(){
- var self = this;
- setTimeout(function(){
- queryListData(false);
- self.endPullupToRefresh();
- }, 500);
- }
- }
- })
- }
- new Promise(function(resolve, reject) {
- mui.plusReady(function() {
- resolve(true);
- })
- }).then(function(resolve, reject) {
- plus.nativeUI.showWaiting();
- //请求头部数据
- queryHeaderData();
- currentUserRole = getBaseInfo();
- hospitalName = getHospitalName();
- initscroller();
- bindEvents();
- });
|