parent
aa988a3d8a
commit
b6238835ef
@ -1,166 +1,134 @@
|
||||
<template>
|
||||
<view class="containers">
|
||||
<view class="steps">
|
||||
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
|
||||
</view>
|
||||
<view class="study">
|
||||
<view class="service-show">
|
||||
<swiper class="service-show-swiper" :indicator-dots="true">
|
||||
<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>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
<view>
|
||||
{{studyInfo.content?studyInfo.content:""}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="asks">
|
||||
|
||||
</view>
|
||||
|
||||
<button @click="goTest" size="mini" type="primary"
|
||||
>去测验({{studyInfo.minute?studyInfo.minute:""}})</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default{
|
||||
data(){
|
||||
return{
|
||||
type:1,
|
||||
steps: [{
|
||||
title: '填报'
|
||||
}, {
|
||||
title: '学习'
|
||||
}, {
|
||||
title: '完成'
|
||||
}],
|
||||
stepActive: 1,
|
||||
studyInfo:{},
|
||||
studyTime:""
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.type = options.type
|
||||
this.getStudy()
|
||||
},
|
||||
methods:{
|
||||
async getStudy(){
|
||||
let that = this
|
||||
this.util.request({
|
||||
api: '/api/mobile/visit/get-ask',
|
||||
data:{
|
||||
type:that.type
|
||||
},
|
||||
utilSuccess: function(res) {
|
||||
that.studyInfo = res
|
||||
},
|
||||
utilFail: function(res) {}
|
||||
})
|
||||
},
|
||||
loadTime(min){
|
||||
let time = min*60*1000
|
||||
},
|
||||
goTest(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.containers {
|
||||
background-color: #fff;
|
||||
min-height: 100vh;
|
||||
padding: 20rpx;
|
||||
padding-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.steps {
|
||||
margin-bottom: 40rpx
|
||||
}
|
||||
.service-show {
|
||||
width: 100%;
|
||||
height: 360rpx;
|
||||
|
||||
position: relative;
|
||||
|
||||
&>video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
&-swiper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
&-btn {
|
||||
display: flex;
|
||||
|
||||
z-index: 3;
|
||||
position: absolute;
|
||||
bottom: 30rpx;
|
||||
right: 33rpx;
|
||||
|
||||
&-img {
|
||||
color: #fff;
|
||||
height: 47rpx;
|
||||
background: #252526;
|
||||
border-radius: 16rpx;
|
||||
opacity: 0.3;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
margin-right: 14rpx;
|
||||
|
||||
&>image {
|
||||
width: 24rpx;
|
||||
height: 21rpx;
|
||||
|
||||
padding-left: 20rpx;
|
||||
padding-right: 10rpx;
|
||||
}
|
||||
|
||||
&__num {
|
||||
font-size: 24rpx;
|
||||
color: #FFFFF0;
|
||||
font-weight: 400;
|
||||
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
&-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>
|
||||
<template>
|
||||
<view class="containers">
|
||||
<view class="steps">
|
||||
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
|
||||
</view>
|
||||
<view class="study">
|
||||
<view class="service-show">
|
||||
<swiper class="service-show-swiper" :indicator-dots="true">
|
||||
<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>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
<view>
|
||||
{{studyInfo.content?studyInfo.content:""}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="asks">
|
||||
|
||||
</view>
|
||||
|
||||
<button @click="goTest" :class="studyMin==-1?'goTest':'noTest'" :disabled="studyMin==-1?false:true">
|
||||
<text v-if="studyMin==-1">去测验</text>
|
||||
<text v-else>需要学习{{studyInfo.minute?studyInfo.minute:""}}分钟可去测验({{studyTime}})</text>
|
||||
|
||||
</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
type: 1,
|
||||
steps: [{
|
||||
title: '填报'
|
||||
}, {
|
||||
title: '学习'
|
||||
}, {
|
||||
title: '完成'
|
||||
}],
|
||||
stepActive: 1,
|
||||
studyInfo: {},
|
||||
studyTime: "00:00", // 学习时间
|
||||
studyMin: -1, // 倒计时
|
||||
timer: null,
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
let that = this
|
||||
this.type = options.type
|
||||
this.getStudy()
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer)
|
||||
} else {
|
||||
this.timer = setInterval(function() {
|
||||
that.loadTime()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
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.studyMin = res.minute * 60
|
||||
},
|
||||
utilFail: function(res) {}
|
||||
})
|
||||
},
|
||||
loadTime() {
|
||||
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
|
||||
--this.studyMin;
|
||||
} else {
|
||||
clearInterval(this.timer);
|
||||
}
|
||||
},
|
||||
goTest() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/visit/testStudy?type=' + this.type
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.containers {
|
||||
background-color: #fff;
|
||||
min-height: 100vh;
|
||||
padding: 20rpx;
|
||||
padding-bottom: 60rpx;
|
||||
position: relative;
|
||||
}
|
||||
.containers>button{
|
||||
position: absolute;
|
||||
bottom:60rpx;
|
||||
margin:20rpx;
|
||||
width:90%;
|
||||
}
|
||||
.steps {
|
||||
margin-bottom: 40rpx
|
||||
}
|
||||
|
||||
.goTest {
|
||||
background-color: #044ed7;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.noTest {
|
||||
background-color: #ddd;
|
||||
color: #000
|
||||
}
|
||||
|
||||
.service-show {
|
||||
width: 100%;
|
||||
height: 360rpx;
|
||||
|
||||
position: relative;
|
||||
}
|
||||
</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