guide_the_message.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. var httpData = GetRequest()
  2. var docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'))
  3. var tempwindow
  4. var previewLayerIndex, followupLayerIndex, KFZDlayerIndex
  5. function closeGuidancePreview() {
  6. layer.close(previewLayerIndex)
  7. }
  8. function closeFollowUpLayer(planDetaiId, relationCode) {
  9. if ($.isArray(relationCode)) {
  10. $.each(relationCode, function (index, item) {
  11. top.rehabilitationGuideVue.saveRehabilitationOperateRecord(planDetaiId, 6, item)
  12. })
  13. } else {
  14. top.rehabilitationGuideVue.saveRehabilitationOperateRecord(planDetaiId, 6, relationCode)
  15. }
  16. layer.close(followupLayerIndex)
  17. }
  18. function closeKFZDlayer(planDetaiId) {
  19. top.rehabilitationGuideVue.saveRehabilitationOperateRecord(planDetaiId, 5)
  20. layer.close(KFZDlayerIndex)
  21. }
  22. function showSuccessMessage(msg) {
  23. layer.msg(msg, {
  24. icon: 1
  25. })
  26. }
  27. function showErrorMessage(msg) {
  28. layer.msg(msg, {
  29. icon: 5
  30. })
  31. }
  32. top.rehabilitationGuideVue = new Vue({
  33. el: '#app',
  34. data: {
  35. doctorlevel: docInfo.doctorlevel,
  36. imgData: {
  37. accept: 'image/gif, image/jpeg, image/png, image/jpg'
  38. },
  39. isCollapse: false,
  40. selectCheckTyperadio: 0,
  41. showAppointHelpCheckBtn: true, //点击预约协诊按钮结束变为false
  42. showRecordFinished: false, //点击完成记录按钮变为true
  43. appointTime: '',
  44. appointDate: '',
  45. appointHour: '',
  46. upImgs: [],
  47. upImgArr: [],
  48. planid: httpData['planid'], // 服务项id
  49. service: {
  50. relationRecordImg: {},
  51. messageList: {}
  52. },
  53. startTime: '',
  54. pickerOptions: {
  55. disabledDate: function (time) {
  56. return time.format('yyyy-MM-dd') < new Date().format('yyyy-MM-dd')
  57. }
  58. },
  59. pId: httpData['pId'], // 康复计划id
  60. patient: httpData['patient'],
  61. patientName: decodeURI(httpData['patientName']),
  62. layerIndex: undefined,
  63. recordId: httpData['recordId'] || undefined,
  64. islimit: false,
  65. messageVisible: false,
  66. messTxt: ''
  67. },
  68. watch: {
  69. appointDate: function () {
  70. if (this.appointDate == new Date().format('yyyy-MM-dd')) {
  71. this.startTime = new Date(new Date().getTime()).format('hh:mm')
  72. } else {
  73. this.startTime = ''
  74. }
  75. }
  76. },
  77. mounted: function () {
  78. this.getServiceItem()
  79. console.log('httpData', httpData)
  80. },
  81. methods: {
  82. sendDx() {
  83. console.log(this.service, 'ooooooooooooo')
  84. var vm = this
  85. rehaAPI.getSurveyMessage({ surveyResultCode: this.service.relationCode, type: 2 }).then(function (res) {
  86. vm.messageVisible = true
  87. vm.messTxt = res.data
  88. })
  89. },
  90. messageWarn() {
  91. var loading = layer.load(0, { shade: false })
  92. var vm = this
  93. rehaAPI.sendFollowMessage({ followupId: this.service.relationCode, doctorCode: docInfo.code }).then(function (res) {
  94. if (res.status == 200) {
  95. vm.updateNoteAndImageRehabilitationOperate(vm.planid, vm.service.relationCode)
  96. setTimeout(function () {
  97. vm.getServiceItem()
  98. vm.messageVisible = false
  99. }, 400)
  100. } else {
  101. layer.close(loading)
  102. }
  103. })
  104. layer.close(loading)
  105. },
  106. closeMessageDialog() {
  107. this.messageVisible = false
  108. },
  109. // 提醒患者 num 1康复指导2康复下转3复诊提醒4上门服务提醒5家签提醒
  110. sendSpecialistWeixinMessage: function (type) {
  111. var vm = this
  112. var text = ''
  113. if (type == 4) {
  114. // 上门服务
  115. text = '请问您是否确认提醒' + vm.patientName + '居民预约上门护理服务?'
  116. } else if (type == 7) {
  117. // 康复复诊
  118. text = '请问您是否确认提醒' + vm.patientName + '居民进行复诊?'
  119. }
  120. var current = layer.confirm(
  121. text,
  122. {
  123. btn: ['确定', '取消'],
  124. title: '提示'
  125. },
  126. function (index) {
  127. var reservationTypeObj = { 0: 2, 1: 3, 2: 1 }
  128. var _type = type == 4 ? 4 : type == 7 ? 3 : ''
  129. var loading = layer.load(0, { shade: false })
  130. var params = {
  131. patient: vm.patient,
  132. doctor: docInfo.uid,
  133. type: _type,
  134. relationCode: vm.planid,
  135. planId: vm.pId,
  136. reservationType: reservationTypeObj[vm.selectCheckTyperadio] //复诊类型:1线上,2线下,3远程
  137. }
  138. rehaAPI.sendSpecialistWeixinMessage(params).then(function (res) {
  139. layer.close(loading)
  140. if (res.status == 200) {
  141. showSuccessMessage('提交成功!')
  142. if (_type == 3 || _type == 4) {
  143. // 提醒患者后,即认为是已完成
  144. vm.saveRehabilitationOperateRecord(vm.planid, type)
  145. }
  146. } else {
  147. showErrorMessage(res.msg)
  148. }
  149. })
  150. layer.close(current) //再执行关闭
  151. }
  152. )
  153. },
  154. appointHelpCheck: function (data) {
  155. var vm = this
  156. vm.showAppointHelpCheckBtn = false
  157. vm.appointTime = vm.appointDate + ' ' + vm.appointHour
  158. var params = {
  159. patient: vm.patient,
  160. doctor: data.familyDoctorCode,
  161. doctorName: data.familyDoctorName, //家签医生
  162. sendTime: vm.appointTime,
  163. planDetailId: vm.planid,
  164. appointmentDoctor: data.specialistDoctorCode,
  165. appointmentDoctorName: data.specialistDoctorName //专科医生
  166. }
  167. var loading = layer.load(0, { shade: false })
  168. rehaAPI.appointmentConsultation(params).then(function (res) {
  169. layer.close(loading)
  170. if (res.status == 200) {
  171. showSuccessMessage('操作成功')
  172. setTimeout(function () {
  173. vm.getServiceItem()
  174. }, 400)
  175. } else {
  176. showErrorMessage(res.msg)
  177. }
  178. })
  179. },
  180. encryptCode: function (docCode) {
  181. var publicKey =
  182. 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4lT0JWcv9xx6Q1hsxMal2F1AmKti/xVbBeh8jrD5CiYsFTH0DO1Mpyvv8YtkGdnDSLRjOQOA1PiaYvZoHIhml/jTvEMsvFlAD5i1BsHa5blLlJxQNp/XI7wpMZPfczqO+I/JONrV6ib+6Ci/1FyTjPQfHaiT2ehGyM/CFzOW1PQIDAQAB'
  183. var encrypt = new JSEncrypt()
  184. encrypt.setPublicKey(publicKey)
  185. return encodeURIComponent(encrypt.encrypt(docCode))
  186. },
  187. openWindow(url, p1, p2) {
  188. try {
  189. if (tempwindow) tempwindow.close()
  190. } catch (e) {
  191. console.log(e)
  192. }
  193. if (p1) {
  194. tempwindow = window.open('_blank', p1, p2)
  195. } else {
  196. tempwindow = window.open('_blank')
  197. }
  198. tempwindow.location = url
  199. },
  200. openHelpCheck: function () {
  201. var encryptCode = this.encryptCode(docInfo.uid)
  202. var url = httpRequest.teamworkService + '/#/teamwork/login?_code=' + encryptCode
  203. this.openWindow(url)
  204. },
  205. recordFinished: function () {
  206. this.showRecordFinished = true
  207. },
  208. //康复指导
  209. kfzd: function () {
  210. var vm = this,
  211. str = '../../rehabilitation/html/rehabilitation_guidance.html?patient=' + vm.patient + '&planDetaiId=' + vm.planid + '&planId=' + vm.pId
  212. KFZDlayerIndex = layer.open({
  213. type: 2,
  214. // offset: ['100px'], //右下角弹出
  215. area: ['660px', '650px'],
  216. shade: 0.5,
  217. title: '康复指导',
  218. fixed: true, //不固定
  219. maxmin: true,
  220. closeBtn: 1,
  221. shift: 5,
  222. shadeClose: false, //点击遮罩关闭层
  223. content: str,
  224. end: function () {
  225. // 未点击确定按钮,点击关闭按钮
  226. vm.getServiceItem()
  227. }
  228. })
  229. },
  230. // 康复随访计划
  231. sfjh: function () {
  232. var vm = this
  233. followupLayerIndex = layer.open({
  234. type: 2,
  235. // offset: ['100px'], //右下角弹出
  236. area: ['80%', '650px'],
  237. shade: 0.5,
  238. title: '随访计划',
  239. fixed: true, //不固定
  240. maxmin: true,
  241. closeBtn: 1,
  242. shift: 5,
  243. shadeClose: false, //点击遮罩关闭层
  244. content: '../../followup/html/followup_newplan.html?patient=' + vm.patient + '&planDetaiId=' + vm.planid + '&planId=' + vm.pId,
  245. end: function () {
  246. // 未点击确定按钮,点击关闭按钮
  247. this.getServiceItem()
  248. }
  249. })
  250. },
  251. zwkf: function () {
  252. top.layer.msg('此功能暂未开放', {
  253. icon: 1
  254. })
  255. },
  256. //康复指导
  257. jkzd: function (planId, patient) {
  258. var vm = this
  259. top.layer.open({
  260. type: 2,
  261. // offset: ['100px'], //右下角弹出
  262. area: ['80%', '648px'],
  263. shade: 0.5,
  264. title: '健康教育',
  265. fixed: true, //不固定
  266. maxmin: true,
  267. closeBtn: 1,
  268. shift: 5,
  269. shadeClose: false, //点击遮罩关闭层
  270. content: '../../guidance/html/index.html#/person-edit-panel?patient=' + patient + '&planId=' + planId
  271. })
  272. },
  273. // openFollowResult() {
  274. // top.layer.open({
  275. // type: 2,
  276. // area: ['600px', '700px'],
  277. // shade: 0.5,
  278. // title: '查看随访表单',
  279. // fixed: true, //不固定
  280. // maxmin: true,
  281. // closeBtn: 1,
  282. // // shift: 5,
  283. // shadeClose: false, //点击遮罩关闭层
  284. // content: '../html/followResult.html'
  285. // })
  286. // },
  287. rehabilitationReservation() {
  288. // 如果是康复复诊过去预约挂号,在就诊信息页面少一个字段显示,1隐藏字段,0正常显示
  289. sessionStorage.setItem('isFuzhen', 1)
  290. top.layer.open({
  291. type: 2,
  292. closeBtn: 1, // 显示关闭按钮
  293. area: ['800px', '90%'],
  294. title: '预约挂号',
  295. content: '../../jbsc/html/appointment/appoint-select.html?patient=' + this.patient
  296. })
  297. },
  298. openFollowRecordForm() {
  299. var vm = this
  300. if (vm.service.disease != '3') {
  301. top.layer.msg('请到app上操作!')
  302. return false
  303. }
  304. if(vm.service.node == '该居民已有最新康复计划,系统自动完成当前计划'){
  305. top.layer.msg('该居民已有最新康复计划,系统自动完成当前计划')
  306. return
  307. }
  308. top.layer.open({
  309. type: 2,
  310. area: ['600px', '700px'],
  311. shade: 0.5,
  312. title: '记录随访表单',
  313. fixed: true, //不固定
  314. maxmin: true,
  315. closeBtn: 1,
  316. // shift: 5,
  317. shadeClose: false, //点击遮罩关闭层
  318. content: '../../rehabilitation/html/followRecord.html?serviceInfo=' + encodeURIComponent(JSON.stringify(this.service)) + '&planDetailId=' + this.planid,
  319. end: function () {
  320. // 未点击确定按钮,点击关闭按钮
  321. vm.getServiceItem()
  322. }
  323. })
  324. },
  325. qwapp: function () {
  326. top.layer.msg('请前往app处理', {
  327. icon: 5
  328. })
  329. },
  330. toDoorDialog() {
  331. var vm = this
  332. top.layer.open({
  333. type: 2,
  334. area: ['850px', '700px'],
  335. shade: 0.5,
  336. title: '代预约',
  337. fixed: true, //不固定
  338. maxmin: true,
  339. closeBtn: 1,
  340. // shift: 5,
  341. shadeClose: false, //点击遮罩关闭层
  342. // content: `/app/rehabilitation/html/toDoorService.html?patient=${this.patient}&detailId=${this.planid}&relationCode=${this.planid}`,
  343. content: `../../rehabilitation/html/toDoorService.html?patient=${this.patient}&detailId=${this.planid}&relationCode=${this.planid}`,
  344. end: function () {
  345. vm.getServiceItem()
  346. }
  347. })
  348. },
  349. viewGuidance: function (o) {
  350. var vm = this
  351. previewLayerIndex = layer.open({
  352. type: 2,
  353. area: ['380px', '600px'],
  354. shade: 0.5,
  355. title: '预览',
  356. fixed: true, //不固定
  357. maxmin: true,
  358. closeBtn: 1,
  359. shift: 5,
  360. shadeClose: false, //点击遮罩关闭层
  361. content: '../../rehabilitation/html/rehabilitation_guidance_preview.html?modelCode=' + o.article
  362. })
  363. },
  364. getServiceItem: function () {
  365. var vm = this
  366. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'))
  367. var loadding = top.layer.load(0, {
  368. shade: false
  369. }) //0代表加载的风格,支持0-2
  370. var params = {
  371. planDetailId: vm.planid
  372. }
  373. if (vm.recordId) {
  374. params['recordId'] = vm.recordId
  375. }
  376. rehaAPI.serviceItem(params).then(function (res) {
  377. top.layer.close(loadding)
  378. if (res.status == 200) {
  379. vm.service = res.data
  380. var isZK = loginDoctor.doctorType == 1 ? true : false
  381. vm.service.isZK = isZK
  382. if (vm.service.completeTime) {
  383. var l = vm.service.completeTime.length
  384. vm.service.shortCompleteTime = vm.service.completeTime.substr(l - 5, l - 1)
  385. }
  386. if (vm.service.isMyTask == 1) {
  387. //执行者
  388. vm.service.isCK = true //无法显示按钮
  389. if (loginDoctor.uid == vm.service.specialistDoctorCode) {
  390. //说明我自己是创建者
  391. vm.service.isCK = false
  392. vm.service.isCreate = true
  393. }
  394. } else {
  395. if (loginDoctor.uid == vm.service.specialistDoctorCode) {
  396. //说明我自己是创建者
  397. vm.service.isCreate = true
  398. }
  399. }
  400. if (vm.service.type == 4 || vm.service.type == 5 || vm.service.type == 7) {
  401. vm.getRelationRecord(vm.service.type, vm.planid).then(function (result) {
  402. if (result.status == 200) {
  403. vm.service.relationList = result.data && result.data.length > 0 ? result.data : undefined
  404. vm.$forceUpdate()
  405. }
  406. })
  407. }
  408. if (vm.service.frequencyCode) {
  409. vm.islimit = true
  410. } else {
  411. vm.islimit = false
  412. }
  413. } else {
  414. top.layer.msg(res.msg, {
  415. icon: 5
  416. })
  417. }
  418. if (vm.service.status == 1) {
  419. var index = top.layer.getFrameIndex(window.name) //先得到当前iframe层的索引
  420. top.layer.title('服务记录详情', index) //再改变当前层的标题
  421. }
  422. })
  423. },
  424. getRelationRecord: function (type, planDetaiId) {
  425. // 1.电话短信 2.康复咨询 3.远程监控检测 4.上门服务 5.康复指导 6 康复随访 7.复诊)
  426. var vm = this
  427. var url = ''
  428. if (type == 5) {
  429. url = 'doctor/specialist/rehabilitation/selectByRelationCode'
  430. } else if (type == 7) {
  431. url = 'third/guahao/selectByRelationCode'
  432. } else if (type == 4) {
  433. url = '/doctor/specialist/rehabilitation/selectRelationCode'
  434. }
  435. var vm = this
  436. var params = {
  437. relationCode: vm.recordId ? vm.recordId : planDetaiId
  438. }
  439. return httpRequest.get(url, { data: params })
  440. },
  441. zdly: function (data) {
  442. var vm = this
  443. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'))
  444. var otherCode, otherName
  445. if (loginDoctor.doctorType == 1) {
  446. otherCode = data.familyDoctorCode
  447. otherName = data.familyDoctorName
  448. } else {
  449. otherCode = data.specialistDoctorCode
  450. otherName = data.specialistDoctorName
  451. }
  452. top.layer.open({
  453. type: 2,
  454. // offset: ['100px'], //右下角弹出
  455. area: ['660px', '600px'],
  456. shade: 0.5,
  457. title: '指导留言',
  458. fixed: true, //不固定
  459. maxmin: true,
  460. closeBtn: 1,
  461. shift: 5,
  462. shadeClose: false, //点击遮罩关闭层
  463. content: '../../consulting/html/consulting.html?otherCode=' + otherCode + '&otherName=' + encodeURI(otherName) + '&planDetailId=' + vm.planid,
  464. end: function () {
  465. // 未点击确定按钮,点击关闭按钮
  466. vm.getServiceItem()
  467. }
  468. })
  469. },
  470. deleteImg: function (idx) {
  471. console.log(idx)
  472. this.upImgs.splice(idx, 1)
  473. },
  474. chakan: function () {
  475. this.isCollapse = !this.isCollapse
  476. },
  477. upLoadImgToBase64: function () {
  478. var vm = this
  479. var img1 = event.target.files[0]
  480. var reader = new FileReader()
  481. var type = img1.type //文件的类型,判断是否是图片
  482. var size = img1.size //文件的大小,判断图片的大小
  483. if (this.imgData.accept.indexOf(type) == -1) {
  484. alert('请选择我们支持的图片格式!')
  485. return false
  486. }
  487. if (size > 3145728) {
  488. alert('请选择3M以内的图片!')
  489. return false
  490. }
  491. reader.readAsDataURL(img1)
  492. reader.onload = function (e) {
  493. vm.upImgs.push({
  494. baseUrl: e.target.result
  495. })
  496. vm.upImgArr.push(img1)
  497. console.log('e', e, 'vm.upImgs', vm.upImgs, 'vm.upImgArr', vm.upImgArr)
  498. //vm.uploadImg(vm.upImgArr);
  499. }
  500. },
  501. qrwc: function (patient, type) {
  502. var vm = this
  503. if (!vm.service.node) {
  504. showErrorMessage('请填写服务记录')
  505. return
  506. }
  507. if (!vm.upImgs.length) {
  508. showErrorMessage('请上传相关记录')
  509. return
  510. }
  511. vm.saveRehabilitationOperateRecord(vm.planid, type)
  512. },
  513. saveRehabilitationOperateRecord: function (planDetailId, type, relationCode, flag) {
  514. var vm = this
  515. var params = {
  516. rehabilitationDetailId: planDetailId,
  517. node: null,
  518. patientCode: vm.patient,
  519. doctorCode: docInfo.uid,
  520. relationRecordType: type,
  521. relationRecordCode: '',
  522. relationRecordImg: null,
  523. status: 0
  524. }
  525. rehaAPI.saveRehabilitationOperateRecord({ dataJson: JSON.stringify(params) }).then(function (res) {
  526. if (res.status == 200) {
  527. if (type == 1 || type == 7) {
  528. vm.uploadImg(vm.upImgArr)
  529. } else if (type == 6) {
  530. vm.updateRelationCodeByDetailId(planDetailId, relationCode)
  531. } else {
  532. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  533. }
  534. } else {
  535. layer.msg(res.msg, {
  536. icon: 5
  537. })
  538. }
  539. })
  540. },
  541. //上传图片
  542. uploadImg: function (data) {
  543. var vm = this
  544. var len = data.length
  545. if (len == 0) {
  546. vm.updateNoteAndImageRehabilitationOperate(vm.planid)
  547. } else {
  548. var file = data[len - 1]
  549. var formData = new FormData()
  550. formData.append('file', file)
  551. rehaAPI.upload(formData).then(function (res) {
  552. if (res.status == 200) {
  553. vm.upImgs[len - 1].img = res.data
  554. data.pop()
  555. vm.$forceUpdate()
  556. vm.uploadImg(data)
  557. } else {
  558. layer.msg(res.msg, {
  559. icon: 5
  560. })
  561. }
  562. })
  563. }
  564. },
  565. updateNoteAndImageRehabilitationOperate: function (planDetailId, relationCode) {
  566. var vm = this
  567. var _image = []
  568. $.each(vm.upImgs, function (index, obj) {
  569. _image.push(obj.img)
  570. })
  571. var params = {
  572. planDetailId: planDetailId,
  573. node: vm.service && vm.service.node ? vm.service.node : '完成',
  574. image: JSON.stringify(_image) || ''
  575. }
  576. if (relationCode) {
  577. params['relationCode'] = relationCode
  578. }
  579. var loadding = top.layer.load(0, {
  580. shade: false
  581. }) //0代表加载的风格,支持0-2
  582. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function (res) {
  583. top.layer.close(loadding)
  584. if (res.status == 200) {
  585. vm.getServiceItem()
  586. top.rehabilitationVue.refresh()
  587. }
  588. })
  589. },
  590. updateRelationCodeByDetailId: function (planDetailId, relationCode) {
  591. var vm = this
  592. var params = {
  593. planDetailId: planDetailId,
  594. relationCode: relationCode
  595. }
  596. rehaAPI.updateRelationCodeByDetailId(params).then(function (res) {
  597. if (res.status == 200) {
  598. vm.getServiceItem()
  599. top.rehabilitationVue.refresh()
  600. } else {
  601. showErrorMessage(res.msg)
  602. }
  603. })
  604. },
  605. viewDetial: function (type, code) {
  606. var vm = this
  607. if (type == 3) {
  608. top.layer.msg('客户端暂不支持查询健康指导记录')
  609. } else if (type == 4) {
  610. top.layer.msg('客户端暂不支持查询随访记录')
  611. } else {
  612. top.layer.open({
  613. type: 2,
  614. // offset: ['100px'], //右下角弹出
  615. area: ['80%', '600px'],
  616. shade: 0.5,
  617. title: '指导教育',
  618. fixed: true, //不固定
  619. maxmin: true,
  620. closeBtn: 1,
  621. shift: 5,
  622. shadeClose: false, //点击遮罩关闭层
  623. content: '../../article/html/article-info.html?articleId=' + code,
  624. end: function () {
  625. // 未点击确定按钮,点击关闭按钮
  626. vm.getServiceItem()
  627. }
  628. })
  629. }
  630. },
  631. getContent: function (value, type) {
  632. var res = value
  633. if (type == 2 || type == 9) {
  634. res = "<img src='" + httpRequest.getImgUrl(res) + "'>"
  635. } else if (type == 3) {
  636. res = '【语音】'
  637. } else if (type == 19) {
  638. res = '【聊天记录】'
  639. } else if (type == 12) {
  640. res = '【视频】'
  641. }
  642. return res
  643. }
  644. },
  645. filters: {
  646. formatDate: function (value, format) {
  647. if (!value) return
  648. var fmt = format || 'yyyy-MM-dd hh:mm'
  649. var date = new Date(value)
  650. if (/(y+)/.test(fmt)) {
  651. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  652. }
  653. let o = {
  654. 'M+': date.getMonth() + 1,
  655. 'd+': date.getDate(),
  656. 'h+': date.getHours(),
  657. 'm+': date.getMinutes(),
  658. 's+': date.getSeconds()
  659. }
  660. for (let k in o) {
  661. if (new RegExp(`(${k})`).test(fmt)) {
  662. let str = o[k] + ''
  663. fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : ('00' + str).substr(str.length))
  664. }
  665. }
  666. return fmt
  667. },
  668. getImgUrl: function (value) {
  669. var url = httpRequest.getImgUrl(value)
  670. return url
  671. }
  672. }
  673. })
  674. $('body').on('click', 'img', function () {
  675. var _this = $(this) //将当前的img元素作为_this传入函数
  676. imgShow('#outerdiv', '#innerdiv', '#bigimg', _this)
  677. })
  678. function imgShow(outerdiv, innerdiv, bigimg, _this) {
  679. var src = _this.attr('src') //获取当前点击的pimg元素中的src属性
  680. $(bigimg).attr('src', src) //设置#bigimg元素的src属性
  681. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  682. $('<img/>')
  683. .attr('src', src)
  684. .load(function () {
  685. var windowW = $(window).width() //获取当前窗口宽度
  686. var windowH = $(window).height() //获取当前窗口高度
  687. var realWidth = this.width //获取图片真实宽度
  688. var realHeight = this.height //获取图片真实高度
  689. var imgWidth, imgHeight
  690. var scale = 0.8 //缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  691. if (realHeight > windowH * scale) {
  692. //判断图片高度
  693. imgHeight = windowH * scale //如大于窗口高度,图片高度进行缩放
  694. imgWidth = (imgHeight / realHeight) * realWidth //等比例缩放宽度
  695. if (imgWidth > windowW * scale) {
  696. //如宽度扔大于窗口宽度
  697. imgWidth = windowW * scale //再对宽度进行缩放
  698. }
  699. } else if (realWidth > windowW * scale) {
  700. //如图片高度合适,判断图片宽度
  701. imgWidth = windowW * scale //如大于窗口宽度,图片宽度进行缩放
  702. imgHeight = (imgWidth / realWidth) * realHeight //等比例缩放高度
  703. } else {
  704. //如果图片真实高度和宽度都符合要求,高宽不变
  705. imgWidth = realWidth
  706. imgHeight = realHeight
  707. }
  708. $(bigimg).css('width', imgWidth) //以最终的宽度对图片缩放
  709. var w = (windowW - imgWidth) / 2 //计算图片与窗口左边距
  710. var h = (windowH - imgHeight) / 2 //计算图片与窗口上边距
  711. $(innerdiv).css({ 'top': h, 'left': w }) //设置#innerdiv的top和left属性
  712. $(outerdiv).fadeIn('fast') //淡入显示#outerdiv及.pimg
  713. })
  714. $(outerdiv).click(function () {
  715. //再次点击淡出消失弹出层
  716. $(this).fadeOut('fast')
  717. })
  718. }