@xtdev/xt-miniprogram-ui 1.2.73 → 1.2.75

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,
@@ -55,6 +63,17 @@ Component({
55
63
  type: Object,
56
64
  value: {},
57
65
  },
66
+ /**
67
+ * 打水印参数
68
+ * {
69
+ * content: '',
70
+ * postion: ''
71
+ * }
72
+ */
73
+ waterData: {
74
+ type: Object | null,
75
+ value: null
76
+ },
58
77
  },
59
78
 
60
79
  /**
@@ -104,6 +123,8 @@ Component({
104
123
  max,
105
124
  sourceType,
106
125
  fileList,
126
+ fileType,
127
+ waterData,
107
128
  } = this.properties;
108
129
  if (customUpload) {
109
130
  this.triggerEvent("upload", {});
@@ -119,20 +140,26 @@ Component({
119
140
  // ios企微环境下不支持该API
120
141
  const { platform, environment } = this.getSystemInfo();
121
142
  console.log(platform, environment);
122
- let chooseImgApi = (environment !== "wxwork" || platform !== "ios") ? wx.chooseMedia : wx.chooseImage;
143
+ let chooseImgApi = (environment !== "wxwork" || platform !== "ios") ? wx.chooseMedia : fileType == 'video' ? wx.chooseVideo : wx.chooseImage;
123
144
  chooseImgApi({
124
145
  count: max - fileList.length,
125
146
  mediaType: ["image"],
147
+ mediaType: fileType == "video" ? ["video"] : ["image"],
126
148
  sizeType: ["compressed"],
127
149
  sourceType,
128
150
  success(res) {
129
151
  console.log(res, "0000");
152
+ if (fileType == "video" && res.tempFiles[0].size / 1024 / 1024 > 100) {
153
+ // 视频上传不允许超过100M
154
+ wx.showToast({title: '视频大小不可超过100M', icon: "none"});
155
+ return;
156
+ }
130
157
  // tempFilePath可以作为img标签的src属性显示图片
131
158
  const tempFilePaths = res.tempFiles;
132
159
  if (Array.isArray(tempFilePaths) && tempFilePaths.length) {
133
160
  Promise.allSettled(
134
161
  tempFilePaths.map((temp) =>
135
- _this.uploadImage_v(temp.tempFilePath || temp.path)
162
+ _this[waterData?'uploadWaterFile' : 'uploadImage_v'](temp.tempFilePath || temp.path, waterData)
136
163
  )
137
164
  ).then((uploadRes) => {
138
165
  wx.hideLoading();
@@ -169,6 +196,43 @@ Component({
169
196
  platform,
170
197
  };
171
198
  },
199
+ /** 上传水印照片 */
200
+ async uploadWaterFile(
201
+ path,
202
+ data = {},
203
+ url = "core/file/upload/multiV2",
204
+ baseUrl = "https://gateway.tanjiu.cn/",
205
+ ) {
206
+ return new Promise((reslove, reject) => {
207
+ let fullUrl = baseUrl + url;
208
+ wx.showLoading("上传中");
209
+ wx.uploadFile({
210
+ url: fullUrl,
211
+ filePath: path,
212
+ name: "file",
213
+ formData: data,
214
+ header: {
215
+ "Content-Type": "multipart/form-data",
216
+ "wow-token": "c9fbecb5fdeecb78e8745db9225d88e1",
217
+ },
218
+ success: (res) => {
219
+ let result = JSON.parse(res.data);
220
+ if (result.code == "0000") {
221
+ reslove(result.data[0]);
222
+ } else {
223
+ reject(result.msg)
224
+ }
225
+ },
226
+ fail: (err) => {
227
+ wx.showToast({
228
+ title: '上传失败',
229
+ icon: "error",
230
+ })
231
+ reject(err);
232
+ },
233
+ });
234
+ });
235
+ },
172
236
  // 上传文件
173
237
  uploadImage_v(filePaths) {
174
238
  return new Promise((resolve, reject) => {
@@ -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
- <image class="file_img" src="{{item}}" mode="aspectFit" bindtap="onPreviewImage" data-url="{{item}}" data-index="{{index}}" />
7
- <!-- 删除 -->
8
- <xt-icon icon="shanchu" size="48" class="close_box" bindtap="onDelete" data-url="{{item}}" data-index="{{index}}" wx:if="{{!disabled}}"></xt-icon>
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="https://img.tanjiu.cn/home/DDDsrH7PpNhneQsXGFmGGPcSM3QYXG8N.png" class="camera_icon" />
18
+ <image src="{{icon}}" class="camera_icon" />
12
19
  <view wx:if="{{uploadDesc}}" class="upload_desc">{{uploadDesc}}</view>
13
20
  </view>
14
21
  </view>
@@ -52,6 +52,8 @@
52
52
  .close_box {
53
53
  position : absolute;
54
54
  line-height: 48rpx;
55
+ width : 48rpx;
56
+ height : 48rpx;
55
57
  top : 0;
56
58
  right : 0;
57
59
  color : rgba(0, 0, 0, 0.5);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtdev/xt-miniprogram-ui",
3
- "version": "1.2.73",
3
+ "version": "1.2.75",
4
4
  "description": "",
5
5
  "miniprogram": "libs",
6
6
  "publishConfig": {