@didaoktv/didaoui-uniapp 1.0.1 → 1.2.1

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.
Files changed (114) hide show
  1. package/README.md +16 -5
  2. package/components/dd-action-sheet/dd-action-sheet.vue +3 -3
  3. package/components/dd-album/album.js +19 -0
  4. package/components/dd-album/dd-album.vue +345 -0
  5. package/components/dd-album/props.js +89 -0
  6. package/components/dd-avatar/avatar.js +19 -0
  7. package/components/dd-avatar/dd-avatar.vue +172 -160
  8. package/components/dd-avatar/props.js +84 -0
  9. package/components/dd-avatar-group/avatarGroup.js +14 -0
  10. package/components/dd-avatar-group/dd-avatar-group.vue +110 -0
  11. package/components/dd-avatar-group/props.js +57 -0
  12. package/components/dd-badge/dd-badge.vue +6 -8
  13. package/components/dd-barcode/dd-barcode.vue +1030 -0
  14. package/components/dd-bill-detail/dd-bill-detail.vue +265 -0
  15. package/components/dd-button/dd-button.vue +17 -17
  16. package/components/dd-calendar/dd-calendar.vue +357 -0
  17. package/components/dd-canvas/dd-canvas.vue +1088 -0
  18. package/components/dd-capsule-button/dd-capsule-button.vue +6 -6
  19. package/components/dd-car-keyboard/carKeyboard.js +6 -0
  20. package/components/dd-car-keyboard/dd-car-keyboard.vue +315 -0
  21. package/components/dd-car-keyboard/props.js +19 -0
  22. package/components/dd-cascader/dd-cascader.vue +405 -0
  23. package/components/dd-cell/dd-cell.vue +50 -23
  24. package/components/dd-cell-group/dd-cell-group.vue +32 -25
  25. package/components/dd-champion-card/dd-champion-card.vue +4 -4
  26. package/components/dd-checkbox/dd-checkbox.vue +30 -39
  27. package/components/dd-checkbox-group/dd-checkbox-group.vue +67 -0
  28. package/components/dd-copy/dd-copy.vue +74 -0
  29. package/components/dd-coupon/dd-coupon.vue +368 -0
  30. package/components/dd-cropper/dd-cropper.vue +1297 -0
  31. package/components/dd-dialog/dd-dialog.vue +1 -1
  32. package/components/dd-divider/dd-divider.vue +3 -3
  33. package/components/dd-dropdown-item/dd-dropdown-item.vue +5 -5
  34. package/components/dd-empty-state/dd-empty-state.vue +1 -1
  35. package/components/dd-field/dd-field.vue +531 -106
  36. package/components/dd-form/dd-form.vue +116 -0
  37. package/components/dd-form/rules.ts +84 -0
  38. package/components/dd-goods-sku/dd-goods-sku.vue +434 -0
  39. package/components/dd-icon/dd-icon.vue +2 -2
  40. package/components/dd-image/dd-image.vue +4 -4
  41. package/components/dd-input/dd-input.vue +5 -5
  42. package/components/dd-keyboard/dd-keyboard.vue +178 -0
  43. package/components/dd-keyboard/keyboard.js +22 -0
  44. package/components/dd-keyboard/props.js +89 -0
  45. package/components/dd-link/dd-link.vue +87 -0
  46. package/components/dd-link/link.js +18 -0
  47. package/components/dd-link/props.js +44 -0
  48. package/components/dd-list-cell/dd-list-cell.vue +4 -4
  49. package/components/dd-loading/dd-loading.vue +1 -1
  50. package/components/dd-loadmore/dd-loadmore.vue +2 -2
  51. package/components/dd-markdown/dd-markdown.vue +344 -0
  52. package/components/dd-markdown/marked.esm.mjs +7 -0
  53. package/components/dd-mini-program-navbar/dd-mini-program-navbar.vue +9 -9
  54. package/components/dd-navigation/dd-navigation.vue +5 -5
  55. package/components/dd-number-keyboard/dd-number-keyboard.vue +200 -0
  56. package/components/dd-number-keyboard/numberKeyboard.js +8 -0
  57. package/components/dd-number-keyboard/props.js +24 -0
  58. package/components/dd-parse/dd-parse.vue +534 -0
  59. package/components/dd-parse/node/handler.wxs +26 -0
  60. package/components/dd-parse/node/node.vue +603 -0
  61. package/components/dd-parse/parse.js +13 -0
  62. package/components/dd-parse/parser.js +1400 -0
  63. package/components/dd-parse/props.js +57 -0
  64. package/components/dd-popover/dd-popover.vue +10 -10
  65. package/components/dd-popover-item/dd-popover-item.vue +3 -3
  66. package/components/dd-popup/dd-popup.vue +5 -5
  67. package/components/dd-poster/dd-poster.vue +695 -0
  68. package/components/dd-progress/dd-progress.vue +3 -3
  69. package/components/dd-pull-refresh/dd-pull-refresh.vue +3 -3
  70. package/components/dd-qrcode/dd-qrcode.vue +509 -0
  71. package/components/dd-qrcode/qrcode.js +1283 -0
  72. package/components/dd-radio/dd-radio.vue +19 -20
  73. package/components/dd-radio-group/dd-radio-group.vue +53 -0
  74. package/components/dd-rate/dd-rate.vue +1 -1
  75. package/components/dd-room-card/dd-room-card.vue +3 -3
  76. package/components/dd-search-bar/dd-search-bar.vue +8 -8
  77. package/components/dd-segmented-tab/dd-segmented-tab.vue +6 -6
  78. package/components/dd-signature/dd-signature.vue +513 -0
  79. package/components/dd-skeleton/dd-skeleton.vue +1 -1
  80. package/components/dd-slider/dd-slider.vue +4 -4
  81. package/components/dd-stat-card/dd-stat-card.vue +5 -5
  82. package/components/dd-step/dd-step.vue +11 -11
  83. package/components/dd-stepper/dd-stepper.vue +6 -6
  84. package/components/dd-swipe-action/dd-swipe-action.vue +1 -1
  85. package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -1
  86. package/components/dd-tabbar-item/dd-tabbar-item.vue +8 -8
  87. package/components/dd-tag/dd-tag.vue +17 -1
  88. package/components/dd-text/dd-text.vue +250 -0
  89. package/components/dd-text/props.js +120 -0
  90. package/components/dd-text/text.js +30 -0
  91. package/components/dd-text/value.js +87 -0
  92. package/components/dd-toast/dd-toast.vue +2 -2
  93. package/components/dd-upload/dd-upload.vue +4 -4
  94. package/components/dd-workorder-card/dd-workorder-card.vue +237 -0
  95. package/index.ts +50 -9
  96. package/libs/config/color.js +16 -0
  97. package/libs/config/config.js +25 -0
  98. package/libs/config/props.js +185 -0
  99. package/libs/config/zIndex.js +20 -0
  100. package/libs/function/digit.js +167 -0
  101. package/libs/function/index.js +932 -0
  102. package/libs/function/test.js +327 -0
  103. package/libs/i18n/index.d.ts +2 -0
  104. package/libs/i18n/index.js +89 -0
  105. package/libs/i18n/locales/zh-Hans.js +86 -0
  106. package/libs/mixin/button.js +18 -0
  107. package/libs/mixin/mixin.js +44 -0
  108. package/libs/mixin/mpMixin.js +13 -0
  109. package/libs/mixin/openType.js +27 -0
  110. package/libs/utils.ts +462 -0
  111. package/libs/vue.js +3 -0
  112. package/package.json +1 -1
  113. package/scss/_dd-shared.scss +40 -0
  114. package/scss/_variables.scss +4 -1
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  - **帝王级配色** — 帝王金 `#F5A623` + 皇家蓝 `#2D4BA0` 双主色,暗色主题默认
8
8
  - **玻璃拟态设计** — 多层级玻璃拟态效果,打造高端夜店沉浸感
9
- - **61 个精心打磨的组件** — 覆盖表单、导航、布局、数据展示、浮层反馈、交互六大类
9
+ - **67 个精心打磨的组件** — 覆盖表单、导航、布局卡片、数据展示、浮层反馈、交互六大类,含 KTV 业务组件(房态卡、账单明细、工单卡、日历、二维码)
10
10
  - **Vue3 + TypeScript** — 完整类型定义,Composition API
11
11
  - **多端兼容** — H5 / 微信小程序 / 抖音小程序 / Android / iOS
12
12
 
@@ -50,12 +50,12 @@ import { DdButton, DdInput } from '@didaoktv/didaoui-uniapp'
50
50
 
51
51
  | 分类 | 数量 | 组件 |
52
52
  | ----- | -- | --------------------------------------------------------------------------------------------------------------------------------------------- |
53
- | 表单输入 | 13 | Button, Input, Field, Switch, Checkbox, Radio, Stepper, SearchBar, Slider, DatePicker, Picker, Rate, Upload |
53
+ | 表单输入 | 17 | Button, Input, Form, Field, Switch, Checkbox, CheckboxGroup, Radio, RadioGroup, Stepper, SearchBar, Slider, DatePicker, Picker, Rate, Upload, Icon |
54
54
  | 导航 | 12 | Navigation, TopNavbar, SwipeableTab, SegmentedTab, Drawer, Tabbar, TabbarItem, Backtop, Collapse, CollapseItem, DropdownMenu, DropdownItem |
55
- | 布局 | 4 | Card, RoomCard, FeatureGrid, Sticky |
55
+ | 布局/卡片 | 8 | Card, RoomCard, FeatureGrid, Sticky, BillDetail, WorkorderCard, Calendar, Qrcode |
56
56
  | 数据展示 | 16 | Tag, StatCard, ChampionCard, Avatar, Badge, ListCell, Cell, CellGroup, CountDown, Divider, Image, Progress, Skeleton, EmptyState, Step, Steps |
57
- | 浮层反馈 | 11 | Modal, ActionSheet, Toast, Alert, Loading, Dialog, Overlay, Popup, Popover, PopoverItem, SwipeAction |
58
- | 交互 | 3 | Swipe, SwipeItem, PullRefresh |
57
+ | 浮层反馈 | 10 | Modal, ActionSheet, Toast, Alert, Loading, Dialog, Overlay, Popup, Popover, PopoverItem |
58
+ | 交互 | 5 | SwipeAction, Swipe, SwipeItem, PullRefresh, Loadmore |
59
59
  | 小程序专属 | 2 | CapsuleButton, MiniProgramNavbar |
60
60
 
61
61
  ## 设计规范
@@ -82,6 +82,17 @@ import { DdButton, DdInput } from '@didaoktv/didaoui-uniapp'
82
82
 
83
83
  4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 px (8pt 基础网格)
84
84
 
85
+ ## 新增业务组件(2026-08-22 纳入设计系统)
86
+
87
+ > 新组件统一以主流组件库(Vant 等)同名/同类组件为 API 设计基准,符合 uni-app 多端规范,只消费上层 `scss/_variables.scss` 既有 token。
88
+
89
+ | 组件 | 用途 | 参考基准 |
90
+ |------|------|---------|
91
+ | `dd-bill-detail` | 账单明细(商品项/小计/合计/支付状态/操作按钮 slot) | Vant `Card` + GoodsAction 聚合 |
92
+ | `dd-workorder-card` | 工单条目卡片(类型/状态/进度/布置 checklist/完成确认) | Vant `Card` + `Tag` + Checklist |
93
+ | `dd-calendar` | 月历 + 时段(日期多选区间/禁选/时段格) | Vant `Calendar` + 主流日历组件 |
94
+ | `dd-qrcode` | 二维码渲染(canvas,内容/尺寸/前景色/背景色/logo) | 主流二维码组件 API |
95
+
85
96
  ## License
86
97
 
87
98
  [MIT](./LICENSE) © 帝到KTV
@@ -130,10 +130,10 @@ function onClose() {
130
130
 
131
131
  &__handle {
132
132
  width: 72rpx;
133
- height: 8rpx;
133
+ height: $dd-space-1;
134
134
  border-radius: $dd-radius-full;
135
135
  background: rgba(255, 255, 255, 0.3);
136
- margin: 8rpx auto 16rpx;
136
+ margin: $dd-space-1 auto $dd-space-2;
137
137
  opacity: 0.6;
138
138
  }
139
139
 
@@ -178,7 +178,7 @@ function onClose() {
178
178
  }
179
179
 
180
180
  &__name {
181
- margin-top: 8rpx;
181
+ margin-top: $dd-space-1;
182
182
  font-size: $dd-font-size-caption;
183
183
  color: $dd-text-secondary;
184
184
  max-width: 128rpx;
@@ -0,0 +1,19 @@
1
+ export default {
2
+ // album 组件
3
+ album: {
4
+ urls: [],
5
+ keyName: '',
6
+ singleSize: 180,
7
+ multipleSize: 70,
8
+ space: 6,
9
+ singleMode: 'scaleToFill',
10
+ multipleMode: 'aspectFill',
11
+ maxCount: 9,
12
+ previewFullImage: true,
13
+ rowCount: 3,
14
+ showMore: true,
15
+ autoWrap: false,
16
+ unit: 'px',
17
+ stop: true,
18
+ }
19
+ }
@@ -0,0 +1,345 @@
1
+ <template>
2
+ <view class="dd-album">
3
+ <!-- 相册行容器,每行显示 rowCount 个图片 -->
4
+ <view
5
+ class="dd-album__row"
6
+ ref="dd-album__row"
7
+ v-for="(arr, index) in showUrls"
8
+ :forComputedUse="albumWidth"
9
+ :key="index"
10
+ :style="{flexWrap: autoWrap ? 'wrap' : 'nowrap'}"
11
+ >
12
+ <!-- 图片包装容器 -->
13
+ <view
14
+ class="dd-album__row__wrapper"
15
+ v-for="(item, index1) in arr"
16
+ :key="index1"
17
+ :style="[imageStyle(index + 1, index1 + 1)]"
18
+ @tap="onPreviewTap($event, getSrc(item))"
19
+ >
20
+ <!-- 图片显示 -->
21
+ <image
22
+ :src="getSrc(item)"
23
+ :mode="
24
+ urls.length === 1
25
+ ? imageHeight > 0
26
+ ? singleMode
27
+ : 'widthFix'
28
+ : multipleMode
29
+ "
30
+ :style="[
31
+ {
32
+ width: imageWidth,
33
+ height: imageHeight,
34
+ borderRadius: shape == 'circle' ? '10000px' : addUnit(radius)
35
+ }
36
+ ]"
37
+ ></image>
38
+ <!-- 超出最大显示数量时的更多提示 -->
39
+ <view
40
+ v-if="
41
+ showMore &&
42
+ urls.length > rowCount * showUrls.length &&
43
+ index === showUrls.length - 1 &&
44
+ index1 === showUrls[showUrls.length - 1].length - 1
45
+ "
46
+ class="dd-album__row__wrapper__text"
47
+ :style="{
48
+ borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
49
+ }"
50
+ >
51
+ <dd-text
52
+ :text="`+${urls.length - maxCount}`"
53
+ color="#fff"
54
+ :size="multipleSize * 0.3"
55
+ align="center"
56
+ customStyle="justify-content: center"
57
+ ></dd-text>
58
+ </view>
59
+ </view>
60
+ </view>
61
+ </view>
62
+ </template>
63
+
64
+ <script>
65
+ import { props } from './props';
66
+ import { mpMixin } from '../../libs/mixin/mpMixin';
67
+ import { mixin } from '../../libs/mixin/mixin';
68
+ import { addUnit, sleep } from '../../libs/function/index';
69
+ import test from '../../libs/function/test';
70
+ // #ifdef APP-NVUE
71
+ // 不支持百分比单位,这里需要通过dom查询组件的宽度
72
+ const dom = uni.requireNativePlugin('dom')
73
+ // #endif
74
+
75
+ /**
76
+ * Album 相册
77
+ * @description 本组件提供一个类似相册的功能,让开发者开发起来更加得心应手。减少重复的模板代码
78
+ *
79
+ * @property {Array} urls 图片地址列表 Array<String>|Array<Object>形式
80
+ * @property {String} keyName 指定从数组的对象元素中读取哪个属性作为图片地址
81
+ * @property {String | Number} singleSize 单图时,图片长边的长度 (默认 180 )
82
+ * @property {String | Number} multipleSize 多图时,图片边长 (默认 70 )
83
+ * @property {String | Number} space 多图时,图片水平和垂直之间的间隔 (默认 6 )
84
+ * @property {String} singleMode 单图时,图片缩放裁剪的模式 (默认 'scaleToFill' )
85
+ * @property {String} multipleMode 多图时,图片缩放裁剪的模式 (默认 'aspectFill' )
86
+ * @property {String | Number} maxCount 取消按钮的提示文字 (默认 9 )
87
+ * @property {Boolean} previewFullImage 是否可以预览图片 (默认 true )
88
+ * @property {String | Number} rowCount 每行展示图片数量,如设置,singleSize和multipleSize将会无效 (默认 3 )
89
+ * @property {Boolean} showMore 超出maxCount时是否显示查看更多的提示 (默认 true )
90
+ * @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' )
91
+ * @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
92
+ * @property {Boolean} autoWrap 自适应换行模式,不受rowCount限制,图片会自动换行 (默认 false )
93
+ * @property {String} unit 图片单位 (默认 px )
94
+ * @event {Function} albumWidth 某些特殊的情况下,需要让文字与相册的宽度相等,这里事件的形式对外发送 (回调参数 width )
95
+ * @example <dd-album :urls="urls2" @albumWidth="width => albumWidth = width" multipleSize="68" ></dd-album>
96
+ */
97
+ export default {
98
+ name: 'dd-album',
99
+ mixins: [mpMixin, mixin, props],
100
+ data() {
101
+ return {
102
+ // 单图的宽度
103
+ singleWidth: 0,
104
+ // 单图的高度
105
+ singleHeight: 0,
106
+ // 单图时,如果无法获取图片的尺寸信息,让图片宽度默认为容器的一定百分比
107
+ singlePercent: 0.6
108
+ }
109
+ },
110
+ watch: {
111
+ urls: {
112
+ immediate: true,
113
+ handler(newVal) {
114
+ // 当只有一张图片时,获取图片尺寸信息
115
+ if (newVal.length === 1) {
116
+ this.getImageRect()
117
+ }
118
+ }
119
+ }
120
+ },
121
+ computed: {
122
+ /**
123
+ * 计算图片样式
124
+ * @param {Number} index1 - 行索引
125
+ * @param {Number} index2 - 列索引
126
+ * @returns {Object} 图片样式对象
127
+ */
128
+ imageStyle() {
129
+ return (index1, index2) => {
130
+ const { space, rowCount, multipleSize, urls } = this,
131
+ rowLen = this.showUrls.length,
132
+ allLen = this.urls.length
133
+ const style = {
134
+ marginRight: addUnit(space),
135
+ marginBottom: addUnit(space)
136
+ }
137
+ // 如果为最后一行,则每个图片都无需下边框
138
+ if (index1 === rowLen && !this.autoWrap) style.marginBottom = 0
139
+ // 每行的最右边一张和总长度的最后一张无需右边框
140
+ if (!this.autoWrap) {
141
+ if (
142
+ index2 === rowCount ||
143
+ (index1 === rowLen &&
144
+ index2 === this.showUrls[index1 - 1].length)
145
+ )
146
+ style.marginRight = 0
147
+ }
148
+ return style
149
+ }
150
+ },
151
+ /**
152
+ * 将图片地址数组划分为二维数组,用于按行显示
153
+ * @returns {Array} 二维数组,每个子数组代表一行图片
154
+ */
155
+ showUrls() {
156
+ if (this.autoWrap) {
157
+ // 自动换行模式下,所有图片放在一行中显示
158
+ return [ this.urls.slice(0, this.maxCount) ];
159
+ } else {
160
+ // 固定行数模式下,按 rowCount 分割图片
161
+ const arr = []
162
+ this.urls.map((item, index) => {
163
+ // 限制最大展示数量
164
+ if (index + 1 <= this.maxCount) {
165
+ // 计算该元素为第几个素组内
166
+ const itemIndex = Math.floor(index / this.rowCount)
167
+ // 判断对应的索引是否存在
168
+ if (!arr[itemIndex]) {
169
+ arr[itemIndex] = []
170
+ }
171
+ arr[itemIndex].push(item)
172
+ }
173
+ })
174
+ return arr
175
+ }
176
+ },
177
+ /**
178
+ * 计算图片宽度
179
+ * @returns {String} 图片宽度样式值
180
+ */
181
+ imageWidth() {
182
+ return addUnit(
183
+ this.urls.length === 1 ? this.singleWidth : this.multipleSize, this.unit
184
+ )
185
+ },
186
+ /**
187
+ * 计算图片高度
188
+ * @returns {String} 图片高度样式值
189
+ */
190
+ imageHeight() {
191
+ return addUnit(
192
+ this.urls.length === 1 ? this.singleHeight : this.multipleSize, this.unit
193
+ )
194
+ },
195
+ /**
196
+ * 计算相册总宽度,用于外部组件对齐
197
+ * 此变量无实际用途,仅仅是为了利用computed特性,让其在urls长度等变化时,重新计算图片的宽度
198
+ * @returns {Number} 相册宽度
199
+ */
200
+ albumWidth() {
201
+ let width = 0
202
+ if (this.urls.length === 1) {
203
+ width = this.singleWidth
204
+ } else {
205
+ width =
206
+ this.showUrls[0].length * this.multipleSize +
207
+ this.space * (this.showUrls[0].length - 1)
208
+ }
209
+ this.$emit('albumWidth', width)
210
+ return width
211
+ }
212
+ },
213
+ emits: ['preview', 'albumWidth'],
214
+ methods: {
215
+ addUnit,
216
+ /**
217
+ * 点击图片预览
218
+ * @param {Event} e - 点击事件对象
219
+ * @param {String} url - 当前点击图片的地址
220
+ */
221
+ onPreviewTap(e, url) {
222
+ // 获取所有图片地址
223
+ const urls = this.urls.map((item) => {
224
+ return this.getSrc(item)
225
+ })
226
+ if (this.previewFullImage) {
227
+ // 使用系统默认预览图片功能
228
+ uni.previewImage({
229
+ current: url,
230
+ urls
231
+ })
232
+ // 是否阻止事件传播
233
+ this.stop && this.preventEvent(e)
234
+ } else {
235
+ // 发送自定义预览事件
236
+ this.$emit('preview', {
237
+ urls,
238
+ currentIndex: urls.indexOf(url)
239
+ })
240
+ }
241
+ },
242
+ /**
243
+ * 获取图片地址
244
+ * @param {String|Object} item - 图片项,可以是字符串或对象
245
+ * @returns {String} 图片地址
246
+ */
247
+ getSrc(item) {
248
+ return test.object(item)
249
+ ? (this.keyName && item[this.keyName]) || item.src
250
+ : item
251
+ },
252
+ /**
253
+ * 单图时,获取图片的尺寸
254
+ * 在小程序中,需要将网络图片的的域名添加到小程序的download域名才可能获取尺寸
255
+ * 在没有添加的情况下,让单图宽度默认为盒子的一定宽度(singlePercent)
256
+ */
257
+ getImageRect() {
258
+ const src = this.getSrc(this.urls[0])
259
+ uni.getImageInfo({
260
+ src,
261
+ success: (res) => {
262
+ let singleSize = this.singleSize;
263
+ // 单位
264
+ let unit = '';
265
+ if (Number.isNaN(Number(this.singleSize))) {
266
+ // 大小中有字符 则记录字符
267
+ unit = this.singleSize.replace(/\d+/g, ''); // 单位
268
+ singleSize = Number(this.singleSize.replace(/\D+/g, ''), 10); // 具体值
269
+ }
270
+
271
+ // 判断图片横向还是竖向展示方式
272
+ const isHorizotal = res.width >= res.height
273
+ this.singleWidth = isHorizotal
274
+ ? singleSize
275
+ : (res.width / res.height) * singleSize
276
+ this.singleHeight = !isHorizotal
277
+ ? singleSize
278
+ : (res.height / res.width) * this.singleWidth
279
+
280
+ // 如果有单位统一设置单位
281
+ if(unit != null && unit !== ''){
282
+ this.singleWidth = this.singleWidth + unit
283
+ this.singleHeight = this.singleHeight + unit
284
+ }
285
+ },
286
+ fail: () => {
287
+ // 获取图片信息失败时,通过组件宽度计算
288
+ this.getComponentWidth()
289
+ }
290
+ })
291
+ },
292
+ /**
293
+ * 获取组件的宽度,用于计算单图显示尺寸
294
+ */
295
+ async getComponentWidth() {
296
+ // 延时一定时间,以获取dom尺寸
297
+ await sleep(30)
298
+ // #ifndef APP-NVUE
299
+ // H5、小程序等平台通过 getRect 获取组件宽度
300
+ this.getRect('.dd-album__row').then((size) => {
301
+ this.singleWidth = size.width * this.singlePercent
302
+ })
303
+ // #endif
304
+
305
+ // #ifdef APP-NVUE
306
+ // NVUE 平台通过 dom 插件获取组件宽度
307
+ // 这里ref="dd-album__row"所在的标签为通过for循环出来,导致this.$refs['dd-album__row']是一个数组
308
+ const ref = this.$refs['dd-album__row'][0]
309
+ ref &&
310
+ dom.getComponentRect(ref, (res) => {
311
+ this.singleWidth = res.size.width * this.singlePercent
312
+ })
313
+ // #endif
314
+ }
315
+ }
316
+ }
317
+ </script>
318
+
319
+ <style lang="scss" scoped>
320
+ @import '../../scss/variables';
321
+ @import '../../scss/dd-shared';
322
+ .dd-album {
323
+ @include flex(column);
324
+
325
+ &__row {
326
+ @include flex(row);
327
+
328
+ &__wrapper {
329
+ position: relative;
330
+
331
+ &__text {
332
+ position: absolute;
333
+ top: 0;
334
+ left: 0;
335
+ right: 0;
336
+ bottom: 0;
337
+ background-color: rgba(0, 0, 0, 0.3);
338
+ @include flex(row);
339
+ justify-content: center;
340
+ align-items: center;
341
+ }
342
+ }
343
+ }
344
+ }
345
+ </style>
@@ -0,0 +1,89 @@
1
+ import { defineMixin } from '../../libs/vue'
2
+ import AlbumDefaultProps from './album'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(AlbumDefaultProps)
6
+ export const props = defineMixin({
7
+ props: {
8
+ // 图片地址,Array<String>|Array<Object>形式
9
+ urls: {
10
+ type: Array,
11
+ default: () => defProps.album.urls
12
+ },
13
+ // 指定从数组的对象元素中读取哪个属性作为图片地址
14
+ keyName: {
15
+ type: String,
16
+ default: () => defProps.album.keyName
17
+ },
18
+ // 单图时,图片长边的长度
19
+ singleSize: {
20
+ type: [String, Number],
21
+ default: () => defProps.album.singleSize
22
+ },
23
+ // 多图时,图片边长
24
+ multipleSize: {
25
+ type: [String, Number],
26
+ default: () => defProps.album.multipleSize
27
+ },
28
+ // 多图时,图片水平和垂直之间的间隔
29
+ space: {
30
+ type: [String, Number],
31
+ default: () => defProps.album.space
32
+ },
33
+ // 单图时,图片缩放裁剪的模式
34
+ singleMode: {
35
+ type: String,
36
+ default: () => defProps.album.singleMode
37
+ },
38
+ // 多图时,图片缩放裁剪的模式
39
+ multipleMode: {
40
+ type: String,
41
+ default: () => defProps.album.multipleMode
42
+ },
43
+ // 最多展示的图片数量,超出时最后一个位置将会显示剩余图片数量
44
+ maxCount: {
45
+ type: [String, Number],
46
+ default: () => defProps.album.maxCount
47
+ },
48
+ // 是否可以预览图片
49
+ previewFullImage: {
50
+ type: Boolean,
51
+ default: () => defProps.album.previewFullImage
52
+ },
53
+ // 每行展示图片数量,如设置,singleSize和multipleSize将会无效
54
+ rowCount: {
55
+ type: [String, Number],
56
+ default: () => defProps.album.rowCount
57
+ },
58
+ // 超出maxCount时是否显示查看更多的提示
59
+ showMore: {
60
+ type: Boolean,
61
+ default: () => defProps.album.showMore
62
+ },
63
+ // 图片形状,circle-圆形,square-方形
64
+ shape: {
65
+ type: String,
66
+ default: () => defProps.image.shape
67
+ },
68
+ // 圆角,单位任意
69
+ radius: {
70
+ type: [String, Number],
71
+ default: () => defProps.image.radius
72
+ },
73
+ // 自适应换行
74
+ autoWrap: {
75
+ type: Boolean,
76
+ default: () => defProps.album.autoWrap
77
+ },
78
+ // 单位
79
+ unit: {
80
+ type: [String],
81
+ default: () => defProps.album.unit
82
+ },
83
+ // 阻止点击冒泡
84
+ stop: {
85
+ type: Boolean,
86
+ default: () => defProps.album.stop
87
+ }
88
+ }
89
+ })
@@ -0,0 +1,19 @@
1
+ export default {
2
+ // avatar 组件
3
+ avatar: {
4
+ src: '',
5
+ shape: 'circle',
6
+ size: 40,
7
+ mode: 'scaleToFill',
8
+ text: '',
9
+ bgColor: '#c0c4cc',
10
+ color: '#ffffff',
11
+ fontSize: 18,
12
+ icon: '',
13
+ mpAvatar: false,
14
+ randomBgColor: false,
15
+ defaultUrl: '',
16
+ colorIndex: '',
17
+ name: ''
18
+ }
19
+ }