7 changed files with 99 additions and 215 deletions
Unified View
Diff Options
-
152components/swiper-video/index.js
-
6components/swiper-video/index.json
-
18components/swiper-video/index.wxml
-
32components/swiper-video/index.wxss
-
82pages/mall/order-info/index.js
-
4pages/mall/order-info/index.json
-
20pages/mall/order-info/index.wxml
@ -1,152 +0,0 @@ |
|||||
const float = require('../../utils/floatObj'); |
|
||||
|
|
||||
Component({ |
|
||||
options: { |
|
||||
addGlobalClass: true |
|
||||
}, |
|
||||
properties: { |
|
||||
// 数据源
|
|
||||
imgList: { |
|
||||
type: Array, |
|
||||
value: [], |
|
||||
observer: "dataChange" |
|
||||
} |
|
||||
}, |
|
||||
data: { |
|
||||
videoContext: null, |
|
||||
imageHeight: 0, |
|
||||
visible: false, |
|
||||
videoUrl: null |
|
||||
}, |
|
||||
methods: { |
|
||||
/** |
|
||||
* 初始化函数 |
|
||||
*/ |
|
||||
init() { |
|
||||
this.setData({ |
|
||||
imageHeight: float.accDiv(float.accMul(750, 9), 16), |
|
||||
}) |
|
||||
this.data.videoContext = wx.createVideoContext('video', this) |
|
||||
}, |
|
||||
isVideoUrl: function (url) { |
|
||||
if (url && url.indexOf('.mp4') >= 0) { |
|
||||
return true |
|
||||
} |
|
||||
return false |
|
||||
}, |
|
||||
dataChange(newVal, oldVal) { |
|
||||
var vindex = -1 |
|
||||
var vurl = null |
|
||||
var imgList = [] |
|
||||
for (let index = 0; index < newVal.length; index++) { |
|
||||
const element = newVal[index] |
|
||||
if (this.isVideoUrl(element)) { |
|
||||
vindex = index |
|
||||
vurl = element |
|
||||
break |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (vindex >= 1) { |
|
||||
newVal.splice(vindex, 1) |
|
||||
imgList = newVal |
|
||||
imgList.unshift(vurl) |
|
||||
this.data.videoContext = wx.createVideoContext('video', this) |
|
||||
} else if (vindex == 0) { |
|
||||
imgList = newVal |
|
||||
this.data.videoContext = wx.createVideoContext('video', this) |
|
||||
} else { |
|
||||
imgList = newVal |
|
||||
} |
|
||||
this.setData({ |
|
||||
videoUrl: vurl, |
|
||||
imgList: imgList |
|
||||
}) |
|
||||
}, |
|
||||
// bindchange: function (event) {
|
|
||||
// if (this.data.videoContext && this.data.status == 1) {
|
|
||||
// this.data.videoContext.pause()
|
|
||||
// }
|
|
||||
// },
|
|
||||
// videoTouch: function () {
|
|
||||
|
|
||||
// if (this.data.timeout) {
|
|
||||
// return
|
|
||||
// }
|
|
||||
// if (!this.data.controls && this.data.status == 1) {
|
|
||||
// this.setData({
|
|
||||
// controls: true
|
|
||||
// })
|
|
||||
// this.data.timeout = setTimeout(() => {
|
|
||||
// this.setData({
|
|
||||
// controls: false
|
|
||||
// })
|
|
||||
// this.data.timeout = null
|
|
||||
// }, 1000)
|
|
||||
// }
|
|
||||
// },
|
|
||||
videoTap: function () { |
|
||||
this.setData({ |
|
||||
visible: true, |
|
||||
}) |
|
||||
if (this.data.videoContext) { |
|
||||
this.data.videoContext.play() |
|
||||
} |
|
||||
}, |
|
||||
onClose: function() { |
|
||||
this.setData({ |
|
||||
visible: false, |
|
||||
}) |
|
||||
if (this.data.videoContext) { |
|
||||
this.data.videoContext.pause() |
|
||||
} |
|
||||
}, |
|
||||
// bindplay: function () {
|
|
||||
// this.setData({
|
|
||||
// status: 1
|
|
||||
// })
|
|
||||
// this.data.timeout = setTimeout(() => {
|
|
||||
// this.setData({
|
|
||||
// controls: false
|
|
||||
// })
|
|
||||
// this.data.timeout = null
|
|
||||
// }, 1500)
|
|
||||
// },
|
|
||||
// bindpause: function () {
|
|
||||
// this.setData({
|
|
||||
// status: 0,
|
|
||||
// controls: true
|
|
||||
// })
|
|
||||
// if (this.data.timeout) {
|
|
||||
// clearTimeout(this.data.timeout)
|
|
||||
// this.data.timeout = null
|
|
||||
// }
|
|
||||
// },
|
|
||||
bindended: function () { |
|
||||
this.data.videoContext.exitFullScreen() |
|
||||
this.setData({ |
|
||||
visible: false |
|
||||
}) |
|
||||
}, |
|
||||
// 图片查看
|
|
||||
viewImage: function (e) { |
|
||||
if (e.currentTarget.dataset.url.indexOf('.mp4') >= 0) { |
|
||||
return |
|
||||
} |
|
||||
var imgList = [] |
|
||||
for (let index = 0; index < this.data.imgList.length; index++) { |
|
||||
if (this.data.imgList[index].indexOf('.mp4') >= 0) { |
|
||||
continue |
|
||||
} |
|
||||
imgList.push(this.data.imgList[index]) |
|
||||
} |
|
||||
wx.previewImage({ |
|
||||
urls: imgList, |
|
||||
current: e.currentTarget.dataset.url |
|
||||
}); |
|
||||
}, |
|
||||
}, |
|
||||
ready() { |
|
||||
this.init(); |
|
||||
} |
|
||||
}) |
|
||||
@ -1,6 +0,0 @@ |
|||||
{ |
|
||||
"component": true, |
|
||||
"usingComponents": { |
|
||||
"wux-landscape": "../landscape/index" |
|
||||
} |
|
||||
} |
|
||||
@ -1,18 +0,0 @@ |
|||||
<wxs module="formate" src="../../pages/mall/index.wxs"></wxs> |
|
||||
<swiper class="screen-swiper square-dot" style="min-height:{{imageHeight}}rpx" indicator-dots="true" indicator-color="#FFFFFF" indicator-active-color="#008AFF"> |
|
||||
<swiper-item wx:for="{{imgList}}" wx:key="index"> |
|
||||
<view wx:if="{{formate.isVideoUrl(item)}}"> |
|
||||
<view class="video-cnt"> |
|
||||
<video src="{{item}}" style="width:100%;min-height:{{imageHeight}}rpx" show-center-play-btn="{{false}}" controls="{{false}}" muted /> |
|
||||
</view> |
|
||||
<text class="play-btn cuIcon-video text-white" style="font-size:80rpx" catchtap="videoTap" wx:if="{{!visible}}"></text> |
|
||||
</view> |
|
||||
<view wx:else bindtap="viewImage" style="width:100%;height:100%" data-url="{{item}}"> |
|
||||
<image src="{{item}}" mode="aspectFill"></image> |
|
||||
</view> |
|
||||
</swiper-item> |
|
||||
</swiper> |
|
||||
|
|
||||
<wux-landscape visible="{{ visible }}" bind:close="onClose"> |
|
||||
<video id="video" src="{{videoUrl}}" style="width:750rpx;min-height:{{imageHeight}}rpx" show-center-play-btn="{{false}}" bindended="bindended"/> |
|
||||
</wux-landscape> |
|
||||
@ -1,32 +0,0 @@ |
|||||
.swiper-cnt { |
|
||||
display: flex; |
|
||||
flex-direction: column; |
|
||||
width: 100%; |
|
||||
position: relative; |
|
||||
} |
|
||||
|
|
||||
.video-cnt { |
|
||||
position: absolute; |
|
||||
top: 0; |
|
||||
left: 0; |
|
||||
z-index: -1 !important; |
|
||||
width: 100%; |
|
||||
height: 100%; |
|
||||
} |
|
||||
|
|
||||
.play-btn { |
|
||||
position: absolute; |
|
||||
top: 150rpx; |
|
||||
left: 342rpx; |
|
||||
z-index: 100; |
|
||||
} |
|
||||
|
|
||||
.play-controls{ |
|
||||
width: 100%; |
|
||||
height: 80rpx; |
|
||||
padding: 15rpx 20rpx; |
|
||||
position: absolute; |
|
||||
display: flex; |
|
||||
bottom: 0px; |
|
||||
z-index: 100; |
|
||||
} |
|
||||
Write
Preview
Loading…
Cancel
Save