admin.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. var scroller1 = null,roleLevel = null,docInfo = null, area=null;
  2. var userRole;
  3. var $docPhoto = $("#doc_photo"),//头像
  4. $active = $('.active'),
  5. $name = $("#doc_name"),//名称
  6. $docType = $("#doc_type"),//类别
  7. $jobName = $("#doc_jobName"),
  8. $hospitalName = $("#hospitalName");//所属医院
  9. mui.plusReady(function() {
  10. plus.nativeUI.showWaiting();
  11. userRole = JSON.parse(plus.storage.getItem("userRole"));
  12. area = userRole[0].code;
  13. roleLevel = area == CITY_CODE ? 4 : area.length==6 ? 3 : 2;
  14. //保存默认的角色权限信息
  15. var selectedRole = JSON.stringify(userRole[0]);
  16. plus.storage.setItem("selectedRole", selectedRole);
  17. window.addEventListener("refreshData", function() {
  18. getSignInfo();
  19. });
  20. //切换角色事件
  21. initQiehuanDom();
  22. // 设备登记入口
  23. judgeCityCode(area)
  24. //非海沧屏蔽
  25. if(area.indexOf(350205)==0||area.indexOf(CITY_CODE)==0) {
  26. $active.find('div').removeClass('new-hide')
  27. $active.find('p').removeClass('new-hide')
  28. }
  29. var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  30. var deptName =docInfo.deptName;
  31. var jobName=docInfo.jobName;
  32. var docName = docInfo.name;//姓名
  33. var docSex = docInfo.sex;//性别
  34. var docPhoto = docInfo.photo; //图像
  35. var docHospitalName = docInfo.hospitalName; //医院
  36. //图片加载失败时使用默认图片
  37. document.getElementById("doc_photo").onerror = function(){
  38. this.src = setDocPhoto(docSex, 10);
  39. }
  40. $docPhoto.attr("src", getImgUrl(docPhoto));
  41. $name.html(docName)//名称
  42. if(deptName || jobName){
  43. $docType.html("("+deptName+jobName+")") //类别
  44. }
  45. $hospitalName.html(userRole[0].name);//显示该医生拥有的管理员权限
  46. if(userRole.length > 1){
  47. $("#selectRole").show();
  48. var html = template("role_tmp", {list: userRole});
  49. $("#roleList").append(html);
  50. }
  51. $('#doc_type').css('max-width', ($('#doc-info').width() - $name.width() - 35) + 'px');
  52. if(!isMultiRole()){
  53. checkIdcard(docInfo.idcard);
  54. }
  55. getSignInfo();//获取签约量、签约率、完成率
  56. bindEvents();
  57. $('#wrapper').height($(window).height())
  58. initScroll();
  59. });
  60. function initScroll() {
  61. //阻尼系数
  62. var deceleration = mui.os.ios?0.003:0.0009;
  63. mui('#wrapper').scroll({
  64. bounce: false,
  65. indicators: true, //是否显示滚动条
  66. deceleration:deceleration
  67. });
  68. mui("#wrapper .mui-scroll").pullToRefresh({
  69. down: {
  70. callback: function() {
  71. var self = this;
  72. setTimeout(function() {
  73. getSignInfo();
  74. self.endPullDownToRefresh();
  75. }, 1000);
  76. }
  77. }
  78. });
  79. //角色切换模块的下拉环境scroll初始
  80. mui("#roleWrapper").scroll({
  81. bounce: false,
  82. indicators: true,
  83. deceleration: deceleration
  84. })
  85. mui("#roleWrapper").pullRefresh();
  86. }
  87. //获取签约量、签约率、完成率
  88. function getSignInfo(){
  89. var endDate = getDateBefore(0);
  90. if(roleLevel!=4){
  91. $("#li-mingyi2").show();
  92. $("#li-mingyi1").hide();
  93. }
  94. sendPost("/statistics/sign_info", {endDate:endDate,area: area,level:roleLevel}, null,
  95. countHandle, 'POST', '', true);
  96. }
  97. function bindEvents(){
  98. mui('#wrapper').on('tap','.wrap', function(){
  99. var href=$(this).attr("data-href");
  100. var hrefId = $(this).attr("data-href-id");
  101. mui.openWindow({
  102. url:href,
  103. id:hrefId,
  104. extras:{
  105. type:$(this).attr("data-id")
  106. },
  107. })
  108. });
  109. mui('#wrapper').on('tap','.div-aitem', function(){
  110. var href=$(this).attr("data-href");
  111. var hrefId = $(this).attr("data-href-id");
  112. var activeId = $(this).attr("data-id");
  113. if(activeId=="5" && roleLevel==2){//两率分析
  114. href = "../../manager/html/lianglvfenxi-sheguan.html";
  115. hrefId = "lianglvfenxi-sheguan.html";
  116. }
  117. if(plus.os.name == "Android" && plus.device.vendor == "Meizu") {
  118. var wv = plus.webview.create( href, hrefId, {hardwareAccelerated:false}, {
  119. type:$(this).attr("data-id")
  120. } );
  121. wv.show("slide-in-right",250);
  122. } else {
  123. mui.openWindow({
  124. url:href,
  125. id:hrefId,
  126. extras:{
  127. type:$(this).attr("data-id")
  128. },
  129. })
  130. }
  131. });
  132. mui('#wrapper').on('tap','.fwfx-ul li',function(){
  133. var href=$(this).attr("data-href");
  134. var hrefId = $(this).attr("data-href-id");
  135. if(href){
  136. mui.openWindow({
  137. url:href,
  138. id:hrefId,
  139. extras:{
  140. type:$(this).attr("data-id")
  141. },
  142. })
  143. }
  144. });
  145. //说明信息相关事件
  146. $("#closeBtn").on("tap", function(){
  147. $(".information").parent().hide();
  148. scroller1.refresh();
  149. });
  150. $("#roleList").on('tap', 'li', function(){
  151. var $this = $(this),
  152. index = $this.data('index'),
  153. name = $this.data('name'),
  154. code = $this.data('code');
  155. $("#hospitalName").text(name);
  156. area = code + '';
  157. roleLevel = area == CITY_CODE ? 4 : area.length==6 ? 3 : 2;
  158. if(area.indexOf(350205)==0||area.indexOf(CITY_CODE)==0) {
  159. $active.find('div').removeClass('new-hide')
  160. $active.find('p').removeClass('new-hide')
  161. }else{
  162. $active.find('div').addClass('new-hide')
  163. $active.find('p').addClass('new-hide')
  164. }
  165. getSignInfo();
  166. mui('#middlePopover').popover('hide');
  167. // 设备登记入口(海沧)
  168. judgeCityCode(code)
  169. //保存默认的角色权限信息
  170. var selectedRole = JSON.stringify(userRole[index]);
  171. plus.storage.setItem("selectedRole", selectedRole);
  172. })
  173. $(".close-btn").on('tap', function(){
  174. mui('#middlePopover').popover('hide');
  175. });
  176. //医生体验
  177. $(".ysty").on("tap",function(){
  178. ysty();
  179. })
  180. $('#li-mingyi1').on("tap",function() {
  181. openWebview('../../mygl/html/mingyiguanli.html')
  182. });
  183. $('#unbind_device').on("tap",function(){
  184. openWebview('jiebangshebei.html');
  185. });
  186. $('#jianjiao-tuisong').on("tap",function(){
  187. <!--openWebview('jianjiaotuisong.html');-->
  188. openWebview("../../jkjy/html/article-store.html", {isAdmin: true});
  189. });
  190. $('#device-manage').on("tap",function(){
  191. openWebview("../../device/html/device-data.html");
  192. });
  193. $(".wjdc").on('tap', function(){
  194. //根据角色权限显示对应的列表信息
  195. // roleLevel: 级别(4:市 3:区 2:社区医院 1:团队)
  196. var userRole = JSON.parse(plus.storage.getItem("userRole"))[0];
  197. if(roleLevel == 4){
  198. openWebview('../../survey/html/survey_list.html');
  199. } else {
  200. mui.confirm("对不起,您无操作权限","提示",
  201. ["我知道了"], function(e){
  202. if(e.index==0) return false;
  203. });
  204. }
  205. });
  206. }
  207. // 设备登记入口(海沧)
  208. function judgeCityCode(code) {
  209. code += "";
  210. if(code.indexOf("350205") == 0){ //海沧区的医生才能够看到设备绑定的入口
  211. $("#device-manage").show()
  212. } else {
  213. $("#device-manage").hide()
  214. }
  215. }
  216. function countHandle(res){
  217. if(res.status == 200) {
  218. res = res.data;
  219. //console.log(JSON.stringify(res))
  220. var rate = res.signRate.rate;
  221. $('#qieyuelv').waterbubble({
  222. txt: parseFloat(rate).toFixed(2) + "%",
  223. data: res.signRate.rate/100,
  224. waterColor: '#12B7F5',
  225. lineWidth:0,
  226. radius: 60,
  227. textColor: 'rgba(0, 0, 0, 0.8)',
  228. font: 'bold 32px arial'
  229. });
  230. var qylvHtml = '<span class="data-lv" style="color: #12b7f5; border-bottom: 1px solid #12b7f5;">'+res.signRate.sign+'</span>'+
  231. '<p>'+res.signRate.people+'</p>';
  232. $(".p-qianyuelv").html(qylvHtml);
  233. var taskRate = res.signTaskRate.rate;
  234. $('#dabiaolv').waterbubble({
  235. txt: parseFloat(taskRate).toFixed(2) + "%",
  236. data: res.signTaskRate.rate/100,
  237. waterColor: '#4ECD70',
  238. lineWidth:0,
  239. radius: 60,
  240. textColor: 'rgba(0, 0, 0, 0.8)',
  241. font: 'bold 32px arial'
  242. });
  243. var dclvHtml = '<span class="data-lv" style="color: #4ECD70; border-bottom: 1px solid #4ECD70;">'+res.signTaskRate.sign+'</span>'+
  244. '<p>'+res.signTaskRate.people+'</p>';
  245. $(".p-dachenglv").html(dclvHtml);
  246. //添加续签
  247. $('#xuqianlv').waterbubble({
  248. txt: res.renewRange,
  249. data: parseFloat(res.renewRange)/100,
  250. waterColor: '#19d5c5',
  251. lineWidth:0,
  252. radius: 60,
  253. textColor: 'rgba(0, 0, 0, 0.8)',
  254. font: 'bold 32px arial'
  255. });
  256. var renew = res.renew.split("/");
  257. var xqlvHtml = '<span class="data-lv" style="color: #19d5c5; border-bottom: 1px solid #19d5c5;">'+renew[0]+'</span>'+
  258. '<p>'+renew[1]+'</p>';
  259. $(".p-xuqianlv").html(xqlvHtml);
  260. $(".div-qyl").html(format_number(res.sign));
  261. $(".div-qianyuelv").html(res.signRate.rate.substring(0,4) + "%");
  262. $(".div-dachenglv").html(res.signTaskRate.rate.substring(0,4) + "%");
  263. } else {
  264. mui.toast(res.msg);
  265. }
  266. // $(".pullDown").hide();
  267. plus.nativeUI.closeWaiting();
  268. }
  269. /**
  270. * 数字3位加一个逗号
  271. * @param {Object} n
  272. */
  273. function format_number(n){
  274. var b=parseInt(n).toString();
  275. var len=b.length;
  276. if(len<=3){return b;}
  277. var r=len%3;
  278. 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(",");
  279. }
  280. /**
  281. * 获取多少天前的日期
  282. */
  283. function getDateBefore(days) {
  284. var now = new Date();
  285. var date = new Date(now.getTime() - days * 24 * 3600 * 1000);
  286. var year = date.getFullYear();
  287. var month = date.getMonth() + 1;
  288. var day = date.getDate();
  289. var hour = date.getHours();
  290. var minute = date.getMinutes();
  291. var second = date.getSeconds();
  292. return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  293. }
  294. function ysty(){
  295. //观察者模式下,不可以再次观察者查看
  296. var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
  297. if(userAgent.observer){
  298. mui.confirm("对不起,您无操作权限","提示",
  299. ["我知道了"], function(e){
  300. if(e.index==0) return false;
  301. });
  302. return;
  303. }
  304. //根据角色权限显示对应的列表信息
  305. // roleLevel: 级别(4:市 3:区 2:社区医院 1:团队)
  306. // var userRole = JSON.parse(plus.storage.getItem("userRole"))[0];
  307. var userRole = JSON.parse(plus.storage.getItem("selectedRole"));
  308. if(roleLevel == 4){
  309. openWebview('../../observer/html/district.html',{code: userRole.code});
  310. }
  311. if(roleLevel == 3){
  312. openWebview('../../observer/html/hospital.html',{code: userRole.code});
  313. }
  314. if(roleLevel == 2){
  315. openWebview('../../observer/html/doctors.html', {code: userRole.code});
  316. }
  317. if(roleLevel == undefined || roleLevel == null || roleLevel == 1){
  318. mui.confirm("对不起,您无操作权限","提示",
  319. ["我知道了"], function(e){
  320. if(e.index==0) return false;
  321. });
  322. }
  323. }