hh-doctor-sdk 0.5.2 → 0.5.6

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.
@@ -64,11 +64,18 @@ module.exports = Behavior({
64
64
  groupIndex++
65
65
  });
66
66
 
67
- if (pdfList.length > 0) {
68
- const showNumber = pdfList.length > 1 ? `共${pdfList.length}个` : '点击查看'
69
- mediaGroups.push(this.mediaItem(groupIndex, 1, `${name}PDF`, pdfList, 'https://imgs.hh-medic.com/icon/hh_icon_pdf.png', showNumber))
67
+ const pdfGroupList = caseImageFilter.pdfGroupList(pdfList)
68
+ pdfGroupList.forEach(pdfsInGroup => {
69
+ const showNumber = pdfsInGroup.length > 1 ? `共${pdfsInGroup.length}个` : '点击查看'
70
+ mediaGroups.push(this.mediaItem(groupIndex, 1, `${name}PDF`, pdfsInGroup, 'https://imgs.hh-medic.com/icon/hh_icon_pdf.png', showNumber))
70
71
  groupIndex++
71
- }
72
+ })
73
+
74
+ // if (pdfList.length > 0) {
75
+ // const showNumber = pdfList.length > 1 ? `共${pdfList.length}个` : '点击查看'
76
+ // mediaGroups.push(this.mediaItem(groupIndex, 1, `${name}PDF`, pdfList, 'https://imgs.hh-medic.com/icon/hh_icon_pdf.png', showNumber))
77
+ // groupIndex++
78
+ // }
72
79
  }
73
80
  } else {
74
81
  // url 类型组件为链接跳转,每个链接作为一个分组使用单独直接点击跳转
@@ -7,10 +7,11 @@
7
7
  */
8
8
  function imageList(caseImageList) {
9
9
  const images = caseImageList.filter((value, index, array) => {
10
+ console.log(JSON.stringify(value))
10
11
  if (value.s3key && value.s3key.length > 0) {
11
12
  return !value.s3key.endsWith('.pdf') && !value.s3key.endsWith('.mp4')
12
13
  }
13
- return value.imageurl && !value.imageurl.includes('.pdf') && !value.url.includes('.mp4')
14
+ return value.imageurl && !value.imageurl.includes('.pdf') && !value.imageurl.includes('.mp4')
14
15
  })
15
16
 
16
17
  const imageDataList = images.map((value, index, array) => {
@@ -100,9 +101,28 @@ function mediaGroupList(mediaList) {
100
101
  return mediaGroups
101
102
  }
102
103
 
104
+ /**
105
+ * 将pdf资料按照6条数据为上限数量进行分组
106
+ * @param {*} mediaList 媒体数据列表
107
+ */
108
+ function pdfGroupList(mediaList) {
109
+ const mediaLength = mediaList.length
110
+ let mediaGroups = []
111
+ let groupSize = Math.floor(mediaLength / 6)
112
+ if (mediaLength % 6 > 0) {
113
+ groupSize += 1
114
+ }
115
+ for (let index = 0; index < groupSize; index++) {
116
+ const imagesInGroup = mediaList.slice(index * 6, (index + 1) * 6)
117
+ mediaGroups.push(imagesInGroup)
118
+ }
119
+ return mediaGroups
120
+ }
121
+
103
122
  module.exports = {
104
123
  imageList,
105
124
  videoList,
106
125
  pdfList,
107
- mediaGroupList
126
+ mediaGroupList,
127
+ pdfGroupList
108
128
  }
@@ -7,13 +7,18 @@ function viewPdfs(files) {
7
7
  this.viewPdf(files[0].url)
8
8
  } else {
9
9
  const items = files.map((file) => {
10
- return file.name
10
+ const last = file.url.lastIndexOf('/')
11
+ const fullFileName = file.url.substring(last + 1)
12
+ const fileName = fullFileName.substring(0, fullFileName.lastIndexOf('.'))
13
+ return fileName
11
14
  })
12
15
  wx.showActionSheet({
13
16
  itemList: items,
14
17
  success: (res) => {
15
- if (res.tapIndex && res.tapIndex != undefined) {
18
+ console.log(`tapIndex === > ${res.tapIndex}`)
19
+ if (res.tapIndex != undefined && res.tapIndex >= 0) {
16
20
  const url = files[res.tapIndex].url
21
+ console.log(url)
17
22
  this.viewPdf(url)
18
23
  }
19
24
  },
@@ -56,12 +56,20 @@ module.exports = Behavior({
56
56
  })
57
57
  });
58
58
 
59
- if (pdfList && pdfList.length > 0) {
59
+ const pdfGroupList = caseImageFilter.pdfGroupList(pdfList)
60
+ pdfGroupList.forEach(pdfsInGroup => {
60
61
  groups.push({
61
- title: `${name}(PDF)`,
62
- files: pdfList
62
+ title: name + '(PDF)',
63
+ files: pdfsInGroup
63
64
  })
64
- }
65
+ })
66
+
67
+ // if (pdfList && pdfList.length > 0) {
68
+ // groups.push({
69
+ // title: `${name}(PDF)`,
70
+ // files: pdfList
71
+ // })
72
+ // }
65
73
  }
66
74
  }
67
75
  }
@@ -146,12 +154,20 @@ module.exports = Behavior({
146
154
  })
147
155
  })
148
156
 
149
- if (pdfList.length > 0) {
157
+ const pdfGroupList = caseImageFilter.pdfGroupList(pdfList)
158
+ pdfGroupList.forEach(pdfsInGroup => {
150
159
  groups.push({
151
160
  title: '刚刚更新(PDF)',
152
- files: pdfList
161
+ files: pdfsInGroup
153
162
  })
154
- }
163
+ })
164
+
165
+ // if (pdfList.length > 0) {
166
+ // groups.push({
167
+ // title: '刚刚更新(PDF)',
168
+ // files: pdfList
169
+ // })
170
+ // }
155
171
  resolve({
156
172
  isNew: true,
157
173
  caseGroups: groups,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-doctor-sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.6",
4
4
  "description": "和缓名医小程序SDK",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"