jufubao-forms 1.0.4-beta2 → 1.0.4-beta4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jufubao-forms",
3
- "version": "1.0.4-beta2",
3
+ "version": "1.0.4-beta4",
4
4
  "private": false,
5
5
  "description": "聚福宝表单业务插件库",
6
6
  "main": "index.js",
@@ -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="aspectFit" @click="handlePreview(i)"></image>
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,21 @@
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%;" :src="getServiceUrl(videoSrc)"></video>
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
+ @click="handleVideoPlay(item)"
108
+ ></video>
109
+ <view v-if="!formPaly[item.field_value + '_play']" class="video_cover">
110
+ <image :src="formPaly[item.field_value + '_cover']" style="width: 100%;height: 100%;" mode="aspectFit"></image>
111
+ <view class="video_play" @click="handleVideoPlay(item)">
112
+ <xd-font-icon icon="iconplayright" color="#fff" size="60"></xd-font-icon>
113
+ </view>
114
+ </view>
101
115
  <view class="close_box" @click.stop="removeMedia(item, i)">
102
116
  <view class="close_box-inner">
103
117
  <xd-font-icon icon="iconguanbi" color="#333333" size="28"></xd-font-icon>
@@ -186,7 +200,7 @@
186
200
  import componentsMixins from "@/mixins/componentsMixins";
187
201
  import extsMixins from "@/mixins/extsMixins";
188
202
  import { mapState } from "vuex";
189
- import getServiceUrl from "@/common/getServiceUrl";
203
+ import getServiceUrl, {getVideoUrl} from "@/common/getServiceUrl";
190
204
  export default {
191
205
  name: "JfbFormsDynamicForm",
192
206
  components: {
@@ -210,6 +224,7 @@
210
224
  return {
211
225
  formName: "",
212
226
  form: {},
227
+ formPaly: {},
213
228
  marketing_tool: "",
214
229
  activity_page_url: "",
215
230
  activity_id: "",
@@ -461,33 +476,50 @@
461
476
  },
462
477
  doAddImage(item){
463
478
  uni.chooseImage({
464
- count: 1,
479
+ count: Number(item.media_count),
465
480
  sourceType: ['album', 'camera'],
466
481
  success: async (res) => {
467
482
  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
483
  this.$xdShowLoading({});
480
- try{
481
- let image = await this.uploadImage(file);
482
- this.form[item.field_value].push(image);
483
- this.handleClearError(item);
484
- this.$xdHideLoading();
485
- }catch(err){
486
- this.$xdHideLoading();
484
+ for(let i = 0; i < res.tempFiles.length; i++){
485
+ if(i < Number(item.media_count)){
486
+ let file = res.tempFiles[i];
487
+ //文件file不能大于item.media_size(MB)
488
+ if(file.size > item.media_size * 1024 * 1024){
489
+ uni.showToast({
490
+ title: '图片大小不能超过' + item.media_size + 'MB',
491
+ duration: 2000,
492
+ icon: "none"
493
+ });
494
+ this.$xdHideLoading();
495
+ return;
496
+ }
497
+ await this.uploadOneImage(file, item);
498
+ }
487
499
  }
500
+ this.$xdHideLoading();
488
501
  }
489
502
  })
490
503
  },
504
+ async uploadOneImage(file, item){
505
+ let image = await this.uploadImage(file);
506
+ this.form[item.field_value].push(image);
507
+ },
508
+ handleVideoPlay(item){
509
+ let videoContext = uni.createVideoContext('video_' + item.field_value, this);
510
+ if(videoContext){
511
+ if(!this.formPaly[item.field_value + '_play']){
512
+ this.$set(this.formPaly, item.field_value + '_play', true)
513
+ videoContext.play();
514
+ }else{
515
+ this.$set(this.formPaly, item.field_value + '_play', false)
516
+ videoContext.pause();
517
+ }
518
+ }
519
+ },
520
+ handleVideoPause(item){
521
+ this.$set(this.formPaly, item.field_value + '_play', false)
522
+ },
491
523
  doAddVideo(item){
492
524
  uni.chooseVideo({
493
525
  sourceType: ['album', 'camera'],
@@ -505,10 +537,19 @@
505
537
  this.$xdShowLoading({});
506
538
  try{
507
539
  let video = await this.uploadImage(file);
540
+ let videoUrl = getVideoUrl(video);
541
+ console.log("videoUrl", videoUrl);
508
542
  this.form[item.field_value].push(video);
543
+ this.formPaly[item.field_value + '_cover'] = videoUrl.url_cover;
509
544
  this.handleClearError(item);
510
545
  this.$xdHideLoading();
511
546
  }catch(err){
547
+ uni.showToast({
548
+ title: '上传失败,重新上传',
549
+ duration: 2000,
550
+ icon: "none"
551
+ });
552
+ this.form[item.field_value] = [];
512
553
  this.$xdHideLoading();
513
554
  }
514
555
  }
@@ -540,7 +581,7 @@
540
581
  resolve(`/${res.key}`);
541
582
  },
542
583
  fail:(err)=>{
543
- resolve('');
584
+ reject(err);
544
585
  console.error(err)
545
586
  }
546
587
  });
@@ -549,10 +590,10 @@
549
590
  })
550
591
  })
551
592
  },
552
- handlePreview(i){
593
+ handlePreview(i, item){
553
594
  uni.previewImage({
554
595
  current: i,
555
- urls: this.showUploadImages
596
+ urls: this.form[item.field_value].map(item => getServiceUrl(item))
556
597
  })
557
598
  },
558
599
  handleClearError(item){
@@ -882,11 +923,36 @@
882
923
  margin-right: 20rpx;
883
924
  margin-bottom: 20rpx;
884
925
  position: relative;
926
+ overflow: hidden;
927
+ display: flex;
928
+ align-items: center;
929
+ .video_cover{
930
+ position: absolute;
931
+ z-index: 2;
932
+ left: 0;
933
+ top: 0;
934
+ width: 100%;
935
+ height: 100%;
936
+ display: flex;
937
+ align-items: center;
938
+ justify-content: center;
939
+ .video_play{
940
+ width: 60rpx;
941
+ height: 60rpx;
942
+ background-color: rgba(0, 0, 0, .5);
943
+ border-radius: 50%;
944
+ position: absolute;
945
+ left: 50%;
946
+ top: 50%;
947
+ transform: translate(-50%, -50%);
948
+ }
949
+ }
885
950
  .close_box{
886
951
  position: absolute;
887
952
  top: 0;
888
953
  right: 0;
889
954
  padding: 10rpx;
955
+ z-index: 5;
890
956
  .close_box-inner{
891
957
  width: 40rpx;
892
958
  height: 40rpx;