index.js 3.0 KB

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