service_item_content.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. !function(){
  2. var httpData=GetRequest();
  3. var userInfo = JSON.parse(window.localStorage.getItem(httpRequest.agentName));
  4. new Vue({
  5. el:"#app",
  6. data:{
  7. planids:httpData['planids'],
  8. serviceData:[
  9. {
  10. relationRecordImg:{},
  11. messageList:{}
  12. }
  13. ],
  14. isCollapse :false,
  15. collapseIndex:0,
  16. qrCode:'',
  17. qrModal:false,
  18. },
  19. mounted:function(){
  20. this.getServiceItemList();
  21. },
  22. methods:{
  23. viewDetial:function(type,code){
  24. var vm=this;
  25. if(type==3||type==4){
  26. top.layer.msg('客户端暂不支持查询随访记录');
  27. }else{
  28. top.layer.open({
  29. type: 2,
  30. // offset: ['100px'], //右下角弹出
  31. area: ['80%', '600px'],
  32. shade: 0.5,
  33. title: '指导留言',
  34. fixed: true, //不固定
  35. maxmin: true,
  36. closeBtn: 1,
  37. shift: 5,
  38. shadeClose: false, //点击遮罩关闭层
  39. content: '../../article/html/article-info.html?articleId=' + code,
  40. end: function() { // 未点击确定按钮,点击关闭按钮
  41. vm.getServiceItem();    
  42. }
  43. });
  44. }
  45. },
  46. chakan:function(){
  47. this.isCollapse=!this.isCollapse;
  48. },
  49. changeCollapseIndex:function(idx){
  50. this.collapseIndex=idx;
  51. },
  52. qwapp:function(){
  53. layer.msg('请前往app处理',{icon:5});
  54. },
  55. //获取服务列表
  56. getServiceItemList:function(){
  57. var vm=this;
  58. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent') || '{}');
  59. var loadding = layer.load(0, {shade: false}); //0代表加载的风格,支持0-2
  60. rehaAPI.serviceItemList({planDetailIds:vm.planids}).then(function(res){
  61. layer.close(loadding);
  62. if(res.status==200){
  63. var isZK=loginDoctor.doctorType==1?true:false;
  64. vm.serviceData=_.map(res.data||{},function(o){
  65. o.isZK=isZK;
  66. if(o.isMyTask==1){//执行者
  67. o.isCK=true;//无法显示按钮
  68. if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者
  69. o.isCK=false;
  70. o.isCreate=true;
  71. }
  72. }else{
  73. if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者
  74. o.isCreate=true;
  75. }
  76. }
  77. console.log(o)
  78. return o
  79. })
  80. }else{
  81. layer.msg(res.msg,{icon:5});
  82. }
  83. })
  84. },
  85. //健康教育
  86. jkjy:function(patient,planId){
  87. var vm=this
  88. layer.open({
  89. type: 2,
  90. area: ['88%', '600px'],
  91. shade: 0.5,
  92. title: '健康教育',
  93. fixed: true, //不固定
  94. maxmin: true,
  95. closeBtn: 1,
  96. shift: 5,
  97. shadeClose: false, //点击遮罩关闭层
  98. content: '../../article/html/article.html?code='+patient+'&planId='+planId+'&isReha=true',
  99. end: function() { // 未点击确定按钮,点击关闭按钮
  100. vm.getServiceItemList();    
  101. }
  102. });
  103. },
  104. // 健康指导
  105. jkzd:function(planId,patient){
  106. var vm=this
  107. layer.open({
  108. type: 2,
  109. // offset: ['100px'], //右下角弹出
  110. area: ['80%', '600px'],
  111. shade: 0.5,
  112. title: '健康指导',
  113. fixed: true, //不固定
  114. maxmin: true,
  115. closeBtn: 1,
  116. shift: 5,
  117. shadeClose: false, //点击遮罩关闭层
  118. content:'../../guidance/html/index.html#/person-edit-panel?patient='+patient+'&planId='+planId,
  119. end: function() { // 未点击确定按钮,点击关闭按钮
  120. vm.getServiceItemList();    
  121. }
  122. });
  123. },
  124. // 暂未开放
  125. zwkf:function(){
  126. layer.msg('此功能暂未开放',{icon:1});
  127. },
  128. goToFinish:function(planid){
  129. var vm=this;
  130. layer.open({
  131. type: 2,
  132. // offset: ['100px'], //右下角弹出
  133. area: ['80%', '600px'],
  134. shade: 0.5,
  135. title: '完成项目确认',
  136. fixed: true, //不固定
  137. maxmin: true,
  138. closeBtn:1,
  139. shift: 5,
  140. shadeClose: false, //点击遮罩关闭层
  141. content: '../../rehabilitation/html/guide_the_message.html?planid='+planid,
  142. end: function() { // 未点击确定按钮,点击关闭按钮
  143. vm.getServiceItemList();    
  144. }
  145. });
  146. },
  147. fwm:function(planid,patient){
  148. this.loadSocket(planid,patient);
  149. },
  150. zdly:function(data){
  151. var vm = this
  152. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  153. var otherCode,otherName;
  154. var planDetailId='';
  155. if(data.specialistDoctorCode==data.executeDoctorCode){
  156. layer.msg('无法与自己聊天',{icon:5});
  157. return ;
  158. }
  159. if(data.isMyTask==1){
  160. otherCode=data.specialistDoctorCode;
  161. otherName=data.specialistDoctorName;
  162. }else{
  163. planDetailId=data.planDetaiId;
  164. otherCode=data.executeDoctorCode;
  165. otherName=data.executeDoctorCode;
  166. }
  167. layer.open({
  168. type: 2,
  169. // offset: ['100px'], //右下角弹出
  170. area: ['80%', '600px'],
  171. shade: 0.5,
  172. title: '指导留言',
  173. fixed: true, //不固定
  174. maxmin: true,
  175. closeBtn:1,
  176. shift: 5,
  177. shadeClose: false, //点击遮罩关闭层
  178. content: '../../consulting/html/consulting.html?otherCode='+otherCode+'&otherName='+encodeURI(otherName)+'&planDetailId='+planDetailId,
  179. end:function(){ // 未点击确定按钮,点击关闭按钮
  180.       vm.getServiceItemList();
  181.     }
  182. });
  183. },
  184. loadSocket:function(planid,patient){
  185. var vm=this;
  186. var imurl=httpRequest.socketUrl;
  187. jQuery.getScript(imurl+"/socket.io/socket.io.js").done(function() {
  188. var type=2;//咨询类型
  189. var socket = io.connect(imurl);
  190. var sessionId = 'system';
  191. socket.emit('login', {userId: userInfo.uid, password: userInfo.uid,sessionId:sessionId,clientType:"doctor"});
  192. socket.on('message', function (data) {
  193. console.log(data);
  194. if(data.type==1){
  195. vm.checkAfterQrCode(planid,patient);
  196. }
  197. });
  198. socket.on('error', function (data) {
  199. console.log(data);
  200. });
  201. socket.on('ack', function (data) {
  202. console.log(data);
  203. vm.getQRCode(planid);
  204. });
  205. function getLocalTime(nS) {
  206. return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
  207. }
  208. })
  209. .fail(function() {
  210. layer.msg('服务码创建失败',{icon:5});
  211. });
  212. },
  213. checkAfterQrCode:function(planid,patient){
  214. var vm=this;
  215. var params={
  216. planDetailId:planid,
  217. patientCode: patient
  218. }
  219. rehaAPI.checkAfterQrCode(params).then(function(res){
  220. var icon=5;
  221. if(res.status==200){
  222. if(res.data.flag){
  223. icon=1;
  224. vm.qrModal=false;
  225. vm.goToFinish(planid);
  226. }
  227. }
  228. layer.msg(res.msg,{icon:icon});
  229. })
  230. },
  231. getQRCode:function(planid){
  232. var vm=this;
  233. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  234. var params={
  235. planDetailId:planid,
  236. doctorCode: loginDoctor.uid
  237. }
  238. rehaAPI.createServiceQrCode(params).then(function(res){
  239. console.log(res);
  240. if(res.status==200){
  241. vm.qrCode=res.data;
  242. setTimeout(function(){
  243. vm.qrModal=true;
  244. },100)
  245. }else{
  246. layer.msg('服务码获取失败',{icon:5});
  247. }
  248. })
  249. }
  250. },
  251. filters:{
  252. formatDate:function(value, format) {
  253. if(!value) return ;
  254. var fmt=format || "yyyy-MM-dd hh:mm";
  255. var date = new Date(value);
  256. if (/(y+)/.test(fmt)) {
  257. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  258. }
  259. let o = {
  260. 'M+': date.getMonth() + 1,
  261. 'd+': date.getDate(),
  262. 'h+': date.getHours(),
  263. 'm+': date.getMinutes(),
  264. 's+': date.getSeconds()
  265. };
  266. for (let k in o) {
  267. if (new RegExp(`(${k})`).test(fmt)) {
  268. let str = o[k] + '';
  269. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
  270. }
  271. }
  272. return fmt;
  273. },
  274. getImgUrl: function(value) {
  275. var url = httpRequest.getImgUrl(value);
  276. return url;
  277. }
  278. }
  279. })
  280. $("body").on('click','img',function(){
  281. var _this = $(this);//将当前的img元素作为_this传入函数
  282. imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  283. });
  284. function imgShow(outerdiv, innerdiv, bigimg, _this){
  285. var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  286. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  287. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  288. $("<img/>").attr("src", src).load(function(){
  289. var windowW = $(window).width();//获取当前窗口宽度
  290. var windowH = $(window).height();//获取当前窗口高度
  291. var realWidth = this.width;//获取图片真实宽度
  292. var realHeight = this.height;//获取图片真实高度
  293. var imgWidth, imgHeight;
  294. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  295. if(realHeight>windowH*scale) {//判断图片高度
  296. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  297. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  298. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  299. imgWidth = windowW*scale;//再对宽度进行缩放
  300. }
  301. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  302. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  303. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  304. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  305. imgWidth = realWidth;
  306. imgHeight = realHeight;
  307. }
  308. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  309. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  310. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  311. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  312. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  313. });
  314. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  315. $(this).fadeOut("fast");
  316. });
  317. }
  318. }();