You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

335 lines
8.4 KiB

3 years ago
<template>
<view class="containers">
<view class="steps">
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
</view>
3 years ago
<view class="study" style="padding:0 20rpx">
1 week ago
<view class="service-show" v-if="studyInfo.file_detail && studyInfo.file_detail.length>0">
<view v-if="picList.length>0&&showSwiperFlag==0">
<u-swiper :list="picList" @change="changeImg" keyName="url"
:height="'360rpx'" :interval='4000' :duration='500' :autoplay='false' circular>
<view slot="indicator" class="indicator">
<view class="indicator__dot" v-for="(item, index) in picList" :key="index"
:class="[index === imgcurrent && 'indicator__dot--active']">
</view>
</view>
</u-swiper>
</view>
<view v-if="videoList.length>0&&showSwiperFlag==1">
<u-swiper :list="videoList" @change="changeVideo" keyName="url"
:height="'360rpx'" :interval='4000' :duration='500' :autoplay='false' circular>
<view slot="indicator" class="indicator">
<view class="indicator__dot" v-for="(item, index) in videoList" :key="index"
:class="[index === videocurrent && 'indicator__dot--active']">
</view>
</view>
</u-swiper>
</view>
<view class="changePicVideo">
<view @click='changeSwiperImg' v-if="picList.length>0">
<image src="../../static/img/pic.png">
</image>{{picList.length}}
</view>
<view @click='changeSwiperVideo' v-if="videoList.length>0">
<image src="../../static/img/video.png">
</image>{{videoList.length}}
</view>
3 years ago
</view>
3 years ago
</view>
3 years ago
<view v-html="studyInfo.content" style="padding-bottom: 160rpx;">
3 years ago
</view>
</view>
<view class="asks">
</view>
<button @click="goTest" :class="studyMin==-1?'goTest':'noTest'" :disabled="studyMin==-1?false:true">
1 week ago
<text v-if="studyMin==-1">{{ quizRequired ? '' : '' }}</text>
<text v-else>{{ quizRequired ? (''+(studyInfo.minute?studyInfo.minute:'')+'('+studyTime+')') : (''+studyTime+'') }}</text>
3 years ago
</button>
</view>
</template>
<script>
export default {
data() {
return {
type: 1,
steps: [{
title: '填报'
}, {
title: '学习'
}, {
title: '完成'
}],
stepActive: 1,
1 week ago
studyInfo: {},
picList:[],
videoList:[],
3 years ago
showSwiperFlag:0,
1 week ago
imgcurrent: 0,
3 years ago
videocurrent:0,
3 years ago
studyTime: "00:00", // 学习时间
1 week ago
// null尚未拉取学习配置避免定时器在 getStudy 返回前误 clear
studyMin: null,
3 years ago
timer: null,
1 week ago
quizRequired: true,
3 years ago
}
},
1 week ago
onLoad(options) {
// uni.navigateTo({
// url:'/pages/visit/testStudy?type=1'
// })
3 years ago
// return
1 week ago
const that = this
3 years ago
this.type = options.type
1 week ago
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
this.timer = setInterval(function() {
that.loadTime()
}, 1000)
3 years ago
this.getStudy()
1 week ago
},
onUnload() {
3 years ago
if (this.timer) {
clearInterval(this.timer)
1 week ago
this.timer = null
}
},
onShareAppMessage() {
return {
title: 'BD访客系统',
path: '/pages/index/index',
// imageUrl: this.logoIndex
}
},
onShareTimeline() {
return {
title: 'BD访客系统',
path: '/pages/index/index',
// imageUrl: this.logoIndex
3 years ago
}
},
2 months ago
3 years ago
methods: {
async getStudy() {
let that = this
1 week ago
const fd = uni.getStorageSync('formdata') || {}
const sd = uni.getStorageSync('studydata') || {}
const mobileParam = fd.mobile || sd.mobile || ''
3 years ago
this.util.request({
api: '/api/mobile/visit/get-ask',
data: {
1 week ago
type: that.type,
mobile: mobileParam
3 years ago
},
utilSuccess: function(res) {
1 week ago
that.studyInfo = res
that.quizRequired = !(
res.quiz_required === 0 ||
res.quiz_required === false ||
res.quiz_required === '0'
)
const files = res.file_detail || []
for(var k of files){
if(k.extension=='mp4'){
that.videoList.push(k)
}else{
that.picList.push(k)
}
}
3 years ago
that.showSwiperFlag = that.picList.length==0? 1 : 0
1 week ago
const minute = res.minute ? parseFloat(res.minute) : 0
// VIP 也强制最短观看时长:若未配置分钟数,默认最短 1 分钟
if (!that.quizRequired && (!minute || minute <= 0)) {
that.studyMin = 60
} else {
that.studyMin = Math.max(0, Math.round(minute * 60))
}
3 years ago
},
utilFail: function(res) {}
})
},
loadTime() {
1 week ago
if (this.studyMin === null || this.studyMin === undefined) {
return
}
3 years ago
if (this.studyMin >= 0) {
let minutes = Math.floor(this.studyMin / 60);
let seconds = Math.floor(this.studyMin % 60);
minutes = minutes < 10 ? "0" + minutes : minutes
seconds = seconds < 10 ? "0" + seconds : seconds
this.studyTime = minutes + ":" + seconds
1 week ago
this.studyMin--
} else if (this.studyMin === -1) {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
3 years ago
}
},
goTest() {
1 week ago
if (!this.quizRequired) {
this.submitWatchOnly()
return
}
const form = uni.getStorageSync('formdata') || {}
const base = {
type: parseInt(this.type),
name: form.name,
mobile: form.mobile,
idcard: form.idcard || form.passcard,
expire_day: this.studyInfo.expire_day
}
const prev = uni.getStorageSync('studydata') || {}
uni.setStorageSync('studydata', Object.assign({}, prev, base))
3 years ago
uni.redirectTo({
3 years ago
url: '/pages/visit/testStudy?type=' + this.type
})
1 week ago
},
submitWatchOnly() {
const form = uni.getStorageSync('formdata') || uni.getStorageSync('studydata') || {}
const that = this
this.util.request({
api: '/api/mobile/visit/ask-save',
method: 'POST',
data: {
type: parseInt(this.type),
name: form.name,
mobile: form.mobile,
idcard: form.idcard || form.passcard,
expire_day: this.studyInfo.expire_day,
content: [],
ask: []
},
utilSuccess: function(res) {
if (uni.getStorageSync('studydata')) {
uni.removeStorageSync('studydata')
}
uni.showToast({
title: '学习已完成',
duration: 1500,
icon: 'none'
})
setTimeout(function() {
if (uni.getStorageSync('formdata')) {
uni.redirectTo({
url: '/pages/visit/addrecord'
})
} else {
uni.redirectTo({
url: '/pages/index/index'
})
}
}, 1500)
},
utilFail: function(res) {
uni.showToast({
title: res || '提交失败',
duration: 2000,
icon: 'none'
})
}
})
},
changeImg(e) {
this.imgcurrent = e.current
},
changeVideo(e) {
this.videocurrent = e.current
},
changeSwiperImg(){
this.showSwiperFlag=0
this.imgcurrent=0
},
changeSwiperVideo(){
this.showSwiperFlag=1
this.videocurrent=0
}
3 years ago
3 years ago
}
}
</script>
3 years ago
<style lang="scss">
.indicator {
@include flex(row);
justify-content: center;
&__dot {
height: 6px;
width: 6px;
border-radius: 100px;
background-color: #fff;
margin: 0 5px;
transition: background-color 0.3s;
&--active {
background-color: #044ed7;
}
}
}
</style>
3 years ago
<style scoped>
.containers {
background-color: #fff;
min-height: 100vh;
padding: 20rpx;
padding-bottom: 60rpx;
position: relative;
}
3 years ago
.containers>button {
position: absolute;
bottom: 60rpx;
margin: 20rpx;
width: 90%;
3 years ago
}
3 years ago
3 years ago
.steps {
margin-bottom: 40rpx
}
.goTest {
background-color: #044ed7;
color: #fff;
}
.noTest {
background-color: #ddd;
color: #000
}
.service-show {
width: 100%;
height: 360rpx;
position: relative;
}
1 week ago
.service-show .changePicVideo{
position: absolute;
right: 80rpx;
bottom: 25rpx;
}
.service-show .changePicVideo view{
background: rgba(0,0,0,0.5);
display: inline-block;
padding: 5rpx 20rpx;
margin: 6rpx;
border-radius: 15rpx;
color: #fff;
font-size: 28rpx;
}
.service-show .changePicVideo view image{
width:24rpx;
height:21rpx;
margin-right: 10rpx;
}
</style>