parent
aa988a3d8a
commit
b6238835ef
@ -1,166 +1,134 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="containers">
|
<view class="containers">
|
||||||
<view class="steps">
|
<view class="steps">
|
||||||
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
|
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
|
||||||
</view>
|
</view>
|
||||||
<view class="study">
|
<view class="study">
|
||||||
<view class="service-show">
|
<view class="service-show">
|
||||||
<swiper class="service-show-swiper" :indicator-dots="true">
|
<swiper class="service-show-swiper" :indicator-dots="true">
|
||||||
<swiper-item v-for="(img,index) in studyInfo.file_detail" :key="index">
|
<swiper-item v-for="(img,index) in studyInfo.file_detail" :key="index">
|
||||||
<u-image height="360rpx" width="100%" :src="img.url" mode="aspectFit"
|
<u-image height="360rpx" width="100%" :src="img.url" mode="aspectFit">
|
||||||
>
|
</u-image>
|
||||||
</u-image>
|
</swiper-item>
|
||||||
</swiper-item>
|
</swiper>
|
||||||
</swiper>
|
</view>
|
||||||
</view>
|
<view>
|
||||||
<view>
|
{{studyInfo.content?studyInfo.content:""}}
|
||||||
{{studyInfo.content?studyInfo.content:""}}
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view class="asks">
|
||||||
<view class="asks">
|
|
||||||
|
</view>
|
||||||
</view>
|
|
||||||
|
<button @click="goTest" :class="studyMin==-1?'goTest':'noTest'" :disabled="studyMin==-1?false:true">
|
||||||
<button @click="goTest" size="mini" type="primary"
|
<text v-if="studyMin==-1">去测验</text>
|
||||||
>去测验({{studyInfo.minute?studyInfo.minute:""}})</button>
|
<text v-else>需要学习{{studyInfo.minute?studyInfo.minute:""}}分钟可去测验({{studyTime}})</text>
|
||||||
</view>
|
|
||||||
</template>
|
</button>
|
||||||
|
</view>
|
||||||
<script>
|
</template>
|
||||||
export default{
|
|
||||||
data(){
|
<script>
|
||||||
return{
|
export default {
|
||||||
type:1,
|
data() {
|
||||||
steps: [{
|
return {
|
||||||
title: '填报'
|
type: 1,
|
||||||
}, {
|
steps: [{
|
||||||
title: '学习'
|
title: '填报'
|
||||||
}, {
|
}, {
|
||||||
title: '完成'
|
title: '学习'
|
||||||
}],
|
}, {
|
||||||
stepActive: 1,
|
title: '完成'
|
||||||
studyInfo:{},
|
}],
|
||||||
studyTime:""
|
stepActive: 1,
|
||||||
}
|
studyInfo: {},
|
||||||
},
|
studyTime: "00:00", // 学习时间
|
||||||
onLoad(options) {
|
studyMin: -1, // 倒计时
|
||||||
this.type = options.type
|
timer: null,
|
||||||
this.getStudy()
|
}
|
||||||
},
|
},
|
||||||
methods:{
|
onLoad(options) {
|
||||||
async getStudy(){
|
let that = this
|
||||||
let that = this
|
this.type = options.type
|
||||||
this.util.request({
|
this.getStudy()
|
||||||
api: '/api/mobile/visit/get-ask',
|
if (this.timer) {
|
||||||
data:{
|
clearInterval(this.timer)
|
||||||
type:that.type
|
} else {
|
||||||
},
|
this.timer = setInterval(function() {
|
||||||
utilSuccess: function(res) {
|
that.loadTime()
|
||||||
that.studyInfo = res
|
}, 1000)
|
||||||
},
|
}
|
||||||
utilFail: function(res) {}
|
|
||||||
})
|
},
|
||||||
},
|
methods: {
|
||||||
loadTime(min){
|
async getStudy() {
|
||||||
let time = min*60*1000
|
let that = this
|
||||||
},
|
this.util.request({
|
||||||
goTest(){
|
api: '/api/mobile/visit/get-ask',
|
||||||
|
data: {
|
||||||
}
|
type: that.type
|
||||||
|
},
|
||||||
}
|
utilSuccess: function(res) {
|
||||||
}
|
that.studyInfo = res
|
||||||
</script>
|
that.studyMin = res.minute * 60
|
||||||
|
},
|
||||||
<style scoped lang="scss">
|
utilFail: function(res) {}
|
||||||
.containers {
|
})
|
||||||
background-color: #fff;
|
},
|
||||||
min-height: 100vh;
|
loadTime() {
|
||||||
padding: 20rpx;
|
if (this.studyMin >= 0) {
|
||||||
padding-bottom: 60rpx;
|
let minutes = Math.floor(this.studyMin / 60);
|
||||||
}
|
let seconds = Math.floor(this.studyMin % 60);
|
||||||
|
minutes = minutes < 10 ? "0" + minutes : minutes
|
||||||
.steps {
|
seconds = seconds < 10 ? "0" + seconds : seconds
|
||||||
margin-bottom: 40rpx
|
this.studyTime = minutes + ":" + seconds
|
||||||
}
|
--this.studyMin;
|
||||||
.service-show {
|
} else {
|
||||||
width: 100%;
|
clearInterval(this.timer);
|
||||||
height: 360rpx;
|
}
|
||||||
|
},
|
||||||
position: relative;
|
goTest() {
|
||||||
|
uni.navigateTo({
|
||||||
&>video {
|
url: '/pages/visit/testStudy?type=' + this.type
|
||||||
width: 100%;
|
})
|
||||||
height: 100%;
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
&-swiper {
|
}
|
||||||
width: 100%;
|
</script>
|
||||||
height: 100%;
|
|
||||||
}
|
<style scoped>
|
||||||
|
.containers {
|
||||||
&-btn {
|
background-color: #fff;
|
||||||
display: flex;
|
min-height: 100vh;
|
||||||
|
padding: 20rpx;
|
||||||
z-index: 3;
|
padding-bottom: 60rpx;
|
||||||
position: absolute;
|
position: relative;
|
||||||
bottom: 30rpx;
|
}
|
||||||
right: 33rpx;
|
.containers>button{
|
||||||
|
position: absolute;
|
||||||
&-img {
|
bottom:60rpx;
|
||||||
color: #fff;
|
margin:20rpx;
|
||||||
height: 47rpx;
|
width:90%;
|
||||||
background: #252526;
|
}
|
||||||
border-radius: 16rpx;
|
.steps {
|
||||||
opacity: 0.3;
|
margin-bottom: 40rpx
|
||||||
display: flex;
|
}
|
||||||
align-items: center;
|
|
||||||
|
.goTest {
|
||||||
margin-right: 14rpx;
|
background-color: #044ed7;
|
||||||
|
color: #fff;
|
||||||
&>image {
|
}
|
||||||
width: 24rpx;
|
|
||||||
height: 21rpx;
|
.noTest {
|
||||||
|
background-color: #ddd;
|
||||||
padding-left: 20rpx;
|
color: #000
|
||||||
padding-right: 10rpx;
|
}
|
||||||
}
|
|
||||||
|
.service-show {
|
||||||
&__num {
|
width: 100%;
|
||||||
font-size: 24rpx;
|
height: 360rpx;
|
||||||
color: #FFFFF0;
|
|
||||||
font-weight: 400;
|
position: relative;
|
||||||
|
}
|
||||||
padding-right: 20rpx;
|
</style>
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-video {
|
|
||||||
color: #fff;
|
|
||||||
height: 47rpx;
|
|
||||||
background: #252526;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
opacity: 0.3;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
&>image {
|
|
||||||
width: 24rpx;
|
|
||||||
height: 21rpx;
|
|
||||||
|
|
||||||
padding-left: 20rpx;
|
|
||||||
padding-right: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__num {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #FFFFF0;
|
|
||||||
font-weight: 400;
|
|
||||||
|
|
||||||
padding-right: 20rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|||||||
@ -0,0 +1,210 @@
|
|||||||
|
<template>
|
||||||
|
<view class="containers">
|
||||||
|
<view class="steps">
|
||||||
|
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
|
||||||
|
</view>
|
||||||
|
<view class="asks">
|
||||||
|
<view v-for="(item,index) in askList">
|
||||||
|
<view>{{index}}{{item.title}}({{item.type==1?'单选':'多选'}})</view>
|
||||||
|
<view v-if="item.type==1">
|
||||||
|
<uni-data-checkbox v-model="result[index]" @change="e=>radioAnswer(e,index)"
|
||||||
|
:localdata="item.answer" :wrap='true' :map="{text:'content',value:'content'}" />
|
||||||
|
</view>
|
||||||
|
<view v-if="item.type==2">
|
||||||
|
<uni-data-checkbox v-model="resultArr[index]" @change="e=>chenckAnswer(e,item,index)"
|
||||||
|
:localdata="item.answer" :wrap='true' multiple :map="{text:'content',value:'content'}" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view disabled class="justify-between submitBtn">
|
||||||
|
<text>需要正确率达{{rate}}%</text>
|
||||||
|
<text @click="submitAnswer">提交</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
type: 1,
|
||||||
|
steps: [{
|
||||||
|
title: '填报'
|
||||||
|
}, {
|
||||||
|
title: '测验'
|
||||||
|
}, {
|
||||||
|
title: '完成'
|
||||||
|
}],
|
||||||
|
stepActive: 1,
|
||||||
|
studyInfo: {},
|
||||||
|
rate: 0,
|
||||||
|
askList: [],
|
||||||
|
correctNum: {},
|
||||||
|
answerList: [],
|
||||||
|
result: {},
|
||||||
|
resultArr: [
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[]
|
||||||
|
],
|
||||||
|
formData: {}
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(options) {
|
||||||
|
let that = this
|
||||||
|
this.type = options.type
|
||||||
|
|
||||||
|
this.getFormdata()
|
||||||
|
this.getStudy()
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getFormdata(){
|
||||||
|
let res = uni.getStorageSync('formdata')
|
||||||
|
this.formData = res
|
||||||
|
},
|
||||||
|
async getStudy() {
|
||||||
|
let that = this
|
||||||
|
this.util.request({
|
||||||
|
api: '/api/mobile/visit/get-ask',
|
||||||
|
data: {
|
||||||
|
type: that.type
|
||||||
|
},
|
||||||
|
utilSuccess: function(res) {
|
||||||
|
that.studyInfo = res
|
||||||
|
that.askList = res.asks
|
||||||
|
that.rate = parseInt(res.rate)
|
||||||
|
},
|
||||||
|
utilFail: function(res) {}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 获取选择的答案
|
||||||
|
radioAnswer(item, index) {
|
||||||
|
this.correctNum[index] = item.detail.data.result
|
||||||
|
},
|
||||||
|
chenckAnswer(e, item, index) {
|
||||||
|
let answer = item.answer
|
||||||
|
let correctLength = 0
|
||||||
|
let data = e.detail.data
|
||||||
|
for (var k of answer) {
|
||||||
|
if (k.result == 1) {
|
||||||
|
correctLength++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 多选少于正确答案数量 返回0 错误
|
||||||
|
if (data.length < correctLength) {
|
||||||
|
console.log(correctLength)
|
||||||
|
this.correctNum[index] = 0
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
for (var m of data) {
|
||||||
|
if (m.result == 0) {
|
||||||
|
this.correctNum[index] = 0
|
||||||
|
} else {
|
||||||
|
this.correctNum[index] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 匹配答案正确率
|
||||||
|
submitAnswer() {
|
||||||
|
console.log(this.correctNum)
|
||||||
|
let correctLength = 0
|
||||||
|
for (var key in this.correctNum) {
|
||||||
|
if (this.correctNum[key] == 1) {
|
||||||
|
correctLength++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let per = parseFloat(correctLength / this.askList.length) * 100
|
||||||
|
if (per < this.rate) {
|
||||||
|
this.util.alert("正确率不达标")
|
||||||
|
} else {
|
||||||
|
this.submitForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
submitForm() {
|
||||||
|
let that = this
|
||||||
|
this.util.request({
|
||||||
|
api: '/api/mobile/visit/visit-save',
|
||||||
|
method: "POST",
|
||||||
|
data: that.formData,
|
||||||
|
utilSuccess: function(res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.errmsg,
|
||||||
|
duration: 2000,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
utilFail: function(res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.errmsg,
|
||||||
|
duration: 2000,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.containers {
|
||||||
|
background-color: #fff;
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 20rpx;
|
||||||
|
padding-bottom: 60rpx;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.asks {}
|
||||||
|
|
||||||
|
.asks>view,
|
||||||
|
.asks>view>view {
|
||||||
|
margin-bottom: 20rpx
|
||||||
|
}
|
||||||
|
|
||||||
|
.containers>.submitBtn {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 60rpx;
|
||||||
|
margin: 20rpx;
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.containers>.submitBtn text {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 10px;
|
||||||
|
text-align: center;
|
||||||
|
width: 70%;
|
||||||
|
background-color: #f8f8f8;
|
||||||
|
font-size: 36rpx;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
padding: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.containers>.submitBtn text:first-child {
|
||||||
|
border-radius: 10rpx 0 0 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.containers>.submitBtn text:last-child {
|
||||||
|
width: 30%;
|
||||||
|
background-color: #044ed7;
|
||||||
|
color: #fff;
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: 0 10rpx 10rpx 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.steps {
|
||||||
|
margin-bottom: 40rpx
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in new issue