@cloudbase/weda-ui-mp 3.14.4 → 3.15.0

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 (40) hide show
  1. package/components/chart/common/data-transform.js +6 -16
  2. package/components/form/form/wd-form.wxss +15 -0
  3. package/components/form/select/dropdown-select/index.js +41 -58
  4. package/components/form/select/dropdown-select/index.wxml +1 -1
  5. package/components/form/select/dropdown-select/index.wxss +1 -2
  6. package/components/form/select/index.js +1 -1
  7. package/components/form/selectMultiple/dropdown-select/index.js +10 -20
  8. package/components/form/selectMultiple/dropdown-select/index.wxss +2 -6
  9. package/components/form/selectMultiple/index.js +94 -45
  10. package/components/form/uploader/index.js +7 -15
  11. package/components/form/uploaderFile/index.js +3 -2
  12. package/components/formdetail/index.js +9 -28
  13. package/components/listView/index.js +1 -1
  14. package/components/listView/index.wxml +5 -5
  15. package/components/listView/index.wxss +20 -67
  16. package/components/qrcode/index.js +3 -4
  17. package/components/wd-form/index.js +72 -163
  18. package/components/wd-form/wd-form.wxss +15 -0
  19. package/components/wd-form-item/wd-form-item.wxss +15 -0
  20. package/components/wd-form-item-obj/wd-form-item.wxss +15 -0
  21. package/components/wd-input/inner-input/index.js +22 -56
  22. package/components/wd-input/inner-input/index.wxml +6 -2
  23. package/components/wd-input/inner-input/wd-input.wxss +15 -0
  24. package/components/wd-progress/wd-progress.wxss +15 -0
  25. package/components/wd-rating/wd-rating.wxss +15 -0
  26. package/components/wd-select/index.js +14 -10
  27. package/components/wd-select/index.json +1 -1
  28. package/components/wd-select/index.wxml +3 -0
  29. package/components/wd-select/select/formats-util.js +9 -0
  30. package/components/wd-select/select/index.js +545 -0
  31. package/components/wd-select/select/index.json +8 -0
  32. package/components/wd-select/select/index.wxml +26 -0
  33. package/components/wd-select/select/index.wxss +5 -0
  34. package/components/wd-select-multiple/index.js +13 -5
  35. package/components/wd-select-multiple/index.wxml +3 -0
  36. package/components/wd-switch/wd-switch.wxss +15 -0
  37. package/components/wd-tag-select/wd-tag-select.wxss +15 -0
  38. package/package.json +1 -1
  39. package/utils/getModelParams.js +27 -1
  40. package/utils/tcb.js +11 -2
@@ -2,10 +2,7 @@ import lodashSet from 'lodash.set';
2
2
  import { isNil } from '../../../utils/lodash';
3
3
 
4
4
  export const checkIsNewData = (props) => {
5
- return (
6
- Object.keys(props.dataSource ?? {}).length === 0 &&
7
- Object.keys(props['dataModel'] ?? {}).length > 0
8
- );
5
+ return Object.keys(props.dataSource ?? {}).length === 0 && Object.keys(props['dataModel'] ?? {}).length > 0;
9
6
  };
10
7
 
11
8
  export function transform(chartType, dataInput, chartInput) {
@@ -56,9 +53,7 @@ export function transform(chartType, dataInput, chartInput) {
56
53
 
57
54
  const finalDataInput = (dataInput ?? [])?.filter((item) => {
58
55
  if (!chartInput.xIsCountEmpty) {
59
- return (
60
- item.XLabel['Value'] !== undefined && item.XLabel['Value'] !== null
61
- );
56
+ return item.XLabel['Value'] !== undefined && item.XLabel['Value'] !== null;
62
57
  }
63
58
 
64
59
  return true;
@@ -100,13 +95,9 @@ export function transform(chartType, dataInput, chartInput) {
100
95
  if (!series[idx]) {
101
96
  series[idx] = {
102
97
  type: chartType,
103
- name:
104
- chartType === 'pie'
105
- ? undefined
106
- : eachYaxis.Cn_Name ?? eachYaxis.Name,
98
+ name: chartType === 'pie' ? undefined : eachYaxis.Cn_Name ?? eachYaxis.Name,
107
99
  stack: chartInput.isPile ? 'pile' : undefined,
108
- showSymbol:
109
- chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
100
+ showSymbol: chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
110
101
  label: {
111
102
  show: chartInput.isSeriesShowSymbol, // 老逻辑这么来的
112
103
  },
@@ -166,8 +157,7 @@ export function transform(chartType, dataInput, chartInput) {
166
157
  type: chartType,
167
158
  name: groupName,
168
159
  stack: chartInput.isPile ? 'pile' : undefined,
169
- showSymbol:
170
- chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
160
+ showSymbol: chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
171
161
  label: {
172
162
  show: chartInput.isSeriesShowSymbol, // 老逻辑这么来的
173
163
  },
@@ -201,7 +191,7 @@ export function transform(chartType, dataInput, chartInput) {
201
191
  });
202
192
  }
203
193
 
204
- console.log(dataInput, chartInput, 'TRANSFORM');
194
+ // console.log(dataInput, chartInput, 'TRANSFORM');
205
195
 
206
196
  if (chartType === 'bar' || chartType === 'line') {
207
197
  const xAxis = {
@@ -1109,4 +1109,19 @@ textarea {
1109
1109
  }
1110
1110
  .wd-mp-form-item-obj .wd-form-item--weui.wd-form-item {
1111
1111
  width: 100%;
1112
+ }
1113
+
1114
+ .wd-input-password-icon {
1115
+ padding: 0 5px;
1116
+ display: flex;
1117
+ cursor: pointer;
1118
+ }
1119
+
1120
+ .wd-pc-input-password-icon {
1121
+ position: absolute;
1122
+ right: -30px;
1123
+ }
1124
+
1125
+ .password-input .wd-form-item-wrap__control-wrap {
1126
+ position: relative;
1112
1127
  }
@@ -59,7 +59,7 @@ Component({
59
59
  searchValue: '',
60
60
  disabledIndex: -1, // 预留参数,暂时无用
61
61
  clickIndex: 0,
62
- index: 0,
62
+ index: -1,
63
63
  status: 0,
64
64
  showOption: [],
65
65
  isFinish: false,
@@ -84,14 +84,7 @@ Component({
84
84
  bindinput: function (event) {
85
85
  const value = event.detail.value;
86
86
 
87
- const {
88
- option,
89
- loadStatus,
90
- isTurnPages,
91
- _needFetch,
92
- ignoreCase,
93
- staticSearchable,
94
- } = this.properties;
87
+ const { option, loadStatus, isTurnPages, _needFetch, ignoreCase, staticSearchable } = this.properties;
95
88
  if (value === '' || value === this.data.searchValue) {
96
89
  this.setData({
97
90
  searchValue: value,
@@ -124,9 +117,7 @@ Component({
124
117
 
125
118
  const searchOption = option.filter((item) => {
126
119
  if (ignoreCase) {
127
- return String(item.label)
128
- .toLowerCase()
129
- .includes(value.toLowerCase());
120
+ return String(item.label).toLowerCase().includes(value.toLowerCase());
130
121
  }
131
122
  return item.label.includes(value);
132
123
  });
@@ -182,7 +173,7 @@ Component({
182
173
  }
183
174
  const { isFinish, searchValue, searchPageNo } = this.data;
184
175
  if (searchValue === '') {
185
- if (this.properties.loadStatus === 1 && isFinish) {
176
+ if (isFinish) {
186
177
  this.setData({
187
178
  pageNo: this.properties.pageNo + 1,
188
179
  isFinish: false,
@@ -193,7 +184,7 @@ Component({
193
184
  });
194
185
  }
195
186
  } else {
196
- if (this.properties.searchStatus === 1 && isFinish) {
187
+ if (isFinish) {
197
188
  this.setData({
198
189
  searchPageNo: this.data.searchPageNo + 1,
199
190
  isFinish: false,
@@ -234,54 +225,46 @@ Component({
234
225
  },
235
226
  },
236
227
  observers: {
237
- 'option, loadStatus, searchOption, searchStatus, _needFetch, staticSearchable':
238
- function (
239
- option,
240
- loadStatus,
241
- searchOption,
242
- searchStatus,
243
- _needFetch,
244
- staticSearchable
245
- ) {
246
- if (this.data.searchValue === '') {
247
- // 初始化会走到这
248
- const { chooseIndexValue } = this.properties;
249
- let index = -1;
250
- if (chooseIndexValue !== '') {
251
- index = option.findIndex((item) => item.value === chooseIndexValue);
252
- } else {
253
- option.some((item, i) => {
254
- if (!item?.disabled) {
255
- index = i;
256
- return true;
257
- }
258
- });
259
- }
228
+ 'option, loadStatus, searchOption, searchStatus, _needFetch, staticSearchable': function (
229
+ option,
230
+ loadStatus,
231
+ searchOption,
232
+ searchStatus,
233
+ _needFetch,
234
+ staticSearchable,
235
+ ) {
236
+ if (this.data.searchValue === '') {
237
+ // 初始化会走到这
238
+ const { chooseIndexValue } = this.properties;
239
+ let index = -1;
240
+ if (chooseIndexValue !== '') {
241
+ index = option.findIndex((item) => item.value === chooseIndexValue);
242
+ }
243
+ this.setData({
244
+ status: loadStatus,
245
+ showOption: option,
246
+ isFinish: true,
247
+ index: index,
248
+ clickIndex: index,
249
+ });
250
+ } else {
251
+ if (_needFetch) {
252
+ // 只有needFetch 才设置searchOption
260
253
  this.setData({
261
- status: loadStatus,
254
+ status: searchStatus,
255
+ showOption: searchOption,
256
+ isFinish: true,
257
+ index: -1,
258
+ });
259
+ } else if (!staticSearchable) {
260
+ this.setData({
261
+ status: searchStatus,
262
262
  showOption: option,
263
263
  isFinish: true,
264
- index: index,
265
- clickIndex: index,
264
+ index: -1,
266
265
  });
267
- } else {
268
- if (_needFetch) {
269
- // 只有needFetch 才设置searchOption
270
- this.setData({
271
- status: searchStatus,
272
- showOption: searchOption,
273
- isFinish: true,
274
- index: -1,
275
- });
276
- } else if (!staticSearchable) {
277
- this.setData({
278
- status: searchStatus,
279
- showOption: option,
280
- isFinish: true,
281
- index: -1,
282
- });
283
- }
284
266
  }
285
- },
267
+ }
268
+ },
286
269
  },
287
270
  });
@@ -26,7 +26,7 @@
26
26
  加载失败
27
27
  <text class="weda-ui-custom-picker__btn weda-ui-custom-picker__btn--link" bindtap="onRetry">重试</text>
28
28
  </view>
29
- <view wx:if="{{status === 3}}" class="weda-ui-custom-picker__status"> 暂无数据 </view>
29
+ <view wx:if="{{status === 3&&!showOption.length}}" class="weda-ui-custom-picker__status"> 暂无数据 </view>
30
30
  </view>
31
31
  </view>
32
32
  </scroll-view>
@@ -280,8 +280,7 @@
280
280
  transform: translateX(0);
281
281
  }
282
282
 
283
- .weda-ui-custom-search.is-focused
284
- .weda-ui-custom-search-box__search-placeholder {
283
+ .weda-ui-custom-search.is-focused .weda-ui-custom-search-box__search-placeholder {
285
284
  display: none;
286
285
  }
287
286
 
@@ -592,7 +592,7 @@ Component({
592
592
  },
593
593
  });
594
594
  const results = data?.records;
595
- console.log(results, param, 'Records');
595
+ // console.log(results, param, 'Records');
596
596
  if (isUpdate && results && results.length > 0) {
597
597
  this.setData({
598
598
  chooseIndexLable: results[0][this.properties.primaryField] || results[0]._id,
@@ -124,10 +124,7 @@ Component({
124
124
  const { selectedCache } = this.data;
125
125
  const index = selectedCache.findIndex((v) => v.value === item.value);
126
126
  if (index > -1) {
127
- return [
128
- ...selectedCache.slice(0, index),
129
- ...selectedCache.slice(index + 1),
130
- ];
127
+ return [...selectedCache.slice(0, index), ...selectedCache.slice(index + 1)];
131
128
  }
132
129
 
133
130
  return [...selectedCache, item];
@@ -182,11 +179,7 @@ Component({
182
179
  },
183
180
  },
184
181
  observers: {
185
- 'option,searchValue,staticSearchable': function (
186
- option,
187
- searchValue,
188
- staticSearchable
189
- ) {
182
+ 'option,searchValue,staticSearchable': function (option, searchValue, staticSearchable) {
190
183
  const { ignoreCase } = this.properties;
191
184
  if (searchValue === '') {
192
185
  this.setData({
@@ -196,11 +189,7 @@ Component({
196
189
  } else if (staticSearchable) {
197
190
  const searchRange = option.filter((item) => {
198
191
  if (ignoreCase) {
199
- return (
200
- String(item.label)
201
- .toLowerCase()
202
- .indexOf(searchValue.toLowerCase()) !== -1
203
- );
192
+ return String(item.label).toLowerCase().indexOf(searchValue.toLowerCase()) !== -1;
204
193
  }
205
194
  return item.label.indexOf(searchValue) !== -1;
206
195
  });
@@ -215,17 +204,18 @@ Component({
215
204
  }
216
205
  },
217
206
  selectedValue: function (selectedValue) {
218
- const data = Array.isArray(selectedValue)
219
- ? selectedValue
220
- : [selectedValue];
207
+ const data = Array.isArray(selectedValue) ? selectedValue : [selectedValue];
221
208
  const optionMap = this.properties.option.reduce((pre, cur) => {
222
209
  pre[cur.value] = cur;
223
210
  return pre;
224
211
  }, {});
225
- const selectedCache = data
226
- .map((d) => optionMap[d])
227
- .filter((item) => !!item);
212
+ const selectedCache = data.map((d) => optionMap[d]).filter((item) => !!item);
228
213
  this.setData({ selectedCache });
229
214
  },
215
+ loadStatus: function (loadStatus) {
216
+ this.setData({
217
+ status: loadStatus,
218
+ });
219
+ },
230
220
  },
231
221
  });
@@ -45,6 +45,7 @@
45
45
  padding: 5px 16px;
46
46
  overflow: auto;
47
47
  flex: 1 1 0px;
48
+ box-sizing: border-box;
48
49
  }
49
50
 
50
51
  .weda-ui-custom-picker__header-btn {
@@ -81,10 +82,6 @@
81
82
  /* height: 199px; */
82
83
  }
83
84
 
84
- .weda-ui-custom-picker__cloumn::-webkit-scrollbar {
85
- display: none;
86
- }
87
-
88
85
  .weda-ui-custom-picker__cloumn-item {
89
86
  display: flex;
90
87
  align-items: center;
@@ -292,8 +289,7 @@
292
289
  transform: translateX(0);
293
290
  }
294
291
 
295
- .weda-ui-custom-search.is-focused
296
- .weda-ui-custom-search-box__search-placeholder {
292
+ .weda-ui-custom-search.is-focused .weda-ui-custom-search-box__search-placeholder {
297
293
  display: none;
298
294
  }
299
295
 
@@ -4,7 +4,8 @@ import { callDataSourceApi } from '../../../utils/tcb';
4
4
  import { arrayToMap } from '../../../utils/tool';
5
5
  import lodashGet from 'lodash.get';
6
6
  import deepEqual from '../../../utils/deepEqual';
7
- import { getWhereList } from '../../../utils/platform';
7
+ import destr from '../../../utils/destr';
8
+ import { getDefaultQuery } from '../../../utils/getModelParams';
8
9
 
9
10
  // 判断值为空,展示placeholder
10
11
  export const isEmpty = (v) => {
@@ -118,6 +119,7 @@ Component({
118
119
  preWhere: [], // 对比 where 监听
119
120
  whereEffected: [], // 每次请求都加上
120
121
  fetchTimed: null, // 防抖
122
+ queryParam: { select: { $master: true } },
121
123
  },
122
124
  lifetimes: {
123
125
  attached() {
@@ -142,8 +144,6 @@ Component({
142
144
  this.setData({
143
145
  option: range,
144
146
  loadStatus: range.length > 0 ? 0 : -1,
145
- });
146
- this.setData({
147
147
  value: this.properties.defaultValue,
148
148
  cls,
149
149
  subCls,
@@ -198,10 +198,17 @@ Component({
198
198
  option: function (options) {
199
199
  this.triggerEvent('changeOptions', { value: { options } });
200
200
  },
201
- where: function (where) {
202
- if (deepEqual(where, this.data.preWhere)) return;
203
- const whereEffected = [].concat(getWhereList(where));
204
- this.setData({ preWhere: where, whereEffected }, () => {
201
+ 'where,queryCondition,sorter': function (where, queryCondition, sorter) {
202
+ const _queryParam = getDefaultQuery({
203
+ supportManyRelated: this.data.supportManyRelated,
204
+ queryCondition,
205
+ where,
206
+ sorter,
207
+ });
208
+ if (deepEqual(_queryParam, this.data.queryParam)) {
209
+ return;
210
+ }
211
+ this.setData({ queryParam: _queryParam }, () => {
205
212
  this._initFetchData();
206
213
  });
207
214
  },
@@ -247,30 +254,42 @@ Component({
247
254
  this.triggerEvent('change', e.detail);
248
255
  },
249
256
  // 初始化搜索数据,包括属性变化/搜索值变化
250
- _initFetchData: function (_where = []) {
257
+ _initFetchData: function (searchValue) {
251
258
  clearTimeout(this.data.fetchTimed);
252
259
  // eslint-disable-next-line rulesdir/no-timer
253
260
  this.data.fetchTimed = setTimeout(() => {
254
261
  const { format, dataSourceName, primaryField } = this.properties;
255
262
  if (['many-many', 'one-many'].concat(format) && dataSourceName && primaryField) {
256
263
  this.setData({ records: [], option: [], pageNo: 1 });
257
- this._fetchData(1, _where, true);
264
+ this._fetchData({ searchValue, _init: true });
258
265
  }
259
266
  }, 300);
260
267
  },
261
268
  // 获取数据列表:一对多,多对多
262
- _fetchData: async function (_pageNo, _where = [], _init = false) {
269
+
270
+ _fetchData: async function ({ queryParam = this.data.queryParam, searchValue = '', pageNo = 1, _init = false }) {
263
271
  const { dataSourceName, primaryField } = this.properties;
264
272
  if (!dataSourceName) return;
265
-
273
+ // 默认筛选条件
274
+ let _filter = destr(this.data.queryParam.filter) ?? {};
275
+ // 根据搜索值查询
276
+ if (searchValue) {
277
+ const search = this.data.ignoreCase ? '$search_ci' : '$search';
278
+ _filter = {
279
+ where: {
280
+ $and: [_filter.where, { $and: [{ [this.data.primaryField]: { [`${search}`]: searchValue } }] }],
281
+ },
282
+ };
283
+ }
266
284
  const records = _init ? [] : this.data.records;
267
- const pageSize = 200;
285
+ const pageSize = 50;
268
286
  const res = await callDataSourceApi({
269
287
  dataSourceName: dataSourceName,
270
- methodName: 'wedaGetRecords',
288
+ methodName: 'wedaGetRecordsV2',
271
289
  params: {
272
- where: [{ $and: [...this.data.whereEffected, ..._where] }],
273
- _pageNo,
290
+ ...queryParam,
291
+ filter: _filter,
292
+ pageNumber: pageNo,
274
293
  pageSize,
275
294
  },
276
295
  });
@@ -280,44 +299,41 @@ Component({
280
299
  label: item[primaryField],
281
300
  value: item._id,
282
301
  }));
283
- if (this.data.records.length === 0 && results?.length === 0) {
284
- // 当异常的时候,主要为了不引起records的observer变化变化设置默认值
285
- this.setData({
286
- loadStatus: -1,
287
- });
288
- } else {
289
- this.setData({
290
- records: records.concat(results || []),
291
- loadStatus: status,
292
- });
293
- }
294
- const finalRecords = records.concat(results || []);
295
302
 
296
- if (finalRecords && finalRecords.length > 0) {
297
- const { value } = this.data;
298
- const label = this.getLabels(value, finalRecords);
299
- const stringRange = this.getChecks(value, finalRecords);
300
- // 默认
301
- this.setData({
302
- option: stringRange,
303
- loadStatus: results.length > 0 ? 0 : -1,
304
- displayLabel: label,
303
+ let finalRecords = records.concat(results || []);
304
+ finalRecords = this.getUniqueOption(finalRecords);
305
+ const { value } = this.data;
306
+
307
+ const unchecked = value.filter((i) => !finalRecords.find((j) => i === j.value));
308
+ // 跨页勾选回显示
309
+ if (unchecked.length) {
310
+ const uncheckedItem = await this.fetchItem(unchecked);
311
+ uncheckedItem?.forEach((i) => {
312
+ if (i) {
313
+ finalRecords.unshift(i);
314
+ }
305
315
  });
306
- return;
307
316
  }
317
+ const label = this.getLabels(value, finalRecords);
318
+ const stringRange = this.getChecks(value, finalRecords);
308
319
  let status = 0;
309
320
  if (!results) {
310
321
  status = 2;
311
- } else if (results.length === 0) {
322
+ } else if (finalRecords.length === 0) {
312
323
  status = 3;
313
- } else {
314
- status = results.length === 200 ? 1 : 0;
315
324
  }
325
+
326
+ // 默认
327
+ this.setData({
328
+ option: stringRange,
329
+ displayLabel: label,
330
+ records: finalRecords,
331
+ loadStatus: status,
332
+ });
316
333
  },
317
334
  _childFetchData: function (e) {
318
335
  const { pageNo, searchValue } = e.detail;
319
- const _where = searchValue ? [{ [this.properties.primaryField]: { $search: searchValue } }] : [];
320
- this._fetchData(pageNo, _where);
336
+ this._fetchData({ pageNo, searchValue });
321
337
  },
322
338
  getLabels: function (values, options) {
323
339
  let labels = values;
@@ -341,6 +357,41 @@ Component({
341
357
  });
342
358
  return stringRange;
343
359
  },
360
+ fetchItem: async function (values) {
361
+ const { queryParam, dataSourceName, primaryField } = this.data;
362
+ const _filter = {
363
+ where: {
364
+ $and: [{ $or: values.map((i) => ({ _id: { $search: i } })) }],
365
+ },
366
+ };
367
+ let data = await callDataSourceApi({
368
+ dataSourceName: dataSourceName,
369
+ methodName: 'wedaGetRecordsV2',
370
+ params: {
371
+ ...queryParam,
372
+ filter: _filter,
373
+ pageNumber: 1,
374
+ pageSize: 200,
375
+ },
376
+ });
377
+ return (
378
+ data?.records?.map((item) => ({
379
+ ...item,
380
+ label: item[primaryField],
381
+ value: item._id,
382
+ })) || []
383
+ );
384
+ },
385
+ getUniqueOption: function (option) {
386
+ const optionMap = option.reduce((acc, item) => {
387
+ if (!acc[item.value]) {
388
+ acc[item.value] = item;
389
+ }
390
+ return acc;
391
+ }, {});
392
+ const uniqueOption = Object.values(optionMap)?.filter((item) => item?.value);
393
+ return uniqueOption;
394
+ },
344
395
  onSearch(event) {
345
396
  const { noEvent, value: searchValue } = event.detail;
346
397
 
@@ -348,10 +399,8 @@ Component({
348
399
  if (!noEvent) {
349
400
  this.triggerEvent('search', { value: searchValue });
350
401
  }
351
-
352
402
  // 接口搜索
353
- const _where = searchValue ? [{ [this.properties.primaryField]: { $search: searchValue } }] : [];
354
- this._initFetchData(_where);
403
+ this._initFetchData(searchValue);
355
404
  },
356
405
  },
357
406
  });
@@ -1,4 +1,4 @@
1
- import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
1
+ import { getCloudInstance, getTempFileURL, getDefaultUploadPath } from '../../../utils/tcb';
2
2
  import { randomStr } from '../../../utils/platform';
3
3
  import { compressImage } from './compress';
4
4
  import { isNil } from '../../../utils/lodash';
@@ -128,22 +128,14 @@ Component({
128
128
  try {
129
129
  const ret = await callbacks.beforeUpload({
130
130
  tempFilePaths: tempFilePaths,
131
- base64Uri: files.contents.map(
132
- (content) =>
133
- `data:image/jpg;base64,${wx.arrayBufferToBase64(content)}`
134
- ),
131
+ base64Uri: files.contents.map((content) => `data:image/jpg;base64,${wx.arrayBufferToBase64(content)}`),
135
132
  });
136
133
  if (typeof ret === 'boolean') {
137
134
  shouldUploadToCos = ret;
138
- } else if (
139
- Array.isArray(ret) &&
140
- ret.every((item) => typeof item === 'string')
141
- ) {
135
+ } else if (Array.isArray(ret) && ret.every((item) => typeof item === 'string')) {
142
136
  tempFilePaths = ret;
143
137
  } else if (!isNil(ret)) {
144
- throw new TypeError(
145
- '小程序端返回值接受布尔值 / 小程序文件临时路径数组'
146
- );
138
+ throw new TypeError('小程序端返回值接受布尔值 / 小程序文件临时路径数组');
147
139
  }
148
140
  } catch (err) {
149
141
  console.error('上传前处理函数抛错', err);
@@ -156,7 +148,8 @@ Component({
156
148
  const tcb = await getCloudInstance();
157
149
  const uploadPromise = tempFilePaths.map(async (tempFilePath) => {
158
150
  const fileType = tempFilePath.split('.')[1];
159
- const cloudPath = `${uploadPath}/${randomStr()}-${Date.now()}.${fileType}`;
151
+ const _uploadPath = await getDefaultUploadPath(uploadPath);
152
+ const cloudPath = `${_uploadPath}/${randomStr()}-${Date.now()}.${fileType}`;
160
153
  let filePath = tempFilePath;
161
154
  if (this.data.isCompressBeforeUpload) {
162
155
  try {
@@ -274,8 +267,7 @@ Component({
274
267
  },
275
268
  layout: function (layout) {
276
269
  const _layout = layout !== 'vertical' ? 'horizontal' : 'vertical';
277
- const layoutCls =
278
- _layout === 'horizontal' ? 'weda-formcells weui-flex' : '';
270
+ const layoutCls = _layout === 'horizontal' ? 'weda-formcells weui-flex' : '';
279
271
  this.setData({ _layout, layoutCls });
280
272
  },
281
273
  sourceType: function (sourceType) {
@@ -1,4 +1,4 @@
1
- import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
1
+ import { getCloudInstance, getTempFileURL, getDefaultUploadPath } from '../../../utils/tcb';
2
2
  import { transSize, randomStr } from '../../../utils/platform';
3
3
  import equal from '../../../utils/deepEqual';
4
4
 
@@ -250,7 +250,8 @@ Component({
250
250
  ..._tempFile,
251
251
  };
252
252
  const uploadPath = 'weda-uploader';
253
- const cloudPath = `${uploadPath}/${randomStr()}-${tempFile.name}`;
253
+ const _uploadPath = await getDefaultUploadPath(uploadPath);
254
+ const cloudPath = `${_uploadPath}/${randomStr()}-${tempFile.name}`;
254
255
  try {
255
256
  const tcb = await getCloudInstance();
256
257
  const uploadTask = await tcb.uploadFile({