admin.js 9.1 KB

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