doctor-index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var d = dialog({contentType: 'load',skin: 'bk-popup'})
  2. var Request = GetRequest();
  3. var doctor = Request["docCode"];
  4. var firstLevelCategoryId = ""
  5. var hospital = "" // 医生所属社区Code
  6. var pageData = {}
  7. function toast(msg){
  8. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
  9. }
  10. function getCategoryByNamePromise(){
  11. return new Promise(function(resolve, reject) {
  12. sendPost("third/jkEdu/Article/getCategoryByName",{name:'健康文章'},"JSON","GET",function(){
  13. toast('请求失败')
  14. },function(res){
  15. resolve(res)
  16. })
  17. })
  18. }
  19. function jimeiHomepagePromise(){
  20. return new Promise(function(resolve, reject) {
  21. sendPost("patient/family_contract/jimeiHomepage",{doctor:doctor,pageIndex:1,pageSize:3},"JSON","GET",function(){
  22. toast('请求失败')
  23. },function(res){
  24. resolve(res)
  25. })
  26. })
  27. }
  28. function queryArticleAPPListPromise(){
  29. return new Promise(function(resolve, reject) {
  30. sendPost("patient/jkEdu/article/queryArticlePcList",{
  31. doctor: doctor,
  32. firstLevelCategoryId: firstLevelCategoryId, // 文章一级分类
  33. isMyArticle: true,
  34. currentUserRole: hospital,
  35. currentUserRoleLevel: 4,
  36. iDisplayStart: 0,
  37. iDisplayLength: 3
  38. },"JSON","GET",function(){
  39. toast('请求失败')
  40. },function(res){
  41. resolve(res)
  42. })
  43. })
  44. }
  45. function bindEvents(){
  46. $('.j-open').on('tap',function(){
  47. var $this = $(this)
  48. $this.addClass('c-hide')
  49. $('.di-down').removeClass('c-hide')
  50. })
  51. $('.j-close').on('tap',function(){
  52. var $this = $(this)
  53. $this.closest('.di-down').addClass('c-hide');
  54. $('.j-open').removeClass('c-hide')
  55. })
  56. $('.xj-li').on('tap',function(){
  57. d.show()
  58. var articleId = $(this).attr('data-id')
  59. window.location.href="../../jkjy/html/article2.html?dataId="+articleId+'&articleId='+articleId+'&type='+'1';
  60. })
  61. $("#more_art").on('tap',function(){
  62. window.location.href="health-article-list.html?docCode="+$(this).attr('data-id')
  63. })
  64. }
  65. $(function(){
  66. d.show()
  67. Promise.all([getCategoryByNamePromise(),jimeiHomepagePromise()]).then(function(responses) {
  68. var res0 = responses[0]
  69. var res1 = responses[1]
  70. if(res0.status == 200 && res1.status == 200) {
  71. firstLevelCategoryId = res0.data.cid
  72. hospital = res1.data.hospital
  73. pageData = res1.data
  74. } else {
  75. d.close()
  76. toast('获取数据失败')
  77. return Promise.reject()
  78. }
  79. }).then(function() {
  80. return queryArticleAPPListPromise().then(function(res) {
  81. d.close()
  82. var list = res.data.aaData
  83. var data = $.extend({},pageData, {
  84. healthEduArticles: list
  85. })
  86. var html = template('list_tmp',{data: data})
  87. $('#main_contain').html(html)
  88. bindEvents()
  89. })
  90. }).catch(function(e) {
  91. d.close()
  92. console && console.error(e)
  93. })
  94. })
  95. template.helper("setPhoto", function(p) {
  96. return getImgUrl(p);
  97. })
  98. template.helper("setTime", function(p) {
  99. if(p && p.length>0){
  100. return p.substr(0,16)
  101. }else{
  102. return ''
  103. }
  104. })