admin.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. var scroller1 = null,roleLevel = null,docInfo = null, area=null;
  2. var userRole;
  3. var $docPhoto = $("#doc_photo"),//头像
  4. $name = $("#doc_name"),//名称
  5. $docType = $("#doc_type"),//类别
  6. $jobName = $("#doc_jobName"),
  7. $hospitalName = $("#hospitalName");//所属医院
  8. mui.plusReady(function() {
  9. plus.nativeUI.showWaiting();
  10. userRole = JSON.parse(plus.storage.getItem("userRole"));
  11. area = userRole[0].code;
  12. roleLevel = area == '361100' ? 4 : area.length==6 ? 3 : 2;
  13. //保存默认的角色权限信息
  14. var selectedRole = JSON.stringify(userRole[0]);
  15. plus.storage.setItem("selectedRole", selectedRole);
  16. window.addEventListener("refreshData", function() {
  17. getJieZhiTime()
  18. });
  19. //切换角色事件
  20. initQiehuanDom();
  21. var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  22. var deptName =docInfo.deptName;
  23. var jobName=docInfo.jobName;
  24. var docName = docInfo.name;//姓名
  25. var docSex = docInfo.sex;//性别
  26. var docPhoto = docInfo.photo; //图像
  27. var docHospitalName = docInfo.hospitalName; //医院
  28. //图片加载失败时使用默认图片
  29. document.getElementById("doc_photo").onerror = function(){
  30. this.src = setDocPhoto(docSex, 10);
  31. }
  32. $docPhoto.attr("src", getImgUrl(docPhoto));
  33. $name.html(docName)//名称
  34. if(deptName || jobName){
  35. $docType.html("("+deptName+jobName+")") //类别
  36. }
  37. $hospitalName.html(userRole[0].name);//显示该医生拥有的管理员权限
  38. if(userRole.length > 1){
  39. $("#selectRole").show();
  40. var html = template("role_tmp", {list: userRole});
  41. $("#roleList").append(html);
  42. }
  43. $('#doc_type').css('max-width', ($('#doc-info').width() - $name.width() - 35) + 'px');
  44. if(!isMultiRole()){
  45. checkIdcard(docInfo.idcard);
  46. }
  47. getJieZhiTime();
  48. bindEvents();
  49. $('#wrapper').height($(window).height())
  50. initScroll();
  51. });
  52. /*
  53. * 加载数据截止时间
  54. */
  55. function getJieZhiTime(){
  56. sendPost("/statistics/time",null,function(res){
  57. },function(res){
  58. if(res.status=="200"){
  59. var date = (res.data && res.data.substring(11,16)) || "";
  60. $(".jiezhi-time").html(date);
  61. }
  62. plus.nativeUI.closeWaiting();
  63. });
  64. }
  65. function initScroll() {
  66. //阻尼系数
  67. var deceleration = mui.os.ios?0.003:0.0009;
  68. mui('#wrapper').scroll({
  69. bounce: false,
  70. indicators: true, //是否显示滚动条
  71. deceleration:deceleration
  72. });
  73. mui("#wrapper .mui-scroll").pullToRefresh({
  74. down: {
  75. callback: function() {
  76. var self = this;
  77. setTimeout(function() {
  78. getJieZhiTime();
  79. self.endPullDownToRefresh();
  80. }, 1000);
  81. }
  82. }
  83. });
  84. //角色切换模块的下拉环境scroll初始
  85. mui("#roleWrapper").scroll({
  86. bounce: false,
  87. indicators: true,
  88. deceleration: deceleration
  89. })
  90. mui("#roleWrapper").pullRefresh();
  91. }
  92. function bindEvents(){
  93. mui('#wrapper').on('tap','.wrap', function(){
  94. var href=$(this).attr("data-href");
  95. var hrefId = $(this).attr("data-href-id");
  96. mui.openWindow({
  97. url:href,
  98. id:hrefId,
  99. extras:{
  100. type:$(this).attr("data-id")
  101. },
  102. })
  103. });
  104. mui('#wrapper').on('tap','.div-aitem', function(){
  105. var href=$(this).attr("data-href");
  106. var hrefId = $(this).attr("data-href-id");
  107. var activeId = $(this).attr("data-id");
  108. if(activeId=="5" && roleLevel==2){//两率分析
  109. href = "../../manager/html/lianglvfenxi-sheguan.html";
  110. hrefId = "lianglvfenxi-sheguan.html";
  111. }
  112. if(plus.os.name == "Android" && plus.device.vendor == "Meizu") {
  113. var wv = plus.webview.create( href, hrefId, {hardwareAccelerated:false}, {
  114. type:$(this).attr("data-id")
  115. } );
  116. wv.show("slide-in-right",250);
  117. } else {
  118. mui.openWindow({
  119. url:href,
  120. id:hrefId,
  121. extras:{
  122. type:$(this).attr("data-id")
  123. },
  124. })
  125. }
  126. });
  127. mui('#wrapper').on('tap','.fwfx-ul li',function(){
  128. var href=$(this).attr("data-href");
  129. var hrefId = $(this).attr("data-href-id");
  130. if(href){
  131. mui.openWindow({
  132. url:href,
  133. id:hrefId,
  134. extras:{
  135. type:$(this).attr("data-id")
  136. },
  137. })
  138. }
  139. });
  140. $("#roleList").on('tap', 'li', function(){
  141. var $this = $(this),
  142. index = $this.data('index'),
  143. name = $this.data('name'),
  144. code = $this.data('code');
  145. $("#hospitalName").text(name);
  146. area = code + '';
  147. roleLevel = area == '350200' ? 4 : area.length==6 ? 3 : 2;
  148. if(area.indexOf(350205)==0||area.indexOf(350200)==0) {
  149. $active.find('div').removeClass('new-hide')
  150. $active.find('p').removeClass('new-hide')
  151. }else{
  152. $active.find('div').addClass('new-hide')
  153. $active.find('p').addClass('new-hide')
  154. }
  155. getJieZhiTime();
  156. mui('#middlePopover').popover('hide');
  157. //保存默认的角色权限信息
  158. var selectedRole = JSON.stringify(userRole[index]);
  159. plus.storage.setItem("selectedRole", selectedRole);
  160. })
  161. $(".close-btn").on('tap', function(){
  162. mui('#middlePopover').popover('hide');
  163. });
  164. //医生体验
  165. $(".ysty").on("tap",function(){
  166. ysty();
  167. })
  168. $('#li-mingyi1').on("tap",function() {
  169. openWebview('../../mygl/html/mingyiguanli.html')
  170. });
  171. $('#unbind_device').on("tap",function(){
  172. openWebview('jiebangshebei.html');
  173. });
  174. $('#jianjiao-tuisong').on("tap",function(){
  175. <!--openWebview('jianjiaotuisong.html');-->
  176. openWebview("../../jkjy/html/article-store.html", {isAdmin: true});
  177. });
  178. $('#device-manage').on("tap",function(){
  179. openWebview("../../device/html/device-data.html");
  180. });
  181. $(".wjdc").on('tap', function(){
  182. //根据角色权限显示对应的列表信息
  183. // roleLevel: 级别(4:市 3:区 2:社区医院 1:团队)
  184. var userRole = JSON.parse(plus.storage.getItem("userRole"))[0];
  185. if(roleLevel == 4){
  186. openWebview('../../survey/html/survey_list.html');
  187. } else {
  188. mui.confirm("对不起,您无操作权限","提示",
  189. ["我知道了"], function(e){
  190. if(e.index==0) return false;
  191. });
  192. }
  193. });
  194. }
  195. /**
  196. * 数字3位加一个逗号
  197. * @param {Object} n
  198. */
  199. function format_number(n){
  200. var b=parseInt(n).toString();
  201. var len=b.length;
  202. if(len<=3){return b;}
  203. var r=len%3;
  204. return r>0?b.slice(0,r)+","+b.slice(r,len).match(/\d{3}/g).join(","):b.slice(r,len).match(/\d{3}/g).join(",");
  205. }
  206. /**
  207. * 获取多少天前的日期
  208. */
  209. function getDateBefore(days) {
  210. var now = new Date();
  211. var date = new Date(now.getTime() - days * 24 * 3600 * 1000);
  212. var year = date.getFullYear();
  213. var month = date.getMonth() + 1;
  214. var day = date.getDate();
  215. var hour = date.getHours();
  216. var minute = date.getMinutes();
  217. var second = date.getSeconds();
  218. return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  219. }
  220. function ysty(){
  221. //观察者模式下,不可以再次观察者查看
  222. var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
  223. if(userAgent.observer){
  224. mui.confirm("对不起,您无操作权限","提示",
  225. ["我知道了"], function(e){
  226. if(e.index==0) return false;
  227. });
  228. return;
  229. }
  230. //根据角色权限显示对应的列表信息
  231. // roleLevel: 级别(4:市 3:区 2:社区医院 1:团队)
  232. // var userRole = JSON.parse(plus.storage.getItem("userRole"))[0];
  233. var userRole = JSON.parse(plus.storage.getItem("selectedRole"));
  234. if(roleLevel == 4){
  235. openWebview('../../observer/html/district.html',{code: userRole.code});
  236. }
  237. if(roleLevel == 3){
  238. openWebview('../../observer/html/hospital.html',{code: userRole.code});
  239. }
  240. if(roleLevel == 2){
  241. openWebview('../../observer/html/doctors.html', {code: userRole.code});
  242. }
  243. if(roleLevel == undefined || roleLevel == null || roleLevel == 1){
  244. mui.confirm("对不起,您无操作权限","提示",
  245. ["我知道了"], function(e){
  246. if(e.index==0) return false;
  247. });
  248. }
  249. }