gyj 2 лет назад
Родитель
Сommit
decd8e6edb

+ 35
- 0
api/handlecase/index.js Просмотреть файл

@@ -77,4 +77,39 @@ export function updateBooking(data) {
77 77
 		method: 'post',
78 78
 		data: data
79 79
 	})
80
+}
81
+
82
+// 根据机构id查询模板
83
+export function getTemplate(data) {
84
+    return request({
85
+        url: `/deptIdentify/getTemplate`,
86
+        method: 'get',
87
+        params: data
88
+    })
89
+}
90
+
91
+// 根据身份证获取生日和性别
92
+export function getInfoByIdCard(query) {
93
+  return request({
94
+    url: '/caseApplication/getInfoByIdCard',
95
+    method: 'get',
96
+    params: query
97
+  })
98
+}
99
+
100
+/** 新增案件 */
101
+export function caseApplicationInsert(data) {
102
+  return request({
103
+    url: '/caseApplication/insert',
104
+    method: 'post',
105
+    data: data
106
+  })
107
+}
108
+// 修改立案申请接口
109
+export function updateComfire(data) {
110
+  return request({
111
+    url: "/caseApplication/update",
112
+    method: "post",
113
+    data: data,
114
+  })
80 115
 }

+ 221
- 53
pages/handlecase/component/newlyAddedCase.vue Просмотреть файл

@@ -12,11 +12,13 @@
12 12
 				<uni-forms-item label="案件标的:" name="caseSubjectAmount" label-width="120px" required>
13 13
 					<uni-easyinput v-model="formData.caseSubjectAmount" type="text" placeholder="请输入案件标的" />
14 14
 				</uni-forms-item>
15
-				<uni-forms-item label="调解模板:" label-width="120px" required>
16
-					<uni-data-select></uni-data-select>
15
+				<uni-forms-item label="模板:" name="templateId" label-width="120px" required 
16
+				:rules="[{'required': true,errorMessage: '模板不能为空'}]"
17
+				>
18
+					<uni-data-select :localdata="templateList" v-model="formData.templateId"></uni-data-select>
17 19
 				</uni-forms-item>
18 20
 				<uni-forms-item label="申请人案件证据资料上传:" name="headImage" label-width="120px">
19
-							<uni-file-picker ref="files" :auto-upload="false" @select="select" :limit='1' />
21
+							<uni-file-picker ref="files" file-mediatype="all" :auto-upload="false" @select="select" :limit='1' />
20 22
 				</uni-forms-item>
21 23
 				<uni-section title="双方信息" type="line" padding></uni-section>
22 24
 				<uni-forms-item label="选择机构或自然人" label-width="120px" name="objectiJuris">
@@ -25,85 +27,145 @@
25 27
 						v-model="formData.affiliate.organizeFlag"
26 28
 						@change='clearValidate'></uni-data-checkbox>
27 29
 				</uni-forms-item>
28
-				<uni-forms-item label="申请人:"  label-width="120px" required v-if="formData.affiliate.organizeFlag==0">
29
-					<uni-easyinput type="text" placeholder="请输入申请人名称" />
30
+				<uni-forms-item label="申请人:" name="affiliate.applicationName" 
31
+				:rules="[{'required': true,errorMessage: '申请人不能为空'}]"
32
+				label-width="120px" required v-if="formData.affiliate.organizeFlag==0">
33
+					<uni-easyinput v-model="formData.affiliate.applicationName" type="text" placeholder="请输入申请人名称" />
30 34
 				</uni-forms-item>
31
-				<uni-forms-item label="申请人机构名称:" label-width="120px" required 
35
+				<uni-forms-item label="申请人机构名称:" name="affiliate.applicationName" label-width="120px"
36
+				 :rules="[{'required': true,errorMessage: '申请人机构名称为空'}]" required
32 37
 				v-if="formData.affiliate.organizeFlag==1"
33 38
 				>
34
-					<uni-easyinput type="text" placeholder="请输入申请人机构名称" />
39
+					<uni-easyinput v-model="formData.affiliate.applicationName" 
40
+					type="text" placeholder="请输入申请人机构名称" />
35 41
 				</uni-forms-item>
36
-				<uni-forms-item label="申请人身份证号码:" label-width="120px" required 
42
+				<uni-forms-item label="申请人身份证号码:" name="affiliate.code" label-width="120px" required 
43
+				:rules="[
44
+					{'required': true,errorMessage: '申请人身份证号码为空'},
45
+					{pattern:'^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$',errorMessage:'申请人身份证格式错误'}
46
+					]"
47
+				
37 48
 				v-if="formData.affiliate.organizeFlag==0"
38 49
 				>
39
-					<uni-easyinput type="text" placeholder="请输入申请人身份证号码" />
50
+					<uni-easyinput v-model="formData.affiliate.code" type="text" placeholder="请输入申请人身份证号码" />
40 51
 				</uni-forms-item>
41
-				<uni-forms-item label="统一社会信用代码:" label-width="120px" required
52
+				<uni-forms-item label="统一社会信用代码:" name="affiliate.code" label-width="120px" required
53
+				:rules="[{'required': true,errorMessage: '统一社会信用代码为空'}]"
42 54
 				v-if="formData.affiliate.organizeFlag==1"
43 55
 				>
44
-					<uni-easyinput type="text" placeholder="请输入统一社会信用代码:" />
56
+					<uni-easyinput type="text" v-model="formData.affiliate.code" placeholder="请输入统一社会信用代码:" />
45 57
 				</uni-forms-item>
46
-				<uni-forms-item label="申请人邮箱:" label-width="120px" required>
47
-					<uni-easyinput type="text" placeholder="请输入申请人邮箱" />
58
+				<uni-forms-item label="申请人邮箱:" name="affiliate.applicationEmail" label-width="120px" required
59
+				:rules="[
60
+					{'required': true,errorMessage: '申请人邮箱不能为空'},
61
+					{pattern:'^\\S+?@\\S+?\\.\\S+?$',errorMessage:'邮箱格式不正确'}
62
+					]"
63
+				>
64
+					<uni-easyinput v-model="formData.affiliate.applicationEmail"
65
+					 type="text" placeholder="请输入申请人邮箱" />
48 66
 				</uni-forms-item>
49
-				<uni-forms-item label="申请人电话:" label-width="120px" required>
50
-					<uni-easyinput type="text" placeholder="请输入申请人电话" />
67
+				<uni-forms-item label="申请人电话:" name="affiliate.applicationPhone" label-width="120px" required
68
+				:rules="[
69
+					{'required': true,errorMessage: '申请人电话不能为空'},
70
+					{pattern:'^[1][3,4,5,6,7,8,9][0-9]{9}$',errorMessage:'申请人电话格式不正确'}
71
+					]"
72
+				>
73
+					<uni-easyinput v-model="formData.affiliate.applicationPhone" type="text" placeholder="请输入申请人电话" />
51 74
 				</uni-forms-item>
52
-				<uni-forms-item label="法定代表人:" label-width="120px" required>
53
-					<uni-easyinput type="text" placeholder="请输入法定代表人" />
75
+				<uni-forms-item label="法定代表人:" name="affiliate.compLegalPerson" label-width="120px" required
76
+				:rules="[{'required': true,errorMessage: '法定代表人不能为空'}]"
77
+				>
78
+					<uni-easyinput v-model="formData.affiliate.compLegalPerson" type="text" placeholder="请输入法定代表人" />
54 79
 				</uni-forms-item>
55
-				<uni-forms-item label="申请人住所:" label-width="120px" required>
56
-					<uni-easyinput type="text" placeholder="请输入申请人住所" />
80
+				<uni-forms-item label="申请人住所:" name="affiliate.applicantHome" label-width="120px" required
81
+				:rules="[{'required': true,errorMessage: '申请人住所不能为空'}]"
82
+				>
83
+					<uni-easyinput v-model="formData.affiliate.applicantHome" type="text" placeholder="请输入申请人住所" />
57 84
 				</uni-forms-item>
58
-				<uni-forms-item label="申请人联系地址:" label-width="120px" required>
59
-					<uni-easyinput type="text" placeholder="请输入申请人联系地址" />
85
+				<uni-forms-item label="申请人联系地址:" name="affiliate.applicantAddress" label-width="120px" required
86
+				:rules="[{'required': true,errorMessage: '申请人联系地址不能为空'}]"
87
+				>
88
+					<uni-easyinput v-model="formData.affiliate.applicantAddress" type="text" placeholder="请输入申请人联系地址" />
60 89
 				</uni-forms-item>
61
-				<uni-forms-item label="代理人联系电话:" label-width="120px" v-if="formData.affiliate.organizeFlag==0">
62
-					<uni-easyinput type="text" placeholder="请输入代理人联系电话" />
90
+				<uni-forms-item label="代理人联系电话:" name="affiliate.contactTelphoneAgent" label-width="120px"
91
+				 
92
+				v-if="formData.affiliate.organizeFlag==0">
93
+					<uni-easyinput v-model="formData.affiliate.contactTelphoneAgent" type="text" placeholder="请输入代理人联系电话" />
63 94
 				</uni-forms-item>
64
-				<uni-forms-item label="代理人联系电话:" label-width="120px" required 
95
+				<uni-forms-item label="代理人联系电话:" name="affiliate.contactTelphoneAgent" label-width="120px" required
96
+				 :rules="[
97
+					 {'required': true,errorMessage: '代理人联系电话不能为空'},
98
+					 {pattern:'^[1][3,4,5,6,7,8,9][0-9]{9}$',errorMessage:'代理人联系电话格式不正确'}
99
+					 ]"
65 100
 				v-if="formData.affiliate.organizeFlag==1"
66 101
 				>
67
-					<uni-easyinput type="text" placeholder="请输入代理人联系电话" />
102
+					<uni-easyinput v-model="formData.affiliate.contactTelphoneAgent" type="text" placeholder="请输入代理人联系电话" />
68 103
 				</uni-forms-item>
69
-				<uni-forms-item label="委托代理人姓名:" label-width="120px" v-if="formData.affiliate.organizeFlag==0">
70
-					<uni-easyinput type="text" placeholder="请输入委托代理人姓名" />
104
+				<uni-forms-item label="委托代理人姓名:" 	name="affiliate.nameAgent" label-width="120px" v-if="formData.affiliate.organizeFlag==0">
105
+					<uni-easyinput v-model="formData.affiliate.nameAgent" type="text" placeholder="请输入委托代理人姓名" />
71 106
 				</uni-forms-item>
72
-				<uni-forms-item label="委托代理人姓名:" label-width="120px" required
107
+				<uni-forms-item label="委托代理人姓名:" name="affiliate.nameAgent"  label-width="120px" required
108
+				:rules="[{'required': true,errorMessage: '委托代理人姓名不能为空'}]"
73 109
 				v-if="formData.affiliate.organizeFlag==1"
74 110
 				>
75
-					<uni-easyinput type="text" placeholder="请输入委托代理人姓名" />
111
+					<uni-easyinput v-model="formData.affiliate.nameAgent" type="text" placeholder="请输入委托代理人姓名" />
76 112
 				</uni-forms-item>
77
-				<uni-forms-item label="代理人邮箱:" label-width="120px" v-if="formData.affiliate.organizeFlag==0">
78
-					<uni-easyinput type="text" placeholder="请输入代理人邮箱" />
113
+				<uni-forms-item label="代理人邮箱:" name="affiliate.agentEmail" label-width="120px" v-if="formData.affiliate.organizeFlag==0">
114
+					<uni-easyinput v-model="formData.affiliate.agentEmail" type="text" placeholder="请输入代理人邮箱" />
79 115
 				</uni-forms-item>
80
-				<uni-forms-item label="代理人邮箱:" label-width="120px" required
116
+				<uni-forms-item label="代理人邮箱:" name="affiliate.agentEmail" label-width="120px" required
117
+				:rules="[
118
+					{'required': true,errorMessage: '代理人邮箱不能为空'},
119
+					{pattern:'^\\S+?@\\S+?\\.\\S+?$',errorMessage:'邮箱格式不正确'}
120
+					]"
81 121
 				v-if="formData.affiliate.organizeFlag==1"
82 122
 				>
83
-					<uni-easyinput type="text" placeholder="请输入代理人邮箱" />
123
+					<uni-easyinput v-model="formData.affiliate.agentEmail" type="text" placeholder="请输入代理人邮箱" />
84 124
 				</uni-forms-item>
85
-				<uni-forms-item label="被申请人姓名:" label-width="120px" required>
86
-					<uni-easyinput type="text" placeholder="请输入被申请人姓名" />
125
+				<uni-forms-item label="被申请人姓名:" name="affiliate.respondentName" label-width="120px" required
126
+				:rules="[{'required': true,errorMessage: '被申请人姓名不能为空'}]"
127
+				>
128
+					<uni-easyinput v-model="formData.affiliate.respondentName" type="text" placeholder="请输入被申请人姓名" />
87 129
 				</uni-forms-item>
88
-				<uni-forms-item label="被申请人联系电话:" label-width="120px" required>
89
-					<uni-easyinput type="text" placeholder="请输入被申请人联系电话" />
130
+				<uni-forms-item label="被申请人联系电话:" name="affiliate.respondentPhone" label-width="120px" required
131
+				:rules="[
132
+					{'required': true,errorMessage: '被申请人联系电话不能为空'},
133
+					{pattern:'^[1][3,4,5,6,7,8,9][0-9]{9}$',errorMessage:'被申请人联系电话格式不正确'}
134
+					]"
135
+				>
136
+					<uni-easyinput v-model="formData.affiliate.respondentPhone" type="text" placeholder="请输入被申请人联系电话" />
90 137
 				</uni-forms-item>
91
-				<uni-forms-item label="被申请人身份证号:" label-width="120px" required>
92
-					<uni-easyinput type="text" placeholder="请输入被申请人身份证号" />
138
+				<uni-forms-item label="被申请人身份证号:" name="affiliate.respondentIdentityNum" label-width="120px" required
139
+				:rules="[
140
+					{'required': true,errorMessage: '被申请人身份证号不能为空'},
141
+					{pattern:'^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$',errorMessage:'被申请人身份证格式错误'}
142
+					
143
+					]"
144
+				>
145
+					<uni-easyinput v-model="formData.affiliate.respondentIdentityNum" @blur="handleBlur" type="text" placeholder="请输入被申请人身份证号" />
93 146
 				</uni-forms-item>
94 147
 				<uni-forms-item label="被申请人性别" label-width="120px" required>
95 148
 					<uni-data-checkbox class='checkbox'
149
+						:disabled='true'
96 150
 						v-model="formData.affiliate.respondentSex"
97 151
 						:localdata="respondentSexy"></uni-data-checkbox>
98 152
 				</uni-forms-item>
99
-				<uni-forms-item label="被申请人出生年月日" label-width="120px" >
100
-					<uni-datetime-picker type="date" :clear-icon="false" />
153
+				<uni-forms-item label="被申请人出生年月日" label-width="120px">
154
+					<uni-datetime-picker v-model="formData.affiliate.respondentBirth" :disabled='true' type="date" :clear-icon="false" />
101 155
 				</uni-forms-item>
102
-				<uni-forms-item label="被申请人住所:" label-width="120px" required>
103
-					<uni-easyinput type="text" placeholder="请输入被申请人住所" />
156
+				<uni-forms-item label="被申请人住所:" name="affiliate.respondentHome" label-width="120px" required
157
+				:rules="[{'required': true,errorMessage: '被申请人住所不能为空'}]"
158
+				>
159
+					<uni-easyinput v-model="formData.affiliate.respondentHome" type="text" placeholder="请输入被申请人住所" />
104 160
 				</uni-forms-item>
105
-				<uni-forms-item label="被申请人邮箱:" label-width="120px" required>
106
-					<uni-easyinput type="text" placeholder="请输入被申请人住所" />
161
+				<uni-forms-item label="被申请人邮箱:" name="affiliate.respondentEmail" label-width="120px" required
162
+				:rules="[
163
+					{'required': true,errorMessage: '被申请人邮箱不能为空'},
164
+					{pattern:'^\\S+?@\\S+?\\.\\S+?$',errorMessage:'邮箱格式不正确'}
165
+					
166
+					]"	
167
+				>
168
+					<uni-easyinput v-model="formData.affiliate.respondentEmail" type="text" placeholder="请输入被申请人邮箱" />
107 169
 				</uni-forms-item>
108 170
 			</uni-forms>
109 171
 			<view class="determine" style="text-align: center;">
@@ -119,6 +181,11 @@
119 181
 </template>
120 182
 
121 183
 <script>
184
+	import {getTemplate,getInfoByIdCard,caseApplicationInsert,updateComfire} from '../../../api/handlecase/index.js'
185
+	import {
186
+		getToken
187
+	} from '@/utils/auth'
188
+	import config from '@/config'
122 189
 	export default {
123 190
 		data() {
124 191
 				return {
@@ -126,9 +193,12 @@
126 193
 						affiliate:{
127 194
 							organizeFlag: 0,
128 195
 							respondentSex: 0,
129
-						}
196
+						},
197
+						columnValueList: [],
198
+						caseAttachList: [],
130 199
 					},
131
-					
200
+					tempFilePaths: null,
201
+					templateList:[],
132 202
 					objectiJurisArr: [{
133 203
 						text: '自然人',
134 204
 						value: 0
@@ -150,7 +220,7 @@
150 220
 							rules:[
151 221
 								{
152 222
 									required: true,
153
-									errorMessage: '请输入申请人调解请求',
223
+									errorMessage: '申请人调解请求不能为空',
154 224
 								},
155 225
 							],
156 226
 						},
@@ -158,7 +228,7 @@
158 228
 							rules:[
159 229
 								{
160 230
 									required: true,
161
-									errorMessage: '请输入事实和理由',
231
+									errorMessage: '事实和理由不能空',
162 232
 								},
163 233
 							],
164 234
 						},
@@ -166,10 +236,19 @@
166 236
 							rules:[
167 237
 								{
168 238
 									required: true,
169
-									errorMessage: '请输入案件标的',
239
+									errorMessage: '案件标的不能为空',
170 240
 								},
171 241
 							],
172
-						}
242
+						},
243
+						respondentEmail:{
244
+							rules:[
245
+								{
246
+									required: true,
247
+									errorMessage: '邮箱不能为空',
248
+								}
249
+							],
250
+						},
251
+						
173 252
 					}
174 253
 				}
175 254
 			
@@ -177,20 +256,109 @@
177 256
 		},
178 257
 		methods:{
179 258
 			clearValidate(val){
180
-				
259
+				 this.$refs["form"].clearValidate()
181 260
 			},
182 261
 			submitReasont(){
183 262
 				this.$refs.form.validate().then(res=>{
184
-						
263
+						this.insertFn(this.formData)
185 264
 					}).catch(err =>{
186 265
 						
187 266
 				})
188 267
 			},
268
+			/** 获取裁决书模板 */
269
+			getTemplateFn(data) {
270
+			      getTemplate(data).then((res) => {
271
+			        //this.templateList = res.rows;
272
+					res.rows.forEach(item=>{
273
+						this.templateList.push({value:item.id,text:item.temName})
274
+					})
275
+			      });
276
+			},
277
+			// 被申请人获取性别喝出生年月
278
+			handleBlur(){
279
+				let idCards = {
280
+				        idCard: this.formData.affiliate.respondentIdentityNum,
281
+				      };
282
+				getInfoByIdCard(idCards).then(res=>{
283
+					this.formData.affiliate.respondentSex = Number(res.respondentSex);
284
+					this.formData.affiliate.respondentBirth = res.respondentBirth;
285
+				})
286
+			},
287
+			// 新增案件
288
+			    insertFn(data) {
289
+			      caseApplicationInsert(data).then((res) => {
290
+					  uni.showToast({
291
+					  	title: '成功',
292
+					  	icon: 'none',
293
+					  	duration: 1000
294
+					  })
295
+					  uni.navigateBack({
296
+					  	delta: 1
297
+					  })
298
+			      });
299
+			},
300
+			//修改案件
301
+				modifyData(data) {
302
+				      updateComfire(data).then((res) => {
303
+				        uni.showToast({
304
+				        	title: '成功',
305
+				        	icon: 'none',
306
+				        	duration: 1000
307
+				        })
308
+				        uni.navigateBack({
309
+				        	delta: 1
310
+				        })
311
+				      });
312
+				},
313
+				// 文件上传
314
+				select(e) {
315
+					this.tempFilePaths = e.tempFilePaths;
316
+					// loading
317
+					uni.showLoading({
318
+						title: '上传中'
319
+					});
320
+					uni.uploadFile({
321
+						url: config.baseUrlTJ + "/common/upload",
322
+						filePath: this.tempFilePaths[0],
323
+						header: {
324
+							Authorization: getToken() || '',
325
+						},
326
+						formData: {
327
+							annexType: 2,
328
+							id: this.formData.id
329
+						},
330
+						name: 'file',
331
+						success: (res) => {
332
+							let result = JSON.parse(res.data)
333
+							 this.formData.caseAttachList.push({
334
+							        annexId: result.annexId,
335
+							  });
336
+							console.log(result.annexId)
337
+							uni.showToast({
338
+								title: '上传成功',
339
+								icon: 'none',
340
+								duration: 1000
341
+							})
342
+							uni.hideLoading();
343
+						},
344
+						fail: (err) => {
345
+							uni.showToast({
346
+								title: '上传失败',
347
+								icon: 'none',
348
+								duration: 1000
349
+							})
350
+							uni.hideLoading()
351
+						}
352
+					})
353
+				},
189 354
 			cencalBut(){
190 355
 				uni.navigateBack({
191 356
 					delta: 1
192 357
 				})
193 358
 			}
359
+		},
360
+		onLoad(data) {
361
+			this.getTemplateFn()
194 362
 		}
195 363
 	}
196 364
 	

+ 71
- 67
uni_modules/uni-file-picker/changelog.md Просмотреть файл

@@ -1,67 +1,71 @@
1
-## 1.0.4(2023-03-29)
2
-- 修复 手动上传删除一个文件后不能再上传的bug
3
-## 1.0.3(2022-12-19)
4
-- 新增 sourceType 属性, 可以自定义图片和视频选择的来源
5
-## 1.0.2(2022-07-04)
6
-- 修复 在uni-forms下样式不生效的bug
7
-## 1.0.1(2021-11-23)
8
-- 修复 参数为对象的情况下,url在某些情况显示错误的bug
9
-## 1.0.0(2021-11-19)
10
-- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
11
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-file-picker](https://uniapp.dcloud.io/component/uniui/uni-file-picker)
12
-## 0.2.16(2021-11-08)
13
-- 修复 传入空对象 ,显示错误的Bug
14
-## 0.2.15(2021-08-30)
15
-- 修复 return-type="object" 时且存在v-model时,无法删除文件的Bug
16
-## 0.2.14(2021-08-23)
17
-- 新增 参数中返回 fileID 字段
18
-## 0.2.13(2021-08-23)
19
-- 修复 腾讯云传入fileID 不能回显的bug
20
-- 修复 选择图片后,不能放大的问题
21
-## 0.2.12(2021-08-17)
22
-- 修复 由于 0.2.11 版本引起的不能回显图片的Bug
23
-## 0.2.11(2021-08-16)
24
-- 新增 clearFiles(index) 方法,可以手动删除指定文件
25
-- 修复 v-model 值设为 null 报错的Bug
26
-## 0.2.10(2021-08-13)
27
-- 修复 return-type="object" 时,无法删除文件的Bug
28
-## 0.2.9(2021-08-03)
29
-- 修复 auto-upload 属性失效的Bug
30
-## 0.2.8(2021-07-31)
31
-- 修复 fileExtname属性不指定值报错的Bug
32
-## 0.2.7(2021-07-31)
33
-- 修复 在某种场景下图片不回显的Bug
34
-## 0.2.6(2021-07-30)
35
-- 修复 return-type为object下,返回值不正确的Bug
36
-## 0.2.5(2021-07-30)
37
-- 修复(重要) H5 平台下如果和uni-forms组件一同使用导致页面卡死的问题
38
-## 0.2.3(2021-07-28)
39
-- 优化 调整示例代码
40
-## 0.2.2(2021-07-27)
41
-- 修复 vue3 下赋值错误的Bug
42
-- 优化 h5平台下上传文件导致页面卡死的问题
43
-## 0.2.0(2021-07-13)
44
-- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
45
-## 0.1.1(2021-07-02)
46
-- 修复 sourceType 缺少默认值导致 ios 无法选择文件
47
-## 0.1.0(2021-06-30)
48
-- 优化 解耦与uniCloud的强绑定关系 ,如不绑定服务空间,默认autoUpload为false且不可更改
49
-## 0.0.11(2021-06-30)
50
-- 修复 由 0.0.10 版本引发的 returnType 属性失效的问题
51
-## 0.0.10(2021-06-29)
52
-- 优化 文件上传后进度条消失时机
53
-## 0.0.9(2021-06-29)
54
-- 修复 在uni-forms 中,删除文件 ,获取的值不对的Bug
55
-## 0.0.8(2021-06-15)
56
-- 修复 删除文件时无法触发 v-model 的Bug
57
-## 0.0.7(2021-05-12)
58
-- 新增 组件示例地址
59
-## 0.0.6(2021-04-09)
60
-- 修复 选择的文件非 file-extname 字段指定的扩展名报错的Bug
61
-## 0.0.5(2021-04-09)
62
-- 优化 更新组件示例
63
-## 0.0.4(2021-04-09)
64
-- 优化 file-extname 字段支持字符串写法,多个扩展名需要用逗号分隔
65
-## 0.0.3(2021-02-05)
66
-- 调整为uni_modules目录规范
67
-- 修复 微信小程序不指定 fileExtname 属性选择失败的Bug
1
+## 1.0.6(2024-01-06)
2
+- 新增 微信小程序不再调用chooseImage,而是调用chooseMedia
3
+## 1.0.5(2024-01-03)
4
+- 新增 上传文件至云存储携带本地文件名称
5
+## 1.0.4(2023-03-29)
6
+- 修复 手动上传删除一个文件后不能再上传的bug
7
+## 1.0.3(2022-12-19)
8
+- 新增 sourceType 属性, 可以自定义图片和视频选择的来源
9
+## 1.0.2(2022-07-04)
10
+- 修复 在uni-forms下样式不生效的bug
11
+## 1.0.1(2021-11-23)
12
+- 修复 参数为对象的情况下,url在某些情况显示错误的bug
13
+## 1.0.0(2021-11-19)
14
+- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
15
+- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-file-picker](https://uniapp.dcloud.io/component/uniui/uni-file-picker)
16
+## 0.2.16(2021-11-08)
17
+- 修复 传入空对象 ,显示错误的Bug
18
+## 0.2.15(2021-08-30)
19
+- 修复 return-type="object" 时且存在v-model时,无法删除文件的Bug
20
+## 0.2.14(2021-08-23)
21
+- 新增 参数中返回 fileID 字段
22
+## 0.2.13(2021-08-23)
23
+- 修复 腾讯云传入fileID 不能回显的bug
24
+- 修复 选择图片后,不能放大的问题
25
+## 0.2.12(2021-08-17)
26
+- 修复 由于 0.2.11 版本引起的不能回显图片的Bug
27
+## 0.2.11(2021-08-16)
28
+- 新增 clearFiles(index) 方法,可以手动删除指定文件
29
+- 修复 v-model 值设为 null 报错的Bug
30
+## 0.2.10(2021-08-13)
31
+- 修复 return-type="object" 时,无法删除文件的Bug
32
+## 0.2.9(2021-08-03)
33
+- 修复 auto-upload 属性失效的Bug
34
+## 0.2.8(2021-07-31)
35
+- 修复 fileExtname属性不指定值报错的Bug
36
+## 0.2.7(2021-07-31)
37
+- 修复 在某种场景下图片不回显的Bug
38
+## 0.2.6(2021-07-30)
39
+- 修复 return-type为object下,返回值不正确的Bug
40
+## 0.2.5(2021-07-30)
41
+- 修复(重要) H5 平台下如果和uni-forms组件一同使用导致页面卡死的问题
42
+## 0.2.3(2021-07-28)
43
+- 优化 调整示例代码
44
+## 0.2.2(2021-07-27)
45
+- 修复 vue3 下赋值错误的Bug
46
+- 优化 h5平台下上传文件导致页面卡死的问题
47
+## 0.2.0(2021-07-13)
48
+- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
49
+## 0.1.1(2021-07-02)
50
+- 修复 sourceType 缺少默认值导致 ios 无法选择文件
51
+## 0.1.0(2021-06-30)
52
+- 优化 解耦与uniCloud的强绑定关系 ,如不绑定服务空间,默认autoUpload为false且不可更改
53
+## 0.0.11(2021-06-30)
54
+- 修复 由 0.0.10 版本引发的 returnType 属性失效的问题
55
+## 0.0.10(2021-06-29)
56
+- 优化 文件上传后进度条消失时机
57
+## 0.0.9(2021-06-29)
58
+- 修复 在uni-forms 中,删除文件 ,获取的值不对的Bug
59
+## 0.0.8(2021-06-15)
60
+- 修复 删除文件时无法触发 v-model 的Bug
61
+## 0.0.7(2021-05-12)
62
+- 新增 组件示例地址
63
+## 0.0.6(2021-04-09)
64
+- 修复 选择的文件非 file-extname 字段指定的扩展名报错的Bug
65
+## 0.0.5(2021-04-09)
66
+- 优化 更新组件示例
67
+## 0.0.4(2021-04-09)
68
+- 优化 file-extname 字段支持字符串写法,多个扩展名需要用逗号分隔
69
+## 0.0.3(2021-02-05)
70
+- 调整为uni_modules目录规范
71
+- 修复 微信小程序不指定 fileExtname 属性选择失败的Bug

+ 247
- 224
uni_modules/uni-file-picker/components/uni-file-picker/choose-and-upload-file.js Просмотреть файл

@@ -1,224 +1,247 @@
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
-		uni.chooseImage({
15
-			count,
16
-			sizeType,
17
-			sourceType,
18
-			extension,
19
-			success(res) {
20
-				resolve(normalizeChooseAndUploadFileRes(res, 'image'));
21
-			},
22
-			fail(res) {
23
-				reject({
24
-					errMsg: res.errMsg.replace('chooseImage:fail', ERR_MSG_FAIL),
25
-				});
26
-			},
27
-		});
28
-	});
29
-}
30
-
31
-function chooseVideo(opts) {
32
-	const {
33
-		camera,
34
-		compressed,
35
-		maxDuration,
36
-		sourceType,
37
-		extension
38
-	} = opts;
39
-	return new Promise((resolve, reject) => {
40
-		uni.chooseVideo({
41
-			camera,
42
-			compressed,
43
-			maxDuration,
44
-			sourceType,
45
-			extension,
46
-			success(res) {
47
-				const {
48
-					tempFilePath,
49
-					duration,
50
-					size,
51
-					height,
52
-					width
53
-				} = res;
54
-				resolve(normalizeChooseAndUploadFileRes({
55
-					errMsg: 'chooseVideo:ok',
56
-					tempFilePaths: [tempFilePath],
57
-					tempFiles: [
58
-					{
59
-						name: (res.tempFile && res.tempFile.name) || '',
60
-						path: tempFilePath,
61
-						size,
62
-						type: (res.tempFile && res.tempFile.type) || '',
63
-						width,
64
-						height,
65
-						duration,
66
-						fileType: 'video',
67
-						cloudPath: '',
68
-					}, ],
69
-				}, 'video'));
70
-			},
71
-			fail(res) {
72
-				reject({
73
-					errMsg: res.errMsg.replace('chooseVideo:fail', ERR_MSG_FAIL),
74
-				});
75
-			},
76
-		});
77
-	});
78
-}
79
-
80
-function chooseAll(opts) {
81
-	const {
82
-		count,
83
-		extension
84
-	} = opts;
85
-	return new Promise((resolve, reject) => {
86
-		let chooseFile = uni.chooseFile;
87
-		if (typeof wx !== 'undefined' &&
88
-			typeof wx.chooseMessageFile === 'function') {
89
-			chooseFile = wx.chooseMessageFile;
90
-		}
91
-		if (typeof chooseFile !== 'function') {
92
-			return reject({
93
-				errMsg: ERR_MSG_FAIL + ' 请指定 type 类型,该平台仅支持选择 image 或 video。',
94
-			});
95
-		}
96
-		chooseFile({
97
-			type: 'all',
98
-			count,
99
-			extension,
100
-			success(res) {
101
-				resolve(normalizeChooseAndUploadFileRes(res));
102
-			},
103
-			fail(res) {
104
-				reject({
105
-					errMsg: res.errMsg.replace('chooseFile:fail', ERR_MSG_FAIL),
106
-				});
107
-			},
108
-		});
109
-	});
110
-}
111
-
112
-function normalizeChooseAndUploadFileRes(res, fileType) {
113
-	res.tempFiles.forEach((item, index) => {
114
-		if (!item.name) {
115
-			item.name = item.path.substring(item.path.lastIndexOf('/') + 1);
116
-		}
117
-		if (fileType) {
118
-			item.fileType = fileType;
119
-		}
120
-		item.cloudPath =
121
-			Date.now() + '_' + index + item.name.substring(item.name.lastIndexOf('.'));
122
-	});
123
-	if (!res.tempFilePaths) {
124
-		res.tempFilePaths = res.tempFiles.map((file) => file.path);
125
-	}
126
-	return res;
127
-}
128
-
129
-function uploadCloudFiles(files, max = 5, onUploadProgress) {
130
-	files = JSON.parse(JSON.stringify(files))
131
-	const len = files.length
132
-	let count = 0
133
-	let self = this
134
-	return new Promise(resolve => {
135
-		while (count < max) {
136
-			next()
137
-		}
138
-
139
-		function next() {
140
-			let cur = count++
141
-			if (cur >= len) {
142
-				!files.find(item => !item.url && !item.errMsg) && resolve(files)
143
-				return
144
-			}
145
-			const fileItem = files[cur]
146
-			const index = self.files.findIndex(v => v.uuid === fileItem.uuid)
147
-			fileItem.url = ''
148
-			delete fileItem.errMsg
149
-
150
-			uniCloud
151
-				.uploadFile({
152
-					filePath: fileItem.path,
153
-					cloudPath: fileItem.cloudPath,
154
-					fileType: fileItem.fileType,
155
-					onUploadProgress: res => {
156
-						res.index = index
157
-						onUploadProgress && onUploadProgress(res)
158
-					}
159
-				})
160
-				.then(res => {
161
-					fileItem.url = res.fileID
162
-					fileItem.index = index
163
-					if (cur < len) {
164
-						next()
165
-					}
166
-				})
167
-				.catch(res => {
168
-					fileItem.errMsg = res.errMsg || res.message
169
-					fileItem.index = index
170
-					if (cur < len) {
171
-						next()
172
-					}
173
-				})
174
-		}
175
-	})
176
-}
177
-
178
-
179
-
180
-
181
-
182
-function uploadFiles(choosePromise, {
183
-	onChooseFile,
184
-	onUploadProgress
185
-}) {
186
-	return choosePromise
187
-		.then((res) => {
188
-			if (onChooseFile) {
189
-				const customChooseRes = onChooseFile(res);
190
-				if (typeof customChooseRes !== 'undefined') {
191
-					return Promise.resolve(customChooseRes).then((chooseRes) => typeof chooseRes === 'undefined' ?
192
-						res : chooseRes);
193
-				}
194
-			}
195
-			return res;
196
-		})
197
-		.then((res) => {
198
-			if (res === false) {
199
-				return {
200
-					errMsg: ERR_MSG_OK,
201
-					tempFilePaths: [],
202
-					tempFiles: [],
203
-				};
204
-			}
205
-			return res
206
-		})
207
-}
208
-
209
-function chooseAndUploadFile(opts = {
210
-	type: 'all'
211
-}) {
212
-	if (opts.type === 'image') {
213
-		return uploadFiles(chooseImage(opts), opts);
214
-	}
215
-	else if (opts.type === 'video') {
216
-		return uploadFiles(chooseVideo(opts), opts);
217
-	}
218
-	return uploadFiles(chooseAll(opts), opts);
219
-}
220
-
221
-export {
222
-	chooseAndUploadFile,
223
-	uploadCloudFiles
224
-};
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
+		// #ifdef MP-WEIXIN
15
+		uni.chooseMedia({
16
+			count,
17
+			sizeType,
18
+			sourceType,
19
+			mediaType: ['image'],
20
+			extension,
21
+			success(res) {
22
+				res.tempFiles.forEach(item => {
23
+					item.path = item.tempFilePath;
24
+				})
25
+				resolve(normalizeChooseAndUploadFileRes(res, 'image'));
26
+			},
27
+			fail(res) {
28
+				reject({
29
+					errMsg: res.errMsg.replace('chooseImage:fail', ERR_MSG_FAIL),
30
+				});
31
+			},
32
+		})
33
+		// #endif
34
+		// #ifndef MP-WEIXIN
35
+		uni.chooseImage({
36
+			count,
37
+			sizeType,
38
+			sourceType,
39
+			extension,
40
+			success(res) {
41
+				resolve(normalizeChooseAndUploadFileRes(res, 'image'));
42
+			},
43
+			fail(res) {
44
+				reject({
45
+					errMsg: res.errMsg.replace('chooseImage:fail', ERR_MSG_FAIL),
46
+				});
47
+			},
48
+		});
49
+		// #endif
50
+
51
+	});
52
+}
53
+
54
+function chooseVideo(opts) {
55
+	const {
56
+		camera,
57
+		compressed,
58
+		maxDuration,
59
+		sourceType,
60
+		extension
61
+	} = opts;
62
+	return new Promise((resolve, reject) => {
63
+		uni.chooseVideo({
64
+			camera,
65
+			compressed,
66
+			maxDuration,
67
+			sourceType,
68
+			extension,
69
+			success(res) {
70
+				const {
71
+					tempFilePath,
72
+					duration,
73
+					size,
74
+					height,
75
+					width
76
+				} = res;
77
+				resolve(normalizeChooseAndUploadFileRes({
78
+					errMsg: 'chooseVideo:ok',
79
+					tempFilePaths: [tempFilePath],
80
+					tempFiles: [
81
+					{
82
+						name: (res.tempFile && res.tempFile.name) || '',
83
+						path: tempFilePath,
84
+						size,
85
+						type: (res.tempFile && res.tempFile.type) || '',
86
+						width,
87
+						height,
88
+						duration,
89
+						fileType: 'video',
90
+						cloudPath: '',
91
+					}, ],
92
+				}, 'video'));
93
+			},
94
+			fail(res) {
95
+				reject({
96
+					errMsg: res.errMsg.replace('chooseVideo:fail', ERR_MSG_FAIL),
97
+				});
98
+			},
99
+		});
100
+	});
101
+}
102
+
103
+function chooseAll(opts) {
104
+	const {
105
+		count,
106
+		extension
107
+	} = opts;
108
+	return new Promise((resolve, reject) => {
109
+		let chooseFile = uni.chooseFile;
110
+		if (typeof wx !== 'undefined' &&
111
+			typeof wx.chooseMessageFile === 'function') {
112
+			chooseFile = wx.chooseMessageFile;
113
+		}
114
+		if (typeof chooseFile !== 'function') {
115
+			return reject({
116
+				errMsg: ERR_MSG_FAIL + ' 请指定 type 类型,该平台仅支持选择 image 或 video。',
117
+			});
118
+		}
119
+		chooseFile({
120
+			type: 'all',
121
+			count,
122
+			extension,
123
+			success(res) {
124
+				resolve(normalizeChooseAndUploadFileRes(res));
125
+			},
126
+			fail(res) {
127
+				reject({
128
+					errMsg: res.errMsg.replace('chooseFile:fail', ERR_MSG_FAIL),
129
+				});
130
+			},
131
+		});
132
+	});
133
+}
134
+
135
+function normalizeChooseAndUploadFileRes(res, fileType) {
136
+	res.tempFiles.forEach((item, index) => {
137
+		if (!item.name) {
138
+			item.name = item.path.substring(item.path.lastIndexOf('/') + 1);
139
+		}
140
+		if (fileType) {
141
+			item.fileType = fileType;
142
+		}
143
+		item.cloudPath =
144
+			Date.now() + '_' + index + item.name.substring(item.name.lastIndexOf('.'));
145
+	});
146
+	if (!res.tempFilePaths) {
147
+		res.tempFilePaths = res.tempFiles.map((file) => file.path);
148
+	}
149
+	return res;
150
+}
151
+
152
+function uploadCloudFiles(files, max = 5, onUploadProgress) {
153
+	files = JSON.parse(JSON.stringify(files))
154
+	const len = files.length
155
+	let count = 0
156
+	let self = this
157
+	return new Promise(resolve => {
158
+		while (count < max) {
159
+			next()
160
+		}
161
+
162
+		function next() {
163
+			let cur = count++
164
+			if (cur >= len) {
165
+				!files.find(item => !item.url && !item.errMsg) && resolve(files)
166
+				return
167
+			}
168
+			const fileItem = files[cur]
169
+			const index = self.files.findIndex(v => v.uuid === fileItem.uuid)
170
+			fileItem.url = ''
171
+			delete fileItem.errMsg
172
+
173
+			uniCloud
174
+				.uploadFile({
175
+					filePath: fileItem.path,
176
+					cloudPath: fileItem.cloudPath,
177
+					fileType: fileItem.fileType,
178
+					onUploadProgress: res => {
179
+						res.index = index
180
+						onUploadProgress && onUploadProgress(res)
181
+					}
182
+				})
183
+				.then(res => {
184
+					fileItem.url = res.fileID
185
+					fileItem.index = index
186
+					if (cur < len) {
187
+						next()
188
+					}
189
+				})
190
+				.catch(res => {
191
+					fileItem.errMsg = res.errMsg || res.message
192
+					fileItem.index = index
193
+					if (cur < len) {
194
+						next()
195
+					}
196
+				})
197
+		}
198
+	})
199
+}
200
+
201
+
202
+
203
+
204
+
205
+function uploadFiles(choosePromise, {
206
+	onChooseFile,
207
+	onUploadProgress
208
+}) {
209
+	return choosePromise
210
+		.then((res) => {
211
+			if (onChooseFile) {
212
+				const customChooseRes = onChooseFile(res);
213
+				if (typeof customChooseRes !== 'undefined') {
214
+					return Promise.resolve(customChooseRes).then((chooseRes) => typeof chooseRes === 'undefined' ?
215
+						res : chooseRes);
216
+				}
217
+			}
218
+			return res;
219
+		})
220
+		.then((res) => {
221
+			if (res === false) {
222
+				return {
223
+					errMsg: ERR_MSG_OK,
224
+					tempFilePaths: [],
225
+					tempFiles: [],
226
+				};
227
+			}
228
+			return res
229
+		})
230
+}
231
+
232
+function chooseAndUploadFile(opts = {
233
+	type: 'all'
234
+}) {
235
+	if (opts.type === 'image') {
236
+		return uploadFiles(chooseImage(opts), opts);
237
+	}
238
+	else if (opts.type === 'video') {
239
+		return uploadFiles(chooseVideo(opts), opts);
240
+	}
241
+	return uploadFiles(chooseAll(opts), opts);
242
+}
243
+
244
+export {
245
+	chooseAndUploadFile,
246
+	uploadCloudFiles
247
+};

+ 675
- 665
uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.vue
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 325
- 325
uni_modules/uni-file-picker/components/uni-file-picker/upload-file.vue Просмотреть файл

@@ -1,325 +1,325 @@
1
-<template>
2
-	<view class="uni-file-picker__files">
3
-		<view v-if="!readonly" class="files-button" @click="choose">
4
-			<slot></slot>
5
-		</view>
6
-		<!-- :class="{'is-text-box':showType === 'list'}" -->
7
-		<view v-if="list.length > 0" class="uni-file-picker__lists is-text-box" :style="borderStyle">
8
-			<!-- ,'is-list-card':showType === 'list-card' -->
9
-
10
-			<view class="uni-file-picker__lists-box" v-for="(item ,index) in list" :key="index" :class="{
11
-				'files-border':index !== 0 && styles.dividline}"
12
-			 :style="index !== 0 && styles.dividline &&borderLineStyle">
13
-				<view class="uni-file-picker__item">
14
-					<!-- :class="{'is-text-image':showType === 'list'}" -->
15
-					<!-- 	<view class="files__image is-text-image">
16
-						<image class="header-image" :src="item.logo" mode="aspectFit"></image>
17
-					</view> -->
18
-					<view class="files__name">{{item.name}}</view>
19
-					<view v-if="delIcon&&!readonly" class="icon-del-box icon-files" @click="delFile(index)">
20
-						<view class="icon-del icon-files"></view>
21
-						<view class="icon-del rotate"></view>
22
-					</view>
23
-				</view>
24
-				<view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
25
-					<progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
26
-					 :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
27
-				</view>
28
-				<view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
29
-					点击重试
30
-				</view>
31
-			</view>
32
-
33
-		</view>
34
-	</view>
35
-</template>
36
-
37
-<script>
38
-	export default {
39
-		name: "uploadFile",
40
-		emits:['uploadFiles','choose','delFile'],
41
-		props: {
42
-			filesList: {
43
-				type: Array,
44
-				default () {
45
-					return []
46
-				}
47
-			},
48
-			delIcon: {
49
-				type: Boolean,
50
-				default: true
51
-			},
52
-			limit: {
53
-				type: [Number, String],
54
-				default: 9
55
-			},
56
-			showType: {
57
-				type: String,
58
-				default: ''
59
-			},
60
-			listStyles: {
61
-				type: Object,
62
-				default () {
63
-					return {
64
-						// 是否显示边框
65
-						border: true,
66
-						// 是否显示分隔线
67
-						dividline: true,
68
-						// 线条样式
69
-						borderStyle: {}
70
-					}
71
-				}
72
-			},
73
-			readonly:{
74
-				type:Boolean,
75
-				default:false
76
-			}
77
-		},
78
-		computed: {
79
-			list() {
80
-				let files = []
81
-				this.filesList.forEach(v => {
82
-					files.push(v)
83
-				})
84
-				return files
85
-			},
86
-			styles() {
87
-				let styles = {
88
-					border: true,
89
-					dividline: true,
90
-					'border-style': {}
91
-				}
92
-				return Object.assign(styles, this.listStyles)
93
-			},
94
-			borderStyle() {
95
-				let {
96
-					borderStyle,
97
-					border
98
-				} = this.styles
99
-				let obj = {}
100
-				if (!border) {
101
-					obj.border = 'none'
102
-				} else {
103
-					let width = (borderStyle && borderStyle.width) || 1
104
-					width = this.value2px(width)
105
-					let radius = (borderStyle && borderStyle.radius) || 5
106
-					radius = this.value2px(radius)
107
-					obj = {
108
-						'border-width': width,
109
-						'border-style': (borderStyle && borderStyle.style) || 'solid',
110
-						'border-color': (borderStyle && borderStyle.color) || '#eee',
111
-						'border-radius': radius
112
-					}
113
-				}
114
-				let classles = ''
115
-				for (let i in obj) {
116
-					classles += `${i}:${obj[i]};`
117
-				}
118
-				return classles
119
-			},
120
-			borderLineStyle() {
121
-				let obj = {}
122
-				let {
123
-					borderStyle
124
-				} = this.styles
125
-				if (borderStyle && borderStyle.color) {
126
-					obj['border-color'] = borderStyle.color
127
-				}
128
-				if (borderStyle && borderStyle.width) {
129
-					let width = borderStyle && borderStyle.width || 1
130
-					let style = borderStyle && borderStyle.style || 0
131
-					if (typeof width === 'number') {
132
-						width += 'px'
133
-					} else {
134
-						width = width.indexOf('px') ? width : width + 'px'
135
-					}
136
-					obj['border-width'] = width
137
-
138
-					if (typeof style === 'number') {
139
-						style += 'px'
140
-					} else {
141
-						style = style.indexOf('px') ? style : style + 'px'
142
-					}
143
-					obj['border-top-style'] = style
144
-				}
145
-				let classles = ''
146
-				for (let i in obj) {
147
-					classles += `${i}:${obj[i]};`
148
-				}
149
-				return classles
150
-			}
151
-		},
152
-
153
-		methods: {
154
-			uploadFiles(item, index) {
155
-				this.$emit("uploadFiles", {
156
-					item,
157
-					index
158
-				})
159
-			},
160
-			choose() {
161
-				this.$emit("choose")
162
-			},
163
-			delFile(index) {
164
-				this.$emit('delFile', index)
165
-			},
166
-			value2px(value) {
167
-				if (typeof value === 'number') {
168
-					value += 'px'
169
-				} else {
170
-					value = value.indexOf('px') !== -1 ? value : value + 'px'
171
-				}
172
-				return value
173
-			}
174
-		}
175
-	}
176
-</script>
177
-
178
-<style lang="scss">
179
-	.uni-file-picker__files {
180
-		/* #ifndef APP-NVUE */
181
-		display: flex;
182
-		/* #endif */
183
-		flex-direction: column;
184
-		justify-content: flex-start;
185
-	}
186
-
187
-	.files-button {
188
-		// border: 1px red solid;
189
-	}
190
-
191
-	.uni-file-picker__lists {
192
-		position: relative;
193
-		margin-top: 5px;
194
-		overflow: hidden;
195
-	}
196
-
197
-	.file-picker__mask {
198
-		/* #ifndef APP-NVUE */
199
-		display: flex;
200
-		/* #endif */
201
-		justify-content: center;
202
-		align-items: center;
203
-		position: absolute;
204
-		right: 0;
205
-		top: 0;
206
-		bottom: 0;
207
-		left: 0;
208
-		color: #fff;
209
-		font-size: 14px;
210
-		background-color: rgba(0, 0, 0, 0.4);
211
-	}
212
-
213
-	.uni-file-picker__lists-box {
214
-		position: relative;
215
-	}
216
-
217
-	.uni-file-picker__item {
218
-		/* #ifndef APP-NVUE */
219
-		display: flex;
220
-		/* #endif */
221
-		align-items: center;
222
-		padding: 8px 10px;
223
-		padding-right: 5px;
224
-		padding-left: 10px;
225
-	}
226
-
227
-	.files-border {
228
-		border-top: 1px #eee solid;
229
-	}
230
-
231
-	.files__name {
232
-		flex: 1;
233
-		font-size: 14px;
234
-		color: #666;
235
-		margin-right: 25px;
236
-		/* #ifndef APP-NVUE */
237
-		word-break: break-all;
238
-		word-wrap: break-word;
239
-		/* #endif */
240
-	}
241
-
242
-	.icon-files {
243
-		/* #ifndef APP-NVUE */
244
-		position: static;
245
-		background-color: initial;
246
-		/* #endif */
247
-	}
248
-
249
-	// .icon-files .icon-del {
250
-	// 	background-color: #333;
251
-	// 	width: 12px;
252
-	// 	height: 1px;
253
-	// }
254
-
255
-
256
-	.is-list-card {
257
-		border: 1px #eee solid;
258
-		margin-bottom: 5px;
259
-		border-radius: 5px;
260
-		box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.1);
261
-		padding: 5px;
262
-	}
263
-
264
-	.files__image {
265
-		width: 40px;
266
-		height: 40px;
267
-		margin-right: 10px;
268
-	}
269
-
270
-	.header-image {
271
-		width: 100%;
272
-		height: 100%;
273
-	}
274
-
275
-	.is-text-box {
276
-		border: 1px #eee solid;
277
-		border-radius: 5px;
278
-	}
279
-
280
-	.is-text-image {
281
-		width: 25px;
282
-		height: 25px;
283
-		margin-left: 5px;
284
-	}
285
-
286
-	.rotate {
287
-		position: absolute;
288
-		transform: rotate(90deg);
289
-	}
290
-
291
-	.icon-del-box {
292
-		/* #ifndef APP-NVUE */
293
-		display: flex;
294
-		margin: auto 0;
295
-		/* #endif */
296
-		align-items: center;
297
-		justify-content: center;
298
-		position: absolute;
299
-		top: 0px;
300
-		bottom: 0;
301
-		right: 5px;
302
-		height: 26px;
303
-		width: 26px;
304
-		// border-radius: 50%;
305
-		// background-color: rgba(0, 0, 0, 0.5);
306
-		z-index: 2;
307
-		transform: rotate(-45deg);
308
-	}
309
-
310
-	.icon-del {
311
-		width: 15px;
312
-		height: 1px;
313
-		background-color: #333;
314
-		// border-radius: 1px;
315
-	}
316
-
317
-	/* #ifdef H5 */
318
-	@media all and (min-width: 768px) {
319
-		.uni-file-picker__files {
320
-			max-width: 375px;
321
-		}
322
-	}
323
-
324
-	/* #endif */
325
-</style>
1
+<template>
2
+	<view class="uni-file-picker__files">
3
+		<view v-if="!readonly" class="files-button" @click="choose">
4
+			<slot></slot>
5
+		</view>
6
+		<!-- :class="{'is-text-box':showType === 'list'}" -->
7
+		<view v-if="list.length > 0" class="uni-file-picker__lists is-text-box" :style="borderStyle">
8
+			<!-- ,'is-list-card':showType === 'list-card' -->
9
+
10
+			<view class="uni-file-picker__lists-box" v-for="(item ,index) in list" :key="index" :class="{
11
+				'files-border':index !== 0 && styles.dividline}"
12
+			 :style="index !== 0 && styles.dividline &&borderLineStyle">
13
+				<view class="uni-file-picker__item">
14
+					<!-- :class="{'is-text-image':showType === 'list'}" -->
15
+					<!-- 	<view class="files__image is-text-image">
16
+						<image class="header-image" :src="item.logo" mode="aspectFit"></image>
17
+					</view> -->
18
+					<view class="files__name">{{item.name}}</view>
19
+					<view v-if="delIcon&&!readonly" class="icon-del-box icon-files" @click="delFile(index)">
20
+						<view class="icon-del icon-files"></view>
21
+						<view class="icon-del rotate"></view>
22
+					</view>
23
+				</view>
24
+				<view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
25
+					<progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
26
+					 :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
27
+				</view>
28
+				<view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
29
+					点击重试
30
+				</view>
31
+			</view>
32
+
33
+		</view>
34
+	</view>
35
+</template>
36
+
37
+<script>
38
+	export default {
39
+		name: "uploadFile",
40
+		emits:['uploadFiles','choose','delFile'],
41
+		props: {
42
+			filesList: {
43
+				type: Array,
44
+				default () {
45
+					return []
46
+				}
47
+			},
48
+			delIcon: {
49
+				type: Boolean,
50
+				default: true
51
+			},
52
+			limit: {
53
+				type: [Number, String],
54
+				default: 9
55
+			},
56
+			showType: {
57
+				type: String,
58
+				default: ''
59
+			},
60
+			listStyles: {
61
+				type: Object,
62
+				default () {
63
+					return {
64
+						// 是否显示边框
65
+						border: true,
66
+						// 是否显示分隔线
67
+						dividline: true,
68
+						// 线条样式
69
+						borderStyle: {}
70
+					}
71
+				}
72
+			},
73
+			readonly:{
74
+				type:Boolean,
75
+				default:false
76
+			}
77
+		},
78
+		computed: {
79
+			list() {
80
+				let files = []
81
+				this.filesList.forEach(v => {
82
+					files.push(v)
83
+				})
84
+				return files
85
+			},
86
+			styles() {
87
+				let styles = {
88
+					border: true,
89
+					dividline: true,
90
+					'border-style': {}
91
+				}
92
+				return Object.assign(styles, this.listStyles)
93
+			},
94
+			borderStyle() {
95
+				let {
96
+					borderStyle,
97
+					border
98
+				} = this.styles
99
+				let obj = {}
100
+				if (!border) {
101
+					obj.border = 'none'
102
+				} else {
103
+					let width = (borderStyle && borderStyle.width) || 1
104
+					width = this.value2px(width)
105
+					let radius = (borderStyle && borderStyle.radius) || 5
106
+					radius = this.value2px(radius)
107
+					obj = {
108
+						'border-width': width,
109
+						'border-style': (borderStyle && borderStyle.style) || 'solid',
110
+						'border-color': (borderStyle && borderStyle.color) || '#eee',
111
+						'border-radius': radius
112
+					}
113
+				}
114
+				let classles = ''
115
+				for (let i in obj) {
116
+					classles += `${i}:${obj[i]};`
117
+				}
118
+				return classles
119
+			},
120
+			borderLineStyle() {
121
+				let obj = {}
122
+				let {
123
+					borderStyle
124
+				} = this.styles
125
+				if (borderStyle && borderStyle.color) {
126
+					obj['border-color'] = borderStyle.color
127
+				}
128
+				if (borderStyle && borderStyle.width) {
129
+					let width = borderStyle && borderStyle.width || 1
130
+					let style = borderStyle && borderStyle.style || 0
131
+					if (typeof width === 'number') {
132
+						width += 'px'
133
+					} else {
134
+						width = width.indexOf('px') ? width : width + 'px'
135
+					}
136
+					obj['border-width'] = width
137
+
138
+					if (typeof style === 'number') {
139
+						style += 'px'
140
+					} else {
141
+						style = style.indexOf('px') ? style : style + 'px'
142
+					}
143
+					obj['border-top-style'] = style
144
+				}
145
+				let classles = ''
146
+				for (let i in obj) {
147
+					classles += `${i}:${obj[i]};`
148
+				}
149
+				return classles
150
+			}
151
+		},
152
+
153
+		methods: {
154
+			uploadFiles(item, index) {
155
+				this.$emit("uploadFiles", {
156
+					item,
157
+					index
158
+				})
159
+			},
160
+			choose() {
161
+				this.$emit("choose")
162
+			},
163
+			delFile(index) {
164
+				this.$emit('delFile', index)
165
+			},
166
+			value2px(value) {
167
+				if (typeof value === 'number') {
168
+					value += 'px'
169
+				} else {
170
+					value = value.indexOf('px') !== -1 ? value : value + 'px'
171
+				}
172
+				return value
173
+			}
174
+		}
175
+	}
176
+</script>
177
+
178
+<style lang="scss">
179
+	.uni-file-picker__files {
180
+		/* #ifndef APP-NVUE */
181
+		display: flex;
182
+		/* #endif */
183
+		flex-direction: column;
184
+		justify-content: flex-start;
185
+	}
186
+
187
+	.files-button {
188
+		// border: 1px red solid;
189
+	}
190
+
191
+	.uni-file-picker__lists {
192
+		position: relative;
193
+		margin-top: 5px;
194
+		overflow: hidden;
195
+	}
196
+
197
+	.file-picker__mask {
198
+		/* #ifndef APP-NVUE */
199
+		display: flex;
200
+		/* #endif */
201
+		justify-content: center;
202
+		align-items: center;
203
+		position: absolute;
204
+		right: 0;
205
+		top: 0;
206
+		bottom: 0;
207
+		left: 0;
208
+		color: #fff;
209
+		font-size: 14px;
210
+		background-color: rgba(0, 0, 0, 0.4);
211
+	}
212
+
213
+	.uni-file-picker__lists-box {
214
+		position: relative;
215
+	}
216
+
217
+	.uni-file-picker__item {
218
+		/* #ifndef APP-NVUE */
219
+		display: flex;
220
+		/* #endif */
221
+		align-items: center;
222
+		padding: 8px 10px;
223
+		padding-right: 5px;
224
+		padding-left: 10px;
225
+	}
226
+
227
+	.files-border {
228
+		border-top: 1px #eee solid;
229
+	}
230
+
231
+	.files__name {
232
+		flex: 1;
233
+		font-size: 14px;
234
+		color: #666;
235
+		margin-right: 25px;
236
+		/* #ifndef APP-NVUE */
237
+		word-break: break-all;
238
+		word-wrap: break-word;
239
+		/* #endif */
240
+	}
241
+
242
+	.icon-files {
243
+		/* #ifndef APP-NVUE */
244
+		position: static;
245
+		background-color: initial;
246
+		/* #endif */
247
+	}
248
+
249
+	// .icon-files .icon-del {
250
+	// 	background-color: #333;
251
+	// 	width: 12px;
252
+	// 	height: 1px;
253
+	// }
254
+
255
+
256
+	.is-list-card {
257
+		border: 1px #eee solid;
258
+		margin-bottom: 5px;
259
+		border-radius: 5px;
260
+		box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.1);
261
+		padding: 5px;
262
+	}
263
+
264
+	.files__image {
265
+		width: 40px;
266
+		height: 40px;
267
+		margin-right: 10px;
268
+	}
269
+
270
+	.header-image {
271
+		width: 100%;
272
+		height: 100%;
273
+	}
274
+
275
+	.is-text-box {
276
+		border: 1px #eee solid;
277
+		border-radius: 5px;
278
+	}
279
+
280
+	.is-text-image {
281
+		width: 25px;
282
+		height: 25px;
283
+		margin-left: 5px;
284
+	}
285
+
286
+	.rotate {
287
+		position: absolute;
288
+		transform: rotate(90deg);
289
+	}
290
+
291
+	.icon-del-box {
292
+		/* #ifndef APP-NVUE */
293
+		display: flex;
294
+		margin: auto 0;
295
+		/* #endif */
296
+		align-items: center;
297
+		justify-content: center;
298
+		position: absolute;
299
+		top: 0px;
300
+		bottom: 0;
301
+		right: 5px;
302
+		height: 26px;
303
+		width: 26px;
304
+		// border-radius: 50%;
305
+		// background-color: rgba(0, 0, 0, 0.5);
306
+		z-index: 2;
307
+		transform: rotate(-45deg);
308
+	}
309
+
310
+	.icon-del {
311
+		width: 15px;
312
+		height: 1px;
313
+		background-color: #333;
314
+		// border-radius: 1px;
315
+	}
316
+
317
+	/* #ifdef H5 */
318
+	@media all and (min-width: 768px) {
319
+		.uni-file-picker__files {
320
+			max-width: 375px;
321
+		}
322
+	}
323
+
324
+	/* #endif */
325
+</style>

+ 292
- 292
uni_modules/uni-file-picker/components/uni-file-picker/upload-image.vue Просмотреть файл

@@ -1,292 +1,292 @@
1
-<template>
2
-	<view class="uni-file-picker__container">
3
-		<view class="file-picker__box" v-for="(item,index) in filesList" :key="index" :style="boxStyle">
4
-			<view class="file-picker__box-content" :style="borderStyle">
5
-				<image class="file-image" :src="item.url" mode="aspectFill" @click.stop="prviewImage(item,index)"></image>
6
-				<view v-if="delIcon && !readonly" class="icon-del-box" @click.stop="delFile(index)">
7
-					<view class="icon-del"></view>
8
-					<view class="icon-del rotate"></view>
9
-				</view>
10
-				<view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
11
-					<progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
12
-					 :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
13
-				</view>
14
-				<view v-if="item.errMsg" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
15
-					点击重试
16
-				</view>
17
-			</view>
18
-		</view>
19
-		<view v-if="filesList.length < limit && !readonly" class="file-picker__box" :style="boxStyle">
20
-			<view class="file-picker__box-content is-add" :style="borderStyle" @click="choose">
21
-				<slot>
22
-					<view class="icon-add"></view>
23
-					<view class="icon-add rotate"></view>
24
-				</slot>
25
-			</view>
26
-		</view>
27
-	</view>
28
-</template>
29
-
30
-<script>
31
-	export default {
32
-		name: "uploadImage",
33
-		emits:['uploadFiles','choose','delFile'],
34
-		props: {
35
-			filesList: {
36
-				type: Array,
37
-				default () {
38
-					return []
39
-				}
40
-			},
41
-			disabled:{
42
-				type: Boolean,
43
-				default: false
44
-			},
45
-			disablePreview: {
46
-				type: Boolean,
47
-				default: false
48
-			},
49
-			limit: {
50
-				type: [Number, String],
51
-				default: 9
52
-			},
53
-			imageStyles: {
54
-				type: Object,
55
-				default () {
56
-					return {
57
-						width: 'auto',
58
-						height: 'auto',
59
-						border: {}
60
-					}
61
-				}
62
-			},
63
-			delIcon: {
64
-				type: Boolean,
65
-				default: true
66
-			},
67
-			readonly:{
68
-				type:Boolean,
69
-				default:false
70
-			}
71
-		},
72
-		computed: {
73
-			styles() {
74
-				let styles = {
75
-					width: 'auto',
76
-					height: 'auto',
77
-					border: {}
78
-				}
79
-				return Object.assign(styles, this.imageStyles)
80
-			},
81
-			boxStyle() {
82
-				const {
83
-					width = 'auto',
84
-						height = 'auto'
85
-				} = this.styles
86
-				let obj = {}
87
-				if (height === 'auto') {
88
-					if (width !== 'auto') {
89
-						obj.height = this.value2px(width)
90
-						obj['padding-top'] = 0
91
-					} else {
92
-						obj.height = 0
93
-					}
94
-				} else {
95
-					obj.height = this.value2px(height)
96
-					obj['padding-top'] = 0
97
-				}
98
-
99
-				if (width === 'auto') {
100
-					if (height !== 'auto') {
101
-						obj.width = this.value2px(height)
102
-					} else {
103
-						obj.width = '33.3%'
104
-					}
105
-				} else {
106
-					obj.width = this.value2px(width)
107
-				}
108
-
109
-				let classles = ''
110
-				for(let i in obj){
111
-					classles+= `${i}:${obj[i]};`
112
-				}
113
-				return classles
114
-			},
115
-			borderStyle() {
116
-				let {
117
-					border
118
-				} = this.styles
119
-				let obj = {}
120
-				const widthDefaultValue = 1
121
-				const radiusDefaultValue = 3
122
-				if (typeof border === 'boolean') {
123
-					obj.border = border ? '1px #eee solid' : 'none'
124
-				} else {
125
-					let width = (border && border.width) || widthDefaultValue
126
-					width = this.value2px(width)
127
-					let radius = (border && border.radius) || radiusDefaultValue
128
-					radius = this.value2px(radius)
129
-					obj = {
130
-						'border-width': width,
131
-						'border-style': (border && border.style) || 'solid',
132
-						'border-color': (border && border.color) || '#eee',
133
-						'border-radius': radius
134
-					}
135
-				}
136
-				let classles = ''
137
-				for(let i in obj){
138
-					classles+= `${i}:${obj[i]};`
139
-				}
140
-				return classles
141
-			}
142
-		},
143
-		methods: {
144
-			uploadFiles(item, index) {
145
-				this.$emit("uploadFiles", item)
146
-			},
147
-			choose() {
148
-				this.$emit("choose")
149
-			},
150
-			delFile(index) {
151
-				this.$emit('delFile', index)
152
-			},
153
-			prviewImage(img, index) {
154
-				let urls = []
155
-				if(Number(this.limit) === 1&&this.disablePreview&&!this.disabled){
156
-					this.$emit("choose")
157
-				}
158
-				if(this.disablePreview) return
159
-				this.filesList.forEach(i => {
160
-					urls.push(i.url)
161
-				})
162
-
163
-				uni.previewImage({
164
-					urls: urls,
165
-					current: index
166
-				});
167
-			},
168
-			value2px(value) {
169
-				if (typeof value === 'number') {
170
-					value += 'px'
171
-				} else {
172
-					if (value.indexOf('%') === -1) {
173
-						value = value.indexOf('px') !== -1 ? value : value + 'px'
174
-					}
175
-				}
176
-				return value
177
-			}
178
-		}
179
-	}
180
-</script>
181
-
182
-<style lang="scss">
183
-	.uni-file-picker__container {
184
-		/* #ifndef APP-NVUE */
185
-		display: flex;
186
-		box-sizing: border-box;
187
-		/* #endif */
188
-		flex-wrap: wrap;
189
-		margin: -5px;
190
-	}
191
-
192
-	.file-picker__box {
193
-		position: relative;
194
-		// flex: 0 0 33.3%;
195
-		width: 33.3%;
196
-		height: 0;
197
-		padding-top: 33.33%;
198
-		/* #ifndef APP-NVUE */
199
-		box-sizing: border-box;
200
-		/* #endif */
201
-	}
202
-
203
-	.file-picker__box-content {
204
-		position: absolute;
205
-		top: 0;
206
-		right: 0;
207
-		bottom: 0;
208
-		left: 0;
209
-		margin: 5px;
210
-		border: 1px #eee solid;
211
-		border-radius: 5px;
212
-		overflow: hidden;
213
-	}
214
-
215
-	.file-picker__progress {
216
-		position: absolute;
217
-		bottom: 0;
218
-		left: 0;
219
-		right: 0;
220
-		/* border: 1px red solid; */
221
-		z-index: 2;
222
-	}
223
-
224
-	.file-picker__progress-item {
225
-		width: 100%;
226
-	}
227
-
228
-	.file-picker__mask {
229
-		/* #ifndef APP-NVUE */
230
-		display: flex;
231
-		/* #endif */
232
-		justify-content: center;
233
-		align-items: center;
234
-		position: absolute;
235
-		right: 0;
236
-		top: 0;
237
-		bottom: 0;
238
-		left: 0;
239
-		color: #fff;
240
-		font-size: 12px;
241
-		background-color: rgba(0, 0, 0, 0.4);
242
-	}
243
-
244
-	.file-image {
245
-		width: 100%;
246
-		height: 100%;
247
-	}
248
-
249
-	.is-add {
250
-		/* #ifndef APP-NVUE */
251
-		display: flex;
252
-		/* #endif */
253
-		align-items: center;
254
-		justify-content: center;
255
-	}
256
-
257
-	.icon-add {
258
-		width: 50px;
259
-		height: 5px;
260
-		background-color: #f1f1f1;
261
-		border-radius: 2px;
262
-	}
263
-
264
-	.rotate {
265
-		position: absolute;
266
-		transform: rotate(90deg);
267
-	}
268
-
269
-	.icon-del-box {
270
-		/* #ifndef APP-NVUE */
271
-		display: flex;
272
-		/* #endif */
273
-		align-items: center;
274
-		justify-content: center;
275
-		position: absolute;
276
-		top: 3px;
277
-		right: 3px;
278
-		height: 26px;
279
-		width: 26px;
280
-		border-radius: 50%;
281
-		background-color: rgba(0, 0, 0, 0.5);
282
-		z-index: 2;
283
-		transform: rotate(-45deg);
284
-	}
285
-
286
-	.icon-del {
287
-		width: 15px;
288
-		height: 2px;
289
-		background-color: #fff;
290
-		border-radius: 2px;
291
-	}
292
-</style>
1
+<template>
2
+	<view class="uni-file-picker__container">
3
+		<view class="file-picker__box" v-for="(item,index) in filesList" :key="index" :style="boxStyle">
4
+			<view class="file-picker__box-content" :style="borderStyle">
5
+				<image class="file-image" :src="item.url" mode="aspectFill" @click.stop="prviewImage(item,index)"></image>
6
+				<view v-if="delIcon && !readonly" class="icon-del-box" @click.stop="delFile(index)">
7
+					<view class="icon-del"></view>
8
+					<view class="icon-del rotate"></view>
9
+				</view>
10
+				<view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
11
+					<progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
12
+					 :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
13
+				</view>
14
+				<view v-if="item.errMsg" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
15
+					点击重试
16
+				</view>
17
+			</view>
18
+		</view>
19
+		<view v-if="filesList.length < limit && !readonly" class="file-picker__box" :style="boxStyle">
20
+			<view class="file-picker__box-content is-add" :style="borderStyle" @click="choose">
21
+				<slot>
22
+					<view class="icon-add"></view>
23
+					<view class="icon-add rotate"></view>
24
+				</slot>
25
+			</view>
26
+		</view>
27
+	</view>
28
+</template>
29
+
30
+<script>
31
+	export default {
32
+		name: "uploadImage",
33
+		emits:['uploadFiles','choose','delFile'],
34
+		props: {
35
+			filesList: {
36
+				type: Array,
37
+				default () {
38
+					return []
39
+				}
40
+			},
41
+			disabled:{
42
+				type: Boolean,
43
+				default: false
44
+			},
45
+			disablePreview: {
46
+				type: Boolean,
47
+				default: false
48
+			},
49
+			limit: {
50
+				type: [Number, String],
51
+				default: 9
52
+			},
53
+			imageStyles: {
54
+				type: Object,
55
+				default () {
56
+					return {
57
+						width: 'auto',
58
+						height: 'auto',
59
+						border: {}
60
+					}
61
+				}
62
+			},
63
+			delIcon: {
64
+				type: Boolean,
65
+				default: true
66
+			},
67
+			readonly:{
68
+				type:Boolean,
69
+				default:false
70
+			}
71
+		},
72
+		computed: {
73
+			styles() {
74
+				let styles = {
75
+					width: 'auto',
76
+					height: 'auto',
77
+					border: {}
78
+				}
79
+				return Object.assign(styles, this.imageStyles)
80
+			},
81
+			boxStyle() {
82
+				const {
83
+					width = 'auto',
84
+						height = 'auto'
85
+				} = this.styles
86
+				let obj = {}
87
+				if (height === 'auto') {
88
+					if (width !== 'auto') {
89
+						obj.height = this.value2px(width)
90
+						obj['padding-top'] = 0
91
+					} else {
92
+						obj.height = 0
93
+					}
94
+				} else {
95
+					obj.height = this.value2px(height)
96
+					obj['padding-top'] = 0
97
+				}
98
+
99
+				if (width === 'auto') {
100
+					if (height !== 'auto') {
101
+						obj.width = this.value2px(height)
102
+					} else {
103
+						obj.width = '33.3%'
104
+					}
105
+				} else {
106
+					obj.width = this.value2px(width)
107
+				}
108
+
109
+				let classles = ''
110
+				for(let i in obj){
111
+					classles+= `${i}:${obj[i]};`
112
+				}
113
+				return classles
114
+			},
115
+			borderStyle() {
116
+				let {
117
+					border
118
+				} = this.styles
119
+				let obj = {}
120
+				const widthDefaultValue = 1
121
+				const radiusDefaultValue = 3
122
+				if (typeof border === 'boolean') {
123
+					obj.border = border ? '1px #eee solid' : 'none'
124
+				} else {
125
+					let width = (border && border.width) || widthDefaultValue
126
+					width = this.value2px(width)
127
+					let radius = (border && border.radius) || radiusDefaultValue
128
+					radius = this.value2px(radius)
129
+					obj = {
130
+						'border-width': width,
131
+						'border-style': (border && border.style) || 'solid',
132
+						'border-color': (border && border.color) || '#eee',
133
+						'border-radius': radius
134
+					}
135
+				}
136
+				let classles = ''
137
+				for(let i in obj){
138
+					classles+= `${i}:${obj[i]};`
139
+				}
140
+				return classles
141
+			}
142
+		},
143
+		methods: {
144
+			uploadFiles(item, index) {
145
+				this.$emit("uploadFiles", item)
146
+			},
147
+			choose() {
148
+				this.$emit("choose")
149
+			},
150
+			delFile(index) {
151
+				this.$emit('delFile', index)
152
+			},
153
+			prviewImage(img, index) {
154
+				let urls = []
155
+				if(Number(this.limit) === 1&&this.disablePreview&&!this.disabled){
156
+					this.$emit("choose")
157
+				}
158
+				if(this.disablePreview) return
159
+				this.filesList.forEach(i => {
160
+					urls.push(i.url)
161
+				})
162
+
163
+				uni.previewImage({
164
+					urls: urls,
165
+					current: index
166
+				});
167
+			},
168
+			value2px(value) {
169
+				if (typeof value === 'number') {
170
+					value += 'px'
171
+				} else {
172
+					if (value.indexOf('%') === -1) {
173
+						value = value.indexOf('px') !== -1 ? value : value + 'px'
174
+					}
175
+				}
176
+				return value
177
+			}
178
+		}
179
+	}
180
+</script>
181
+
182
+<style lang="scss">
183
+	.uni-file-picker__container {
184
+		/* #ifndef APP-NVUE */
185
+		display: flex;
186
+		box-sizing: border-box;
187
+		/* #endif */
188
+		flex-wrap: wrap;
189
+		margin: -5px;
190
+	}
191
+
192
+	.file-picker__box {
193
+		position: relative;
194
+		// flex: 0 0 33.3%;
195
+		width: 33.3%;
196
+		height: 0;
197
+		padding-top: 33.33%;
198
+		/* #ifndef APP-NVUE */
199
+		box-sizing: border-box;
200
+		/* #endif */
201
+	}
202
+
203
+	.file-picker__box-content {
204
+		position: absolute;
205
+		top: 0;
206
+		right: 0;
207
+		bottom: 0;
208
+		left: 0;
209
+		margin: 5px;
210
+		border: 1px #eee solid;
211
+		border-radius: 5px;
212
+		overflow: hidden;
213
+	}
214
+
215
+	.file-picker__progress {
216
+		position: absolute;
217
+		bottom: 0;
218
+		left: 0;
219
+		right: 0;
220
+		/* border: 1px red solid; */
221
+		z-index: 2;
222
+	}
223
+
224
+	.file-picker__progress-item {
225
+		width: 100%;
226
+	}
227
+
228
+	.file-picker__mask {
229
+		/* #ifndef APP-NVUE */
230
+		display: flex;
231
+		/* #endif */
232
+		justify-content: center;
233
+		align-items: center;
234
+		position: absolute;
235
+		right: 0;
236
+		top: 0;
237
+		bottom: 0;
238
+		left: 0;
239
+		color: #fff;
240
+		font-size: 12px;
241
+		background-color: rgba(0, 0, 0, 0.4);
242
+	}
243
+
244
+	.file-image {
245
+		width: 100%;
246
+		height: 100%;
247
+	}
248
+
249
+	.is-add {
250
+		/* #ifndef APP-NVUE */
251
+		display: flex;
252
+		/* #endif */
253
+		align-items: center;
254
+		justify-content: center;
255
+	}
256
+
257
+	.icon-add {
258
+		width: 50px;
259
+		height: 5px;
260
+		background-color: #f1f1f1;
261
+		border-radius: 2px;
262
+	}
263
+
264
+	.rotate {
265
+		position: absolute;
266
+		transform: rotate(90deg);
267
+	}
268
+
269
+	.icon-del-box {
270
+		/* #ifndef APP-NVUE */
271
+		display: flex;
272
+		/* #endif */
273
+		align-items: center;
274
+		justify-content: center;
275
+		position: absolute;
276
+		top: 3px;
277
+		right: 3px;
278
+		height: 26px;
279
+		width: 26px;
280
+		border-radius: 50%;
281
+		background-color: rgba(0, 0, 0, 0.5);
282
+		z-index: 2;
283
+		transform: rotate(-45deg);
284
+	}
285
+
286
+	.icon-del {
287
+		width: 15px;
288
+		height: 2px;
289
+		background-color: #fff;
290
+		border-radius: 2px;
291
+	}
292
+</style>

+ 109
- 109
uni_modules/uni-file-picker/components/uni-file-picker/utils.js Просмотреть файл

@@ -1,109 +1,109 @@
1
-/**
2
- * 获取文件名和后缀
3
- * @param {String} name
4
- */
5
-export const get_file_ext = (name) => {
6
-	const last_len = name.lastIndexOf('.')
7
-	const len = name.length
8
-	return {
9
-		name: name.substring(0, last_len),
10
-		ext: name.substring(last_len + 1, len)
11
-	}
12
-}
13
-
14
-/**
15
- * 获取扩展名
16
- * @param {Array} fileExtname
17
- */
18
-export const get_extname = (fileExtname) => {
19
-	if (!Array.isArray(fileExtname)) {
20
-		let extname = fileExtname.replace(/(\[|\])/g, '')
21
-		return extname.split(',')
22
-	} else {
23
-		return fileExtname
24
-	}
25
-	return []
26
-}
27
-
28
-/**
29
- * 获取文件和检测是否可选
30
- */
31
-export const get_files_and_is_max = (res, _extname) => {
32
-	let filePaths = []
33
-	let files = []
34
-	if(!_extname || _extname.length === 0){
35
-		return {
36
-			filePaths,
37
-			files
38
-		}
39
-	}
40
-	res.tempFiles.forEach(v => {
41
-		let fileFullName = get_file_ext(v.name)
42
-		const extname = fileFullName.ext.toLowerCase()
43
-		if (_extname.indexOf(extname) !== -1) {
44
-			files.push(v)
45
-			filePaths.push(v.path)
46
-		}
47
-	})
48
-	if (files.length !== res.tempFiles.length) {
49
-		uni.showToast({
50
-			title: `当前选择了${res.tempFiles.length}个文件 ,${res.tempFiles.length - files.length} 个文件格式不正确`,
51
-			icon: 'none',
52
-			duration: 5000
53
-		})
54
-	}
55
-
56
-	return {
57
-		filePaths,
58
-		files
59
-	}
60
-}
61
-
62
-
63
-/**
64
- * 获取图片信息
65
- * @param {Object} filepath
66
- */
67
-export const get_file_info = (filepath) => {
68
-	return new Promise((resolve, reject) => {
69
-		uni.getImageInfo({
70
-			src: filepath,
71
-			success(res) {
72
-				resolve(res)
73
-			},
74
-			fail(err) {
75
-				reject(err)
76
-			}
77
-		})
78
-	})
79
-}
80
-/**
81
- * 获取封装数据
82
- */
83
-export const get_file_data = async (files, type = 'image') => {
84
-	// 最终需要上传数据库的数据
85
-	let fileFullName = get_file_ext(files.name)
86
-	const extname = fileFullName.ext.toLowerCase()
87
-	let filedata = {
88
-		name: files.name,
89
-		uuid: files.uuid,
90
-		extname: extname || '',
91
-		cloudPath: files.cloudPath,
92
-		fileType: files.fileType,
93
-		url: files.path || files.path,
94
-		size: files.size, //单位是字节
95
-		image: {},
96
-		path: files.path,
97
-		video: {}
98
-	}
99
-	if (type === 'image') {
100
-		const imageinfo = await get_file_info(files.path)
101
-		delete filedata.video
102
-		filedata.image.width = imageinfo.width
103
-		filedata.image.height = imageinfo.height
104
-		filedata.image.location = imageinfo.path
105
-	} else {
106
-		delete filedata.image
107
-	}
108
-	return filedata
109
-}
1
+/**
2
+ * 获取文件名和后缀
3
+ * @param {String} name
4
+ */
5
+export const get_file_ext = (name) => {
6
+	const last_len = name.lastIndexOf('.')
7
+	const len = name.length
8
+	return {
9
+		name: name.substring(0, last_len),
10
+		ext: name.substring(last_len + 1, len)
11
+	}
12
+}
13
+
14
+/**
15
+ * 获取扩展名
16
+ * @param {Array} fileExtname
17
+ */
18
+export const get_extname = (fileExtname) => {
19
+	if (!Array.isArray(fileExtname)) {
20
+		let extname = fileExtname.replace(/(\[|\])/g, '')
21
+		return extname.split(',')
22
+	} else {
23
+		return fileExtname
24
+	}
25
+	return []
26
+}
27
+
28
+/**
29
+ * 获取文件和检测是否可选
30
+ */
31
+export const get_files_and_is_max = (res, _extname) => {
32
+	let filePaths = []
33
+	let files = []
34
+	if(!_extname || _extname.length === 0){
35
+		return {
36
+			filePaths,
37
+			files
38
+		}
39
+	}
40
+	res.tempFiles.forEach(v => {
41
+		let fileFullName = get_file_ext(v.name)
42
+		const extname = fileFullName.ext.toLowerCase()
43
+		if (_extname.indexOf(extname) !== -1) {
44
+			files.push(v)
45
+			filePaths.push(v.path)
46
+		}
47
+	})
48
+	if (files.length !== res.tempFiles.length) {
49
+		uni.showToast({
50
+			title: `当前选择了${res.tempFiles.length}个文件 ,${res.tempFiles.length - files.length} 个文件格式不正确`,
51
+			icon: 'none',
52
+			duration: 5000
53
+		})
54
+	}
55
+
56
+	return {
57
+		filePaths,
58
+		files
59
+	}
60
+}
61
+
62
+
63
+/**
64
+ * 获取图片信息
65
+ * @param {Object} filepath
66
+ */
67
+export const get_file_info = (filepath) => {
68
+	return new Promise((resolve, reject) => {
69
+		uni.getImageInfo({
70
+			src: filepath,
71
+			success(res) {
72
+				resolve(res)
73
+			},
74
+			fail(err) {
75
+				reject(err)
76
+			}
77
+		})
78
+	})
79
+}
80
+/**
81
+ * 获取封装数据
82
+ */
83
+export const get_file_data = async (files, type = 'image') => {
84
+	// 最终需要上传数据库的数据
85
+	let fileFullName = get_file_ext(files.name)
86
+	const extname = fileFullName.ext.toLowerCase()
87
+	let filedata = {
88
+		name: files.name,
89
+		uuid: files.uuid,
90
+		extname: extname || '',
91
+		cloudPath: files.cloudPath,
92
+		fileType: files.fileType,
93
+		url: files.path || files.path,
94
+		size: files.size, //单位是字节
95
+		image: {},
96
+		path: files.path,
97
+		video: {}
98
+	}
99
+	if (type === 'image') {
100
+		const imageinfo = await get_file_info(files.path)
101
+		delete filedata.video
102
+		filedata.image.width = imageinfo.width
103
+		filedata.image.height = imageinfo.height
104
+		filedata.image.location = imageinfo.path
105
+	} else {
106
+		delete filedata.image
107
+	}
108
+	return filedata
109
+}

+ 83
- 83
uni_modules/uni-file-picker/package.json Просмотреть файл

@@ -1,83 +1,83 @@
1
-{
2
-  "id": "uni-file-picker",
3
-  "displayName": "uni-file-picker 文件选择上传",
4
-  "version": "1.0.4",
5
-  "description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间",
6
-  "keywords": [
7
-    "uni-ui",
8
-    "uniui",
9
-    "图片上传",
10
-    "文件上传"
11
-],
12
-  "repository": "https://github.com/dcloudio/uni-ui",
13
-  "engines": {
14
-    "HBuilderX": ""
15
-  },
16
-  "directories": {
17
-    "example": "../../temps/example_temps"
18
-  },
19
-"dcloudext": {
20
-    "sale": {
21
-      "regular": {
22
-        "price": "0.00"
23
-      },
24
-      "sourcecode": {
25
-        "price": "0.00"
26
-      }
27
-    },
28
-    "contact": {
29
-      "qq": ""
30
-    },
31
-    "declaration": {
32
-      "ads": "无",
33
-      "data": "无",
34
-      "permissions": "无"
35
-    },
36
-    "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
37
-    "type": "component-vue"
38
-  },
39
-  "uni_modules": {
40
-    "dependencies": ["uni-scss"],
41
-    "encrypt": [],
42
-    "platforms": {
43
-      "cloud": {
44
-        "tcb": "y",
45
-        "aliyun": "y"
46
-      },
47
-      "client": {
48
-        "App": {
49
-          "app-vue": "y",
50
-          "app-nvue": "n"
51
-        },
52
-        "H5-mobile": {
53
-          "Safari": "y",
54
-          "Android Browser": "y",
55
-          "微信浏览器(Android)": "y",
56
-          "QQ浏览器(Android)": "y"
57
-        },
58
-        "H5-pc": {
59
-          "Chrome": "y",
60
-          "IE": "y",
61
-          "Edge": "y",
62
-          "Firefox": "y",
63
-          "Safari": "y"
64
-        },
65
-        "小程序": {
66
-          "微信": "y",
67
-          "阿里": "y",
68
-          "百度": "y",
69
-          "字节跳动": "y",
70
-          "QQ": "y"
71
-        },
72
-        "快应用": {
73
-          "华为": "u",
74
-          "联盟": "u"
75
-        },
76
-        "Vue": {
77
-            "vue2": "y",
78
-            "vue3": "y"
79
-        }
80
-      }
81
-    }
82
-  }
83
-}
1
+{
2
+  "id": "uni-file-picker",
3
+  "displayName": "uni-file-picker 文件选择上传",
4
+  "version": "1.0.6",
5
+  "description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间",
6
+  "keywords": [
7
+    "uni-ui",
8
+    "uniui",
9
+    "图片上传",
10
+    "文件上传"
11
+],
12
+  "repository": "https://github.com/dcloudio/uni-ui",
13
+  "engines": {
14
+    "HBuilderX": ""
15
+  },
16
+  "directories": {
17
+    "example": "../../temps/example_temps"
18
+  },
19
+"dcloudext": {
20
+    "sale": {
21
+      "regular": {
22
+        "price": "0.00"
23
+      },
24
+      "sourcecode": {
25
+        "price": "0.00"
26
+      }
27
+    },
28
+    "contact": {
29
+      "qq": ""
30
+    },
31
+    "declaration": {
32
+      "ads": "无",
33
+      "data": "无",
34
+      "permissions": "无"
35
+    },
36
+    "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
37
+    "type": "component-vue"
38
+  },
39
+  "uni_modules": {
40
+    "dependencies": ["uni-scss"],
41
+    "encrypt": [],
42
+    "platforms": {
43
+      "cloud": {
44
+        "tcb": "y",
45
+        "aliyun": "y"
46
+      },
47
+      "client": {
48
+        "App": {
49
+          "app-vue": "y",
50
+          "app-nvue": "n"
51
+        },
52
+        "H5-mobile": {
53
+          "Safari": "y",
54
+          "Android Browser": "y",
55
+          "微信浏览器(Android)": "y",
56
+          "QQ浏览器(Android)": "y"
57
+        },
58
+        "H5-pc": {
59
+          "Chrome": "y",
60
+          "IE": "y",
61
+          "Edge": "y",
62
+          "Firefox": "y",
63
+          "Safari": "y"
64
+        },
65
+        "小程序": {
66
+          "微信": "y",
67
+          "阿里": "y",
68
+          "百度": "y",
69
+          "字节跳动": "y",
70
+          "QQ": "y"
71
+        },
72
+        "快应用": {
73
+          "华为": "u",
74
+          "联盟": "u"
75
+        },
76
+        "Vue": {
77
+            "vue2": "y",
78
+            "vue3": "y"
79
+        }
80
+      }
81
+    }
82
+  }
83
+}

+ 10
- 10
uni_modules/uni-file-picker/readme.md Просмотреть файл

@@ -1,11 +1,11 @@
1
-
2
-## FilePicker 文件选择上传
3
-
4
-> **组件名:uni-file-picker**
5
->  代码块: `uFilePicker`
6
-
7
-
8
-文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间
9
-
10
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-file-picker)
1
+
2
+## FilePicker 文件选择上传
3
+
4
+> **组件名:uni-file-picker**
5
+>  代码块: `uFilePicker`
6
+
7
+
8
+文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间
9
+
10
+### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-file-picker)
11 11
 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839