@vtj/materials 0.13.16 → 0.13.18
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/dist/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +3 -3
- package/dist/assets/icons/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +2 -2
- package/dist/assets/uni-ui/index.umd.js +2 -2
- package/dist/assets/vant/index.umd.js +2 -2
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +4 -4
- package/dist/deps/@vtj/ui/style.css +1 -1
- package/dist/deps/@vtj/utils/index.umd.js +28 -33
- package/dist/deps/@vueuse/core/index.iife.min.js +1 -1
- package/dist/deps/element-plus/index.css +1 -1
- package/dist/deps/element-plus/index.full.min.js +14 -14
- package/dist/deps/element-plus/zh-cn.js +1 -1
- package/dist/deps/uni-app/index.umd.js +1 -1
- package/dist/deps/uni-h5/index.umd.js +8 -8
- package/dist/deps/uni-h5/style.css +1 -1
- package/dist/deps/uni-h5-vue/index.umd.js +1 -1
- package/dist/deps/uni-ui/index.umd.js +1 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/dist/deps/vue/vue.global.js +88 -53
- package/dist/deps/vue/vue.global.prod.js +9 -9
- package/package.json +12 -12
- package/src/antdv/image.ts +1 -1
- package/src/element/image.ts +1 -1
- package/src/element/virtualizedTable.ts +6 -6
- package/src/manifest.json +69 -0
- package/src/pages/index.vue +2 -0
- package/src/pages.json +19 -0
- package/src/uni-ui/index.ts +88 -58
- package/src/{uni-ui/lib/uni.scss → uni.scss} +4 -0
- package/src/version.ts +2 -2
- package/src/uni-ui/lib/uni-col/uni-col.vue +0 -324
- package/src/uni-ui/lib/uni-collapse/uni-collapse.vue +0 -153
- package/src/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +0 -425
- package/src/uni-ui/lib/uni-data-picker/keypress.js +0 -45
- package/src/uni-ui/lib/uni-data-picker/uni-data-picker.vue +0 -604
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +0 -622
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.css +0 -76
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +0 -335
- package/src/uni-ui/lib/uni-data-select/uni-data-select.vue +0 -590
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +0 -188
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +0 -985
- package/src/uni-ui/lib/uni-datetime-picker/i18n/en.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hans.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hant.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +0 -1032
- package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +0 -1230
- package/src/uni-ui/lib/uni-datetime-picker/util.js +0 -448
- package/src/uni-ui/lib/uni-easyinput/common.js +0 -54
- package/src/uni-ui/lib/uni-easyinput/uni-easyinput.vue +0 -790
- package/src/uni-ui/lib/uni-fav/i18n/en.json +0 -4
- package/src/uni-ui/lib/uni-fav/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hans.json +0 -4
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hant.json +0 -4
- package/src/uni-ui/lib/uni-fav/uni-fav.vue +0 -170
- package/src/uni-ui/lib/uni-file-picker/choose-and-upload-file.js +0 -280
- package/src/uni-ui/lib/uni-file-picker/uni-file-picker.vue +0 -668
- package/src/uni-ui/lib/uni-file-picker/upload-file.vue +0 -325
- package/src/uni-ui/lib/uni-file-picker/upload-image.vue +0 -292
- package/src/uni-ui/lib/uni-file-picker/utils.js +0 -110
- package/src/uni-ui/lib/uni-forms/uni-forms.vue +0 -416
- package/src/uni-ui/lib/uni-forms/utils.js +0 -293
- package/src/uni-ui/lib/uni-forms/validate.js +0 -486
- package/src/uni-ui/lib/uni-forms-item/uni-forms-item.vue +0 -630
- package/src/uni-ui/lib/uni-goods-nav/i18n/en.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hans.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hant.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +0 -231
- package/src/uni-ui/lib/uni-grid/uni-grid.vue +0 -148
- package/src/uni-ui/lib/uni-icons/uni-icons.uvue +0 -91
- package/src/uni-ui/lib/uni-icons/uni-icons.vue +0 -114
- package/src/uni-ui/lib/uni-icons/uniicons.css +0 -664
- package/src/uni-ui/lib/uni-icons/uniicons.ttf +0 -0
- package/src/uni-ui/lib/uni-icons/uniicons_file.ts +0 -664
- package/src/uni-ui/lib/uni-icons/uniicons_file_vue.js +0 -649
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +0 -168
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +0 -404
- package/src/uni-ui/lib/uni-list/uni-list.vue +0 -123
- package/src/uni-ui/lib/uni-list/uni-refresh.vue +0 -65
- package/src/uni-ui/lib/uni-list/uni-refresh.wxs +0 -87
- package/src/uni-ui/lib/uni-load-more/i18n/en.json +0 -5
- package/src/uni-ui/lib/uni-load-more/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hans.json +0 -5
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hant.json +0 -5
- package/src/uni-ui/lib/uni-load-more/uni-load-more.vue +0 -456
- package/src/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +0 -484
- package/src/uni-ui/lib/uni-popup/i18n/en.json +0 -7
- package/src/uni-ui/lib/uni-popup/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hans.json +0 -7
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hant.json +0 -7
- package/src/uni-ui/lib/uni-popup/keypress.js +0 -45
- package/src/uni-ui/lib/uni-popup/popup.js +0 -26
- package/src/uni-ui/lib/uni-popup/uni-popup.uvue +0 -90
- package/src/uni-ui/lib/uni-popup/uni-popup.vue +0 -552
- package/src/uni-ui/lib/uni-popup-dialog/keypress.js +0 -45
- package/src/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +0 -324
- package/src/uni-ui/lib/uni-popup-message/uni-popup-message.vue +0 -149
- package/src/uni-ui/lib/uni-rate/uni-rate.vue +0 -380
- package/src/uni-ui/lib/uni-row/uni-row.vue +0 -193
- package/src/uni-ui/lib/uni-search-bar/i18n/en.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hans.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hant.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/uni-search-bar.vue +0 -339
- package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +0 -311
- package/src/uni-ui/lib/uni-swipe-action-item/isPC.js +0 -12
- package/src/uni-ui/lib/uni-swipe-action-item/mpalipay.js +0 -195
- package/src/uni-ui/lib/uni-swipe-action-item/mpother.js +0 -260
- package/src/uni-ui/lib/uni-swipe-action-item/mpwxs.js +0 -84
- package/src/uni-ui/lib/uni-swipe-action-item/render.js +0 -270
- package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +0 -493
- package/src/uni-ui/lib/uni-swipe-action-item/wx.wxs +0 -341
- package/src/uni-ui/lib/uni-table/uni-table.vue +0 -496
- package/src/uni-ui/lib/uni-td/uni-td.vue +0 -99
- package/src/uni-ui/lib/uni-th/filter-dropdown.vue +0 -559
- package/src/uni-ui/lib/uni-th/uni-th.vue +0 -322
- package/src/uni-ui/lib/uni-tr/table-checkbox.vue +0 -181
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +0 -208
- package/src/uni-ui/lib/uni-transition/createAnimation.js +0 -131
- package/src/uni-ui/lib/uni-transition/uni-transition.vue +0 -310
- package/src/uni-ui/polyfill.ts +0 -41
@@ -1,170 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<view
|
3
|
-
:class="[circle === true || circle === 'true' ? 'uni-fav--circle' : '']"
|
4
|
-
:style="[{ backgroundColor: checked ? bgColorChecked : bgColor }]"
|
5
|
-
@click="onClick"
|
6
|
-
class="uni-fav">
|
7
|
-
<!-- #ifdef MP-ALIPAY -->
|
8
|
-
<!-- <view class="uni-fav-star" v-if="!checked && (star === true || star === 'true')">
|
9
|
-
<uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" size="14" type="star-filled" />
|
10
|
-
</view> -->
|
11
|
-
<!-- #endif -->
|
12
|
-
<!-- #ifndef MP-ALIPAY -->
|
13
|
-
<uni-icons
|
14
|
-
:color="fgColor"
|
15
|
-
:style="{ color: checked ? fgColorChecked : fgColor }"
|
16
|
-
class="uni-fav-star"
|
17
|
-
size="14"
|
18
|
-
type="star-filled"
|
19
|
-
v-if="!checked && (star === true || star === 'true')" />
|
20
|
-
<!-- #endif -->
|
21
|
-
<text
|
22
|
-
:style="{ color: checked ? fgColorChecked : fgColor }"
|
23
|
-
class="uni-fav-text"
|
24
|
-
>{{ checked ? contentFav : contentDefault }}</text
|
25
|
-
>
|
26
|
-
</view>
|
27
|
-
</template>
|
28
|
-
|
29
|
-
<script>
|
30
|
-
/**
|
31
|
-
* Fav 收藏按钮
|
32
|
-
* @description 用于收藏功能,可点击切换选中、不选中的状态
|
33
|
-
* @tutorial https://ext.dcloud.net.cn/plugin?id=864
|
34
|
-
* @property {Boolean} star = [true|false] 按钮是否带星星
|
35
|
-
* @property {String} bgColor 未收藏时的背景色
|
36
|
-
* @property {String} bgColorChecked 已收藏时的背景色
|
37
|
-
* @property {String} fgColor 未收藏时的文字颜色
|
38
|
-
* @property {String} fgColorChecked 已收藏时的文字颜色
|
39
|
-
* @property {Boolean} circle = [true|false] 是否为圆角
|
40
|
-
* @property {Boolean} checked = [true|false] 是否为已收藏
|
41
|
-
* @property {Object} contentText = [true|false] 收藏按钮文字
|
42
|
-
* @property {Boolean} stat 是否开启统计功能
|
43
|
-
* @event {Function} click 点击 fav按钮触发事件
|
44
|
-
* @example <uni-fav :checked="true"/>
|
45
|
-
*/
|
46
|
-
|
47
|
-
import { initVueI18n } from '@dcloudio/uni-i18n';
|
48
|
-
import messages from './i18n/index.js';
|
49
|
-
const { t } = initVueI18n(messages);
|
50
|
-
|
51
|
-
export default {
|
52
|
-
name: 'UniFav',
|
53
|
-
// TODO 兼容 vue3,需要注册事件
|
54
|
-
emits: ['click'],
|
55
|
-
props: {
|
56
|
-
star: {
|
57
|
-
type: [Boolean, String],
|
58
|
-
default: true
|
59
|
-
},
|
60
|
-
bgColor: {
|
61
|
-
type: String,
|
62
|
-
default: '#eeeeee'
|
63
|
-
},
|
64
|
-
fgColor: {
|
65
|
-
type: String,
|
66
|
-
default: '#666666'
|
67
|
-
},
|
68
|
-
bgColorChecked: {
|
69
|
-
type: String,
|
70
|
-
default: '#007aff'
|
71
|
-
},
|
72
|
-
fgColorChecked: {
|
73
|
-
type: String,
|
74
|
-
default: '#FFFFFF'
|
75
|
-
},
|
76
|
-
circle: {
|
77
|
-
type: [Boolean, String],
|
78
|
-
default: false
|
79
|
-
},
|
80
|
-
checked: {
|
81
|
-
type: Boolean,
|
82
|
-
default: false
|
83
|
-
},
|
84
|
-
contentText: {
|
85
|
-
type: Object,
|
86
|
-
default() {
|
87
|
-
return {
|
88
|
-
contentDefault: '',
|
89
|
-
contentFav: ''
|
90
|
-
};
|
91
|
-
}
|
92
|
-
},
|
93
|
-
stat: {
|
94
|
-
type: Boolean,
|
95
|
-
default: false
|
96
|
-
}
|
97
|
-
},
|
98
|
-
computed: {
|
99
|
-
contentDefault() {
|
100
|
-
return this.contentText.contentDefault || t('uni-fav.collect');
|
101
|
-
},
|
102
|
-
contentFav() {
|
103
|
-
return this.contentText.contentFav || t('uni-fav.collected');
|
104
|
-
}
|
105
|
-
},
|
106
|
-
watch: {
|
107
|
-
checked() {
|
108
|
-
if (uni.report && this.stat) {
|
109
|
-
if (this.checked) {
|
110
|
-
uni.report('收藏', '收藏');
|
111
|
-
} else {
|
112
|
-
uni.report('取消收藏', '取消收藏');
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
},
|
117
|
-
methods: {
|
118
|
-
onClick() {
|
119
|
-
this.$emit('click');
|
120
|
-
}
|
121
|
-
}
|
122
|
-
};
|
123
|
-
</script>
|
124
|
-
|
125
|
-
<style lang="scss">
|
126
|
-
$fav-height: 25px;
|
127
|
-
|
128
|
-
.uni-fav {
|
129
|
-
/* #ifndef APP-NVUE */
|
130
|
-
display: flex;
|
131
|
-
/* #endif */
|
132
|
-
flex-direction: row;
|
133
|
-
align-items: center;
|
134
|
-
justify-content: center;
|
135
|
-
width: 60px;
|
136
|
-
height: $fav-height;
|
137
|
-
line-height: $fav-height;
|
138
|
-
text-align: center;
|
139
|
-
border-radius: 3px;
|
140
|
-
/* #ifdef H5 */
|
141
|
-
cursor: pointer;
|
142
|
-
/* #endif */
|
143
|
-
}
|
144
|
-
|
145
|
-
.uni-fav--circle {
|
146
|
-
border-radius: 30px;
|
147
|
-
}
|
148
|
-
|
149
|
-
.uni-fav-star {
|
150
|
-
/* #ifndef APP-NVUE */
|
151
|
-
display: flex;
|
152
|
-
/* #endif */
|
153
|
-
height: $fav-height;
|
154
|
-
line-height: 24px;
|
155
|
-
margin-right: 3px;
|
156
|
-
align-items: center;
|
157
|
-
justify-content: center;
|
158
|
-
}
|
159
|
-
|
160
|
-
.uni-fav-text {
|
161
|
-
/* #ifndef APP-NVUE */
|
162
|
-
display: flex;
|
163
|
-
/* #endif */
|
164
|
-
height: $fav-height;
|
165
|
-
line-height: $fav-height;
|
166
|
-
align-items: center;
|
167
|
-
justify-content: center;
|
168
|
-
font-size: 12px;
|
169
|
-
}
|
170
|
-
</style>
|
@@ -1,280 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const ERR_MSG_OK = 'chooseAndUploadFile:ok';
|
4
|
-
const ERR_MSG_FAIL = 'chooseAndUploadFile:fail';
|
5
|
-
|
6
|
-
function chooseImage(opts) {
|
7
|
-
const {
|
8
|
-
count,
|
9
|
-
sizeType = ['original', 'compressed'],
|
10
|
-
sourceType,
|
11
|
-
extension
|
12
|
-
} = opts;
|
13
|
-
return new Promise((resolve, reject) => {
|
14
|
-
// 微信由于旧接口不再维护,针对微信小程序平台改用chooseMedia接口
|
15
|
-
// #ifdef MP-WEIXIN
|
16
|
-
// uni.chooseMedia({
|
17
|
-
// count,
|
18
|
-
// sizeType,
|
19
|
-
// sourceType,
|
20
|
-
// mediaType: ['image'],
|
21
|
-
// extension,
|
22
|
-
// success(res) {
|
23
|
-
// res.tempFiles.forEach(item => {
|
24
|
-
// item.path = item.tempFilePath;
|
25
|
-
// })
|
26
|
-
// resolve(normalizeChooseAndUploadFileRes(res, 'image'));
|
27
|
-
// },
|
28
|
-
// fail(res) {
|
29
|
-
// reject({
|
30
|
-
// errMsg: res.errMsg.replace('chooseImage:fail', ERR_MSG_FAIL),
|
31
|
-
// });
|
32
|
-
// },
|
33
|
-
// })
|
34
|
-
// #endif
|
35
|
-
// #ifndef MP-WEIXIN
|
36
|
-
uni.chooseImage({
|
37
|
-
count,
|
38
|
-
sizeType,
|
39
|
-
sourceType,
|
40
|
-
extension,
|
41
|
-
success(res) {
|
42
|
-
resolve(normalizeChooseAndUploadFileRes(res, 'image'));
|
43
|
-
},
|
44
|
-
fail(res) {
|
45
|
-
reject({
|
46
|
-
errMsg: res.errMsg.replace('chooseImage:fail', ERR_MSG_FAIL)
|
47
|
-
});
|
48
|
-
}
|
49
|
-
});
|
50
|
-
// #endif
|
51
|
-
});
|
52
|
-
}
|
53
|
-
|
54
|
-
function chooseVideo(opts) {
|
55
|
-
const { count, camera, compressed, maxDuration, sourceType, extension } =
|
56
|
-
opts;
|
57
|
-
return new Promise((resolve, reject) => {
|
58
|
-
// 微信由于旧接口不再维护,针对微信小程序平台改用chooseMedia接口
|
59
|
-
// #ifdef MP-WEIXIN
|
60
|
-
// uni.chooseMedia({
|
61
|
-
// count,
|
62
|
-
// compressed,
|
63
|
-
// maxDuration,
|
64
|
-
// sourceType,
|
65
|
-
// extension,
|
66
|
-
// mediaType: ['video'],
|
67
|
-
// success(res) {
|
68
|
-
// const { tempFiles } = res;
|
69
|
-
// resolve(
|
70
|
-
// normalizeChooseAndUploadFileRes(
|
71
|
-
// {
|
72
|
-
// errMsg: 'chooseVideo:ok',
|
73
|
-
// tempFiles: tempFiles.map((item) => {
|
74
|
-
// return {
|
75
|
-
// name: item.name || '',
|
76
|
-
// path: item.tempFilePath,
|
77
|
-
// thumbTempFilePath: item.thumbTempFilePath,
|
78
|
-
// size: item.size,
|
79
|
-
// type: (res.tempFile && res.tempFile.type) || '',
|
80
|
-
// width: item.width,
|
81
|
-
// height: item.height,
|
82
|
-
// duration: item.duration,
|
83
|
-
// fileType: 'video',
|
84
|
-
// cloudPath: ''
|
85
|
-
// };
|
86
|
-
// })
|
87
|
-
// },
|
88
|
-
// 'video'
|
89
|
-
// )
|
90
|
-
// );
|
91
|
-
// },
|
92
|
-
// fail(res) {
|
93
|
-
// reject({
|
94
|
-
// errMsg: res.errMsg.replace('chooseVideo:fail', ERR_MSG_FAIL)
|
95
|
-
// });
|
96
|
-
// }
|
97
|
-
// });
|
98
|
-
// #endif
|
99
|
-
// #ifndef MP-WEIXIN
|
100
|
-
uni.chooseVideo({
|
101
|
-
camera,
|
102
|
-
compressed,
|
103
|
-
maxDuration,
|
104
|
-
sourceType,
|
105
|
-
extension,
|
106
|
-
success(res) {
|
107
|
-
const { tempFilePath, duration, size, height, width } = res;
|
108
|
-
resolve(
|
109
|
-
normalizeChooseAndUploadFileRes(
|
110
|
-
{
|
111
|
-
errMsg: 'chooseVideo:ok',
|
112
|
-
tempFilePaths: [tempFilePath],
|
113
|
-
tempFiles: [
|
114
|
-
{
|
115
|
-
name: (res.tempFile && res.tempFile.name) || '',
|
116
|
-
path: tempFilePath,
|
117
|
-
size,
|
118
|
-
type: (res.tempFile && res.tempFile.type) || '',
|
119
|
-
width,
|
120
|
-
height,
|
121
|
-
duration,
|
122
|
-
fileType: 'video',
|
123
|
-
cloudPath: ''
|
124
|
-
}
|
125
|
-
]
|
126
|
-
},
|
127
|
-
'video'
|
128
|
-
)
|
129
|
-
);
|
130
|
-
},
|
131
|
-
fail(res) {
|
132
|
-
reject({
|
133
|
-
errMsg: res.errMsg.replace('chooseVideo:fail', ERR_MSG_FAIL)
|
134
|
-
});
|
135
|
-
}
|
136
|
-
});
|
137
|
-
// #endif
|
138
|
-
});
|
139
|
-
}
|
140
|
-
|
141
|
-
function chooseAll(opts) {
|
142
|
-
const { count, extension } = opts;
|
143
|
-
return new Promise((resolve, reject) => {
|
144
|
-
let chooseFile = uni.chooseFile;
|
145
|
-
if (
|
146
|
-
typeof wx !== 'undefined' &&
|
147
|
-
typeof wx.chooseMessageFile === 'function'
|
148
|
-
) {
|
149
|
-
chooseFile = wx.chooseMessageFile;
|
150
|
-
}
|
151
|
-
if (typeof chooseFile !== 'function') {
|
152
|
-
return reject({
|
153
|
-
errMsg:
|
154
|
-
ERR_MSG_FAIL + ' 请指定 type 类型,该平台仅支持选择 image 或 video。'
|
155
|
-
});
|
156
|
-
}
|
157
|
-
chooseFile({
|
158
|
-
type: 'all',
|
159
|
-
count,
|
160
|
-
extension,
|
161
|
-
success(res) {
|
162
|
-
resolve(normalizeChooseAndUploadFileRes(res));
|
163
|
-
},
|
164
|
-
fail(res) {
|
165
|
-
reject({
|
166
|
-
errMsg: res.errMsg.replace('chooseFile:fail', ERR_MSG_FAIL)
|
167
|
-
});
|
168
|
-
}
|
169
|
-
});
|
170
|
-
});
|
171
|
-
}
|
172
|
-
|
173
|
-
function normalizeChooseAndUploadFileRes(res, fileType) {
|
174
|
-
res.tempFiles.forEach((item, index) => {
|
175
|
-
if (!item.name) {
|
176
|
-
item.name = item.path.substring(item.path.lastIndexOf('/') + 1);
|
177
|
-
}
|
178
|
-
if (fileType) {
|
179
|
-
item.fileType = fileType;
|
180
|
-
}
|
181
|
-
item.cloudPath =
|
182
|
-
Date.now() +
|
183
|
-
'_' +
|
184
|
-
index +
|
185
|
-
item.name.substring(item.name.lastIndexOf('.'));
|
186
|
-
});
|
187
|
-
if (!res.tempFilePaths) {
|
188
|
-
res.tempFilePaths = res.tempFiles.map((file) => file.path);
|
189
|
-
}
|
190
|
-
return res;
|
191
|
-
}
|
192
|
-
|
193
|
-
function uploadCloudFiles(files, max = 5, onUploadProgress) {
|
194
|
-
files = JSON.parse(JSON.stringify(files));
|
195
|
-
const len = files.length;
|
196
|
-
let count = 0;
|
197
|
-
let self = this;
|
198
|
-
return new Promise((resolve) => {
|
199
|
-
while (count < max) {
|
200
|
-
next();
|
201
|
-
}
|
202
|
-
|
203
|
-
function next() {
|
204
|
-
let cur = count++;
|
205
|
-
if (cur >= len) {
|
206
|
-
!files.find((item) => !item.url && !item.errMsg) && resolve(files);
|
207
|
-
return;
|
208
|
-
}
|
209
|
-
const fileItem = files[cur];
|
210
|
-
const index = self.files.findIndex((v) => v.uuid === fileItem.uuid);
|
211
|
-
fileItem.url = '';
|
212
|
-
delete fileItem.errMsg;
|
213
|
-
|
214
|
-
uniCloud
|
215
|
-
.uploadFile({
|
216
|
-
filePath: fileItem.path,
|
217
|
-
cloudPath: fileItem.cloudPath,
|
218
|
-
fileType: fileItem.fileType,
|
219
|
-
onUploadProgress: (res) => {
|
220
|
-
res.index = index;
|
221
|
-
onUploadProgress && onUploadProgress(res);
|
222
|
-
}
|
223
|
-
})
|
224
|
-
.then((res) => {
|
225
|
-
fileItem.url = res.fileID;
|
226
|
-
fileItem.index = index;
|
227
|
-
if (cur < len) {
|
228
|
-
next();
|
229
|
-
}
|
230
|
-
})
|
231
|
-
.catch((res) => {
|
232
|
-
fileItem.errMsg = res.errMsg || res.message;
|
233
|
-
fileItem.index = index;
|
234
|
-
if (cur < len) {
|
235
|
-
next();
|
236
|
-
}
|
237
|
-
});
|
238
|
-
}
|
239
|
-
});
|
240
|
-
}
|
241
|
-
|
242
|
-
function uploadFiles(choosePromise, { onChooseFile, onUploadProgress }) {
|
243
|
-
return choosePromise
|
244
|
-
.then((res) => {
|
245
|
-
if (onChooseFile) {
|
246
|
-
const customChooseRes = onChooseFile(res);
|
247
|
-
if (typeof customChooseRes !== 'undefined') {
|
248
|
-
return Promise.resolve(customChooseRes).then((chooseRes) =>
|
249
|
-
typeof chooseRes === 'undefined' ? res : chooseRes
|
250
|
-
);
|
251
|
-
}
|
252
|
-
}
|
253
|
-
return res;
|
254
|
-
})
|
255
|
-
.then((res) => {
|
256
|
-
if (res === false) {
|
257
|
-
return {
|
258
|
-
errMsg: ERR_MSG_OK,
|
259
|
-
tempFilePaths: [],
|
260
|
-
tempFiles: []
|
261
|
-
};
|
262
|
-
}
|
263
|
-
return res;
|
264
|
-
});
|
265
|
-
}
|
266
|
-
|
267
|
-
function chooseAndUploadFile(
|
268
|
-
opts = {
|
269
|
-
type: 'all'
|
270
|
-
}
|
271
|
-
) {
|
272
|
-
if (opts.type === 'image') {
|
273
|
-
return uploadFiles(chooseImage(opts), opts);
|
274
|
-
} else if (opts.type === 'video') {
|
275
|
-
return uploadFiles(chooseVideo(opts), opts);
|
276
|
-
}
|
277
|
-
return uploadFiles(chooseAll(opts), opts);
|
278
|
-
}
|
279
|
-
|
280
|
-
export { chooseAndUploadFile, uploadCloudFiles };
|