hh-doctor-sdk 0.5.2 → 0.5.4

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 类型组件为链接跳转,每个链接作为一个分组使用单独直接点击跳转
@@ -100,9 +100,28 @@ function mediaGroupList(mediaList) {
100
100
  return mediaGroups
101
101
  }
102
102
 
103
+ /**
104
+ * 将pdf资料按照6条数据为上限数量进行分组
105
+ * @param {*} mediaList 媒体数据列表
106
+ */
107
+ function pdfGroupList(mediaList) {
108
+ const mediaLength = mediaList.length
109
+ let mediaGroups = []
110
+ let groupSize = Math.floor(mediaLength / 6)
111
+ if (mediaLength % 6 > 0) {
112
+ groupSize += 1
113
+ }
114
+ for (let index = 0; index < groupSize; index++) {
115
+ const imagesInGroup = mediaList.slice(index * 6, (index + 1) * 6)
116
+ mediaGroups.push(imagesInGroup)
117
+ }
118
+ return mediaGroups
119
+ }
120
+
103
121
  module.exports = {
104
122
  imageList,
105
123
  videoList,
106
124
  pdfList,
107
- mediaGroupList
125
+ mediaGroupList,
126
+ pdfGroupList
108
127
  }
@@ -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.4",
4
4
  "description": "和缓名医小程序SDK",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"