From d794f1212c0e39e2fdc534de89b4616f350f547a Mon Sep 17 00:00:00 2001
From: xpz2018 <107107461@qq.com>
Date: Sat, 30 May 2020 10:12:56 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/swiper-video/index.js | 152 -----------------------------
components/swiper-video/index.json | 6 --
components/swiper-video/index.wxml | 18 ----
components/swiper-video/index.wxss | 32 ------
pages/mall/order-info/index.js | 82 +++++++++++++++-
pages/mall/order-info/index.json | 4 +-
pages/mall/order-info/index.wxml | 20 +++-
7 files changed, 99 insertions(+), 215 deletions(-)
delete mode 100644 components/swiper-video/index.js
delete mode 100644 components/swiper-video/index.json
delete mode 100644 components/swiper-video/index.wxml
delete mode 100644 components/swiper-video/index.wxss
diff --git a/components/swiper-video/index.js b/components/swiper-video/index.js
deleted file mode 100644
index ee671b8..0000000
--- a/components/swiper-video/index.js
+++ /dev/null
@@ -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();
- }
-})
\ No newline at end of file
diff --git a/components/swiper-video/index.json b/components/swiper-video/index.json
deleted file mode 100644
index 8764966..0000000
--- a/components/swiper-video/index.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "component": true,
- "usingComponents": {
- "wux-landscape": "../landscape/index"
- }
-}
\ No newline at end of file
diff --git a/components/swiper-video/index.wxml b/components/swiper-video/index.wxml
deleted file mode 100644
index b8861d5..0000000
--- a/components/swiper-video/index.wxml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/components/swiper-video/index.wxss b/components/swiper-video/index.wxss
deleted file mode 100644
index 22c413f..0000000
--- a/components/swiper-video/index.wxss
+++ /dev/null
@@ -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;
-}
\ No newline at end of file
diff --git a/pages/mall/order-info/index.js b/pages/mall/order-info/index.js
index 6cd13bf..36f5508 100644
--- a/pages/mall/order-info/index.js
+++ b/pages/mall/order-info/index.js
@@ -23,7 +23,10 @@ Page({
unitPrice: 0
},
amount: null,
- isIPhoneX: false
+ isIPhoneX: false,
+ imageHeight: 0,
+ visible: false,
+ videoUrl: null
},
/**
* 生命周期函数--监听页面加载
@@ -36,6 +39,7 @@ Page({
}
this.setData({
token: app.globalData.token,
+ imageHeight: float.accDiv(float.accMul(750, 9), 16),
isIPhoneX: app.globalData.isIPhoneX
})
event.on('EventMessage', this, this.onEvent)
@@ -48,13 +52,40 @@ Page({
request.get('/bxe-mall/product/' + options.id).then(result => {
//成功回调
wx.hideLoading()
- if(Number(result.data.minBuyNum) > 1){
+ if (Number(result.data.minBuyNum) > 1) {
this.data.form.number = parseInt(result.data.minBuyNum)
}
+ var vindex = -1
+ var vurl = null
+ var imgList = []
+ for (let index = 0; index < result.data.imgList.length; index++) {
+ const element = result.data.imgList[index]
+ if (this.isVideoUrl(element)) {
+ vindex = index
+ vurl = element
+ break
+ }
+ }
+ if (vindex >= 1) {
+ result.data.imgList.splice(vindex, 1)
+ imgList = result.data.imgList
+ imgList.unshift(vurl)
+ this.videoContext = wx.createVideoContext('video')
+ } else if (vindex == 0) {
+ imgList = result.data.imgList
+ this.videoContext = wx.createVideoContext('video')
+ } else {
+ imgList = result.data.imgList
+ }
+ this.setData({
+ videoUrl: vurl,
+ imgList: imgList
+ })
this.setData({
['form.productId']: options.id,
orderInfo: result.data,
- imgList: result.data.imgList
+ videoUrl: vurl,
+ imgList: imgList
})
}).catch(err => {
//异常回调
@@ -63,6 +94,12 @@ Page({
})
}
},
+ isVideoUrl: function (url) {
+ if (url && url.indexOf('.mp4') >= 0) {
+ return true
+ }
+ return false
+ },
// 事件处理
onEvent: function (message) {
console.log('mall>>order>>onEvent', message)
@@ -74,6 +111,45 @@ Page({
wx.navigateBack()
}
},
+ videoTap: function () {
+ this.setData({
+ visible: true,
+ })
+ if (this.videoContext) {
+ this.videoContext.play()
+ }
+ },
+ onClose: function () {
+ this.setData({
+ visible: false,
+ })
+ if (this.videoContext) {
+ this.videoContext.pause()
+ }
+ },
+ bindended: function () {
+ this.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
+ });
+ },
// 根据
checkDisableTag: function (sukId, match, element) {
match[sukId] = element.id
diff --git a/pages/mall/order-info/index.json b/pages/mall/order-info/index.json
index be72d57..c546c16 100644
--- a/pages/mall/order-info/index.json
+++ b/pages/mall/order-info/index.json
@@ -2,6 +2,6 @@
"usingComponents": {
"wux-button": "/components/button/index",
"wux-input-number": "/components/input-number/index",
- "swiper-video": "/components/swiper-video/index"
-}
+ "wux-landscape": "/components/landscape/index"
+ }
}
\ No newline at end of file
diff --git a/pages/mall/order-info/index.wxml b/pages/mall/order-info/index.wxml
index 06b7633..ebf4e5e 100644
--- a/pages/mall/order-info/index.wxml
+++ b/pages/mall/order-info/index.wxml
@@ -6,7 +6,19 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
¥{{form.unitPrice || orderInfo.price}}
@@ -79,4 +91,8 @@
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file