@xtdev/xt-miniprogram-ui 1.2.73 → 1.2.74
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.
|
@@ -26,6 +26,10 @@ Component({
|
|
|
26
26
|
type: String,
|
|
27
27
|
value: "",
|
|
28
28
|
},
|
|
29
|
+
icon: {
|
|
30
|
+
type: String,
|
|
31
|
+
value: "https://img.tanjiu.cn/home/DDDsrH7PpNhneQsXGFmGGPcSM3QYXG8N.png",
|
|
32
|
+
},
|
|
29
33
|
fileList: {
|
|
30
34
|
type: Array,
|
|
31
35
|
value: [],
|
|
@@ -43,6 +47,10 @@ Component({
|
|
|
43
47
|
type: Array,
|
|
44
48
|
value: ["album", "camera"],
|
|
45
49
|
},
|
|
50
|
+
fileType: {
|
|
51
|
+
type: String,
|
|
52
|
+
value: "image",
|
|
53
|
+
},
|
|
46
54
|
customUpload: {
|
|
47
55
|
type: Boolean,
|
|
48
56
|
value: false,
|
|
@@ -104,6 +112,7 @@ Component({
|
|
|
104
112
|
max,
|
|
105
113
|
sourceType,
|
|
106
114
|
fileList,
|
|
115
|
+
fileType,
|
|
107
116
|
} = this.properties;
|
|
108
117
|
if (customUpload) {
|
|
109
118
|
this.triggerEvent("upload", {});
|
|
@@ -119,14 +128,20 @@ Component({
|
|
|
119
128
|
// ios企微环境下不支持该API
|
|
120
129
|
const { platform, environment } = this.getSystemInfo();
|
|
121
130
|
console.log(platform, environment);
|
|
122
|
-
let chooseImgApi = (environment !== "wxwork" || platform !== "ios") ? wx.chooseMedia : wx.chooseImage;
|
|
131
|
+
let chooseImgApi = (environment !== "wxwork" || platform !== "ios") ? wx.chooseMedia : fileType == 'video' ? wx.chooseVideo : wx.chooseImage;
|
|
123
132
|
chooseImgApi({
|
|
124
133
|
count: max - fileList.length,
|
|
125
134
|
mediaType: ["image"],
|
|
135
|
+
mediaType: fileType == "video" ? ["video"] : ["image"],
|
|
126
136
|
sizeType: ["compressed"],
|
|
127
137
|
sourceType,
|
|
128
138
|
success(res) {
|
|
129
139
|
console.log(res, "0000");
|
|
140
|
+
if (fileType == "video" && res.tempFiles[0].size / 1024 / 1024 > 100) {
|
|
141
|
+
// 视频上传不允许超过100M
|
|
142
|
+
wx.showToast({title: '视频大小不可超过100M', icon: "none"});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
130
145
|
// tempFilePath可以作为img标签的src属性显示图片
|
|
131
146
|
const tempFilePaths = res.tempFiles;
|
|
132
147
|
if (Array.isArray(tempFilePaths) && tempFilePaths.length) {
|
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
<view class="title_text" wx:if="{{title}}">{{title}}</view>
|
|
4
4
|
<view class="file_box">
|
|
5
5
|
<view wx:for="{{fileList}}" wx:key="index" class="file_item">
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
<block wx:if="{{fileType == 'video'}}">
|
|
7
|
+
<video class="file_img" src="{{item}}" mode="aspectFill" data-url="{{item}}" data-index="{{index}}" />
|
|
8
|
+
<!-- 删除 -->
|
|
9
|
+
<image src="https://img.tanjiu.cn/home/idzQXfttSiQryeX3jYEfc5xjWhZPdwY4.png" class="close_box" mode="aspectFill" bindtap="onDelete" data-url="{{item}}" data-index="{{index}}" wx:if="{{!disabled}}"></image>
|
|
10
|
+
</block>
|
|
11
|
+
<block wx:else>
|
|
12
|
+
<image class="file_img" src="{{item}}" mode="aspectFit" bindtap="onPreviewImage" data-url="{{item}}" data-index="{{index}}" />
|
|
13
|
+
<!-- 删除 -->
|
|
14
|
+
<xt-icon icon="shanchu" size="48" class="close_box" bindtap="onDelete" data-url="{{item}}" data-index="{{index}}" wx:if="{{!disabled}}"></xt-icon>
|
|
15
|
+
</block>
|
|
9
16
|
</view>
|
|
10
17
|
<view class="file_item" wx:if="{{!disabled && fileList.length<max}}" bindtap="startTakePhoto">
|
|
11
|
-
<image src="
|
|
18
|
+
<image src="{{icon}}" class="camera_icon" />
|
|
12
19
|
<view wx:if="{{uploadDesc}}" class="upload_desc">{{uploadDesc}}</view>
|
|
13
20
|
</view>
|
|
14
21
|
</view>
|