service_item_content.js 9.6 KB

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