Browse Source

视频答题基础功能效果

h5_css
蟑螂恶霸 3 years ago
parent
commit
2f32573232
  1. 88
      components/s-video/s-video.vue
  2. 191
      components/tabbar/tabbar.vue
  3. 2
      pages/index/index.vue
  4. 33
      pages/scan/scan.vue
  5. BIN
      static/videos/video1/video1.mp4
  6. BIN
      static/videos/video1/video1.ogg
  7. BIN
      static/videos/video1/video1.webm
  8. BIN
      static/videos/video2/video2.mp4
  9. BIN
      static/videos/video3/video3.mp4

88
components/s-video/s-video.vue

@ -0,0 +1,88 @@
<template>
<view class="video-wrapper" id="video-container">
<view style="position: relative;width: 414px; height: 300px;">
<video :src="videoObjTmp.url" @ended="videoEnded()" :autoplay="auto" style="width: 414px;height: 300px;"></video>
<view class="question"></view>
<view class="popup-layer-back" v-show="question">
<view class="popup-layer-close" @click="question=false">关闭</view>
<view class="popup-layer">
<h2>答案填充</h2>
<p @click="nextQuestion()">答题后跳转下一视频</p>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: "s-video",
data() {
return {
videoObj: {
url: "/static/videos/video1/video1.mp4",
childen: {
url: "/static/videos/video2/video2.mp4",
childen: {
url: "/static/videos/video3/video3.mp4"
}
}
},
videoObjTmp: {},
videoUrl: "",
auto: true,
question: false,
};
},
created() {
this.initVideo();
},
methods: {
initVideo() {
this.videoObjTmp = this.videoObj;
},
videoEnded() {
this.auto = false;
this.question = true;
},
nextQuestion() {
this.videoObjTmp = this.videoObjTmp.childen;
this.question = false;
this.auto = true;
}
}
}
</script>
<style>
/* 首先设置背景层 */
.popup-layer-back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 9998;
}
/* 然后设置弹出层 */
.popup-layer {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
padding: 20px;
z-index: 9999;
}
/* 设置关闭按钮 */
.popup-layer-close {
position: absolute;
top: 5px;
right: 5px;
cursor: pointer;
}
</style>

191
components/tabbar/tabbar.vue

@ -4,11 +4,11 @@
<view class="handleBox" v-for="(item,index) in tabBarList" :key="index">
<view class="menuBox" @click="goPages(item.pageIndex)">
<view class="menuIcon">
<image v-if="item.type!=selectIndex" class="img" :src="item.iconPath"></image>
<image v-if="item.type!=selectIndex" class="img" :src="item.iconPath"></image>
<image v-else class="img" :src="item.selectIconPath"></image>
</view>
<view class="menuName">
<text :class="item.type==selectIndex?'TextColor':'Text'" >{{item.tabbarName}}</text>
<text :class="item.type==selectIndex?'TextColor':'Text'">{{item.tabbarName}}</text>
</view>
</view>
</view>
@ -18,113 +18,112 @@
</template>
<script>
export default {
props: {
page: {
type: String,
default: "homeIndex"
}
},
watch: {
page: {
handler(value) {
this.selectIndex = value;
},
immediate: true,
deep: true
}
},
data() {
return {
selectIndex: "",
tabBarList: [],
}
},
//uniapp子组件不支持应用生命周期,所以只能用vue生命周期
created() {
export default {
props: {
page: {
type: String,
default: "homeIndex"
}
},
watch: {
page: {
handler(value) {
this.selectIndex = value;
},
immediate: true,
deep: true
}
},
data() {
return {
selectIndex: "",
tabBarList: [],
}
//tabbar数据,这儿也支持后台定义通过接口获取数据
// this.tabBarList = [{
// "tabbarName":"", //tababr名称
// "iconPath":"", //tabbar icon
// "selectIconPath":"", //tabbar 选择icon
// "pageIndex":"" //页面路径
// }]
this.listTabbar();
},methods: {
listTabbar() {
this.$api.listTabbar({})
.then(res => {
console.log(res)
for (var i = 0; i < res.data.length; i++) {
if (res.data[i].hide == 1) {
this.tabBarList.push({
"tabbarName": res.data[i].title,
"iconPath": res.data[i].selectedIconPath,
"selectIconPath": res.data[i].selectedIconPath,
"pageIndex": res.data[i].pagePath,
"type": res.data[i].type
});
}
}
}).catch((e) => console.log(e)); //捕获异常
},
//进入tabble页
goPages(pageIndex) {
uni.switchTab({
url:"/"+pageIndex
})
//uniapp子组件不支持应用生命周期,所以只能用vue生命周期
created() {
//tabbar数据,这儿也支持后台定义通过接口获取数据
// this.tabBarList = [{
// "tabbarName":"", //tababr名称
// "iconPath":"", //tabbar icon
// "selectIconPath":"", //tabbar 选择icon
// "pageIndex":"" //页面路径
// }]
this.listTabbar();
},
methods: {
listTabbar() {
this.$api.listTabbar({})
.then(res => {
for (var i = 0; i < res.data.length; i++) {
if (res.data[i].hide == 1) {
this.tabBarList.push({
"tabbarName": res.data[i].title,
"iconPath": res.data[i].selectedIconPath,
"selectIconPath": res.data[i].selectedIconPath,
"pageIndex": res.data[i].pagePath,
"type": res.data[i].type
});
}
}
}).catch((e) => console.log(e)); //捕获异常
},
//进入tabble页
goPages(pageIndex) {
uni.switchTab({
url: "/" + pageIndex
})
},
},
}
},
}
</script>
<style lang="scss">
.tab_bar {
width: 100vw;
height: 120rpx;
position: fixed;
bottom: 30rpx;
/* 模糊大小就是靠的blur这个函数中的数值大小 */
backdrop-filter: blur(10px);
border-radius: 60rpx;
.tab_bar {
width: 100vw;
height: 120rpx;
position: fixed;
bottom: 30rpx;
/* 模糊大小就是靠的blur这个函数中的数值大小 */
backdrop-filter: blur(10px);
border-radius: 60rpx;
.tabbarBox {
display: flex;
margin-top: 10rpx;
justify-content: space-evenly;
.tabbarBox {
display: flex;
margin-top: 10rpx;
justify-content: space-evenly;
.handleBox {
width: 20vw;
height: 110rpx;
.handleBox {
width: 20vw;
height: 110rpx;
.menuBox {
padding: 0rpx 20rpx;
width: 120rpx;
height: 98%;
text-align: center;
.menuBox {
padding: 0rpx 20rpx;
width: 120rpx;
height: 98%;
text-align: center;
.img {
width: 50rpx;
height: 50rpx;
}
}
}
}
.img {
width: 50rpx;
height: 50rpx;
}
}
}
}
}
.Text {
font-size: 24rpx;
font-family: Cochin, serif;
font-weight: 900;
}
.TextColor {
@extend .Text;
color: #d81e06;
}
.Text {
font-size: 24rpx;
font-family: Cochin, serif;
font-weight: 900;
}
.TextColor {
@extend .Text;
color: #d81e06;
}
</style>

2
pages/index/index.vue

@ -44,7 +44,7 @@
},
onLoad() {
this.getSwiperList();
this.checkLogin()
// this.checkLogin()
},
onShow() {
this.page= "home"

33
pages/scan/scan.vue

@ -2,6 +2,7 @@
<view>
<view class="video-wrapper" id="video-container">
</view>
<sVideo></sVideo>
<tabbar :page="page"></tabbar>
</view>
@ -9,6 +10,7 @@
<script>
import tabbar from "@/components/tabbar/tabbar.vue";
import sVideo from "@/components/s-video/s-video.vue";
export default {
data() {
@ -16,26 +18,29 @@
page: "",
};
},
onReady(){
onReady() {
this.QR();
},
onShow() {
this.page= "scan"
this.page = "scan"
},
methods:{
QR() {
uni.scanCode({
onlyFromCamera: true,
success: (res) => {
console.log('扫描二维码成功,结果:' + res.result);
},
error: (res) => {
console.log('扫描二维码出现错误')
}
})
methods: {
QR() {
// uni.scanCode({
// onlyFromCamera: true,
// success: (res) => {
// console.log('扫描二维码成功,结果:' + res.result);
// },
// error: (res) => {
// console.log('扫描二维码出现错误')
// }
// })
},
},
components: {tabbar}
components: {
tabbar,
sVideo
}
}
</script>

BIN
static/videos/video1/video1.mp4

Binary file not shown.

BIN
static/videos/video1/video1.ogg

Binary file not shown.

BIN
static/videos/video1/video1.webm

Binary file not shown.

BIN
static/videos/video2/video2.mp4

Binary file not shown.

BIN
static/videos/video3/video3.mp4

Binary file not shown.
Loading…
Cancel
Save