video.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view>
  3. <!-- 视频 -->
  4. <!-- #ifndef APP-PLUS -->
  5. <view class="diy_video acea-row row-center-wrapper" :style="[boxStyle]">
  6. <video :src="link" :show-mute-btn="pageGesture" :poster="cover" controls :autoplay="false" loop
  7. objectFit="cover"></video>
  8. </view>
  9. <!-- #endif -->
  10. <!-- app端为了解决层级太高,挡住了自定义底部菜单的问题,如果使用原生底部菜单,不存在遮挡问题,可以去掉判断,使用上面的写法就行。 -->
  11. <!-- #ifdef APP-PLUS -->
  12. <view class="diy_video acea-row row-center-wrapper" :style="[boxStyle]">
  13. <iframe :onload="onloadCode" style="width:100%;height:100%;"></iframe>
  14. </view>
  15. <!-- #endif -->
  16. </view>
  17. </template>
  18. <script>
  19. // +----------------------------------------------------------------------
  20. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  21. // +----------------------------------------------------------------------
  22. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  23. // +----------------------------------------------------------------------
  24. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  25. // +----------------------------------------------------------------------
  26. // | Author: CRMEB Team <admin@crmeb.com>
  27. // +----------------------------------------------------------------------
  28. export default {
  29. name: 'pictureCube',
  30. props: {
  31. dataConfig: {
  32. type: Object,
  33. default: () => {}
  34. },
  35. },
  36. data() {
  37. return {
  38. pageGesture: true,
  39. onloadCode: ''
  40. };
  41. },
  42. created() {
  43. // #ifdef APP
  44. this.onloadCode =
  45. `this.contentWindow.document.body.innerHTML = '<video style="width: 100%;height: 100%" objectFit="cover" controls="controls" loop show-mute-btn="${this.pageGesture}" poster="${this.cover}" src="${this.link}"></video>';`
  46. // #endif
  47. },
  48. computed: {
  49. //视频封面
  50. cover() {
  51. return this.dataConfig.cover.url
  52. },
  53. //视频地址
  54. link() {
  55. if (this.dataConfig.tabConfig.tabVal === 0) {
  56. return this.dataConfig.uploadVideo.url
  57. } else {
  58. return this.dataConfig.link.val
  59. }
  60. },
  61. //最外层盒子的样式
  62. boxStyle() {
  63. return {
  64. borderRadius: this.dataConfig.bgStyle.val * 2 + 'rpx',
  65. background: `linear-gradient(${this.dataConfig.bgColor.color[0].item}, ${this.dataConfig.bgColor.color[1].item})`,
  66. margin: this.dataConfig.mbConfig.val * 2 + 'rpx' + ' ' + this.dataConfig.lrConfig.val * 2 + 'rpx' +
  67. ' ' + 0,
  68. padding: this.dataConfig.upConfig.val * 2 + 'rpx' + ' ' + 0 + ' ' + this.dataConfig.downConfig.val *
  69. 2 + 'rpx'
  70. }
  71. },
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .diy_video {
  77. iframe {
  78. border: none;
  79. body {
  80. margin: 0;
  81. }
  82. }
  83. video {
  84. width: 100%;
  85. height: 340rpx;
  86. border-radius: 14rpx;
  87. }
  88. }
  89. </style>