service_item_content.js 10 KB

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