hh-doctor-sdk 0.7.6 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/consultation/detail/behaviors/consultation-chat-behaviors.js +2 -2
- package/components/consultation/detail/behaviors/consultation-header-media-behaviors.js +1 -1
- package/components/consultation/detail/consultation-detail-page.js +2 -1
- package/components/consultation/detail/widget/case-image-filter.js +39 -18
- package/components/utils/common-utils.js +43 -1
- package/components/video-chat-page/behaviors/chat-files-behaviors.js +3 -3
- package/package.json +1 -1
|
@@ -179,11 +179,11 @@ module.exports = Behavior({
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
if (caseImageList && caseImageList.length > 0) {
|
|
182
|
-
const isVideo = caseImageList[0].imageurl
|
|
182
|
+
const isVideo = caseImageFilter.isVideoUrl(caseImageList[0].imageurl)
|
|
183
183
|
message.type = isVideo ? MessageTypes.video : MessageTypes.image
|
|
184
184
|
message.images = caseImageList
|
|
185
185
|
message.isVideo = isVideo
|
|
186
|
-
message.cover = isVideo ? caseImageList[0].imageurl
|
|
186
|
+
message.cover = isVideo ? caseImageFilter.videoSnapshotUrl(caseImageList[0].imageurl) : caseImageList[0].smallImage
|
|
187
187
|
message.number = `共${caseImageList.length}${isVideo ? '个' : '张'}`
|
|
188
188
|
message.template = MessageTemplates.image
|
|
189
189
|
|
|
@@ -58,7 +58,7 @@ module.exports = Behavior({
|
|
|
58
58
|
videoGroupList.forEach(videosInGroup => {
|
|
59
59
|
const unit = '个'
|
|
60
60
|
const fileType = 4
|
|
61
|
-
let thumb = videosInGroup[0].
|
|
61
|
+
let thumb = videosInGroup[0].thumb
|
|
62
62
|
const showNumber = !['HISINFO', 'METER'].includes(type.toUpperCase()) ? `共${videosInGroup.length}${unit}` : '点击查看'
|
|
63
63
|
mediaGroups.push(this.mediaItem(groupIndex, fileType, name, videosInGroup, thumb, showNumber))
|
|
64
64
|
groupIndex++
|
|
@@ -6,6 +6,7 @@ var audioAnimationInterval
|
|
|
6
6
|
const hhNavigation = require('../../hh-navigation')
|
|
7
7
|
const doctorLoader = require('../../public/doctor-loader')
|
|
8
8
|
const permission = require('../../utils/permission-utils')
|
|
9
|
+
const { urlEndsWith } = require('../../utils/common-utils')
|
|
9
10
|
|
|
10
11
|
Page({
|
|
11
12
|
|
|
@@ -119,7 +120,7 @@ Page({
|
|
|
119
120
|
_playAudio(event) {
|
|
120
121
|
const url = event.currentTarget.dataset.url
|
|
121
122
|
const index = event.currentTarget.dataset.index
|
|
122
|
-
const playerUrl = `${url}${url
|
|
123
|
+
const playerUrl = `${url}${urlEndsWith(url, '.amr') ? '.mp3' : ''}`
|
|
123
124
|
const same = playerUrl == currentPlayUrl
|
|
124
125
|
this._stopPlayAudio()
|
|
125
126
|
if (same) {
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
const { urlEndsWith, appendUrlQuery } = require('../../../utils/common-utils')
|
|
2
|
+
|
|
3
|
+
function isVideoUrl(url) {
|
|
4
|
+
return urlEndsWith(url, '.mp4')
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function isPdfUrl(url) {
|
|
8
|
+
return urlEndsWith(url, '.pdf')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** 视频封面:OSS 截帧,兼容已带签名参数的 URL */
|
|
12
|
+
function videoSnapshotUrl(url) {
|
|
13
|
+
return appendUrlQuery(url, 'x-oss-process=video/snapshot,t_0,f_jpg')
|
|
14
|
+
}
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* 获取媒体数据中的图片数据列表,单条数据格式如下:
|
|
3
18
|
*
|
|
@@ -6,15 +21,16 @@
|
|
|
6
21
|
* @param {*} caseImageList 媒体数据原始列表
|
|
7
22
|
*/
|
|
8
23
|
function imageList(caseImageList) {
|
|
9
|
-
const images = caseImageList.filter((value
|
|
24
|
+
const images = caseImageList.filter((value) => {
|
|
10
25
|
console.log(JSON.stringify(value))
|
|
11
|
-
|
|
12
|
-
|
|
26
|
+
const key = value.s3key
|
|
27
|
+
if (key && key.length > 0) {
|
|
28
|
+
return !isPdfUrl(key) && !isVideoUrl(key)
|
|
13
29
|
}
|
|
14
|
-
return value.imageurl && !value.imageurl
|
|
30
|
+
return value.imageurl && !isPdfUrl(value.imageurl) && !isVideoUrl(value.imageurl)
|
|
15
31
|
})
|
|
16
32
|
|
|
17
|
-
const imageDataList = images.map((value
|
|
33
|
+
const imageDataList = images.map((value) => {
|
|
18
34
|
const imageurl = value.imageurl
|
|
19
35
|
return {
|
|
20
36
|
type: 'image',
|
|
@@ -33,19 +49,20 @@ function imageList(caseImageList) {
|
|
|
33
49
|
* @param {*} caseImageList 媒体数据原始列表
|
|
34
50
|
*/
|
|
35
51
|
function videoList(caseImageList) {
|
|
36
|
-
const videos = caseImageList.filter((value
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
const videos = caseImageList.filter((value) => {
|
|
53
|
+
const key = value.s3key
|
|
54
|
+
if (key && key.length > 0) {
|
|
55
|
+
return isVideoUrl(key)
|
|
39
56
|
}
|
|
40
|
-
return value.imageurl
|
|
57
|
+
return isVideoUrl(value.imageurl)
|
|
41
58
|
})
|
|
42
59
|
|
|
43
|
-
const imageDataList = videos.map((value
|
|
60
|
+
const imageDataList = videos.map((value) => {
|
|
44
61
|
const imageurl = value.imageurl
|
|
45
62
|
return {
|
|
46
63
|
type: 'video',
|
|
47
64
|
url: imageurl,
|
|
48
|
-
thumb: imageurl
|
|
65
|
+
thumb: videoSnapshotUrl(imageurl)
|
|
49
66
|
}
|
|
50
67
|
})
|
|
51
68
|
return imageDataList
|
|
@@ -59,13 +76,14 @@ function videoList(caseImageList) {
|
|
|
59
76
|
* @param {*} caseImageList 媒体数据原始列表
|
|
60
77
|
*/
|
|
61
78
|
function pdfList(caseImageList) {
|
|
62
|
-
const pdfs = caseImageList.filter((value
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
const pdfs = caseImageList.filter((value) => {
|
|
80
|
+
const key = value.s3key
|
|
81
|
+
if (key && key.length > 0) {
|
|
82
|
+
return isPdfUrl(key)
|
|
65
83
|
}
|
|
66
|
-
return value.imageurl
|
|
84
|
+
return isPdfUrl(value.imageurl)
|
|
67
85
|
})
|
|
68
|
-
return pdfs.map((value
|
|
86
|
+
return pdfs.map((value) => {
|
|
69
87
|
return pdfData(value.imageurl, value.imagedesc)
|
|
70
88
|
})
|
|
71
89
|
}
|
|
@@ -124,5 +142,8 @@ module.exports = {
|
|
|
124
142
|
videoList,
|
|
125
143
|
pdfList,
|
|
126
144
|
mediaGroupList,
|
|
127
|
-
pdfGroupList
|
|
128
|
-
|
|
145
|
+
pdfGroupList,
|
|
146
|
+
isVideoUrl,
|
|
147
|
+
isPdfUrl,
|
|
148
|
+
videoSnapshotUrl
|
|
149
|
+
}
|
|
@@ -57,6 +57,48 @@ function getLinkName(link) {
|
|
|
57
57
|
return '点此前往'
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* 去掉 query/hash 后判断路径是否以指定扩展名结尾(兼容带签名参数的 URL)
|
|
62
|
+
* @param {string} url
|
|
63
|
+
* @param {string} ext 如 '.mp4'
|
|
64
|
+
*/
|
|
65
|
+
function urlEndsWith(url, ext) {
|
|
66
|
+
if (!url || !ext) {
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
let path = url
|
|
70
|
+
const q = path.indexOf('?')
|
|
71
|
+
if (q >= 0) {
|
|
72
|
+
path = path.substring(0, q)
|
|
73
|
+
}
|
|
74
|
+
const h = path.indexOf('#')
|
|
75
|
+
if (h >= 0) {
|
|
76
|
+
path = path.substring(0, h)
|
|
77
|
+
}
|
|
78
|
+
return path.toLowerCase().endsWith(ext.toLowerCase())
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 给 URL 追加 query 参数(已有 ? 时用 &,兼容签名 URL)
|
|
83
|
+
* @param {string} url
|
|
84
|
+
* @param {string} query 如 'x-oss-process=video/snapshot,t_0,f_jpg',可带或不带前导 ?/&
|
|
85
|
+
*/
|
|
86
|
+
function appendUrlQuery(url, query) {
|
|
87
|
+
if (!url) {
|
|
88
|
+
return url
|
|
89
|
+
}
|
|
90
|
+
if (!query) {
|
|
91
|
+
return url
|
|
92
|
+
}
|
|
93
|
+
const q = String(query).replace(/^[?&]/, '')
|
|
94
|
+
if (!q) {
|
|
95
|
+
return url
|
|
96
|
+
}
|
|
97
|
+
return url + (url.indexOf('?') >= 0 ? '&' : '?') + q
|
|
98
|
+
}
|
|
99
|
+
|
|
60
100
|
module.exports = {
|
|
61
|
-
findLinkFromText
|
|
101
|
+
findLinkFromText,
|
|
102
|
+
urlEndsWith,
|
|
103
|
+
appendUrlQuery
|
|
62
104
|
}
|
|
@@ -115,14 +115,14 @@ module.exports = Behavior({
|
|
|
115
115
|
let type = 'image'
|
|
116
116
|
const url = file.fileUrl
|
|
117
117
|
let thumb = url
|
|
118
|
-
const isVideo =
|
|
119
|
-
const isPdf =
|
|
118
|
+
const isVideo = caseImageFilter.isVideoUrl(url)
|
|
119
|
+
const isPdf = caseImageFilter.isPdfUrl(url)
|
|
120
120
|
if (isPdf) {
|
|
121
121
|
type = 'pdf'
|
|
122
122
|
thumb = 'https://image.hh-medic.com/icon/pacs/hh_icon_pdf.png'
|
|
123
123
|
} else if (isVideo) {
|
|
124
124
|
type = 'video'
|
|
125
|
-
thumb =
|
|
125
|
+
thumb = caseImageFilter.videoSnapshotUrl(url)
|
|
126
126
|
}
|
|
127
127
|
const data = {
|
|
128
128
|
url: url,
|