guide_the_message.js 23 KB

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