@cloudbase/weda-ui 0.2.16 → 1.0.24
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.
- package/README.md +41 -169
- package/package.json +23 -11
- package/src/configs/components/calendar.json +4 -1
- package/src/configs/components/chart/bar.json +724 -0
- package/src/configs/components/chart/line.json +679 -0
- package/src/configs/components/chart/pie.json +497 -0
- package/src/configs/components/chart/statisticsCard.json +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +21 -6
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/graphicCard.json +84 -73
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +19 -3
- package/src/configs/components/listView.json +65 -18
- package/src/configs/components/lottery.json +151 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +87 -75
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +4 -1
- package/src/configs/components/scrollVeiw.json +74 -22
- package/src/configs/components/swiper.json +4 -1
- package/src/configs/components/tabs.json +51 -8
- package/src/configs/components/text.json +33 -25
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +20 -0
- package/src/index.js +2 -0
- package/src/mp/components/button/index.wxml +1 -2
- package/src/mp/components/chart/bar/index.js +258 -0
- package/src/mp/components/chart/bar/index.json +6 -0
- package/src/mp/components/chart/bar/index.wxml +3 -0
- package/src/mp/components/chart/bar/index.wxss +9 -0
- package/src/mp/components/chart/common/config/bar.js +50 -0
- package/src/mp/components/chart/common/config/global.js +16 -0
- package/src/mp/components/chart/common/config/line.js +48 -0
- package/src/mp/components/chart/common/config/pie.js +36 -0
- package/src/mp/components/chart/common/core/eChartBar.js +263 -0
- package/src/mp/components/chart/common/core/eChartBase.js +375 -0
- package/src/mp/components/chart/common/core/eChartLine.js +229 -0
- package/src/mp/components/chart/common/core/eChartPie.js +166 -0
- package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
- package/src/mp/components/chart/line/index.js +247 -0
- package/src/mp/components/chart/line/index.json +6 -0
- package/src/mp/components/chart/line/index.wxml +3 -0
- package/src/mp/components/chart/line/index.wxss +9 -0
- package/src/mp/components/chart/pie/index.js +182 -0
- package/src/mp/components/chart/pie/index.json +6 -0
- package/src/mp/components/chart/pie/index.wxml +4 -0
- package/src/mp/components/chart/pie/index.wxss +9 -0
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/form/index.wxml +1 -2
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +348 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +101 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +76 -44
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +61 -29
- package/src/mp/components/graphicCard/index.js +26 -28
- package/src/mp/components/listView/index.js +52 -64
- package/src/mp/components/listView/index.wxml +2 -2
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/lottery/index.js +270 -0
- package/src/mp/components/lottery/index.json +4 -0
- package/src/mp/components/lottery/index.wxml +43 -0
- package/src/mp/components/lottery/index.wxss +317 -0
- package/src/mp/components/navLayout/index.js +3 -3
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/wxOpenApi/phone/index.json +4 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +10 -1
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/constant.js +15 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/lodash.js +2 -0
- package/src/mp/utils/platform.js +25 -0
- package/src/mp/utils/tcb.js +44 -0
- package/src/setupTests.js +2 -1
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- package/src/web/components/chart/bar/index.tsx +140 -0
- package/src/web/components/chart/common/config/bar.js +49 -0
- package/src/web/components/chart/common/config/global.js +16 -0
- package/src/web/components/chart/common/config/line.js +50 -0
- package/src/web/components/chart/common/config/pie.js +37 -0
- package/src/web/components/chart/common/core/eChartBar.js +265 -0
- package/src/web/components/chart/common/core/eChartBase.ts +383 -0
- package/src/web/components/chart/common/core/eChartLine.js +231 -0
- package/src/web/components/chart/common/core/eChartPie.js +170 -0
- package/src/web/components/chart/common/core/type.ts +34 -0
- package/src/web/components/chart/common/echart.css +106 -0
- package/src/web/components/chart/common/echarts.ts +33 -0
- package/src/web/components/chart/common/useChart.tsx +69 -0
- package/src/web/components/chart/line/index.tsx +136 -0
- package/src/web/components/chart/pie/index.tsx +99 -0
- package/src/web/components/chart/statisticsCard/index.tsx +29 -8
- package/src/web/components/form/checkbox/index.tsx +61 -23
- package/src/web/components/form/formcell/index.tsx +10 -5
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
- package/src/web/components/form/radio/index.tsx +90 -53
- package/src/web/components/form/select/h5.tsx +371 -72
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +392 -145
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +90 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/tips/index.css +4 -0
- package/src/web/components/form/tips/index.tsx +4 -3
- package/src/web/components/form/uploader/uploader.h5.tsx +28 -19
- package/src/web/components/form/uploader/uploader.pc.tsx +17 -20
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +48 -44
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +28 -26
- package/src/web/components/graphicCard/index.css +1 -5
- package/src/web/components/graphicCard/index.tsx +4 -3
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +13 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +10 -18
- package/src/web/components/lottery/index.css +327 -0
- package/src/web/components/lottery/index.tsx +567 -0
- package/src/web/components/lottery/lotteryUtil.ts +130 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +231 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/tabs/index.tsx +2 -0
- package/src/web/components/tabs/tabs.h5.tsx +43 -33
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/utils/{constant.js → constant.ts} +17 -2
- package/src/web/utils/lodash.ts +2 -0
- package/src/web/utils/platform.js +10 -1
- package/src/web/utils/tcb.js +20 -6
- package/src/web/weda-ui.css +2 -0
- package/CHANGELOG.md +0 -240
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/mp/.gitignore +0 -10
- package/src/web/.DS_Store +0 -0
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
|
@@ -24,8 +24,7 @@ Component({
|
|
|
24
24
|
value: 'horizontal',
|
|
25
25
|
},
|
|
26
26
|
defaultValue: {
|
|
27
|
-
type:
|
|
28
|
-
value: '',
|
|
27
|
+
type: null,
|
|
29
28
|
},
|
|
30
29
|
single: {
|
|
31
30
|
type: Boolean,
|
|
@@ -41,30 +40,39 @@ Component({
|
|
|
41
40
|
cloudFile: [],
|
|
42
41
|
files: [],
|
|
43
42
|
urls: [],
|
|
43
|
+
singleFlag: false,
|
|
44
44
|
uploadFile: async function (files) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
try {
|
|
46
|
+
// 文件上传的函数,返回一个promise
|
|
47
|
+
const uploadPath = 'weda-uploader';
|
|
48
|
+
const tcb = await getCloudInstance();
|
|
49
|
+
const uploadPromise = files.tempFilePaths.map(
|
|
50
|
+
async (tempFilePath, index) => {
|
|
51
|
+
var spark = new SparkMD5.ArrayBuffer();
|
|
52
|
+
spark.append(files.contents[index]);
|
|
53
|
+
var md5Path = spark.end(false);
|
|
54
|
+
const fileType = tempFilePath.split('.')[1];
|
|
55
|
+
const cloudPath = `${uploadPath}/${md5Path}-${Date.now()}.${fileType}`;
|
|
56
|
+
const uploadRes = await tcb.uploadFile({
|
|
57
|
+
cloudPath,
|
|
58
|
+
filePath: tempFilePath,
|
|
59
|
+
});
|
|
60
|
+
return { fileID: uploadRes.fileID };
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
const uploadFileList = await Promise.all(uploadPromise);
|
|
64
|
+
const cloudUrls = uploadFileList.map((file) => file.fileID);
|
|
65
|
+
// 这里返回的东西会在uploadSuccess回调函数中获取到
|
|
66
|
+
// https://github.com/wechat-miniprogram/weui-miniprogram/blob/a3630575910302e3b94e69fcef266d2b509de650/src/components/uploader/uploader.ts#L149
|
|
67
|
+
// 写死的从返回值的 .urls 获取展示用的url来用。一定要将tempFilePaths透传下去,否则会重新加载然后出现闪白
|
|
68
|
+
return { urls: files.tempFilePaths, cloudUrls };
|
|
69
|
+
} catch (e) {
|
|
70
|
+
wx.showToast({
|
|
71
|
+
title: `${e}` || '上传失败',
|
|
72
|
+
icon: 'none',
|
|
73
|
+
duration: 2000,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
68
76
|
},
|
|
69
77
|
},
|
|
70
78
|
methods: {
|
|
@@ -75,7 +83,7 @@ Component({
|
|
|
75
83
|
const urls = e.detail.cloudUrls; // uploadFile 获取返回值
|
|
76
84
|
// 小程序自带tempURL 不需要调用 tcb.getTempFileURL 获取
|
|
77
85
|
this.triggerEvent('success', {
|
|
78
|
-
value: urls
|
|
86
|
+
value: urls,
|
|
79
87
|
});
|
|
80
88
|
this.setData({
|
|
81
89
|
files: this.data.files.concat(e.detail.urls.map((url) => ({ url }))),
|
|
@@ -83,30 +91,54 @@ Component({
|
|
|
83
91
|
});
|
|
84
92
|
},
|
|
85
93
|
onDelete: function (e) {
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
if (this.data.urls.length == 0) {
|
|
95
|
+
var storgeUrls = [];
|
|
96
|
+
this.data.cloudFile.forEach((v, index) => {
|
|
97
|
+
if (e.detail.index != index) {
|
|
98
|
+
storgeUrls.push(v);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
this.setData({
|
|
102
|
+
files: this.data.files.filter((v, index) => e.detail.index !== index),
|
|
103
|
+
urls: storgeUrls,
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
this.setData({
|
|
107
|
+
files: this.data.files.filter((v, index) => e.detail.index !== index),
|
|
108
|
+
urls: this.data.urls.filter((v, index) => e.detail.index !== index),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
90
111
|
},
|
|
91
112
|
},
|
|
92
113
|
observers: {
|
|
93
114
|
defaultValue: async function (value) {
|
|
94
|
-
|
|
95
|
-
|
|
115
|
+
//当单图片上传且默认值为空数组时,初次渲染更新value,以避免空串提交类型不匹配问题
|
|
116
|
+
if (Array.isArray(value) && !this.data.singleFlag) {
|
|
117
|
+
this.setData({
|
|
118
|
+
urls: value
|
|
119
|
+
});
|
|
120
|
+
this.data.singleFlag = true;
|
|
96
121
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
122
|
+
if (value) {
|
|
123
|
+
let httpFiles = [];
|
|
124
|
+
for (let f of value) {
|
|
125
|
+
const hf = await getTempFileURL(f);
|
|
126
|
+
const httpFile = { url: hf };
|
|
127
|
+
httpFiles.push(httpFile);
|
|
128
|
+
}
|
|
129
|
+
this.setData({
|
|
130
|
+
files: httpFiles,
|
|
131
|
+
cloudFile:
|
|
132
|
+
JSON.stringify(value) != JSON.stringify(this.data.cloudFile)
|
|
133
|
+
? value
|
|
134
|
+
: [],
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
this.setData({
|
|
138
|
+
files: [],
|
|
139
|
+
cloudFile: [],
|
|
140
|
+
});
|
|
102
141
|
}
|
|
103
|
-
this.setData({
|
|
104
|
-
files: httpFiles,
|
|
105
|
-
cloudFile:
|
|
106
|
-
JSON.stringify(value) != JSON.stringify(this.data.cloudFile)
|
|
107
|
-
? value
|
|
108
|
-
: [],
|
|
109
|
-
});
|
|
110
142
|
},
|
|
111
143
|
|
|
112
144
|
'maxUploadCount, single': function (maxUploadCount, single) {
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
<mp-cells>
|
|
2
2
|
<mp-cell>
|
|
3
|
-
<mp-uploader
|
|
3
|
+
<mp-uploader
|
|
4
|
+
max-size="{{maxSize * 1024 * 1024}}"
|
|
5
|
+
files="{{files}}"
|
|
6
|
+
showDelete="{{true}}"
|
|
7
|
+
ext-class="{{layout}}"
|
|
8
|
+
bindfail="uploadError"
|
|
9
|
+
bindsuccess="uploadSuccess"
|
|
10
|
+
select="{{selectFile}}"
|
|
11
|
+
upload="{{uploadFile}}"
|
|
12
|
+
maxCount="{{maxCount}}"
|
|
13
|
+
title="{{title}}"
|
|
14
|
+
binddelete="onDelete">
|
|
15
|
+
</mp-uploader>
|
|
4
16
|
</mp-cell>
|
|
5
17
|
</mp-cells>
|
|
6
18
|
<!-- uploader delete 实际代码接受 showDelete
|
|
@@ -9,7 +21,7 @@
|
|
|
9
21
|
|
|
10
22
|
<!-- bind开头的是事件handler,wxml模版中不能带 `{{}}`
|
|
11
23
|
```
|
|
12
|
-
<mp-uploader files="{{files}}" showDelete="{{true}}" ext-class="{{layout}}" bindfail="uploadError" bindsuccess="uploadSuccess" select="{{selectFile}}" upload="{{uploadFile}}" maxCount="{{maxUploadCount}}" title="{{title}}"
|
|
24
|
+
<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>
|
|
13
25
|
```
|
|
14
|
-
upload 是函数带{{}}, bindtelete直接传函数名字符串
|
|
26
|
+
upload 是函数带{{}}, bindtelete直接传函数名字符串
|
|
15
27
|
-->
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
|
|
2
2
|
import SparkMD5 from '../../../utils/spark-md5';
|
|
3
|
-
import { transSize } from '../../../utils/platform';
|
|
3
|
+
import { transSize, uuid } from '../../../utils/platform';
|
|
4
4
|
Component({
|
|
5
5
|
options: {
|
|
6
6
|
virtualHost: true,
|
|
@@ -22,8 +22,7 @@ Component({
|
|
|
22
22
|
value: false,
|
|
23
23
|
},
|
|
24
24
|
defaultValue: {
|
|
25
|
-
type:
|
|
26
|
-
value: [],
|
|
25
|
+
type: null,
|
|
27
26
|
},
|
|
28
27
|
maxUploadCount: {
|
|
29
28
|
type: Number,
|
|
@@ -60,6 +59,8 @@ Component({
|
|
|
60
59
|
files: [],
|
|
61
60
|
urls: [],
|
|
62
61
|
cloudFile: [],
|
|
62
|
+
strogeUrls: [],
|
|
63
|
+
singleFlag: false
|
|
63
64
|
},
|
|
64
65
|
methods: {
|
|
65
66
|
// 批量上传文件前置事件
|
|
@@ -133,13 +134,8 @@ Component({
|
|
|
133
134
|
if (!this.handleBefore(files?.tempFiles)) return;
|
|
134
135
|
const uploadPath = 'weda-uploader';
|
|
135
136
|
const uploadPromise = files.tempFiles.map(async (tempFile) => {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
.readFileSync(tempFile?.path, 'utf8', 0);
|
|
139
|
-
var spark = new SparkMD5.ArrayBuffer();
|
|
140
|
-
spark.append(res);
|
|
141
|
-
var md5Path = spark.end(false);
|
|
142
|
-
const cloudPath = `${uploadPath}/${md5Path}-${tempFile.name}`;
|
|
137
|
+
const cloudPath = `${uploadPath}/${uuid().replaceAll('-', '')}-${tempFile.name
|
|
138
|
+
}`;
|
|
143
139
|
tempFile.percent = '0';
|
|
144
140
|
tempFile.cloudPath = null;
|
|
145
141
|
tempFile.filePath = tempFile?.path || null;
|
|
@@ -162,9 +158,18 @@ Component({
|
|
|
162
158
|
_this.data.files[index].status = 'success';
|
|
163
159
|
const arr = [];
|
|
164
160
|
arr.push(res.fileID);
|
|
161
|
+
let strogeUrls = [];
|
|
162
|
+
//为了避免死循环 在组件接到默认值后用cloudFile做暂存,造成urls跟cloudFile不同步,根据暂存状态来处理更新urls
|
|
163
|
+
if (_this.data.cloudFile.length > 0) {
|
|
164
|
+
strogeUrls = [..._this.data.cloudFile, ...arr];
|
|
165
|
+
} else {
|
|
166
|
+
strogeUrls = [..._this.data.urls, ...arr];
|
|
167
|
+
}
|
|
168
|
+
//同步urls cloudFile
|
|
165
169
|
_this.setData({
|
|
166
|
-
files: _this.data.files,
|
|
167
|
-
urls: [...
|
|
170
|
+
files: [..._this.data.files],
|
|
171
|
+
urls: [...strogeUrls],
|
|
172
|
+
cloudFile: [...strogeUrls],
|
|
168
173
|
});
|
|
169
174
|
if (_this.properties.single) {
|
|
170
175
|
_this.triggerEvent('success', {
|
|
@@ -188,6 +193,7 @@ Component({
|
|
|
188
193
|
this.data.files[index].uploaded = transSize(res.totalBytesSent);
|
|
189
194
|
this.setData({
|
|
190
195
|
files: this.data.files,
|
|
196
|
+
//cloudFile:this.data.cloudFile.concat(this.data.files)
|
|
191
197
|
});
|
|
192
198
|
});
|
|
193
199
|
return { fileID: uploadTask.fileID };
|
|
@@ -204,15 +210,30 @@ Component({
|
|
|
204
210
|
},
|
|
205
211
|
|
|
206
212
|
onDelete: function (e) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
if (this.data.urls.length == 0) {
|
|
214
|
+
var storgeUrls = [];
|
|
215
|
+
this.data.cloudFile.forEach((v, index) => {
|
|
216
|
+
if (e.target.dataset.item.cloudPath != v) {
|
|
217
|
+
storgeUrls.push(v);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
this.setData({
|
|
221
|
+
files: this.data.files.filter(
|
|
222
|
+
(v, index) => e.target.dataset.item.cloudPath !== v.cloudPath
|
|
223
|
+
),
|
|
224
|
+
urls: storgeUrls,
|
|
225
|
+
});
|
|
226
|
+
} else {
|
|
227
|
+
const filelist = this.data.files.filter(
|
|
228
|
+
(item) => e.target.dataset.item?.path != item?.path
|
|
229
|
+
);
|
|
230
|
+
this.setData({
|
|
231
|
+
files: filelist,
|
|
232
|
+
urls: this.data.urls.filter(
|
|
233
|
+
(v, index) => e.target.dataset.item?.cloudPath != v
|
|
234
|
+
),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
216
237
|
},
|
|
217
238
|
reload: function (e) {
|
|
218
239
|
this.handleUpload(e.target.dataset.item);
|
|
@@ -236,11 +257,15 @@ Component({
|
|
|
236
257
|
},
|
|
237
258
|
observers: {
|
|
238
259
|
defaultValue: async function (value) {
|
|
239
|
-
|
|
240
|
-
|
|
260
|
+
//当单图片上传且默认值为空数组时,初次渲染更新value,以避免空串提交类型不匹配问题
|
|
261
|
+
if (Array.isArray(value) && !this.data.singleFlag) {
|
|
262
|
+
this.setData({
|
|
263
|
+
urls: value
|
|
264
|
+
});
|
|
265
|
+
this.data.singleFlag = true;
|
|
241
266
|
}
|
|
242
267
|
let httpFiles = [];
|
|
243
|
-
if (value.
|
|
268
|
+
if (value && JSON.stringify(value) != '[]') {
|
|
244
269
|
for (let f of value) {
|
|
245
270
|
const hf = await getTempFileURL(f);
|
|
246
271
|
const uuidReg = /[0-9a-f]{8}([0-9a-f]{4}){3}[0-9a-f]{12}-/;
|
|
@@ -256,12 +281,19 @@ Component({
|
|
|
256
281
|
};
|
|
257
282
|
httpFiles.push(httpFile);
|
|
258
283
|
}
|
|
284
|
+
this.setData({
|
|
285
|
+
files: httpFiles,
|
|
286
|
+
cloudFile:
|
|
287
|
+
JSON.stringify(value) != JSON.stringify(this.data.cloudFile)
|
|
288
|
+
? value
|
|
289
|
+
: [],
|
|
290
|
+
});
|
|
291
|
+
} else {
|
|
292
|
+
this.setData({
|
|
293
|
+
files: [],
|
|
294
|
+
cloudFile: [],
|
|
295
|
+
});
|
|
259
296
|
}
|
|
260
|
-
|
|
261
|
-
this.setData({
|
|
262
|
-
files: httpFiles,
|
|
263
|
-
cloudFile: value,
|
|
264
|
-
});
|
|
265
297
|
},
|
|
266
298
|
'maxUploadCount, single': function (maxUploadCount, single) {
|
|
267
299
|
const maxCount = single ? 1 : maxUploadCount;
|
|
@@ -109,11 +109,11 @@ Component({
|
|
|
109
109
|
}
|
|
110
110
|
item.paramObj = paramObj;
|
|
111
111
|
if (item.withParams && item.params.length > 0) {
|
|
112
|
-
wx.
|
|
112
|
+
wx.redirectTo({
|
|
113
113
|
url: '../' + item?.insideUrl + '/index?' + item.paramObj.join('&'),
|
|
114
114
|
});
|
|
115
115
|
} else {
|
|
116
|
-
wx.
|
|
116
|
+
wx.redirectTo({
|
|
117
117
|
url: '../' + item?.insideUrl + '/index',
|
|
118
118
|
});
|
|
119
119
|
}
|
|
@@ -161,17 +161,16 @@ Component({
|
|
|
161
161
|
optionList,
|
|
162
162
|
});
|
|
163
163
|
},
|
|
164
|
-
'titleMaxLines,titleColor,titleFontWeight,titleFontSize,textAlign,titleLineHeight':
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
titleStyle = `
|
|
164
|
+
'titleMaxLines,titleColor,titleFontWeight,titleFontSize,textAlign,titleLineHeight': function (
|
|
165
|
+
titleMaxLines,
|
|
166
|
+
titleColor,
|
|
167
|
+
titleFontWeight,
|
|
168
|
+
titleFontSize,
|
|
169
|
+
textAlign,
|
|
170
|
+
titleLineHeight
|
|
171
|
+
) {
|
|
172
|
+
let titleStyle = this.properties.titleStyle;
|
|
173
|
+
titleStyle = `
|
|
175
174
|
-webkit-line-clamp:${titleMaxLines ? titleMaxLines : 'revert'};
|
|
176
175
|
color: ${titleColor};
|
|
177
176
|
font-weight: ${titleFontWeight};
|
|
@@ -179,19 +178,18 @@ Component({
|
|
|
179
178
|
text-align: ${textAlign};
|
|
180
179
|
line-height: ${titleLineHeight == 'auto' ? 'normal' : titleLineHeight};
|
|
181
180
|
`;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
'desMaxLines,desColor,desFontWeight,desFontSize,textAlign,desLineHeight':
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
desStyle = `
|
|
181
|
+
this.setData({ titleStyle });
|
|
182
|
+
},
|
|
183
|
+
'desMaxLines,desColor,desFontWeight,desFontSize,textAlign,desLineHeight': function (
|
|
184
|
+
desMaxLines,
|
|
185
|
+
desColor,
|
|
186
|
+
desFontWeight,
|
|
187
|
+
desFontSize,
|
|
188
|
+
textAlign,
|
|
189
|
+
desLineHeight
|
|
190
|
+
) {
|
|
191
|
+
let desStyle = this.properties.desStyle;
|
|
192
|
+
desStyle = `
|
|
195
193
|
-webkit-line-clamp:${desMaxLines ? desMaxLines : 'revert'};
|
|
196
194
|
color: ${desColor};
|
|
197
195
|
font-weight: ${desFontWeight};
|
|
@@ -199,7 +197,7 @@ Component({
|
|
|
199
197
|
text-align: ${textAlign};
|
|
200
198
|
line-height: ${desLineHeight == 'auto' ? 'normal' : desLineHeight};
|
|
201
199
|
`;
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
this.setData({ desStyle });
|
|
201
|
+
},
|
|
204
202
|
},
|
|
205
203
|
});
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
unequal: 'neq', // 不等于
|
|
5
|
-
include: 'search', // 包含
|
|
6
|
-
exclude: '_exclude', // 不包含
|
|
7
|
-
begin_with: '_begin_with', // 开头是
|
|
8
|
-
greater: 'gt', // 大于
|
|
9
|
-
greater_or_equal: 'gte', // 大于等于
|
|
10
|
-
less: 'lt', // 小于
|
|
11
|
-
less_or_equal: 'lte', // 小于等于
|
|
12
|
-
in: 'in', // 多选值
|
|
13
|
-
not_in: 'nin', // 不在多选值
|
|
14
|
-
};
|
|
1
|
+
import { REL_DICT } from '../../utils/constant';
|
|
2
|
+
import { isNil } from '../../utils/lodash';
|
|
3
|
+
|
|
15
4
|
const ORDERTYPE = ['asc', 'desc'];
|
|
16
5
|
const getWhereList = (where) => {
|
|
17
6
|
let result = [];
|
|
@@ -28,7 +17,7 @@ const getWhereList = (where) => {
|
|
|
28
17
|
rel = 'regex';
|
|
29
18
|
val = `^((?!${val}).)*$`;
|
|
30
19
|
}
|
|
31
|
-
if (item2?.logic !== 'or' && item2?.key && rel && !
|
|
20
|
+
if (item2?.logic !== 'or' && item2?.key && rel && !isNil(val)) {
|
|
32
21
|
result.push({ key: item2.key, rel, val });
|
|
33
22
|
}
|
|
34
23
|
});
|
|
@@ -38,7 +27,6 @@ const getWhereList = (where) => {
|
|
|
38
27
|
};
|
|
39
28
|
const DEFAULT_DATA = {
|
|
40
29
|
pageNo: 1,
|
|
41
|
-
loading: false,
|
|
42
30
|
total: 0,
|
|
43
31
|
records: [],
|
|
44
32
|
pageStr: '0/0',
|
|
@@ -90,7 +78,7 @@ Component({
|
|
|
90
78
|
value: (v) => v,
|
|
91
79
|
},
|
|
92
80
|
},
|
|
93
|
-
data: { ...DEFAULT_DATA },
|
|
81
|
+
data: { ...DEFAULT_DATA, isReLoad: false, loading: false },
|
|
94
82
|
methods: {
|
|
95
83
|
/**
|
|
96
84
|
* 列表容器拉取数据,放在 setData 的回调函数中执行
|
|
@@ -98,10 +86,10 @@ Component({
|
|
|
98
86
|
_fetchData: async function () {
|
|
99
87
|
const { app } = getApp();
|
|
100
88
|
const callDataSource = app?.cloud?.callDataSource;
|
|
101
|
-
const { pageNo, loading } = this.data;
|
|
89
|
+
const { pageNo, loading, isReLoad } = this.data;
|
|
102
90
|
const { datasource, orderBy, orderType, where, pageSize } =
|
|
103
91
|
this.properties;
|
|
104
|
-
if (loading) return;
|
|
92
|
+
if (loading && !isReLoad) return;
|
|
105
93
|
if (!callDataSource) {
|
|
106
94
|
console.warn(`当前环境缺少方法 app.cloud.callDataSource`);
|
|
107
95
|
return;
|
|
@@ -115,7 +103,7 @@ Component({
|
|
|
115
103
|
const tcbParams = {};
|
|
116
104
|
|
|
117
105
|
// tcb分页参数
|
|
118
|
-
if (!
|
|
106
|
+
if (!isNil(pageNo) && !isNil(pageSize)) {
|
|
119
107
|
tcbParams['pageNo'] = pageNo;
|
|
120
108
|
tcbParams['pageSize'] = pageSize;
|
|
121
109
|
}
|
|
@@ -128,32 +116,40 @@ Component({
|
|
|
128
116
|
const whereEffected = [].concat(getWhereList(where));
|
|
129
117
|
whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
|
|
130
118
|
// tcb结果和事件
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
records,
|
|
147
|
-
loading: false,
|
|
148
|
-
pageStr: `${total > 0 ? pageNo : 0}/${
|
|
149
|
-
Math.ceil(total / pageSize) || 0
|
|
150
|
-
}`,
|
|
151
|
-
},
|
|
152
|
-
() => {
|
|
153
|
-
this._handleEvents(data);
|
|
154
|
-
setTimeout(() => this._firstScreenLoadMore(), 150);
|
|
119
|
+
try {
|
|
120
|
+
const data = await callDataSource({
|
|
121
|
+
dataSourceName,
|
|
122
|
+
methodName,
|
|
123
|
+
params: tcbParams,
|
|
124
|
+
});
|
|
125
|
+
let records = data?.records || [];
|
|
126
|
+
let total = data?.total || 0;
|
|
127
|
+
if (
|
|
128
|
+
['loadMoreButton', 'bottomLoad'].includes(
|
|
129
|
+
this.properties.pagination
|
|
130
|
+
) &&
|
|
131
|
+
!isReLoad
|
|
132
|
+
) {
|
|
133
|
+
records = [...this.data.records, ...records]; // TODO 可能存在单次 setData 数据量过大引起小程序性能问题
|
|
155
134
|
}
|
|
156
|
-
|
|
135
|
+
this.setData(
|
|
136
|
+
{
|
|
137
|
+
total,
|
|
138
|
+
records,
|
|
139
|
+
loading: false,
|
|
140
|
+
isReLoad: false,
|
|
141
|
+
pageStr: `${total > 0 ? pageNo : 0}/${
|
|
142
|
+
Math.ceil(total / pageSize) || 0
|
|
143
|
+
}`,
|
|
144
|
+
},
|
|
145
|
+
() => {
|
|
146
|
+
this._handleEvents(data);
|
|
147
|
+
setTimeout(() => this._firstScreenLoadMore(), 150);
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
} catch (e) {
|
|
151
|
+
this.setData({ loading: false });
|
|
152
|
+
}
|
|
157
153
|
},
|
|
158
154
|
/**
|
|
159
155
|
* 下一页
|
|
@@ -236,31 +232,22 @@ Component({
|
|
|
236
232
|
_observerSign: function () {
|
|
237
233
|
this.signObserver = this.createIntersectionObserver();
|
|
238
234
|
this.signObserver
|
|
239
|
-
.
|
|
235
|
+
.relativeToViewport()
|
|
240
236
|
.observe('#weda-list-view_sign', (res) => {
|
|
241
237
|
this.setData({ isVisiableSign: res?.intersectionRatio > 0 });
|
|
242
238
|
});
|
|
243
239
|
},
|
|
244
240
|
},
|
|
245
241
|
observers: {
|
|
246
|
-
'datasource,orderBy,orderType,where,pageSize,pagination': function (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
dDatasource !== this.properties.datasource ||
|
|
256
|
-
dOrderBy !== this.properties.orderBy ||
|
|
257
|
-
dOrderType !== this.properties.orderType ||
|
|
258
|
-
dWhere !== this.properties.where ||
|
|
259
|
-
dPageSize !== this.properties.pageSize ||
|
|
260
|
-
dPagination !== this.properties.pagination
|
|
261
|
-
) {
|
|
262
|
-
this.setData({ ...DEFAULT_DATA }, () => this._fetchData());
|
|
263
|
-
}
|
|
242
|
+
'datasource,orderBy,orderType,where,pageSize,pagination': function () {
|
|
243
|
+
clearTimeout(this._timer);
|
|
244
|
+
this._timer = setTimeout(
|
|
245
|
+
() =>
|
|
246
|
+
this.setData({ ...DEFAULT_DATA, isReLoad: true }, () =>
|
|
247
|
+
this._fetchData()
|
|
248
|
+
),
|
|
249
|
+
200
|
|
250
|
+
);
|
|
264
251
|
},
|
|
265
252
|
isVisiableSign: function (dIsVisiableSign) {
|
|
266
253
|
if (dIsVisiableSign && this.properties.pagination === 'bottomLoad') {
|
|
@@ -275,6 +262,7 @@ Component({
|
|
|
275
262
|
},
|
|
276
263
|
lifetimes: {
|
|
277
264
|
attached: function () {
|
|
265
|
+
clearTimeout(this._timer);
|
|
278
266
|
this._fetchData();
|
|
279
267
|
this._observerSign();
|
|
280
268
|
},
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<scroll-view scroll-y scroll-with-animation lower-threshold="5" style="
|
|
1
|
+
<scroll-view scroll-y scroll-with-animation lower-threshold="5" style="{{style}}"
|
|
2
2
|
class="weda-list-view__containor weda-ui {{className}}">
|
|
3
3
|
<!-- 列表插槽 -->
|
|
4
4
|
<view class="{{template === 'cardList' ? 'weda-list-view-card' : ''}}" id="weda-list-view_content">
|
|
5
5
|
<slot></slot>
|
|
6
6
|
</view>
|
|
7
7
|
|
|
8
|
-
<view class="weda-list-view__more">
|
|
8
|
+
<view class="weda-list-view__more {{'weda-list-view__more-' + pagination}}">
|
|
9
9
|
<!-- 加载更多 -->
|
|
10
10
|
<block wx:if="{{pagination==='loadMoreButton' && pageSize * pageNo < total}}">
|
|
11
11
|
<view class="weda-list-view__more-text" bindtap="handleNext">加载更多</view>
|