fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<template>
    <div class="customPage">
        <p class="basicTip">
            小贴士:为防止失真热区图片尺寸需与区域大小严格一致
        </p>
        <div>
            <el-form-item label="热区图片:">
                <custom-upload-img
                  @handle-success="handleSuccess"
                  @handle-remove="handleRemove"
                  :fileList="fileList"
                >
                </custom-upload-img>
            </el-form-item>
            <el-form-item label="视频文件:" :required="true">
                <el-popover
                    placement="top-start"
                    width="200"
                    trigger="hover"
                    v-if="form.videoUrl"
                    :content="form.videoUrl">
                    <i class="el-icon-info" slot="reference"></i>
                </el-popover>
                <custom-upload-img class="uploadVideo"
                  @handle-success="handleVideoSuccess"
                  @handle-remove="handleVideoRemove"
                  :fileList="fileVideoList"
                  :accept='".mp4"'
                >
                </custom-upload-img>
            </el-form-item>
        </div>
        <div v-if="form.videoUrl">
            <div>
                <el-form-item label="视频控件开关:" class="videoFormItem">
                    <el-checkbox v-model="form.playBtn">显示播放控件
                        <span class="itemTips">
                            是否显示视频播放/暂停按钮、播放进度等控件
                        </span>
                    </el-checkbox>
                </el-form-item>
            </div>
            <div>
                <el-form-item label="视频播放模式:" class="videoFormItem">
                    <el-checkbox v-model="form.loopPlay">开启循环播放</el-checkbox>
                    <el-checkbox v-model="form.autoPlay">开启自动播放</el-checkbox>
                    <el-checkbox v-model="form.mutePlay">静音播放视频</el-checkbox>
                    <!-- <el-checkbox v-model="form.autoStopPlay">自动暂停播放</el-checkbox> -->
                </el-form-item>
            </div>
            <p class="basicTip">
                小贴士:ios 暂不支持自动播放
            </p>
        </div>
    </div>
</template>
 
<script>
import { mapMutations } from 'vuex'
 
export default {
  props: ['form'],
  data () {
    return {
    }
  },
  computed: {
    fileList () {
      return this.form.fileUrl ? [{ url: this.form.fileUrl }] : []
    },
    fileVideoList () {
      return this.form.videoUrl ? [{ url: this.form.videoUrl }] : []
    }
  },
  methods: {
    ...mapMutations(['updateCurrent']),
    /**
     * 上传视频成功
     */
    handleVideoSuccess (data) {
      this.updateCurrent({ videoUrl: data.url })
    },
    handleVideoRemove (data) {
      this.updateCurrent({ videoUrl: null, playBtn: false, loopPlay: false, autoPlay: false, mutePlay: false, autoStopPlay: false })
    },
    /**
     * 获取上传成功的图片
     */
    handleSuccess (data) {
      this.updateCurrent({ fileUrl: data.url })
    },
    /**
     * 移除图片
     */
    handleRemove (data) {
      this.updateCurrent({ fileUrl: null })
    }
  }
}
</script>
 
<style lang="scss">
  .el-popover{
    background: rgba(0,0,0,.7) !important;
    color: #ffffff !important
  }
  .el-popover[x-placement^=top] .popper__arrow::after {
    border-top-color: rgba(0,0,0,.7) !important;
  }
  .uploadVideo{
    display: inline-block;
    margin-left: 10px;
    vertical-align: top;
  }
  .videoFormItem {
    .el-form-item__label{
      width: auto !important;
    }
  }
</style>