jufubao-forms 1.0.4-beta2 → 1.0.4-beta3
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/package.json
CHANGED
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
<template v-if="item.field_type === 'media'">
|
|
85
85
|
<view v-if="item.validate_type==='image'" class="img_list">
|
|
86
86
|
<view class="img_box" v-for="(img, i) in form[item.field_value]" :key="i">
|
|
87
|
-
<image :src="getServiceUrl(img)" class="img_item" mode="
|
|
87
|
+
<image :src="getServiceUrl(img)" class="img_item" mode="widthFix" @click="handlePreview(i, item)"></image>
|
|
88
88
|
<view class="close_box" @click.stop="removeMedia(item, i)">
|
|
89
89
|
<view class="close_box-inner">
|
|
90
90
|
<xd-font-icon icon="iconguanbi" color="#333333" size="28"></xd-font-icon>
|
|
@@ -97,7 +97,20 @@
|
|
|
97
97
|
</view>
|
|
98
98
|
<view v-else-if="item.validate_type==='video'" class="img_list">
|
|
99
99
|
<view class="img_box" v-for="(videoSrc, i) in form[item.field_value]" :key="i">
|
|
100
|
-
<video style="width: 100%;height: 100%;"
|
|
100
|
+
<video style="width: 100%;height: 100%;"
|
|
101
|
+
:id="'video_' + item.field_value"
|
|
102
|
+
:src="getServiceUrl(videoSrc)"
|
|
103
|
+
:controls="false"
|
|
104
|
+
:show-center-play-btn="false"
|
|
105
|
+
@pause="handleVideoPause(item)"
|
|
106
|
+
@ended="handleVideoPause(item)"
|
|
107
|
+
></video>
|
|
108
|
+
<view v-if="!formPaly[item.field_value + '_play']" class="video_cover">
|
|
109
|
+
<image :src="formPaly[item.field_value + '_cover']" style="width: 100%;height: 100%;" mode="aspectFit"></image>
|
|
110
|
+
<view class="video_play" @click="handleVideoPlay(item)">
|
|
111
|
+
<xd-font-icon icon="iconplayright" color="#fff" size="60"></xd-font-icon>
|
|
112
|
+
</view>
|
|
113
|
+
</view>
|
|
101
114
|
<view class="close_box" @click.stop="removeMedia(item, i)">
|
|
102
115
|
<view class="close_box-inner">
|
|
103
116
|
<xd-font-icon icon="iconguanbi" color="#333333" size="28"></xd-font-icon>
|
|
@@ -186,7 +199,7 @@
|
|
|
186
199
|
import componentsMixins from "@/mixins/componentsMixins";
|
|
187
200
|
import extsMixins from "@/mixins/extsMixins";
|
|
188
201
|
import { mapState } from "vuex";
|
|
189
|
-
import getServiceUrl from "@/common/getServiceUrl";
|
|
202
|
+
import getServiceUrl, {getVideoUrl} from "@/common/getServiceUrl";
|
|
190
203
|
export default {
|
|
191
204
|
name: "JfbFormsDynamicForm",
|
|
192
205
|
components: {
|
|
@@ -210,6 +223,7 @@
|
|
|
210
223
|
return {
|
|
211
224
|
formName: "",
|
|
212
225
|
form: {},
|
|
226
|
+
formPaly: {},
|
|
213
227
|
marketing_tool: "",
|
|
214
228
|
activity_page_url: "",
|
|
215
229
|
activity_id: "",
|
|
@@ -461,33 +475,43 @@
|
|
|
461
475
|
},
|
|
462
476
|
doAddImage(item){
|
|
463
477
|
uni.chooseImage({
|
|
464
|
-
count:
|
|
478
|
+
count: Number(item.media_count),
|
|
465
479
|
sourceType: ['album', 'camera'],
|
|
466
480
|
success: async (res) => {
|
|
467
481
|
console.log('chooseImage',res);
|
|
468
|
-
// let filePath = res.tempFilePaths[0];
|
|
469
|
-
let file = res.tempFiles[0];
|
|
470
|
-
//文件file不能大于item.media_size(MB)
|
|
471
|
-
if(file.size > item.media_size * 1024 * 1024){
|
|
472
|
-
uni.showToast({
|
|
473
|
-
title: '图片大小不能超过' + item.media_size + 'MB',
|
|
474
|
-
duration: 2000,
|
|
475
|
-
icon: "none"
|
|
476
|
-
});
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
482
|
this.$xdShowLoading({});
|
|
480
|
-
|
|
481
|
-
let
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
483
|
+
for(let i = 0; i < res.tempFiles.length; i++){
|
|
484
|
+
let file = res.tempFiles[i];
|
|
485
|
+
//文件file不能大于item.media_size(MB)
|
|
486
|
+
if(file.size > item.media_size * 1024 * 1024){
|
|
487
|
+
uni.showToast({
|
|
488
|
+
title: '图片大小不能超过' + item.media_size + 'MB',
|
|
489
|
+
duration: 2000,
|
|
490
|
+
icon: "none"
|
|
491
|
+
});
|
|
492
|
+
this.$xdHideLoading();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
await this.uploadOneImage(file, item);
|
|
487
496
|
}
|
|
497
|
+
this.$xdHideLoading();
|
|
488
498
|
}
|
|
489
499
|
})
|
|
490
500
|
},
|
|
501
|
+
async uploadOneImage(file, item){
|
|
502
|
+
let image = await this.uploadImage(file);
|
|
503
|
+
this.form[item.field_value].push(image);
|
|
504
|
+
},
|
|
505
|
+
handleVideoPlay(item){
|
|
506
|
+
let videoContext = uni.createVideoContext('video_' + item.field_value, this);
|
|
507
|
+
if(videoContext){
|
|
508
|
+
videoContext.play();
|
|
509
|
+
this.$set(this.formPaly, item.field_value + '_play', true)
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
handleVideoPause(item){
|
|
513
|
+
this.$set(this.formPaly, item.field_value + '_play', false)
|
|
514
|
+
},
|
|
491
515
|
doAddVideo(item){
|
|
492
516
|
uni.chooseVideo({
|
|
493
517
|
sourceType: ['album', 'camera'],
|
|
@@ -505,7 +529,10 @@
|
|
|
505
529
|
this.$xdShowLoading({});
|
|
506
530
|
try{
|
|
507
531
|
let video = await this.uploadImage(file);
|
|
532
|
+
let videoUrl = getVideoUrl(video);
|
|
533
|
+
console.log("videoUrl", videoUrl);
|
|
508
534
|
this.form[item.field_value].push(video);
|
|
535
|
+
this.formPaly[item.field_value + '_cover'] = videoUrl.url_cover;
|
|
509
536
|
this.handleClearError(item);
|
|
510
537
|
this.$xdHideLoading();
|
|
511
538
|
}catch(err){
|
|
@@ -549,10 +576,10 @@
|
|
|
549
576
|
})
|
|
550
577
|
})
|
|
551
578
|
},
|
|
552
|
-
handlePreview(i){
|
|
579
|
+
handlePreview(i, item){
|
|
553
580
|
uni.previewImage({
|
|
554
581
|
current: i,
|
|
555
|
-
urls: this.
|
|
582
|
+
urls: this.form[item.field_value].map(item => getServiceUrl(item))
|
|
556
583
|
})
|
|
557
584
|
},
|
|
558
585
|
handleClearError(item){
|
|
@@ -882,11 +909,34 @@
|
|
|
882
909
|
margin-right: 20rpx;
|
|
883
910
|
margin-bottom: 20rpx;
|
|
884
911
|
position: relative;
|
|
912
|
+
overflow: hidden;
|
|
913
|
+
.video_cover{
|
|
914
|
+
position: absolute;
|
|
915
|
+
z-index: 2;
|
|
916
|
+
left: 0;
|
|
917
|
+
top: 0;
|
|
918
|
+
width: 100%;
|
|
919
|
+
height: 100%;
|
|
920
|
+
display: flex;
|
|
921
|
+
align-items: center;
|
|
922
|
+
justify-content: center;
|
|
923
|
+
.video_play{
|
|
924
|
+
width: 60rpx;
|
|
925
|
+
height: 60rpx;
|
|
926
|
+
background-color: rgba(0, 0, 0, .5);
|
|
927
|
+
border-radius: 50%;
|
|
928
|
+
position: absolute;
|
|
929
|
+
left: 50%;
|
|
930
|
+
top: 50%;
|
|
931
|
+
transform: translate(-50%, -50%);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
885
934
|
.close_box{
|
|
886
935
|
position: absolute;
|
|
887
936
|
top: 0;
|
|
888
937
|
right: 0;
|
|
889
938
|
padding: 10rpx;
|
|
939
|
+
z-index: 5;
|
|
890
940
|
.close_box-inner{
|
|
891
941
|
width: 40rpx;
|
|
892
942
|
height: 40rpx;
|