Applet swiper carousel scrolling map Pictures + Videos

Code went straight to the theme
wxml:

Click ( here) folded or unfolded

  1. <view class="test_box">
  2.   <swiper indicator-dots="{{indicatorDots}}"
  3.   autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" >
  4.   <swiper-item>
  5.   <view class='ceng'>
  6.       <image src="{{mdc_videofenmian}}" hidden="{{xiaoshi}}"/>
  7.       <view class='btn'><image src="/img/play.png" hidden="{{xiaoshi}}" bindtap="bindPlay" /></view>
  8.       <video src="{{mdc_video}}" objectFit="cover" bindtouchmove="mdc_move1" controls id="mdcVideo" style="width:100%;height:100% " hidden="{{mdc_show}}" >
  9.         <cover-view class='mdc_return' bindtap='returnquanping'>退出全屏</cover-view>
  10.       </video>
  11.   </view>
  12.     </swiper-item>
  13.   <block wx:for="{{imgUrls}}">
  14.     
  15.     <swiper-item>
  16.       <image src="{{item}}"/>
  17.     </swiper-item>
  18.   </block>
  19. </swiper>
  20. </view>

wxss:

Click ( here) folded or unfolded

  1. // pages/test/test.js
  2. Page({
  3.   /**
  4.    * Initial data page
  5.    */
  6.   data: {
  7. // swiper pictures circulation path address
  8.     imgUrls: [
  9.      '/img/01.jpg',
  10.       '/img/02.jpg',
  11.       '/img/03.jpg'
  12.    
  13.     ],
  14.     indicatorDots: false,
  15.     autoplay: false,
  16.     interval: 5000,
  17.     duration: 1000,
  18.     // video path
  19.     mdc_video:'https://cloud.video.taobao.com/play/u/576446681/p/1/e/6/t/1/50140370746.mp4',
  20.     // replace the cover art video
  21.      mdc_videofenmian:'/img/f2.png',
  22.     Cover art // video display parameters disappear
  23.     xiaoshi: false,
  24.     // video display disappears parameters
  25.     mdc_show:true,
  26.   },
  27.   /**
  28.    * Life Cycle function - listen for page loads
  29.    */
  30.   onLoad: function (options) {
  31.   
  32.   },
  33.   /**
  34.    * Life Cycle function - listen for the first time the page rendering is complete
  35.    */
  36.   onReady: function (res) {
  37.     
  38.   },
  39.   /**
  40.    * Life Cycle functions - page display monitor
  41.    */
  42.   onShow: function () {
  43.   
  44.   },
  45.   /**
  46.    * Life Cycle function - monitor page Hide
  47.    */
  48.   onHide: function () {
  49.   
  50.   },
  51.   /**
  52.    * Life Cycle function - monitor page unload
  53.    */
  54.   onUnload: function () {
  55.   
  56.   },
  57.   /**
  58.    * Page-related event handler - the drop-down monitor user actions
  59.    */
  60.   onPullDownRefresh: function () {
  61.   
  62.   },
  63.   /**
  64.    * Bottoming event handler to pull the page
  65.    */
  66.   onReachBottom: function () {
  67.   
  68.   },
  69.   /**
  70.    * User top right, click Share
  71.    */
  72.   onShareAppMessage: function () {
  73.   
  74.   },
  75.   // When the cover clicks the appropriate action to obtain video parameters in the property in JS 
  76.   // Key: Click the picture to the next video to play, but after a pause video playback directly trigger video () the outcome of the program is 150ms delay before playback video on the perfect solution
  77.   bindPlay:function(e){
  78.     var that =this;
  79.    that.videoContext = wx.createVideoContext('mdcVideo');
  80.   // that.videoContext.play()
  81.    that.videoContext.pause();
  82.    setTimeout(function () {
  83.      that.videoContext.play()
  84.    }, 150);
  85.     that.setData({ 
  86.       xiaoshi: true,
  87.       mdc_show:false
  88.     })
  89.      
  90.   },
  91. // Andrews system can detect the distance x video touchemove slides, this has as proof of handover swiper
  92. // ios system to detect x is less than a video touchemove slide to switch through cover-view click event
  93.   mdc_move1: function (e) {
  94.     var that = this;
  95.     console.log(e)
  96.     console.log(e.touches[0].pageX)
  97.     that.videoContext = wx.createVideoContext('mdcVideo');
  98.     if (e.touches[0].clientX > 20) {
  99.       console.log(5555555555555555)
  100.       // that.videoContext.pause();
  101.       that.setData({
  102.       xiaoshi: false,
  103.       mdc_show: true,
  104.      })
  105.     }
  106.   },
  107.   returnquanping:function(e){
  108.     var that = this;
  109.     that.setData({
  110.       xiaoshi: false,
  111.       mdc_show: true,
  112.     })
  113.   }
  114. })
 

Guess you like

Origin www.cnblogs.com/it66/p/11115785.html