c-pop-videos.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="mask" catchtouchmove="true" :class="maskState===0 ? 'none' : maskState===1 ? 'show' : ''" >
  3. <view class="mask-content" @click.stop.prevent="stopPrevent">
  4. <view class="icon-wrap" @click.stop="toggleMask('none')">
  5. <u-icon name="/static/app/close.png" size="60rpx"></u-icon>
  6. </view>
  7. <view class="video-wraps">
  8. <view class="video-wrap">
  9. <view class="inner">
  10. <video id="myVideo" :src="defautlOptions.url" object-fit="cover" controls style="width: 100%;height: 100%;"></video>
  11. </view>
  12. </view>
  13. </view>
  14. <!-- <view class="title">
  15. <image style="width: 262rpx;height: 52rpx" src="@/static/app/activity_title.png" mode="aspectFit"></image>
  16. </view>
  17. <view class="desc">
  18. <image style="width: 632rpx;height: 598rpx;" src="@/static/app/activity_content.png" mode="aspectFit"></image>
  19. </view> -->
  20. <!-- <view class="action-content">
  21. <u-button type="primary"
  22. style="margin-bottom: 30rpx;"
  23. shape="circle"
  24. class="c-button"
  25. :text="defautlOptions.confirmText"
  26. @click="confirm">
  27. </u-button>
  28. </view> -->
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. name:"c-pop-videos",
  35. data() {
  36. return {
  37. maskState: 0,
  38. defautlOptions: {
  39. url: 'https://miniprogram.galeriejulesgautret.com/prod-api/profile/upload/2022/05/01/ebc6d6d4-4d26-4ff9-a542-fec2b3208566.mp4',
  40. }
  41. };
  42. },
  43. methods: {
  44. stopPrevent(){
  45. },
  46. toggleMask(type){
  47. if(type == "none"){
  48. console.log(this.videoContext)
  49. this.videoContext.stop();
  50. }
  51. let timer = type === 'show' ? 10 : 30;
  52. let state = type === 'show' ? 1 : 0;
  53. this.maskState = 2;
  54. setTimeout(()=>{
  55. this.maskState = state;
  56. }, timer)
  57. },
  58. /**
  59. * @description 确认
  60. * @param {Object} title: String desc: String
  61. */
  62. $confirm(options = {}){
  63. this.videoContext = uni.createVideoContext('myVideo')
  64. // 继承原来的
  65. this.defautlOptions = Object.assign(this.defautlOptions, options);
  66. return new Promise((resolve,reject)=> {
  67. this.toggleMask('show')
  68. // 播放
  69. this.videoContext.play()
  70. this._confirm = () => {
  71. resolve(1)
  72. this._confirm = null;
  73. }
  74. this._cancel = () => {
  75. resolve(0)
  76. this._cancel = null;
  77. }
  78. })
  79. },
  80. confirm() {
  81. if(this._confirm){
  82. this._confirm()
  83. this.toggleMask();
  84. }
  85. },
  86. cancel() {
  87. if(this._cancel){
  88. this._cancel()
  89. this.toggleMask();
  90. }
  91. }
  92. },
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .mask{
  97. display: flex;
  98. align-items: center;
  99. justify-content: center;
  100. position: fixed;
  101. left: 0;
  102. top: var(--window-top);
  103. bottom: 0;
  104. width: 100vw;
  105. background: rgba(0,0,0,0);
  106. z-index: 10001;
  107. transition: .6s;
  108. .mask-content{
  109. padding-top: 0rpx;
  110. display: flex;
  111. flex-direction: column;
  112. width: 720rpx;
  113. min-height: 806rpx;
  114. // background: #fff;
  115. // background: url(@/static/app/activity_bg.png) no-repeat center center/ 720rpx 806rpx;
  116. border-radius: 15px;
  117. transition: transform .1s opacity 0.1s;
  118. transform: scale(1.2);
  119. transition-timing-function: ease-out;
  120. opacity: 0.3;
  121. }
  122. &.none{
  123. display: none;
  124. }
  125. &.show{
  126. background: rgba(0,0,0,.8);
  127. .mask-content{
  128. transition: transform .3s;
  129. opacity: 1;
  130. transform: scale(1);
  131. }
  132. }
  133. .title{
  134. padding-top: 20rpx;
  135. display: flex;
  136. justify-content: center;
  137. align-items: center;
  138. }
  139. .desc {
  140. margin-top: 55rpx;
  141. display: flex;
  142. justify-content: center;
  143. align-items: center;
  144. }
  145. .action-content{
  146. padding-top: 40rpx;
  147. padding-left: 15rpx;
  148. padding-right: 15rpx;
  149. position: absolute;
  150. bottom: -130rpx;
  151. left: 0;
  152. right: 0;
  153. }
  154. }
  155. .icon-wrap{
  156. position: absolute;
  157. top: -40rpx;
  158. right: 20rpx;
  159. }
  160. .video-wrap{
  161. position: absolute;
  162. width: 690rpx;
  163. height: 420rpx;
  164. z-index: 2;
  165. left: 50%;
  166. margin-left: -345rpx;
  167. background-color: #fff;
  168. margin-top: 160rpx;
  169. padding: 5px;
  170. .inner{
  171. background-color: #000;
  172. height: 100%;
  173. }
  174. }
  175. </style>