@cloudbase/weda-ui-mp 3.20.1 → 3.20.3

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.
@@ -47,7 +47,7 @@ Component({
47
47
  type: Boolean,
48
48
  value: true,
49
49
  },
50
- defauleShowLocation: {
50
+ defaultShowLocation: {
51
51
  type: Boolean,
52
52
  value: true,
53
53
  },
@@ -107,9 +107,7 @@ Component({
107
107
  const { locationType, dataSource } = this.properties;
108
108
  const getReverseGeocoder = async (location) => {
109
109
  const { isApikeyStatus } = this.data;
110
- let key = isApikeyStatus.apiKey
111
- ? isApikeyStatus.apiKey
112
- : await this.getApikey(dataSource.name, 'get');
110
+ let key = isApikeyStatus.apiKey ? isApikeyStatus.apiKey : await this.getApikey(dataSource.name, 'get');
113
111
  if (key) {
114
112
  qqmapsdk = new QQMapWX({
115
113
  key: key,
@@ -123,9 +121,7 @@ Component({
123
121
  poiname: result?.formatted_addresses?.recommend,
124
122
  detailedAddress: result?.address,
125
123
  };
126
- let isCustomLocation = this.checkCustomLocation(
127
- this.properties.value
128
- );
124
+ let isCustomLocation = this.checkCustomLocation(this.properties.value);
129
125
  if (isCustomLocation) {
130
126
  this.setData({
131
127
  currentLocations: detailLocation,
@@ -156,16 +152,10 @@ Component({
156
152
  detailedAddress: '',
157
153
  };
158
154
  // 表单为新增时回传点位信息
159
- let isCustomLocation = this.checkCustomLocation(
160
- this.properties.value
161
- );
155
+ let isCustomLocation = this.checkCustomLocation(this.properties.value);
162
156
  let customLocation = {
163
- latitude: isCustomLocation
164
- ? this.properties.value?.geopoint?.coordinates[1]
165
- : '',
166
- longitude: isCustomLocation
167
- ? this.properties.value?.geopoint?.coordinates[0]
168
- : '',
157
+ latitude: isCustomLocation ? this.properties.value?.geopoint?.coordinates[1] : '',
158
+ longitude: isCustomLocation ? this.properties.value?.geopoint?.coordinates[0] : '',
169
159
  poiname: this.properties.value?.address,
170
160
  detailedAddress: this.properties.value?.detailedAddress,
171
161
  };
@@ -176,10 +166,7 @@ Component({
176
166
  message: '',
177
167
  },
178
168
  });
179
- this.setLocation(
180
- isCustomLocation ? customLocation : location,
181
- isCustomLocation
182
- );
169
+ this.setLocation(isCustomLocation ? customLocation : location, isCustomLocation);
183
170
  if (!isCustomLocation) {
184
171
  locationType !== 1 && this.setData({ isAddrShow: true });
185
172
  } else {
@@ -199,10 +186,7 @@ Component({
199
186
  };
200
187
  const getCustomInfoLocation = () => {
201
188
  let customInfoLocation = customInfo.getCurrentLocation();
202
- if (
203
- !!customInfoLocation &&
204
- typeof customInfoLocation.then === 'function'
205
- ) {
189
+ if (!!customInfoLocation && typeof customInfoLocation.then === 'function') {
206
190
  customInfoLocation
207
191
  .then((res) => {
208
192
  drowMapMarks(res);
@@ -410,10 +394,7 @@ Component({
410
394
  this.changeValueFormat(location);
411
395
  },
412
396
  checkCustomLocation(params) {
413
- if (
414
- !params?.address ||
415
- (params?.geopoint?.type && params?.geopoint?.type != 'Point')
416
- ) {
397
+ if (!params?.address || (params?.geopoint?.type && params?.geopoint?.type != 'Point')) {
417
398
  return false;
418
399
  }
419
400
  return true;
@@ -465,11 +446,7 @@ Component({
465
446
  value: function (value) {
466
447
  const currentLocations = this.data.currentLocations;
467
448
  if (value || !currentLocations.latitude) {
468
- const {
469
- geopoint: { coordinates } = {},
470
- address: poiname,
471
- detailedAddress,
472
- } = value || {};
449
+ const { geopoint: { coordinates } = {}, address: poiname, detailedAddress } = value || {};
473
450
 
474
451
  if (!coordinates?.[0]) return;
475
452
 
@@ -512,7 +489,7 @@ Component({
512
489
  {
513
490
  'weui-flex': isFlex,
514
491
  [className]: className,
515
- }
492
+ },
516
493
  );
517
494
  this.setData({ cls });
518
495
  },
@@ -2,6 +2,7 @@ import { getCloudInstance, getTempFileURL, getDefaultUploadPath } from '../../..
2
2
  import { randomStr } from '../../../utils/platform';
3
3
  import { compressImage } from './compress';
4
4
  import { isNil } from '../../../utils/lodash';
5
+ import { storageTypeIsHttps } from '../uploaderFile/upload';
5
6
 
6
7
  Component({
7
8
  options: {
@@ -99,6 +100,10 @@ Component({
99
100
  type: Object,
100
101
  value: null,
101
102
  },
103
+ storageType: {
104
+ type: String,
105
+ value: 'cloudID',
106
+ },
102
107
  },
103
108
  data: {
104
109
  maxCount: 0,
@@ -172,6 +177,17 @@ Component({
172
177
  cloudPath,
173
178
  filePath,
174
179
  });
180
+ let result = uploadRes.fileID;
181
+ let file = files?.tempFiles[0];
182
+ // 小程序自带tempURL 不需要调用 tcb.getTempFileURL 获取
183
+ if (storageTypeIsHttps(this.data.storageType)) {
184
+ result = await getTempFileURL(uploadRes.fileID);
185
+ file = { ...file, url: result };
186
+ }
187
+ this.triggerEvent('success', {
188
+ value: result,
189
+ file: file,
190
+ });
175
191
  return { fileID: uploadRes.fileID };
176
192
  });
177
193
  const uploadFileList = await Promise.all(uploadPromise);
@@ -195,11 +211,7 @@ Component({
195
211
  },
196
212
  uploadSuccess: async function (e) {
197
213
  const urls = e.detail.cloudUrls; // uploadFile 获取返回值
198
- // 小程序自带tempURL 不需要调用 tcb.getTempFileURL 获取
199
- this.triggerEvent('success', {
200
- value: this.properties.single ? urls[0] : urls,
201
- file: e.detail.file,
202
- });
214
+
203
215
  const newUrls = [...this.data.cloudFile, ...urls];
204
216
  this.setData({
205
217
  files: this.data.files.concat(e.detail.urls.map((url) => ({ url }))),
@@ -228,8 +240,11 @@ Component({
228
240
  }
229
241
  this.handleChange(newUrls, true);
230
242
  },
231
- handleChange: function (values, isDelete = false) {
243
+ handleChange: async function (values, isDelete = false) {
232
244
  let value = values;
245
+ if (storageTypeIsHttps(this.data.storageType)) {
246
+ value = await Promise.all(values.map((i) => getTempFileURL(i)));
247
+ }
233
248
  if (this.properties.single) {
234
249
  value = values[0] ?? '';
235
250
  }
@@ -80,6 +80,10 @@ Component({
80
80
  type: String,
81
81
  value: '点击上传',
82
82
  },
83
+ storageType: {
84
+ type: String,
85
+ value: 'cloudID',
86
+ },
83
87
  },
84
88
  data: {
85
89
  maxCount: 0,
@@ -1,5 +1,7 @@
1
1
  import { transSize, randomStr } from '../../../utils/platform';
2
- import { getCloudInstance, getDefaultUploadPath } from '../../../utils/tcb';
2
+ import { getCloudInstance, getDefaultUploadPath, getTempFileURL } from '../../../utils/tcb';
3
+
4
+ export const storageTypeIsHttps = (storageType) => storageType === 'https';
3
5
 
4
6
  const ACTION = { CHOOSE_MEDIA: 'chooseMedia', CHOOSE_MESSAGE_FILE: 'chooseMessageFile' };
5
7
 
@@ -226,15 +228,16 @@ const handleUploadFile = async ({
226
228
  };
227
229
 
228
230
  export const upload = (uploadInstance) => {
229
- const { config, onSuccess, onFail } = uploadInstance;
231
+ const { config, onFail } = uploadInstance;
230
232
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
231
233
  const { action, disabled, maxSize, ..._config } = config;
232
234
  if (disabled) return;
233
235
  const success = (res) => {
234
- const result = handleUpload(res.tempFiles, uploadInstance);
235
- onSuccess(result);
236
+ // 文件选择成功
237
+ handleUpload(res.tempFiles, uploadInstance);
236
238
  };
237
239
  const fail = (e) => {
240
+ // 文件选择失败
238
241
  onFail(e);
239
242
  };
240
243
 
@@ -260,17 +263,35 @@ export const initUploadInstance = ({ action, config, previewFile }, _this) => {
260
263
  urls: cloudPathList,
261
264
  cloudFile: cloudPathList,
262
265
  });
266
+ const { single, storageType } = _this.data;
263
267
  let _value = cloudPathList;
264
- if (_this.data.single) {
265
- _value = cloudPathList[0] ?? '';
268
+ if (storageTypeIsHttps(storageType)) {
269
+ Promise.all(_value.map((i) => getTempFileURL(i))).then((res) => {
270
+ _value = single ? cloudPathList[0] ?? '' : res;
271
+ _this.handleChange(_value);
272
+ });
273
+ } else {
274
+ if (single) {
275
+ _value = cloudPathList[0] ?? '';
276
+ }
277
+ _this.handleChange(_value);
266
278
  }
267
- _this.handleChange(_value);
268
279
  },
269
280
  onSuccess(res) {
270
- _this.triggerEvent('success', {
271
- value: res.cloudPath,
272
- file: res,
273
- });
281
+ const { storageType } = _this.data;
282
+ if (storageTypeIsHttps(storageType)) {
283
+ getTempFileURL(res.cloudPath).then((url) => {
284
+ _this.triggerEvent('success', {
285
+ value: url,
286
+ file: { ...res, url },
287
+ });
288
+ });
289
+ } else {
290
+ _this.triggerEvent('success', {
291
+ value: res.cloudPath,
292
+ file: res,
293
+ });
294
+ }
274
295
  },
275
296
  onFail(e) {
276
297
  _this.triggerEvent('error', e);
@@ -272,7 +272,7 @@ export default Behavior({
272
272
  type: Boolean,
273
273
  value: false,
274
274
  },
275
- defauleShowLocation: {
275
+ defaultShowLocation: {
276
276
  type: Boolean,
277
277
  value: true,
278
278
  },
@@ -31,7 +31,7 @@ Component({
31
31
  type: Boolean,
32
32
  value: true,
33
33
  },
34
- defauleShowLocation: {
34
+ defaultShowLocation: {
35
35
  type: Boolean,
36
36
  value: true,
37
37
  },
@@ -14,7 +14,7 @@
14
14
  customLocation="{{customLocation}}"
15
15
  customRange="{{customRange}}"
16
16
  dataSource="{{dataSource}}"
17
- defauleShowLocation="{{defauleShowLocation}}"
17
+ defaultShowLocation="{{defaultShowLocation}}"
18
18
  drag="{{drag}}"
19
19
  locationType="{{locationType}}"
20
20
  locationRange="{{locationRange}}"
@@ -68,3 +68,7 @@
68
68
  .weda-RichTextView ._img {
69
69
  vertical-align: middle;
70
70
  }
71
+
72
+ .weda-RichTextView .p {
73
+ min-height: 1em;
74
+ }
@@ -1,11 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-magic-numbers */
2
2
  import { commonCompBehavior } from '../../utils/common-behavior';
3
- import {
4
- getStartMoment,
5
- convertValueToDateItem,
6
- getYMD,
7
- convertMethodParam,
8
- } from '../../utils/getFormLegacy';
3
+ import { getStartMoment, convertValueToDateItem, getYMD, convertMethodParam } from '../../utils/getFormLegacy';
9
4
  import { WEEKS, getConfigDataObj, convertWeeks } from './weeks';
10
5
 
11
6
  Component({
@@ -41,6 +36,12 @@ Component({
41
36
  type: Array,
42
37
  value: [],
43
38
  },
39
+ start: {
40
+ type: null,
41
+ },
42
+ end: {
43
+ type: null,
44
+ },
44
45
  },
45
46
  data: {
46
47
  currentValue: null, // 时间戳
@@ -114,10 +115,7 @@ Component({
114
115
  const { _oldCurrentValue, _oldCurrentMonthValue } = this.data;
115
116
  const currentValue = getStartMoment('day', value, false)?.valueOf();
116
117
  const currentMonthValue = getStartMoment('month', initMonth)?.valueOf();
117
- if (
118
- currentValue !== _oldCurrentValue ||
119
- currentMonthValue !== _oldCurrentMonthValue
120
- ) {
118
+ if (currentValue !== _oldCurrentValue || currentMonthValue !== _oldCurrentMonthValue) {
121
119
  this.setData({
122
120
  currentValue,
123
121
  currentMonthValue,
@@ -136,12 +134,14 @@ Component({
136
134
  const checkedDay = getYMD(dateItem);
137
135
  this.setData({ checkedDay });
138
136
  },
139
- 'currentMonthValue,configDataObj': function (
140
- currentMonthValue,
141
- configDataObj
142
- ) {
143
- const { year, month } = convertValueToDateItem(currentMonthValue);
144
- const weeks = convertWeeks(year, month, configDataObj);
137
+ 'currentMonthValue,configDataObj,start,end': function (currentMonthValue, configDataObj, start, end) {
138
+ const dateItem = convertValueToDateItem(currentMonthValue);
139
+ if (!dateItem) {
140
+ console.error('Invalid date item returned from convertValueToDateItem');
141
+ return;
142
+ }
143
+ const { year, month } = dateItem;
144
+ const weeks = convertWeeks(year, month, configDataObj, [start, end]);
145
145
  const yearMonthDisplay = `${year}年${month + 1}月`;
146
146
  this.setData({ weeks, yearMonthDisplay });
147
147
  },
@@ -1,9 +1,4 @@
1
- import {
2
- getStartMoment,
3
- convertValueToDateItem,
4
- getYMD,
5
- convertYearMonthToWeeks,
6
- } from '../../utils/getFormLegacy';
1
+ import { getStartMoment, convertValueToDateItem, getYMD, convertYearMonthToWeeks } from '../../utils/getFormLegacy';
7
2
 
8
3
  export const WEEKS = ['日', '一', '二', '三', '四', '五', '六'];
9
4
  export const BLOCK_NAME = 'weda-calendar';
@@ -25,8 +20,8 @@ export const getConfigDataObj = (configData) => {
25
20
  };
26
21
 
27
22
  // 带上外部配置,转星期
28
- export const convertWeeks = (year, month, configDataObj) => {
29
- const weeks = convertYearMonthToWeeks(year, month, null, {
23
+ export const convertWeeks = (year, month, configDataObj, range) => {
24
+ const weeks = convertYearMonthToWeeks(year, month, range, {
30
25
  isPreNext: true,
31
26
  isDynamic: true,
32
27
  });
@@ -14,6 +14,7 @@
14
14
 
15
15
  .wd-image {
16
16
  max-width: 100%;
17
+ vertical-align: middle;
17
18
  }
18
19
 
19
20
  @media screen and (max-width: 768px) {
@@ -31,7 +31,7 @@
31
31
  customLocation="{{customLocation}}"
32
32
  customRange="{{customRange}}"
33
33
  dataSource="{{dataSource}}"
34
- defauleShowLocation="{{defauleShowLocation}}"
34
+ defaultShowLocation="{{defaultShowLocation}}"
35
35
  drag="{{drag}}"
36
36
  locationType="{{locationType}}"
37
37
  locationRange="{{locationRange}}"
@@ -147,7 +147,7 @@ Component({
147
147
  _option = range;
148
148
  }
149
149
  const label = this.getLabels(value, _option);
150
- const checkRange = this.getChecks(value, _option, this.data.displayValue);
150
+ const checkRange = this.getChecks(value, _option);
151
151
  // 默认
152
152
  this.setData({
153
153
  option: checkRange,
@@ -284,13 +284,13 @@ Component({
284
284
  this._fetchData({ pageNo, searchValue });
285
285
  }
286
286
  },
287
- getLabels: function (values, options, _preLabel) {
287
+ getLabels: function (values, options) {
288
288
  let labels = values;
289
289
  if (Array.isArray(values) && Array.isArray(options)) {
290
290
  const rm = arrayToMap(options, 'value');
291
291
  labels = values.map((d) => {
292
292
  const obj = rm[d];
293
- let item = lodashGet(obj, 'text') ?? lodashGet(obj, 'label') ?? _preLabel ?? d;
293
+ let item = lodashGet(obj, 'text') ?? lodashGet(obj, 'label') ?? d;
294
294
  return textToString(item);
295
295
  });
296
296
  }
@@ -2,7 +2,7 @@
2
2
  <view class="{{classPrefix + '-tabs__header'}}">
3
3
  <view class="{{classPrefix + '-tabs__header-item-wrap' }}">
4
4
  <view class="{{classPrefix + '-tabs__header-item-content'}}">
5
- <scroll-view scroll-x="true" scroll-into-view="{{scrollId}}" class="{{classPrefix + '-tabs__scroll'}}" enable-flex="true" wx:if="{{direction!=='vertical'}}">
5
+ <scroll-view scroll-x="true" scroll-into-view="{{scrollId}}" class="{{classPrefix + '-tabs__scroll'}}" enable-flex="true" enhanced="{{true}}" show-scrollbar="{{false}}" wx:if="{{direction!=='vertical'}}" >
6
6
  <view wx:for="{{list}}" class="{{classPrefix + '-tabs__item'}} {{item.selected?'is-selected':''}} {{item.isDisabled?'is-disabled':''}}" wx:for-index="index" wx:for-item="item" wx:key="index" id="{{'cell-'+index}}" bindtap="onItemClick" data-value="{{index}}" data-item="{{item}}">
7
7
  <view wx-if="{{item.iconType !== 'none' && item.iconPosition === 'prefix'}}" class="{{classPrefix + '-tabs__item-icon'}}">
8
8
  <wd-icon type="{{item.iconType}}" name="{{ item.iconType === 'inner' ? item.innerIcon : item.outerImage}}" src="{{item.iconType === 'custom' ? item.outerImage : ''}}" size="xs" />
@@ -30,6 +30,10 @@ Component({
30
30
  type: String,
31
31
  value: '点击上传',
32
32
  },
33
+ storageType: {
34
+ type: String,
35
+ value: 'cloudID',
36
+ },
33
37
  },
34
38
  methods: {
35
39
  initValue: function () {
@@ -36,6 +36,7 @@
36
36
  callbacks="{{callbacks}}"
37
37
  uploadButtonText="{{uploadButtonText}}"
38
38
  uploadTipText="{{uploadTipText}}"
39
+ storageType="{{storageType}}"
39
40
  />
40
41
  </wd-form-item>
41
42
  </block>
@@ -3,7 +3,8 @@ import formFieldBehavior from '../form-field-behavior/form-field-behavior';
3
3
  import itemBehavior from '../form-field-behavior/item-behavior';
4
4
  import isEqual from '../../utils/deepEqual';
5
5
  import { convertSingleValue } from '../../utils/platform';
6
- import { upload } from '../form/uploaderFile/upload';
6
+ import { upload, storageTypeIsHttps } from '../form/uploaderFile/upload';
7
+ import { getTempFileURL } from '../../utils/tcb';
7
8
 
8
9
  Component({
9
10
  options: {
@@ -44,6 +45,10 @@ Component({
44
45
  type: String,
45
46
  value: 'normal',
46
47
  },
48
+ storageType: {
49
+ type: String,
50
+ value: 'cloudID',
51
+ },
47
52
  },
48
53
  data: {
49
54
  files: [],
@@ -87,17 +92,35 @@ Component({
87
92
  files,
88
93
  });
89
94
  const cloudPathList = files.map((i) => i.cloudId).filter((j) => !!j);
95
+ const { single, storageType } = _this.data;
90
96
  let _value = cloudPathList;
91
- if (_this.data.single) {
92
- _value = cloudPathList[0] ?? '';
97
+ if (storageTypeIsHttps(storageType)) {
98
+ Promise.all(_value.map((i) => getTempFileURL(i))).then((res) => {
99
+ _value = single ? cloudPathList[0] ?? '' : res;
100
+ _this.handleChange({ detail: { value: _value } });
101
+ });
102
+ } else {
103
+ if (single) {
104
+ _value = cloudPathList[0] ?? '';
105
+ }
106
+ _this.handleChange({ detail: { value: _value } });
93
107
  }
94
- _this.handleChange({ detail: { value: _value } });
95
108
  },
96
109
  onSuccess(res) {
97
- _this.triggerEvent('success', {
98
- value: res.cloudPath,
99
- file: res,
100
- });
110
+ const { storageType } = _this.data;
111
+ if (storageTypeIsHttps(storageType)) {
112
+ getTempFileURL(res.cloudPath).then((url) => {
113
+ _this.triggerEvent('success', {
114
+ value: url,
115
+ file: { ...res, url },
116
+ });
117
+ });
118
+ } else {
119
+ _this.triggerEvent('success', {
120
+ value: res.cloudPath,
121
+ file: res,
122
+ });
123
+ }
101
124
  },
102
125
  onFail(e) {
103
126
  _this.triggerEvent('error', e);
@@ -163,13 +186,14 @@ Component({
163
186
  'name, value, label, required, visible, disabled, readOnly, sourceType': function () {
164
187
  this.updateWidgetAPI();
165
188
  },
166
- 'disabled,sourceType,maxUploadCount,sizeType,maxSize,single': function (
189
+ 'disabled,sourceType,maxUploadCount,sizeType,maxSize,single,storageType': function (
167
190
  disabled,
168
191
  sourceType,
169
192
  maxUploadCount,
170
193
  sizeType,
171
194
  maxSize,
172
195
  single,
196
+ storageType,
173
197
  ) {
174
198
  const config = {
175
199
  disabled,
@@ -178,6 +202,7 @@ Component({
178
202
  sizeType,
179
203
  maxSize,
180
204
  single,
205
+ storageType,
181
206
  };
182
207
  this.setConfig(config);
183
208
  },
@@ -39,6 +39,7 @@
39
39
  compressQuality="{{compressQuality}}"
40
40
  compressedHeight="{{compressedHeight}}"
41
41
  compressedWidth="{{compressedWidth}}"
42
+ storageType="{{storageType}}"
42
43
  callbacks="{{callbacks}}"
43
44
  bind:change="handleChange"
44
45
  sourceType="{{sourceType}}"
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.20.1",
6
+ "version": "3.20.3",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"
package/utils/enum.js CHANGED
@@ -1051,6 +1051,7 @@ export const PROPS_WHERE_REL_MEMBER = [].concat(PROPS_WHERE_REL, [
1051
1051
  export const WD_LOCATION_TYPE = [
1052
1052
  { label: '无', value: 1 },
1053
1053
  { label: '用户当前位置', value: 2 },
1054
+ { label: '自定义位置', value: 3 },
1054
1055
  ];
1055
1056
 
1056
1057
  export const WD_LOCATION_RANGE = [