index.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. var isLeader = false,
  2. level,
  3. docCode = '',
  4. docInfo;
  5. var request = getRequest(),
  6. target_url = request.target_url
  7. $(function(){
  8. var height = window.innerHeight;
  9. $("#content-main").css("height", height-51+"px");
  10. //获取医生基本信息
  11. getDoctorInfo();
  12. });
  13. function getDoctorInfo(){
  14. APIService.getDoctorInfo().then(function(res){
  15. if(res.status == 200){
  16. docInfo = res.data;
  17. docCode = docInfo.code;
  18. isLeader = docInfo.isLeader == '1' ? true : false;
  19. level = docInfo.level;
  20. window.localStorage.setItem('docInfo', JSON.stringify(docInfo));
  21. if(isLeader){
  22. $("#consultMenu").removeClass("hidden");
  23. }
  24. //先获取团队信息显示
  25. getTeamInfo();
  26. }else{
  27. showWarningMsg(res.msg)
  28. }
  29. })
  30. }
  31. function getTeamInfo(){
  32. APIService.getTeamInfo(docCode).then(function(res){
  33. if(res.status == 200){
  34. var manageTeams = '',
  35. orderTeams = '';
  36. var isLeader2 = false;
  37. if(level == 3){ //健管师,则续方订单中需要加上额外的两个菜单
  38. orderTeams = '<li><a class="J_menuItem" href="order-list-jg.html?type=1" data-index="0">需跟踪订单</a></li>'+
  39. '<li><a class="J_menuItem" href="order-list-jg.html?type=2" data-index="0">已接收订单</a></li>';
  40. }
  41. for(var i=0; i<res.data.length; i++){
  42. var item = res.data[i];
  43. if(item.leaderCode == docInfo.code){
  44. isLeader2 = true;
  45. }else{
  46. isLeader2 = false;
  47. }
  48. console.log(isLeader2);
  49. manageTeams += '<li><a class="J_menuItem" href="prescription-management.html?id='+item.id+'" data-index="0" data-id="'+item.id+'">'+item.name+'</a></li>';
  50. orderTeams += '<li><a class="J_menuItem" href="order-list.html?id='+item.id+'&isLeader='+isLeader2+'" data-index="0">'+item.name+'</a></li>';
  51. }
  52. $("#manageTeams").empty().append(manageTeams);
  53. $("#orderTeams").empty().append(orderTeams);
  54. //如果有显示咨询,则登录IM
  55. if(isLeader){
  56. loginIm();
  57. }
  58. if(target_url) {
  59. var url = decodeURIComponent(target_url)
  60. $('#content-main .J_iframe').eq(0).attr('src', url)
  61. } else {
  62. var $adminLink = $('#manageTeams a[data-id="'+docInfo.adminTeamCode+'"]');
  63. if($adminLink.length) {
  64. $adminLink.trigger('click')
  65. } else {
  66. $("#manageTeams li").eq(0).trigger('click')
  67. }
  68. }
  69. }else{
  70. showWarningMsg(res.msg)
  71. }
  72. });
  73. }
  74. function loginIm(){
  75. var params = {
  76. user_id: docInfo.code,
  77. token: '',
  78. client_id: '',
  79. platform: 4
  80. }
  81. APIService.loginIm({data: params}).then(function(res){
  82. console.log("im 登录成功");
  83. })
  84. }