@cloudbase/weda-ui 2.0.10 → 2.0.11

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 (90) hide show
  1. package/package.json +9 -2
  2. package/src/mp/components/button/index.js +1 -1
  3. package/src/mp/components/button/index.wxml +19 -19
  4. package/src/mp/components/calendar/index.js +64 -37
  5. package/src/mp/components/calendar/index.wxml +28 -8
  6. package/src/mp/components/carousel/index.wxml +30 -3
  7. package/src/mp/components/chart/bar/index.js +1 -2
  8. package/src/mp/components/chart/bar/index.wxml +7 -2
  9. package/src/mp/components/chart/common/config/bar.js +1 -1
  10. package/src/mp/components/chart/common/core/eChartBar.js +29 -34
  11. package/src/mp/components/chart/common/core/eChartBase.js +46 -32
  12. package/src/mp/components/chart/common/core/eChartLine.js +34 -40
  13. package/src/mp/components/chart/common/core/eChartPie.js +12 -9
  14. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +19 -2
  15. package/src/mp/components/chart/ec-canvas/wx-canvas.js +24 -22
  16. package/src/mp/components/chart/line/index.js +2 -2
  17. package/src/mp/components/chart/line/index.wxml +7 -2
  18. package/src/mp/components/chart/pie/index.js +1 -1
  19. package/src/mp/components/chart/pie/index.wxml +7 -3
  20. package/src/mp/components/chart/statisticsCard/index.wxml +5 -1
  21. package/src/mp/components/dataView/index.wxml +2 -2
  22. package/src/mp/components/form/checkbox/index.js +10 -6
  23. package/src/mp/components/form/checkbox/index.wxml +26 -23
  24. package/src/mp/components/form/form/index.wxml +3 -3
  25. package/src/mp/components/form/formcell/index.wxml +9 -9
  26. package/src/mp/components/form/formcell/index.wxss +1 -1
  27. package/src/mp/components/form/input/index.js +3 -3
  28. package/src/mp/components/form/input/index.wxml +36 -30
  29. package/src/mp/components/form/input/index.wxss +2 -2
  30. package/src/mp/components/form/location/components/mapChoose/index.wxml +59 -12
  31. package/src/mp/components/form/location/index.wxml +39 -7
  32. package/src/mp/components/form/radio/index.js +9 -5
  33. package/src/mp/components/form/radio/index.wxml +23 -23
  34. package/src/mp/components/form/select/index.js +156 -97
  35. package/src/mp/components/form/select/index.wxml +39 -37
  36. package/src/mp/components/form/select/index.wxss +1 -1
  37. package/src/mp/components/form/select/region/index.js +18 -12
  38. package/src/mp/components/form/switch/index.wxml +20 -16
  39. package/src/mp/components/form/textarea/index.wxml +12 -8
  40. package/src/mp/components/form/tips/index.wxml +1 -3
  41. package/src/mp/components/form/uploader/index.js +1 -1
  42. package/src/mp/components/form/uploader/index.wxml +19 -18
  43. package/src/mp/components/form/uploader/weui-uploader.js +210 -200
  44. package/src/mp/components/form/uploader/weui-uploader.wxml +81 -38
  45. package/src/mp/components/form/uploaderFile/index.js +5 -4
  46. package/src/mp/components/form/uploaderFile/index.wxml +97 -41
  47. package/src/mp/components/graphicCard/index.js +26 -24
  48. package/src/mp/components/graphicCard/index.wxml +30 -6
  49. package/src/mp/components/image/index.wxml +25 -18
  50. package/src/mp/components/image/index.wxss +3 -1
  51. package/src/mp/components/listView/index.wxml +34 -11
  52. package/src/mp/components/lottery/index.wxml +29 -7
  53. package/src/mp/components/lottery/index.wxss +31 -25
  54. package/src/mp/components/navLayout/index.wxml +29 -7
  55. package/src/mp/components/navigationBar/index.wxml +162 -53
  56. package/src/mp/components/swiper/index.wxml +12 -7
  57. package/src/mp/components/tabs/index.js +14 -10
  58. package/src/mp/components/tabs/index.wxml +2 -1
  59. package/src/mp/components/text/index.wxml +2 -1
  60. package/src/mp/components/text/index.wxss +1 -1
  61. package/src/mp/components/wxOpenApi/phone/index.wxml +11 -12
  62. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +11 -12
  63. package/src/mp/components/wxOpenApi/share/index.wxml +11 -12
  64. package/src/mp/components/wxOpenApi/userInfo/index.wxml +10 -11
  65. package/src/mp/style/weda-ui.wxss +8 -3
  66. package/src/mp/utils/deepEqual.js +37 -37
  67. package/src/mp/utils/destr.js +41 -40
  68. package/src/mp/utils/dr_square_point.js +10 -6
  69. package/src/setupTests.js +13 -13
  70. package/src/web/components/button/index.tsx +44 -40
  71. package/src/web/components/carousel/index.tsx +1 -1
  72. package/src/web/components/chart/common/config/bar.js +1 -1
  73. package/src/web/components/chart/common/core/eChartBar.js +28 -34
  74. package/src/web/components/chart/common/core/eChartLine.js +34 -40
  75. package/src/web/components/chart/common/core/eChartPie.js +12 -9
  76. package/src/web/components/form/form/index.tsx +5 -5
  77. package/src/web/components/form/formcell/index.css +5 -1
  78. package/src/web/components/form/formcell/index.tsx +1 -1
  79. package/src/web/components/form/select/h5.tsx +154 -103
  80. package/src/web/components/form/select/index.css +0 -3
  81. package/src/web/components/form/textarea/index.tsx +1 -1
  82. package/src/web/components/form/uploader/uploader.h5.tsx +26 -20
  83. package/src/web/components/image/index.tsx +1 -1
  84. package/src/web/components/link/index.tsx +1 -1
  85. package/src/web/components/navLayout/index.tsx +1 -1
  86. package/src/web/components/navigationBar/index.tsx +2 -2
  87. package/src/web/components/picker/timePicker.tsx +1 -1
  88. package/src/web/components/text/index.tsx +13 -14
  89. package/src/web/utils/isObjectEqual.js +2 -1
  90. package/src/web/weda-ui.css +4 -0
@@ -115,7 +115,7 @@ Component({
115
115
  //当单图片上传且默认值为空数组时,初次渲染更新value,以避免空串提交类型不匹配问题
116
116
  if (Array.isArray(value) && !this.data.singleFlag) {
117
117
  this.setData({
118
- urls: value
118
+ urls: value,
119
119
  });
120
120
  this.data.singleFlag = true;
121
121
  }
@@ -1,29 +1,30 @@
1
1
  <view
2
- class="weda-ui weui-cells weui-cells_form {{className}}"
3
- id="{{id}}"
4
- style="{{style}}"
2
+ class="weda-ui weui-cells weui-cells_form {{className}}"
3
+ id="{{id}}"
4
+ style="{{style}}"
5
5
  >
6
- <mp-uploader
7
- max-size="{{maxSize * 1024 * 1024}}"
8
- files="{{files}}"
9
- title="{{title}}"
10
- showDelete="{{true}}"
11
- ext-class="{{layout}}"
12
- bindfail="uploadError"
13
- bindsuccess="uploadSuccess"
14
- layout="{{layout}}"
15
- select="{{selectFile}}"
16
- upload="{{uploadFile}}"
17
- maxCount="{{maxCount}}"
18
- binddelete="onDelete">
19
- </mp-uploader>
6
+ <mp-uploader
7
+ max-size="{{maxSize * 1024 * 1024}}"
8
+ files="{{files}}"
9
+ title="{{title}}"
10
+ showDelete="{{true}}"
11
+ ext-class="{{layout}}"
12
+ bindfail="uploadError"
13
+ bindsuccess="uploadSuccess"
14
+ layout="{{layout}}"
15
+ select="{{selectFile}}"
16
+ upload="{{uploadFile}}"
17
+ maxCount="{{maxCount}}"
18
+ binddelete="onDelete"
19
+ >
20
+ </mp-uploader>
20
21
  </view>
21
22
 
22
23
  <!-- uploader delete 实际代码接受 showDelete
23
24
  https://developers.weixin.qq.com/community/develop/doc/000a4e7b9cc158c110aa3961056400
24
25
  -->
25
26
 
26
- <!-- bind开头的是事件handler,wxml模版中不能带 `{{}}`
27
+ <!-- bind开头的是事件handler,wxml模版中不能带 `{{}}`
27
28
  ```
28
29
  <mp-uploader files="{{files}}" showDelete="{{true}}" ext-class="{{layout}}" bindfail="uploadError" bindsuccess="uploadSuccess" select="{{selectFile}}" upload="{{uploadFile}}" maxCount="{{maxUploadCount}}" title="{{title}}" binddelete="onDelete"></mp-uploader>
29
30
  ```
@@ -1,209 +1,219 @@
1
1
  Component({
2
- options: {
3
- addGlobalClass: true,
4
- virtualHost: true
2
+ options: {
3
+ addGlobalClass: true,
4
+ virtualHost: true,
5
+ },
6
+ properties: {
7
+ title: {
8
+ type: String,
9
+ value: '图片上传',
5
10
  },
6
- properties: {
7
- title: {
8
- type: String,
9
- value: '图片上传'
10
- },
11
- sizeType: {
12
- type: Array,
13
- value: ['original', 'compressed']
14
- },
15
- sourceType: {
16
- type: Array,
17
- value: ['album', 'camera']
18
- },
19
- maxSize: {
20
- type: Number,
21
- value: 5 * 1024 * 1024
22
- },
23
- maxCount: {
24
- // 最多上传多少个文件
25
- type: Number,
26
- value: 1
27
- },
28
- files: {
29
- // 当前的图片列表, {url, error, loading}
30
- type: Array,
31
- value: [],
32
- observer(newVal) {
33
- this.setData({
34
- currentFiles: newVal
35
- });
36
- }
37
- },
38
- select: {
39
- // 过滤某个文件
40
- type: null,
41
- value: () => { }
42
- },
43
- upload: {
44
- // 返回Promise的一个文件上传的函数
45
- type: null,
46
- value: null
47
- },
48
- tips: {
49
- type: String,
50
- value: ''
51
- },
52
- layout: {
53
- type: String,
54
- value: 'horizontal'
55
- },
56
- extClass: {
57
- type: String,
58
- value: ''
59
- },
60
- showDelete: {
61
- // 是否显示delete按钮
62
- type: Boolean,
63
- value: true
64
- }
11
+ sizeType: {
12
+ type: Array,
13
+ value: ['original', 'compressed'],
65
14
  },
66
- data: {
67
- currentFiles: [],
68
- showPreview: false,
69
- previewImageUrls: []
15
+ sourceType: {
16
+ type: Array,
17
+ value: ['album', 'camera'],
70
18
  },
71
- ready() { },
72
- methods: {
73
- previewImage(e) {
74
- const { index } = e.currentTarget.dataset;
75
- const previewImageUrls = [];
76
- this.data.files.forEach((item) => {
77
- previewImageUrls.push(item.url);
78
- });
19
+ maxSize: {
20
+ type: Number,
21
+ value: 5 * 1024 * 1024,
22
+ },
23
+ maxCount: {
24
+ // 最多上传多少个文件
25
+ type: Number,
26
+ value: 1,
27
+ },
28
+ files: {
29
+ // 当前的图片列表, {url, error, loading}
30
+ type: Array,
31
+ value: [],
32
+ observer(newVal) {
33
+ this.setData({
34
+ currentFiles: newVal,
35
+ });
36
+ },
37
+ },
38
+ select: {
39
+ // 过滤某个文件
40
+ type: null,
41
+ value: () => {},
42
+ },
43
+ upload: {
44
+ // 返回Promise的一个文件上传的函数
45
+ type: null,
46
+ value: null,
47
+ },
48
+ tips: {
49
+ type: String,
50
+ value: '',
51
+ },
52
+ layout: {
53
+ type: String,
54
+ value: 'horizontal',
55
+ },
56
+ extClass: {
57
+ type: String,
58
+ value: '',
59
+ },
60
+ showDelete: {
61
+ // 是否显示delete按钮
62
+ type: Boolean,
63
+ value: true,
64
+ },
65
+ },
66
+ data: {
67
+ currentFiles: [],
68
+ showPreview: false,
69
+ previewImageUrls: [],
70
+ },
71
+ ready() {},
72
+ methods: {
73
+ previewImage(e) {
74
+ const { index } = e.currentTarget.dataset;
75
+ const previewImageUrls = [];
76
+ this.data.files.forEach((item) => {
77
+ previewImageUrls.push(item.url);
78
+ });
79
+ this.setData({
80
+ previewImageUrls,
81
+ previewCurrent: index,
82
+ showPreview: true,
83
+ });
84
+ },
85
+ chooseImage() {
86
+ if (this.uploading) return;
87
+ wx.chooseImage({
88
+ count: this.data.maxCount - this.data.files.length,
89
+ sizeType: this.data.sizeType,
90
+ sourceType: this.data.sourceType,
91
+ success: (res) => {
92
+ // console.log('chooseImage resp', res)
93
+ // 首先检查文件大小
94
+ let invalidIndex = -1;
95
+ // @ts-ignore
96
+ res.tempFiles.forEach((item, index) => {
97
+ if (item.size > this.data.maxSize) {
98
+ invalidIndex = index;
99
+ }
100
+ });
101
+ if (typeof this.data.select === 'function') {
102
+ const ret = this.data.select(res);
103
+ if (ret === false) {
104
+ return;
105
+ }
106
+ }
107
+ if (invalidIndex >= 0) {
108
+ this.triggerEvent(
109
+ 'fail',
110
+ {
111
+ type: 1,
112
+ errMsg: `chooseImage:fail size exceed ${this.data.maxSize}`,
113
+ total: res.tempFilePaths.length,
114
+ index: invalidIndex,
115
+ },
116
+ {}
117
+ );
118
+ return;
119
+ }
120
+ // 获取文件内容
121
+ const mgr = wx.getFileSystemManager();
122
+ const contents = res.tempFilePaths.map((item) => {
123
+ // @ts-ignore
124
+ const fileContent = mgr.readFileSync(item);
125
+ return fileContent;
126
+ });
127
+ const obj = {
128
+ tempFilePaths: res.tempFilePaths,
129
+ tempFiles: res.tempFiles,
130
+ contents,
131
+ };
132
+ // 触发选中的事件,开发者根据内容来上传文件,上传了把上传的结果反馈到files属性里面
133
+ this.triggerEvent('select', obj, {});
134
+ const files = res.tempFilePaths.map((item, i) => ({
135
+ loading: true,
136
+ url:
137
+ res.tempFilePaths[i] ||
138
+ `data:image/jpg;base64,${wx.arrayBufferToBase64(contents[i])}`,
139
+ }));
140
+ if (!files || !files.length) return;
141
+ if (typeof this.data.upload === 'function') {
142
+ const len = this.data.files.length;
143
+ const newFiles = this.data.files.concat(files);
79
144
  this.setData({
80
- previewImageUrls,
81
- previewCurrent: index,
82
- showPreview: true
145
+ files: newFiles,
146
+ currentFiles: newFiles,
83
147
  });
84
- },
85
- chooseImage() {
86
- if (this.uploading)
87
- return;
88
- wx.chooseImage({
89
- count: this.data.maxCount - this.data.files.length,
90
- sizeType: this.data.sizeType,
91
- sourceType: this.data.sourceType,
92
- success: (res) => {
93
- // console.log('chooseImage resp', res)
94
- // 首先检查文件大小
95
- let invalidIndex = -1;
96
- // @ts-ignore
97
- res.tempFiles.forEach((item, index) => {
98
- if (item.size > this.data.maxSize) {
99
- invalidIndex = index;
100
- }
101
- });
102
- if (typeof this.data.select === 'function') {
103
- const ret = this.data.select(res);
104
- if (ret === false) {
105
- return;
106
- }
107
- }
108
- if (invalidIndex >= 0) {
109
- this.triggerEvent('fail', {
110
- type: 1,
111
- errMsg: `chooseImage:fail size exceed ${this.data.maxSize}`,
112
- total: res.tempFilePaths.length,
113
- index: invalidIndex
114
- }, {});
115
- return;
116
- }
117
- // 获取文件内容
118
- const mgr = wx.getFileSystemManager();
119
- const contents = res.tempFilePaths.map((item) => {
120
- // @ts-ignore
121
- const fileContent = mgr.readFileSync(item);
122
- return fileContent;
123
- });
124
- const obj = {
125
- tempFilePaths: res.tempFilePaths,
126
- tempFiles: res.tempFiles,
127
- contents
128
- };
129
- // 触发选中的事件,开发者根据内容来上传文件,上传了把上传的结果反馈到files属性里面
130
- this.triggerEvent('select', obj, {});
131
- const files = res.tempFilePaths.map((item, i) => ({
132
- loading: true,
133
- url: res.tempFilePaths[i] ||
134
- `data:image/jpg;base64,${wx.arrayBufferToBase64(contents[i])}`
135
- }));
136
- if (!files || !files.length)
137
- return;
138
- if (typeof this.data.upload === 'function') {
139
- const len = this.data.files.length;
140
- const newFiles = this.data.files.concat(files);
141
- this.setData({
142
- files: newFiles,
143
- currentFiles: newFiles
144
- });
145
- this.loading = true;
146
- this.data
147
- .upload(obj)
148
- .then((json) => {
149
- this.loading = false;
150
- if (json.urls) {
151
- const oldFiles = this.data.files;
152
- json.urls.forEach((url, index) => {
153
- oldFiles[len + index].url = url;
154
- oldFiles[len + index].loading = false;
155
- });
156
- this.setData({
157
- files: oldFiles,
158
- currentFiles: newFiles
159
- });
160
- this.triggerEvent('success', json, {});
161
- }
162
- else {
163
- this.triggerEvent('fail', {
164
- type: 3,
165
- errMsg: 'upload file fail, urls not found'
166
- }, {});
167
- }
168
- })
169
- .catch((err) => {
170
- this.loading = false;
171
- const oldFiles = this.data.files;
172
- res.tempFilePaths.forEach((item, index) => {
173
- oldFiles[len + index].error = true;
174
- oldFiles[len + index].loading = false;
175
- });
176
- this.setData({
177
- files: oldFiles,
178
- currentFiles: newFiles
179
- });
180
- this.triggerEvent('fail', {
181
- type: 3,
182
- errMsg: 'upload file fail',
183
- error: err
184
- }, {});
185
- });
186
- }
187
- },
188
- fail: (fail) => {
189
- if (fail.errMsg.indexOf('chooseImage:fail cancel') >= 0) {
190
- this.triggerEvent('cancel', {}, {});
191
- return;
192
- }
193
- fail.type = 2;
194
- this.triggerEvent('fail', fail, {});
148
+ this.loading = true;
149
+ this.data
150
+ .upload(obj)
151
+ .then((json) => {
152
+ this.loading = false;
153
+ if (json.urls) {
154
+ const oldFiles = this.data.files;
155
+ json.urls.forEach((url, index) => {
156
+ oldFiles[len + index].url = url;
157
+ oldFiles[len + index].loading = false;
158
+ });
159
+ this.setData({
160
+ files: oldFiles,
161
+ currentFiles: newFiles,
162
+ });
163
+ this.triggerEvent('success', json, {});
164
+ } else {
165
+ this.triggerEvent(
166
+ 'fail',
167
+ {
168
+ type: 3,
169
+ errMsg: 'upload file fail, urls not found',
170
+ },
171
+ {}
172
+ );
195
173
  }
196
- });
174
+ })
175
+ .catch((err) => {
176
+ this.loading = false;
177
+ const oldFiles = this.data.files;
178
+ res.tempFilePaths.forEach((item, index) => {
179
+ oldFiles[len + index].error = true;
180
+ oldFiles[len + index].loading = false;
181
+ });
182
+ this.setData({
183
+ files: oldFiles,
184
+ currentFiles: newFiles,
185
+ });
186
+ this.triggerEvent(
187
+ 'fail',
188
+ {
189
+ type: 3,
190
+ errMsg: 'upload file fail',
191
+ error: err,
192
+ },
193
+ {}
194
+ );
195
+ });
196
+ }
197
197
  },
198
- deletePic(e) {
199
- const index = e.detail.index;
200
- const files = this.data.files;
201
- const file = files.splice(index, 1);
202
- this.setData({
203
- files,
204
- currentFiles: files
205
- });
206
- this.triggerEvent('delete', { index, item: file[0] });
207
- }
208
- }
198
+ fail: (fail) => {
199
+ if (fail.errMsg.indexOf('chooseImage:fail cancel') >= 0) {
200
+ this.triggerEvent('cancel', {}, {});
201
+ return;
202
+ }
203
+ fail.type = 2;
204
+ this.triggerEvent('fail', fail, {});
205
+ },
206
+ });
207
+ },
208
+ deletePic(e) {
209
+ const index = e.detail.index;
210
+ const files = this.data.files;
211
+ const file = files.splice(index, 1);
212
+ this.setData({
213
+ files,
214
+ currentFiles: files,
215
+ });
216
+ this.triggerEvent('delete', { index, item: file[0] });
217
+ },
218
+ },
209
219
  });
@@ -1,45 +1,88 @@
1
1
  <view class="weui-uploader {{extClass}}">
2
- <view class="weui-uploader__hd {{layout}}">
3
- <view class="weda-formcells__label weui-cell">
4
- <block wx:if="{{layout === 'horizontal'}}">
5
- <view class="">
6
- <view class="weui-uploader__title">{{title}}</view>
7
- <view class="weui-uploader__info" wx:if="{{maxCount > 1}}">{{currentFiles.length}}/{{maxCount}}</view>
8
- </view>
9
- <label wx:if="{{true}}" class="weda-formcells__flag">*</label>
10
- </block>
11
- <block wx:if="{{layout === 'vertical'}}">
12
- <view class="weui-uploader__label">
13
- <view class="weui-uploader__title">{{title}}</view>
14
- <label wx:if="{{true}}" class="weda-formcells__flag">*</label>
15
- </view>
16
- <view class="weui-uploader__info" wx:if="{{maxCount > 1}}">{{currentFiles.length}}/{{maxCount}}</view>
17
- </block>
2
+ <view class="weui-uploader__hd {{layout}}">
3
+ <view class="weda-formcells__label weui-cell">
4
+ <block wx:if="{{layout === 'horizontal'}}">
5
+ <view class="">
6
+ <view class="weui-uploader__title">{{title}}</view>
7
+ <view class="weui-uploader__info" wx:if="{{maxCount > 1}}"
8
+ >{{currentFiles.length}}/{{maxCount}}</view
9
+ >
18
10
  </view>
11
+ <label wx:if="{{true}}" class="weda-formcells__flag">*</label>
12
+ </block>
13
+ <block wx:if="{{layout === 'vertical'}}">
14
+ <view class="weui-uploader__label">
15
+ <view class="weui-uploader__title">{{title}}</view>
16
+ <label wx:if="{{true}}" class="weda-formcells__flag">*</label>
17
+ </view>
18
+ <view class="weui-uploader__info" wx:if="{{maxCount > 1}}"
19
+ >{{currentFiles.length}}/{{maxCount}}</view
20
+ >
21
+ </block>
19
22
  </view>
20
- <view class="weui-uploader__bd">
21
- <view class="weui-uploader__files">
22
- <block wx:for="{{currentFiles}}" wx:key="*this">
23
- <view wx:if="{{item.error}}" data-index="{{index}}" bindtap="previewImage" class="weui-uploader__file weui-uploader__file_status">
24
- <image class="weui-uploader__img" src="{{item.url}}" mode="aspectFill" />
25
- <view class="weui-uploader__file-content">
26
- <icon type="warn" size="23" color="#F43530"></icon>
27
- </view>
28
- </view>
29
- <view wx:elif="{{item.loading}}" data-index="{{index}}" bindtap="previewImage" class="weui-uploader__file weui-uploader__file_status">
30
- <image class="weui-uploader__img" src="{{item.url}}" mode="aspectFill" />
31
- <view class="weui-uploader__file-content">
32
- <view class="weui-loading"></view>
33
- </view>
34
- </view>
35
- <view wx:else class="weui-uploader__file" data-index="{{index}}" bindtap="previewImage">
36
- <image class="weui-uploader__img" src="{{item.url}}" mode="aspectFill" />
37
- </view>
38
- </block>
23
+ </view>
24
+ <view class="weui-uploader__bd">
25
+ <view class="weui-uploader__files">
26
+ <block wx:for="{{currentFiles}}" wx:key="*this">
27
+ <view
28
+ wx:if="{{item.error}}"
29
+ data-index="{{index}}"
30
+ bindtap="previewImage"
31
+ class="weui-uploader__file weui-uploader__file_status"
32
+ >
33
+ <image
34
+ class="weui-uploader__img"
35
+ src="{{item.url}}"
36
+ mode="aspectFill"
37
+ />
38
+ <view class="weui-uploader__file-content">
39
+ <icon type="warn" size="23" color="#F43530"></icon>
40
+ </view>
41
+ </view>
42
+ <view
43
+ wx:elif="{{item.loading}}"
44
+ data-index="{{index}}"
45
+ bindtap="previewImage"
46
+ class="weui-uploader__file weui-uploader__file_status"
47
+ >
48
+ <image
49
+ class="weui-uploader__img"
50
+ src="{{item.url}}"
51
+ mode="aspectFill"
52
+ />
53
+ <view class="weui-uploader__file-content">
54
+ <view class="weui-loading"></view>
55
+ </view>
39
56
  </view>
40
- <view wx:if="{{currentFiles.length < maxCount}}" class="weui-uploader__input-box" hover-class="weui-active">
41
- <view class="weui-uploader__input" bindtap="chooseImage"></view>
57
+ <view
58
+ wx:else
59
+ class="weui-uploader__file"
60
+ data-index="{{index}}"
61
+ bindtap="previewImage"
62
+ >
63
+ <image
64
+ class="weui-uploader__img"
65
+ src="{{item.url}}"
66
+ mode="aspectFill"
67
+ />
42
68
  </view>
69
+ </block>
70
+ </view>
71
+ <view
72
+ wx:if="{{currentFiles.length < maxCount}}"
73
+ class="weui-uploader__input-box"
74
+ hover-class="weui-active"
75
+ >
76
+ <view class="weui-uploader__input" bindtap="chooseImage"></view>
43
77
  </view>
44
- <mp-gallery class="gallery" hide-on-click="{{true}}" show-delete="{{showDelete}}" show="{{showPreview}}" binddelete="deletePic" img-urls="{{previewImageUrls}}" current="{{previewCurrent}}"></mp-gallery>
78
+ </view>
79
+ <mp-gallery
80
+ class="gallery"
81
+ hide-on-click="{{true}}"
82
+ show-delete="{{showDelete}}"
83
+ show="{{showPreview}}"
84
+ binddelete="deletePic"
85
+ img-urls="{{previewImageUrls}}"
86
+ current="{{previewCurrent}}"
87
+ ></mp-gallery>
45
88
  </view>
@@ -60,7 +60,7 @@ Component({
60
60
  urls: [],
61
61
  cloudFile: [],
62
62
  strogeUrls: [],
63
- singleFlag: false
63
+ singleFlag: false,
64
64
  },
65
65
  methods: {
66
66
  // 批量上传文件前置事件
@@ -134,8 +134,9 @@ Component({
134
134
  if (!this.handleBefore(files?.tempFiles)) return;
135
135
  const uploadPath = 'weda-uploader';
136
136
  const uploadPromise = files.tempFiles.map(async (tempFile) => {
137
- const cloudPath = `${uploadPath}/${uuid().replaceAll('-', '')}-${tempFile.name
138
- }`;
137
+ const cloudPath = `${uploadPath}/${uuid().replaceAll('-', '')}-${
138
+ tempFile.name
139
+ }`;
139
140
  tempFile.percent = '0';
140
141
  tempFile.cloudPath = null;
141
142
  tempFile.filePath = tempFile?.path || null;
@@ -260,7 +261,7 @@ Component({
260
261
  //当单图片上传且默认值为空数组时,初次渲染更新value,以避免空串提交类型不匹配问题
261
262
  if (Array.isArray(value) && !this.data.singleFlag) {
262
263
  this.setData({
263
- urls: value
264
+ urls: value,
264
265
  });
265
266
  this.data.singleFlag = true;
266
267
  }