first commit
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
<!--#
|
||||
layout("/mobile/platform.html"){
|
||||
#-->
|
||||
<style>
|
||||
[v-clock] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<div v-clock id="app" style="padding: 0 10px;">
|
||||
<div v-show="showMsg"
|
||||
style="margin: 1.2rem 0.20rem 0.4rem 0.20rem;padding: 0.3rem 0.34rem;text-align: center">
|
||||
<div class="weui-msg">
|
||||
<div class="weui-msg__icon-area">
|
||||
<i v-if="flag" class="weui-icon-success weui-icon_msg"></i>
|
||||
<i v-else class="weui-icon-warn weui-icon_msg"></i>
|
||||
</div>
|
||||
<div class="weui-msg__text-area">
|
||||
<h2 class="weui-msg__title">{{msg}}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!showMsg" style="padding-top: 20px">
|
||||
<div style="width: 100%;text-align: center;color: #1ea0fa"><h2>{{viewData.name}}</h2></div>
|
||||
<div style="width: 100%;margin-top: 20px;font-size: 14px; text-align: center;color: rgb(120,120,120)">
|
||||
<span>考试时间:{{viewData.answer_start_time}} - {{viewData.answer_end_time}}</span>
|
||||
<span>分值:({{viewData.fraction}})</span>
|
||||
</div>
|
||||
<div style="width: 100%;margin-top: 20px" v-if="viewData.explain_txt" v-html="viewData.explain_txt">
|
||||
</div>
|
||||
<hr v-if="viewData.explain_txt"
|
||||
style="margin-top: 20px;border: none;border-bottom: 1px rgb(150,150,150) dashed"/>
|
||||
|
||||
<div style="margin-top: 50px">
|
||||
<van-panel style="margin: 20px 0;box-shadow: 0 0 10px rgb(220,220,220)"
|
||||
v-for="sub,idx in viewData.subjects" :title="(idx+1)+'. '+ getTxt(sub.name)">
|
||||
<!-- 单选-->
|
||||
<div style="padding: 10px" v-if="sub.type==1">
|
||||
<van-radio v-for="ans in sub.answer" :name="ans.id" v-model="sub.val"
|
||||
style="padding: 10px 10px;margin: 0;box-sizing: border-box;">
|
||||
<div style="width: 100%;margin: 5px 0" v-html="ans.option_txt"></div>
|
||||
</van-radio>
|
||||
</div>
|
||||
|
||||
<!-- 多选-->
|
||||
<div style="padding: 10px" v-if="sub.type==2">
|
||||
<van-checkbox-group style="position: relative;box-sizing: border-box;" v-model="sub.val">
|
||||
|
||||
<van-checkbox v-for="ans in sub.answer" shape="square" :name="ans.id"
|
||||
style="padding: 10px 10px;margin: 0;box-sizing: border-box;">
|
||||
<div style="width: 100%;margin: 5px 0" v-html="ans.option_txt"></div>
|
||||
|
||||
</van-checkbox>
|
||||
|
||||
</van-checkbox-group>
|
||||
</div>
|
||||
</van-panel>
|
||||
</div>
|
||||
|
||||
<div style="width: 100%;text-align: center;margin-top: 30px;margin-bottom: 10px">
|
||||
<van-button color="#1ea0fa" v-show="viewData!={}" type="primary" :loading="loading" @click.native="subData"
|
||||
style="width: 70%">
|
||||
提交试卷
|
||||
</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: "#app",
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
showMsg: false,
|
||||
showPage: false,
|
||||
msg: '',
|
||||
flag: false,
|
||||
viewData: {},
|
||||
formData: [],
|
||||
getTxt(val) {
|
||||
if (val) {
|
||||
return val.replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi, '').replace(/<[^>]+?>/g, '').replace(/\s+/g, ' ').replace(/ /g, ' ').replace(/>/g, ' ');
|
||||
}
|
||||
return ''
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
subData() {
|
||||
this.formData = []
|
||||
let subject = this.viewData.subjects
|
||||
|
||||
if (moment().format("HH:mm:ss") > this.viewData.answer_end_time) {
|
||||
this.$notify({type: 'danger', message: "您已超时,此次作废!"})
|
||||
this.flag = true
|
||||
this.showMsg = true
|
||||
return
|
||||
}
|
||||
|
||||
for (let i = 0; i < subject.length; i++) {
|
||||
if (subject[i].val == "" || subject[i].val == []) {
|
||||
this.$notify({type: 'warning', message: "第" + (i + 1) + "题未答"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.viewData.subjects.forEach(v => {
|
||||
if (v.type == 1) {
|
||||
this.formData.push({"papers_id": this.viewData.id, "subject_id": v.id, "answer_id": v.val})
|
||||
} else if (v.type == 2) {
|
||||
v.val.forEach(x => {
|
||||
this.formData.push({"papers_id": this.viewData.id, "subject_id": v.id, "answer_id": x})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
this.loading = true
|
||||
$.post("/platform/hd/zxdt/mobile/answer/doAdd", {replyList: JSON.stringify(this.formData)}, (res) => {
|
||||
if (res.code == 0) {
|
||||
this.loading = false
|
||||
this.msg = '您的答卷已提交,感谢您的参与!'
|
||||
this.flag = true
|
||||
this.showMsg = true
|
||||
} else {
|
||||
this.$notify({type: 'danger', message: res.msg})
|
||||
}
|
||||
})
|
||||
},
|
||||
pageData() {
|
||||
this.formData = []
|
||||
$.get("/platform/hd/zxdt/mobile/answer/findOne", (res) => {
|
||||
const {code, data, msg} = res
|
||||
if (!data) {
|
||||
this.msg = "您今日的答题次数已用完"
|
||||
this.flag = true
|
||||
this.showMsg = true
|
||||
return
|
||||
}
|
||||
|
||||
if (code == 0) {
|
||||
|
||||
if (moment().format("HH:mm:ss") < data.answer_start_time) {
|
||||
this.msg = "未到答题时间"
|
||||
this.flag = true
|
||||
this.showMsg = true
|
||||
return
|
||||
} else if (moment().format("HH:mm:ss") > data.answer_end_time) {
|
||||
this.msg = "答题时间已过"
|
||||
this.flag = true
|
||||
this.showMsg = true
|
||||
return
|
||||
}
|
||||
|
||||
data.subjects.forEach(v => {
|
||||
v.val = v.type === 1 ? "" : []
|
||||
})
|
||||
this.viewData = data
|
||||
this.showMsg = false
|
||||
} else {
|
||||
this.msg = msg
|
||||
this.showMsg = true
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.pageData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
Reference in New Issue
Block a user