init
This commit is contained in:
@@ -0,0 +1,589 @@
|
||||
<!--#
|
||||
layout("/mobile/platform.html"){
|
||||
#-->
|
||||
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'Indie Flower';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(/assets/platform/fonts/m8JVjfNVeKWVnh3QMuKkFcZVaUuH.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
|
||||
.page-survey {
|
||||
background-color: rgba(242, 242, 242, 1);
|
||||
}
|
||||
|
||||
.page-survey .survey-container {
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
padding-top: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.survey-container .question-list {
|
||||
flex: auto;
|
||||
padding-bottom: 84px;
|
||||
}
|
||||
|
||||
.question {
|
||||
position: relative;
|
||||
margin-bottom: 20px;
|
||||
background: rgba(255, 255, 255, 1);
|
||||
}
|
||||
|
||||
.question-head {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
padding: 20px;
|
||||
background: rgba(255, 255, 255, 1);
|
||||
}
|
||||
|
||||
.question-tags {
|
||||
position: absolute;
|
||||
top: -2px;
|
||||
}
|
||||
|
||||
.question-title {
|
||||
position: relative;
|
||||
font-size: 1.125em;
|
||||
font-weight: normal;
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.question-seq {
|
||||
display: block;
|
||||
margin-right: 8px;
|
||||
font-size: 18px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.question-title .text {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.question-body {
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.question-footer {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.van-checkbox {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.van-cell__title {
|
||||
font-size: 16px;
|
||||
color: rgba(0, 0, 0, 1);
|
||||
}
|
||||
|
||||
.page-control {
|
||||
padding: 20px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-gap: 20px;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.survey-head-top {
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.survey-head-top .randomCount {
|
||||
font-family: 'Arial', sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
color: #000000;
|
||||
background-color: #f0f0f0;
|
||||
border: 1px solid #000000;
|
||||
border-radius: 5px;
|
||||
padding: 5px 20px;
|
||||
}
|
||||
|
||||
.survey-head-top .score {
|
||||
/*font-family: 'Comic Sans MS', cursive;*/
|
||||
font-family: 'Indie Flower', cursive;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
|
||||
.survey-head {
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.survey-head .title {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.survey-head .desc {
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="root">
|
||||
<m-page-loading v-if="mLoading"></m-page-loading>
|
||||
<van-nav-bar title="知识竞答" left-arrow placeholder fixed
|
||||
@click-left="history.go(-1)"></van-nav-bar>
|
||||
<template v-if="!mLoading">
|
||||
<div class="page-survey" style="touch-action: manipulation;min-height: 100vh;">
|
||||
<div class="survey-container">
|
||||
<!-- v-if="questionData.qlx==2 && (questionData.ctMode==1 || questionData.ctMode==2)"-->
|
||||
<div class="survey-head-top">
|
||||
<template>
|
||||
<div v-if="questionData.qlx==2 && questionData.ctMode==2 && isSameDay && randomCount > 0"
|
||||
class="randomCount"
|
||||
@click="openRandomCount">
|
||||
第<span>{{randomCount}}</span>轮
|
||||
</div>
|
||||
<div v-if="questionData.qlx==2 && (questionData.ctMode==1 || (questionData.ctMode==2 && !isSameDay))"
|
||||
class="randomCount"
|
||||
@click="openRandomCount">
|
||||
<!--定时定题 可切换时间查看以前的题目-->
|
||||
<span>{{currentDate}}</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="score" v-if="finishAnswer && ( currentScore || currentScore===0 )">
|
||||
得分{{currentScore}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="survey-head">
|
||||
<div class="title">
|
||||
{{questionData.qtitle}}
|
||||
</div>
|
||||
<div class="desc">
|
||||
{{titleMsg}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="question-list">
|
||||
<section v-for="(issue,issueIdx) in issueList" :key="issue.iid" class="question"
|
||||
:id="'issue'+issue.iid">
|
||||
<div class="question-head">
|
||||
<div class="question-tags">
|
||||
<template v-if="issue.itx===1">
|
||||
<van-tag :type="issue.iisdx?'primary':'warning'">{{issue.iisdx?'单选':'多选'}}
|
||||
</van-tag>
|
||||
</template>
|
||||
<van-tag v-if="issue.fraction" type="primary">{{issue.fraction}}分</van-tag>
|
||||
</div>
|
||||
<h2 class="question-title">
|
||||
<span class="question-seq">
|
||||
<b>
|
||||
{{issueIdx+1}}
|
||||
</b>
|
||||
</span>
|
||||
<div class="text" v-html="issue.iname"></div>
|
||||
</h2>
|
||||
|
||||
</div>
|
||||
<div class="question-body">
|
||||
<van-checkbox-group v-model="issue.userSelect" :ref="'checkboxGroup'+issue.iid">
|
||||
<van-cell-group>
|
||||
<van-cell
|
||||
v-for="(item,index) in issue.wors"
|
||||
clickable
|
||||
:key="item"
|
||||
:title="item.wtxt"
|
||||
@click="cellToggle(issue,item.wid)"
|
||||
>
|
||||
<template #label v-if="finishAnswer || finishAllAnswer">
|
||||
<div>
|
||||
{{item.correct?'正确答案':''}}
|
||||
</div>
|
||||
</template>
|
||||
<template #icon>
|
||||
<van-checkbox :name="item.wid" :ref="'checkboxes'+item.wid"
|
||||
:disabled="finishAnswer || finishAllAnswer"
|
||||
:shape="issue.iisdx?'round':'square'"></van-checkbox>
|
||||
</template>
|
||||
</van-cell>
|
||||
</van-cell-group>
|
||||
</van-checkbox-group>
|
||||
|
||||
</div>
|
||||
<div class="question-footer" v-if="finishAnswer || finishAllAnswer">
|
||||
<div>
|
||||
<div style="display: flex;align-items: center;"
|
||||
:style="{color:(issue.isEqual?'#15db81':'red')}">
|
||||
{{issue.isEqual?'回答正确':'回答错误'}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="page-control">
|
||||
<template v-if="!finishAnswer">
|
||||
<van-button type="info" block @click="save()">保存</van-button>
|
||||
<van-button type="info" block @click="submit()">提交</van-button>
|
||||
</template>
|
||||
|
||||
<van-button v-if="canAnswerAgain && finishAnswer" type="info" block @click="answerAgain">
|
||||
再答一次
|
||||
</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<van-action-sheet
|
||||
v-model="randomCountSheetShow"
|
||||
:actions="randomActions"
|
||||
@select="randomCountSelect"
|
||||
cancel-text="取消"
|
||||
close-on-click-action
|
||||
></van-action-sheet>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const BASE_URL = '/mobile/question/h5'
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
questionData: {
|
||||
issues: []
|
||||
},
|
||||
currentIssueIndex: 0,
|
||||
replyInfo: [],
|
||||
finishAnswer: false,
|
||||
finishAllAnswer: false,
|
||||
mLoading: true,
|
||||
|
||||
//用户已答题总轮数
|
||||
randomCount: null,
|
||||
currentRandomCountScore: 0,
|
||||
sumScore: 0,
|
||||
randomCountSheetShow: false,
|
||||
randomActions: [],
|
||||
currentRandomCount: null,
|
||||
|
||||
//能否再次答题
|
||||
canAnswerAgain: false,
|
||||
|
||||
//当前的时间(针对定时定题)
|
||||
currentDate: moment().format('YYYY-MM-DD'),
|
||||
|
||||
//当前分数
|
||||
currentScore: null,
|
||||
|
||||
//获取用户已回答的轮数 针对单天随机
|
||||
userHasAnswerRandomNum: 0
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
issueList() {
|
||||
return this.questionData.issues
|
||||
},
|
||||
titleMsg() {
|
||||
const radios = this.issueList.filter(v => v.itx === 1 && v.iisdx)
|
||||
const checkBoxes = this.issueList.filter(v => v.itx === 1 && !v.iisdx)
|
||||
|
||||
const radioScore = radios && radios.length > 0 ? radios[0].fraction : 0
|
||||
const checkBoxesScore = checkBoxes && checkBoxes.length > 0 ? checkBoxes[0].fraction : 0
|
||||
|
||||
const radioScoreSum = radios.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b, 0)
|
||||
const checkBoxesScoreSum = checkBoxes.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b, 0)
|
||||
|
||||
const sumScore = radioScoreSum + checkBoxesScoreSum
|
||||
|
||||
let radiosText = ''
|
||||
let checkBoxesText = ''
|
||||
|
||||
if (radios && radios.length > 0) {
|
||||
radiosText = "单选题" + radios.length + "题,每题" + radioScore + "分,合计" + radioScoreSum + "分;"
|
||||
}
|
||||
if (checkBoxes && checkBoxes.length > 0) {
|
||||
checkBoxesText = "多选题" + checkBoxes.length + "题,每题" + checkBoxesScore + "分,合计" + checkBoxesScoreSum + "分;总分" + sumScore + "分。"
|
||||
}
|
||||
return "说明:" + radiosText + checkBoxesText
|
||||
},
|
||||
|
||||
fullScore() {
|
||||
return this.issueList.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b)
|
||||
},
|
||||
radioNum() {
|
||||
return this.issueList.filter(v => v.idx === 1 && v.iisdx).map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b)
|
||||
},
|
||||
checkBoxNum() {
|
||||
|
||||
},
|
||||
|
||||
//判断是否为同一天
|
||||
isSameDay() {
|
||||
if (this.questionData.startTime && this.questionData.endTime) {
|
||||
return moment(this.questionData.startTime).isSame(moment(this.questionData.endTime), 'day')
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
openRandomCount() {
|
||||
this.randomCountSheetShow = true
|
||||
this.randomActions = []
|
||||
|
||||
if (this.questionData.qlx == 2 && this.questionData.ctMode == 2 && this.isSameDay) {
|
||||
for (let i = 0; i < this.userHasAnswerRandomNum; i++) {
|
||||
this.randomActions.push({
|
||||
name: '第' + (i + 1) + '轮',
|
||||
val: i + 1
|
||||
})
|
||||
}
|
||||
} else if (this.questionData.qlx == 2 && (this.questionData.ctMode == 1 || (this.questionData.ctMode == 2 && !this.isSameDay))) {
|
||||
const {startTime, endTime} = this.questionData
|
||||
const startMoment = moment(startTime)
|
||||
const endMoment = moment(endTime)
|
||||
const now = moment()
|
||||
// 计算两个日期之间相差的天数
|
||||
const daysDifference = endMoment.diff(startMoment, 'days')
|
||||
for (let i = 0; i <= daysDifference; i++) {
|
||||
this.randomActions.push({
|
||||
name: startMoment.clone().add(i, 'days').format('YYYY-MM-DD'),
|
||||
val: startMoment.clone().add(i, 'days').format('YYYY-MM-DD'),
|
||||
disabled: moment(startMoment.clone().add(i, 'days').format('YYYY-MM-DD')).isAfter(now)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
async randomCountSelect(val) {
|
||||
if (this.questionData.qlx == 2 && this.questionData.ctMode == 2 && this.isSameDay) {
|
||||
this.randomCount = val.val
|
||||
} else if (this.questionData.qlx == 2 && this.questionData.ctMode == 2 && !this.isSameDay) {
|
||||
this.currentDate = val.val
|
||||
} else if (this.questionData.qlx == 2 && this.questionData.ctMode == 1) {
|
||||
this.currentDate = val.val
|
||||
}
|
||||
await this.getQuestionData()
|
||||
await this.checkUserFinishAnswer()
|
||||
await this.checkCanAnswerAgain()
|
||||
await this.getScore()
|
||||
},
|
||||
|
||||
async getQuestionData() {
|
||||
const resp = await $.get(BASE_URL + '/questionInfo/' + this.id, {
|
||||
currentDate: this.currentDate,
|
||||
randomCount: this.randomCount
|
||||
})
|
||||
this.questionData = resp.data
|
||||
},
|
||||
cellToggle(issue, worId) {
|
||||
if (this.finishAnswer || this.finishAllAnswer) {
|
||||
return
|
||||
}
|
||||
this.toggle(issue, worId)
|
||||
},
|
||||
|
||||
toggle(issue, worId) {
|
||||
//单选
|
||||
if (issue.iisdx) {
|
||||
vue.$refs['checkboxGroup' + issue.iid][0].toggleAll(false)
|
||||
} else {
|
||||
|
||||
}
|
||||
console.log(issue.userSelect)
|
||||
this.$refs['checkboxes' + worId][0].toggle()
|
||||
setTimeout(() => {
|
||||
console.log(issue.userSelect)
|
||||
})
|
||||
},
|
||||
|
||||
save() {
|
||||
this.$modal.confirm('保存后下次可继续做答,您确定要保存吗?').then(async () => {
|
||||
const replies = this.questionData.issues.map(v => {
|
||||
return {
|
||||
qid: v.iid,
|
||||
issueId: v.iid,
|
||||
userSelect: v.userSelect,
|
||||
}
|
||||
})
|
||||
|
||||
const {code} = await $.post(BASE_URL + '/saveAnswer', {
|
||||
replies: JSON.stringify(replies),
|
||||
questionId: this.questionData.qid,
|
||||
isSave: true,
|
||||
randomCount: this.randomCount
|
||||
})
|
||||
this.$modal.closeLoading()
|
||||
if (code === 0) {
|
||||
this.$modal.msg('保存成功')
|
||||
} else {
|
||||
this.$modal.msg('保存失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
submit() {
|
||||
const iids = this.questionData.issues.filter(v => !v.userSelect).map(v => v.iid)
|
||||
|
||||
if (iids.length > 0) {
|
||||
this.$toast('您还有' + iids.length + '题未作答,请答完后再提交!')
|
||||
document.getElementById('issue' + iids[0]).scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'center',
|
||||
'inline': 'start'
|
||||
});
|
||||
return
|
||||
}
|
||||
|
||||
const msg = '一旦提交不可修改,您确定要提交吗?'
|
||||
|
||||
this.$modal.confirm(msg).then(async () => {
|
||||
const replies = this.questionData.issues.map(v => {
|
||||
return {
|
||||
qid: this.id,
|
||||
issueId: v.iid,
|
||||
userSelect: v.userSelect,
|
||||
}
|
||||
})
|
||||
|
||||
const {code} = await $.post(BASE_URL + '/saveAnswer', {
|
||||
replies: JSON.stringify(replies),
|
||||
questionId: this.questionData.qid,
|
||||
isSave: false,
|
||||
randomCount: this.randomCount
|
||||
})
|
||||
this.$modal.closeLoading()
|
||||
if (code === 0) {
|
||||
this.$modal.msg('提交成功')
|
||||
await this.getUserHasAnswerRandomNum()
|
||||
await this.checkUserFinishAnswer()
|
||||
await this.getReply()
|
||||
await this.assignmentAnswer()
|
||||
await this.checkUserFinishAnswer()
|
||||
await this.checkCanAnswerAgain()
|
||||
await this.getScore()
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取回答信息
|
||||
async getReply() {
|
||||
const resp = await $.get(BASE_URL + '/answerInfo/' + this.id)
|
||||
this.replyInfo = resp.data
|
||||
},
|
||||
//用户是否全部答完提交
|
||||
async checkUserFinishAnswer() {
|
||||
this.mLoading = true
|
||||
const resp = await $.get(BASE_URL + '/checkUserFinishAnswer', {
|
||||
questionId: this.id,
|
||||
randomCount: this.randomCount,
|
||||
currentDate: this.currentDate
|
||||
})
|
||||
this.mLoading = false
|
||||
this.finishAnswer = resp.data
|
||||
await this.getReply()
|
||||
await this.assignmentAnswer()
|
||||
},
|
||||
|
||||
//答案赋值
|
||||
assignmentAnswer() {
|
||||
this.questionData.issues.forEach(issue => {
|
||||
const rwids = this.replyInfo.filter(v => v.issueId === issue.iid).map(v => v.rwid)
|
||||
rwids.forEach(rwid => {
|
||||
this.toggle(issue, rwid)
|
||||
})
|
||||
const wids = issue.wors.filter(v => v.correct).map(v => v.wid)
|
||||
const userSelects = this.replyInfo.filter(v => v.issueId === issue.iid).map(v => v.rwid)
|
||||
const isEqual = wids.length === userSelects.length && wids.every(value => userSelects.includes(value))
|
||||
issue.isEqual = isEqual
|
||||
})
|
||||
},
|
||||
|
||||
answerAgain() {
|
||||
this.finishAnswer = false
|
||||
setTimeout(() => {
|
||||
this.questionData.issues.forEach(issue => {
|
||||
issue.wors.forEach(wor => {
|
||||
this.$refs['checkboxes' + wor.wid][0].toggle(false)
|
||||
})
|
||||
})
|
||||
}, 0)
|
||||
},
|
||||
|
||||
async getUserHasAnswerRandomNum() {
|
||||
const resp = await $.get(BASE_URL + '/getUserHasAnswerRandomNum', {
|
||||
questionId: this.id
|
||||
})
|
||||
this.userHasAnswerRandomNum = resp.data
|
||||
this.randomCount = this.userHasAnswerRandomNum
|
||||
},
|
||||
|
||||
async checkCanAnswerAgain() {
|
||||
const resp = await $.get(BASE_URL + '/checkCanAnswerAgain', {
|
||||
questionId: this.id,
|
||||
randomCount: this.randomCount,
|
||||
currentDate: this.currentDate
|
||||
})
|
||||
this.canAnswerAgain = resp.data
|
||||
},
|
||||
|
||||
async getScore() {
|
||||
const resp = await $.get(BASE_URL + '/getScore/', {
|
||||
questionId: this.id,
|
||||
randomCount: this.randomCount,
|
||||
currentDate: this.currentDate
|
||||
})
|
||||
this.currentScore = resp.data
|
||||
}
|
||||
|
||||
},
|
||||
async created() {
|
||||
this.id = GetQueryString("id")
|
||||
await this.getQuestionData()
|
||||
await this.checkCanAnswerAgain()
|
||||
await this.getUserHasAnswerRandomNum()
|
||||
await this.checkUserFinishAnswer()
|
||||
await this.getScore()
|
||||
this.mLoading = false
|
||||
}
|
||||
})
|
||||
|
||||
window.addEventListener('pageshow', async e => {
|
||||
if (e.persisted || (window.performance && window.performance.navigation.type === 2)) {
|
||||
vue.id = GetQueryString("id")
|
||||
await vue.getQuestionData()
|
||||
// await vue.getRanDomModeNum()
|
||||
// await vue.getSumScore()
|
||||
// await vue.checkUserFinishAnswer()
|
||||
// await vue.getCurrentRandomCountScore()
|
||||
this.mLoading = false
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,464 @@
|
||||
<!--#
|
||||
layout("/mobile/platform.html"){
|
||||
#-->
|
||||
|
||||
<style>
|
||||
.middle-subject {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background-color: #f6f7f9;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.middle-subject-info-padding {
|
||||
padding: 10px;
|
||||
background-color: #f6f7f9;
|
||||
}
|
||||
|
||||
.middle-subject-info-scroll {
|
||||
/*height: 100%;*/
|
||||
height: calc(100vh - 110px);
|
||||
max-height: calc(100vh - 110px);
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.middle-subject-info-head {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.middle-subject-topic-icon {
|
||||
width: 30px;
|
||||
padding: 2px;
|
||||
font-size: 10px;
|
||||
background-color: #1678ff;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
border-radius: 0 0 5px 5px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
.middle-subject-title {
|
||||
margin-bottom: 1rem;
|
||||
font-weight: bolder;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.middle-subject-other {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.middle-subject-topic {
|
||||
background-color: #FFFFFF;
|
||||
margin-bottom: 1rem;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 2px 2px 12px 4px rgba(0, 0, 0, 0.1);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.middle-subject-topic-title {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
.middle-subject-topic-submit {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.middle-subject-topic-desc {
|
||||
color: rgb(160, 160, 160);
|
||||
text-align: left;
|
||||
margin-left: 20px;
|
||||
font-size: 12px;
|
||||
margin-bottom: 10px;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.itx_field {
|
||||
background-color: #fff;
|
||||
background-image: none;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #dcdfe6;
|
||||
box-sizing: border-box;
|
||||
color: #606266;
|
||||
display: inline-block;
|
||||
font-size: inherit;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
outline: none;
|
||||
padding: 0 15px;
|
||||
transition: border-color .2s cubic-bezier(.645, .045, .355, 1);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.middle-subject-topic-submit .u-btn {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.middle-subject-info-search {
|
||||
position: absolute;
|
||||
bottom: 45%;
|
||||
right: 0;
|
||||
height: 40px;
|
||||
z-index: 999;
|
||||
background-color: #FFF;
|
||||
box-shadow: 0 0 20px rgb(230, 230, 230);
|
||||
border-radius: 20px 0 0 20px;
|
||||
}
|
||||
|
||||
.middle-subject-info-search-icon {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
box-shadow: 0 0 10px #1678ff;
|
||||
border-radius: 20px 0 0 20px;
|
||||
background-color: #FFF;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.middle-subject-info-search-info {
|
||||
padding: 0 10px;
|
||||
display: flex;
|
||||
height: inherit;
|
||||
z-index: 999;
|
||||
align-items: center;
|
||||
box-shadow: 0 0 10px #1678ff;
|
||||
border-radius: 20px 0 0 20px;
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.middle-subject-info-footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
max-height: 64px;
|
||||
background-color: #FFF;
|
||||
box-shadow: 0 0 20px rgb(230, 230, 230);
|
||||
z-index: 999;
|
||||
padding: 10px 20px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.middle-subject-info-footer-save {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.middle-subject-info-footer-save .van-button {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.middle-subject-info-footer-pagination {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.wsm {
|
||||
max-height: 80px;
|
||||
/*overflow: scroll;*/
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.wsm * {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.wsm p {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.wsmPopup {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="middle-subject">
|
||||
<van-nav-bar title="在线调查" left-arrow
|
||||
@click-left="history.back()"></van-nav-bar>
|
||||
|
||||
<div class="middle-subject-info">
|
||||
<div class="middle-subject-info-scroll">
|
||||
<div class="middle-subject-info-padding">
|
||||
<div class="middle-subject-info-head">
|
||||
<div class="middle-subject-title">{{ questionData.qtitle }}</div>
|
||||
<div class="middle-subject-other">
|
||||
<template v-if="questionData.qlx!==3">
|
||||
<!-- <span>创建人:{{ questionData.username }}</span>-->
|
||||
<!-- <span>总题数:{{ issueList.length }}</span>-->
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="middle-subject-info-body">
|
||||
<div class="middle-subject-topic" v-for="(issue,issueIndex) in issueList" :key="issue.qid">
|
||||
<div v-if="!issue.iisdx" class="middle-subject-topic-icon">
|
||||
<span>多选</span>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px">
|
||||
<span v-if="issue.iisbd" style="color: red;">*</span>
|
||||
<span class="middle-subject-topic-title">
|
||||
{{ issueIndex + 1 }}.
|
||||
{{ removeHTMLTag(issue.iname) }}
|
||||
<span v-if="issue.iminselect">(最少选择:{{issue.iminselect}})</span>
|
||||
<span v-if="issue.imaxselect">(最多选择:{{issue.imaxselect}})</span>
|
||||
<div v-if="issue.its" class="middle-subject-topic-desc"
|
||||
style="margin-left: 17px;font-size: 12px;font-weight: 500;">
|
||||
{{ issue.its }}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- 选择题 -->
|
||||
<template v-if="issue.itx===1">
|
||||
<!-- 单选题 -->
|
||||
<van-radio-group v-if="issue.iisdx" v-model="issue.rwid" :disabled="replyFinish">
|
||||
<div v-for="(wor,worIndex) in issue.wors" :key="wor.wid">
|
||||
<van-radio :ref="wor.wid" :name="wor.wid">
|
||||
{{ letterList[worIndex] }}. {{ wor.wtxt }}
|
||||
</van-radio>
|
||||
<div class="middle-subject-topic-desc">
|
||||
<van-row gutter="16">
|
||||
<van-col span="8" v-if="wor.wimg">
|
||||
<image style="height: 80px;width: 80px"
|
||||
:src="'/file_server/fileStreamPreview?id='+wor.wimg"
|
||||
mode="aspectFit">
|
||||
</image>
|
||||
</van-col>
|
||||
<van-col span="16" v-if="wor.wsm">
|
||||
<div class="wsm" v-html="wor.wsm" @click="openWsm(wor.wsm)"></div>
|
||||
</van-col>
|
||||
</van-row>
|
||||
</div>
|
||||
</div>
|
||||
</van-radio-group>
|
||||
|
||||
<!-- 多选题 -->
|
||||
<van-checkbox-group v-else-if="!issue.iisdx" v-model="issue.rwid"
|
||||
:disabled="replyFinish"
|
||||
:max="issue.imaxselect ? issue.imaxselect:0">
|
||||
<div v-for="(wor,worIndex) in issue.wors" :key="worIndex">
|
||||
<van-checkbox :ref="wor.wid" :name="wor.wid" shape="square">
|
||||
{{ letterList[worIndex] }}. {{ wor.wtxt }}
|
||||
</van-checkbox>
|
||||
<div class="middle-subject-topic-desc">
|
||||
<van-row gutter="16">
|
||||
<van-col span="8" v-if="wor.wimg">
|
||||
<image style="height: 80px;width: 80px"
|
||||
:src="'/file_server/fileStreamPreview?id='+wor.wimg"
|
||||
mode="aspectFit">
|
||||
</image>
|
||||
</van-col>
|
||||
<van-col span="16" v-if="wor.wsm">
|
||||
<div class="wsm" v-html=" wor.wsm" @click="openWsm(wor.wsm)"></div>
|
||||
</van-col>
|
||||
</van-row>
|
||||
</div>
|
||||
</div>
|
||||
</van-checkbox-group>
|
||||
</template>
|
||||
|
||||
<!-- 填空题 -->
|
||||
<template v-if="issue.itx===2">
|
||||
<van-field v-model="issue.rval" type="text" border
|
||||
class="itx_field"
|
||||
cursor-spacing="100"
|
||||
:show-confirmbar="false"
|
||||
:disabled="replyFinish" :auto-height="true" maxlength="2000"></van-field>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="middle-subject-info-footer">
|
||||
<div class="middle-subject-info-footer-save">
|
||||
<van-button size="medium" type="primary" @click="saveAnswer"
|
||||
:disabled="replyFinish">保存
|
||||
</van-button>
|
||||
<van-button size="medium" type="info" :disabled="replyFinish"
|
||||
@click="submitAnswer">
|
||||
提交
|
||||
</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<van-popup v-model="wsmPopup" round :style="{ height: '80%',width:'90%' }">
|
||||
<div v-html="wsmContent" class="wsmPopup"></div>
|
||||
</van-popup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
mixins: [mobileMixins],
|
||||
data() {
|
||||
return {
|
||||
id: null,
|
||||
questionData: {},
|
||||
issueList: [],
|
||||
replyInfo: [],
|
||||
wsmContent: null,
|
||||
wsmPopup: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
letterList() {
|
||||
const alphabet = Array.from(new Array(26), (ele, index) => {
|
||||
return String.fromCharCode(65 + index);
|
||||
})
|
||||
return alphabet
|
||||
},
|
||||
replyFinish() {
|
||||
return this.replyInfo.some(v => !v.save)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openWsm(content) {
|
||||
this.wsmContent = content
|
||||
this.wsmPopup = true
|
||||
},
|
||||
|
||||
async getQuestionData() {
|
||||
const resp = await $.get('/mobile/question/h5/questionInfo/' + this.id)
|
||||
this.questionData = resp.data
|
||||
this.issueList = this.questionData && this.questionData.issues
|
||||
},
|
||||
saveAnswer() {
|
||||
const formData = this.formatFormData()
|
||||
formData.forEach(v => v.save = true)
|
||||
this.$modal.loading('保存中')
|
||||
$.post('/mobile/question/h5/saveAnswer', {repliesArray: JSON.stringify(formData)}).then(res => {
|
||||
this.$modal.closeLoading()
|
||||
if (res.code === 0) {
|
||||
this.$modal.msg('保存成功')
|
||||
this.getReply()
|
||||
} else {
|
||||
this.$modal.msg('保存失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
submitAnswer() {
|
||||
const formData = this.formatFormData()
|
||||
formData.forEach(v => v.save = false)
|
||||
this.$modal.confirm('您确定要提交吗?提交后不能修改!').then(() => {
|
||||
this.$modal.loading('提交中')
|
||||
$.post('/mobile/question/h5/saveAnswer', {repliesArray: JSON.stringify(formData)}).then(res => {
|
||||
this.$modal.closeLoading()
|
||||
if (res.code === 0) {
|
||||
this.$modal.msg('提交成功')
|
||||
this.getReply()
|
||||
} else {
|
||||
this.$modal.msg('提交失败')
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
validAnswer() {
|
||||
|
||||
},
|
||||
|
||||
//格式化提交数据
|
||||
formatFormData() {
|
||||
const formData = []
|
||||
this.issueList.forEach(v => {
|
||||
if (v.itx === 1 && v.iisdx) {
|
||||
//单选
|
||||
if (v.rwid) {
|
||||
formData.push({
|
||||
"rwid": v.rwid,
|
||||
"qid": this.questionData.qid,
|
||||
"issueId": v.iid
|
||||
})
|
||||
}
|
||||
} else if (v.itx === 1 && !v.iisdx) {
|
||||
//多选
|
||||
if (v.rwid) {
|
||||
v.rwid.forEach(r => {
|
||||
formData.push({
|
||||
"rwid": r,
|
||||
"qid": this.questionData.qid,
|
||||
"issueId": v.iid
|
||||
})
|
||||
})
|
||||
}
|
||||
} else if (v.itx === 2) {
|
||||
if (v.rval) {
|
||||
formData.push({
|
||||
"rval": v.rval,
|
||||
"qid": this.questionData.qid,
|
||||
"issueId": v.iid
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
return formData
|
||||
},
|
||||
//获取回答信息并赋值
|
||||
async getReply() {
|
||||
const resp = await $.get('/mobile/question/h5/answerInfo/' + this.id)
|
||||
this.replyInfo = resp.data
|
||||
this.issueList.forEach((issue, issueIndex) => {
|
||||
if (issue.itx === 1 && issue.iisdx) {
|
||||
//单选
|
||||
const rw = this.replyInfo.find(answer => answer.issueId === issue.iid)
|
||||
this.$set(this.issueList[issueIndex], 'rwid', rw ? rw.rwid : null)
|
||||
} else if (issue.itx === 1 && !issue.iisdx) {
|
||||
//多选
|
||||
const rws = this.replyInfo.filter(answer => answer.issueId === issue.iid).map(v => v.rwid)
|
||||
this.$set(this.issueList[issueIndex], 'rwid', rws ? rws : [])
|
||||
} else if (issue.itx === 2) {
|
||||
//填空题
|
||||
const rw = this.replyInfo.find(answer => answer.issueId === issue.iid)
|
||||
this.$set(this.issueList[issueIndex], 'rval', rw ? rw.rval : null)
|
||||
}
|
||||
})
|
||||
},
|
||||
defaultChecked() {
|
||||
const itx = this.issueList[0]['itx']
|
||||
const iisdx = this.issueList[0]['iisdx']
|
||||
|
||||
//判断用户是否选过 并且是选择题才可以
|
||||
if (this.replyInfo.length === 0 && itx === 1) {
|
||||
if (iisdx) {
|
||||
const defaultOption = this.issueList[0]['wors'].find(v => v.wismr === true)
|
||||
this.$set(this.issueList[0], 'rwid', defaultOption ? defaultOption.rwid : null)
|
||||
} else {
|
||||
const defaultOptionIds = this.issueList[0]['wors'].filter(v => v.wismr === true).map(v => v.wid)
|
||||
this.$set(this.issueList[0], 'rwid', defaultOptionIds ? defaultOptionIds : [])
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.id = GetQueryString("id")
|
||||
await this.getQuestionData()
|
||||
await this.getReply()
|
||||
// await this.defaultChecked()
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,105 @@
|
||||
<!--#
|
||||
layout("/mobile/platform.html"){
|
||||
#-->
|
||||
<style>
|
||||
#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.cell-card {
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
|
||||
width: 90%;
|
||||
margin: 20px auto;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.text-overflow {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div id="app" v-cloak>
|
||||
<van-nav-bar title="问卷调查" left-arrow placeholder fixed @click-left="history.back()"></van-nav-bar>
|
||||
<div>
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-list v-model="loading"
|
||||
:finished="finished"
|
||||
:finished-text="tableData.length>0?'没有更多了':''"
|
||||
@load="onLoad">
|
||||
<van-cell v-for="item in tableData" class="cell-card" @click="openView(item.qid)">
|
||||
<div class="text-overflow" style="font-weight: bold">{{item.qtitle}}</div>
|
||||
<div style="font-size: 12px" v-html="item.qsm"></div>
|
||||
</van-cell>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
<van-empty
|
||||
v-if="tableData.length==0"
|
||||
class="custom-image"
|
||||
image="/none.svg"
|
||||
description="暂无数据"
|
||||
></van-empty>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
loading: false,
|
||||
finished: false,
|
||||
refreshing: false,
|
||||
pageForm: {
|
||||
pageNumber: 1,
|
||||
pageSize: 5,
|
||||
totalCount: 0
|
||||
},
|
||||
tableData: [],
|
||||
appid: 'wx9fd2b07ea126f9f6',
|
||||
redirect_uri: location.protocol + "//" + location.host,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async onRefresh() {
|
||||
this.tableData = []
|
||||
this.pageForm = {
|
||||
pageNumber: 1,
|
||||
pageSize: 5,
|
||||
totalCount: 0
|
||||
}
|
||||
await this.onLoad()
|
||||
setTimeout(() => {
|
||||
this.refreshing = false
|
||||
}, 1000)
|
||||
|
||||
},
|
||||
async onLoad() {
|
||||
this.loading = true
|
||||
$.post('/mobile/question/list/pageData', this.pageForm).then(res => {
|
||||
this.loading = false
|
||||
if (res.code === 0) {
|
||||
this.tableData = this.tableData.concat(res.data.list)
|
||||
if (this.tableData.length === res.data.totalCount) {
|
||||
this.finished = true
|
||||
} else {
|
||||
this.pageForm.pageNumber++
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
openView(id) {
|
||||
window.location.href = this.redirect_uri + '/platform/zgfw/mobile/questionnaire?qid=' + id
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,345 @@
|
||||
<!--#
|
||||
layout("/mobile/platform.html"){
|
||||
#-->
|
||||
|
||||
<style>
|
||||
.container {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.top-back {
|
||||
width: 100%;
|
||||
background-color: rgb(22, 120, 255);
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.title {
|
||||
position: fixed;
|
||||
left: 40px;
|
||||
top: 110px;
|
||||
font-size: 24px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: relative;
|
||||
min-height: calc(100vh - 46px - 44px);
|
||||
max-height: calc(100vh - 46px - 44px);
|
||||
overflow-y: scroll;
|
||||
background: #f3f3f3;
|
||||
}
|
||||
|
||||
.quizzes-item {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.quizzes-item-v {
|
||||
box-sizing: border-box;
|
||||
padding: 1rem;
|
||||
width: 100%;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.quizzes-item-info {
|
||||
position: relative;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.quizzes-item-info-icon {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.quizzes-item-info-icon img {
|
||||
width: 6rem;
|
||||
height: 5rem;
|
||||
}
|
||||
|
||||
.quizzes-item-info-title {
|
||||
margin-bottom: 1rem;
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
.quizzes-item-info-right {
|
||||
font-size: 13px;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.quizzes-item-info-tip {
|
||||
color: #606266;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.quizzes-item-info-text {
|
||||
color: #232426;
|
||||
}
|
||||
|
||||
.winPopup {
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
}
|
||||
.winPopup img{
|
||||
transform: translateY(-50%);
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.winPopup .van-popup__close-icon{
|
||||
|
||||
}
|
||||
|
||||
.iconDiv {
|
||||
color: white;
|
||||
font-size: 66px;
|
||||
text-align: center;
|
||||
position: fixed;
|
||||
bottom: 90px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.win_tag{
|
||||
position: relative;
|
||||
top: 16px;
|
||||
left: 5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="container">
|
||||
<van-sticky>
|
||||
<van-nav-bar title="列表" left-arrow
|
||||
@click-left="history.back()"></van-nav-bar>
|
||||
</van-sticky>
|
||||
|
||||
<van-tabs v-model="queryForm.status" @change="doSearch">
|
||||
<van-tab title="进行中" name="1"></van-tab>
|
||||
<van-tab title="已结束" name="2"></van-tab>
|
||||
</van-tabs>
|
||||
|
||||
<div class="content">
|
||||
<div v-for="(item, index) in tableData" :id="item.qid" :key="item.qid">
|
||||
<div class="quizzes-item" @click="openAnswer(item)">
|
||||
<div class="quizzes-item-v">
|
||||
<div class="quizzes-item-info">
|
||||
<div class="quizzes-item-info-icon">
|
||||
<image src="/assets/mobile/svg/question/quizzes2.svg"/>
|
||||
</div>
|
||||
<div class="quizzes-item-info-v">
|
||||
<div class="quizzes-item-info-title">{{ item.qtitle }}</div>
|
||||
<!-- <div class="quizzes-item-info-right">-->
|
||||
<!-- <span class="quizzes-item-info-tip">创建时间:</span>-->
|
||||
<!-- <span class="quizzes-item-info-text">-->
|
||||
<!-- {{ moment(item.createTime).format('YYYY年MM月DD日') }}-->
|
||||
<!-- </span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="quizzes-item-info-right" v-if="item.qlx!==4">-->
|
||||
<!-- <span class="quizzes-item-info-tip">题目数量:</span>-->
|
||||
<!-- <span class="quizzes-item-info-text">-->
|
||||
<!-- {{item.ctMode === 1 ? item.topicTotal : item.ctNum }}-->
|
||||
<!-- </span>-->
|
||||
<!-- <span class="quizzes-item-info-text" style="position: absolute;right: 0" >-->
|
||||
<!-- <van-tag @click.stop="showWinInfo(item)" type="primary" class="win_tag" v-if="item.qlx===2 && item.isRaffle && moment(item.startTime).diff(moment(new Date().getTime()),'days') < 0">获奖信息</van-tag>-->
|
||||
<!-- </span>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<van-empty v-if="finished && !tableData.length" text="暂无问卷" icon-size="320"
|
||||
src="/static/img/notData.svg">
|
||||
</van-empty>
|
||||
</div>
|
||||
|
||||
<van-popup v-model="winPopupShow" class="winPopup"
|
||||
:style="{ height: '100%' }"
|
||||
>
|
||||
<div style="display: flex;align-items: center">
|
||||
<img v-if="isWin" width="100%" height="60%" src="/assets/mobile/img/question/win.png"/>
|
||||
<img v-if="!isWin" width="100%" height="50%" src="/assets/mobile/img/question/noWin1.png"/>
|
||||
</div>
|
||||
<div class="iconDiv">
|
||||
<div v-if="isWin" style="font-size: 14px;!important;">恭喜您中奖了,本次活动中奖机会只有一次喔!</div>
|
||||
<van-icon @click="winPopupShow = false" name="close"></van-icon>
|
||||
</div>
|
||||
</van-popup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
mixins: [mobileMixins],
|
||||
data() {
|
||||
return {
|
||||
questionStatus: '1',
|
||||
scrollTop: 0,
|
||||
statusBarHeight: 0,
|
||||
pageLoading: false,
|
||||
queryForm: {
|
||||
status: '1'
|
||||
},
|
||||
winPopupShow:false,
|
||||
isWin:false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.queryForm.type = GetQueryString("type")
|
||||
this.doSearch()
|
||||
},
|
||||
methods: {
|
||||
async showWinInfo({qid}) {
|
||||
const {data} = await $.post('/mobile/question/h5/winInfo', {questionId: qid})
|
||||
const userId = "${@shiro.getPrincipalProperty('id')}"
|
||||
const user = data.find(o => o.id === userId)
|
||||
this.isWin = user !== undefined
|
||||
this.winList = data
|
||||
console.log(this.isWin)
|
||||
this.winPopupShow = true
|
||||
|
||||
/*vant.Dialog.alert({
|
||||
message: '每人仅有一次中奖机会喔,立即查询获奖信息。'
|
||||
}).then(() => {
|
||||
this.winPopupShow = true
|
||||
});*/
|
||||
},
|
||||
pageData() {
|
||||
this.$modal.loading()
|
||||
this.tableLoading = true
|
||||
|
||||
$.post('/mobile/question/h5/pageData', {...this.pageForm, ...this.queryForm}).then(res => {
|
||||
this.tableData = this.tableData.concat(res.data.list)
|
||||
this.pageForm.totalCount = res.data.totalCount
|
||||
if (this.tableData.length === this.pageForm.totalCount) {
|
||||
this.finished = true
|
||||
} else {
|
||||
this.pageForm.pageNumber++
|
||||
}
|
||||
this.tableLoading = false
|
||||
this.$modal.closeLoading()
|
||||
})
|
||||
|
||||
|
||||
// $.post('/activity/question/h5/pageData', this.pageForm, {
|
||||
// params: this.queryForm
|
||||
// }).then(res => {
|
||||
// this.tableData = this.tableData.concat(res.data.list)
|
||||
// this.pageForm.totalCount = res.data.totalCount
|
||||
// if (this.tableData.length === this.pageForm.totalCount) {
|
||||
// this.finished = true
|
||||
// } else {
|
||||
// this.pageForm.pageNumber++
|
||||
// }
|
||||
// this.tableLoading = false
|
||||
// this.$modal.closeLoading()
|
||||
// }).finally(() => {
|
||||
// this.tableLoading = false
|
||||
// this.finished = true
|
||||
// this.$modal.closeLoading()
|
||||
// })
|
||||
},
|
||||
|
||||
tabChange(index) {
|
||||
this.page.current = index;
|
||||
// this.refresh();
|
||||
},
|
||||
lower(e) {
|
||||
if (!this.finished) this.loadData();
|
||||
},
|
||||
|
||||
async hasPermissionByIssue(groupId) {
|
||||
const resp = await this.$http.get('/platform/question/applets/list/hasPermission', {
|
||||
params: {groupId: groupId}
|
||||
})
|
||||
return resp
|
||||
},
|
||||
|
||||
async openAnswer(item) {
|
||||
const {qid, qlx, qflag, activityUserScopeId} = item
|
||||
if (qflag !== 2) {
|
||||
this.$modal.msg('该问卷未发布')
|
||||
return
|
||||
}
|
||||
|
||||
const now = new Date().getTime()
|
||||
if (now < item.startTime || now > item.endTime) {
|
||||
this.$modal.msg('不在开启时间内')
|
||||
return
|
||||
}
|
||||
|
||||
/*if (activityUserScopeId) {
|
||||
const resp = await $.get('/mobile/question/h5/checkPermission/' + activityUserScopeId)
|
||||
if (!resp.data) {
|
||||
this.$modal.msg('您无权限参加')
|
||||
return
|
||||
}
|
||||
}*/
|
||||
|
||||
if (qlx === 1) {
|
||||
//调查
|
||||
location.href = '/mobile/question/h5/poll/index?id=' + qid
|
||||
} else if (qlx === 2) {
|
||||
//答题
|
||||
location.href = '/mobile/question/h5/answer/index?id=' + qid
|
||||
} else if (qlx === 3) {
|
||||
//购物
|
||||
location.href = '/mobile/question/h5/shop/index?id=' + qid
|
||||
} else if (qlx === 4) {
|
||||
//蛋糕卡
|
||||
location.href = '/mobile/question/h5/cake/index?id=' + qid
|
||||
}
|
||||
|
||||
|
||||
// if (qlx === 4) {
|
||||
// if (item.startTime > new Date().getTime() || item.endTime < new Date().getTime()) {
|
||||
// uni.showToast({
|
||||
// title: "不在开启时间内",
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// });
|
||||
// return
|
||||
// }
|
||||
// if (item.startTime)
|
||||
// uni.navigateTo({
|
||||
// url: "/pages/quizzes/cakeAnswer/cakeAnswer?id=" + id
|
||||
// });
|
||||
// } else if (qlx === 2) {
|
||||
// if (activityUserScopeId) {
|
||||
// const resp = await this.hasPermissionByIssue(activityUserScopeId)
|
||||
// if (resp.code !== 0) {
|
||||
// uni.showToast({
|
||||
// title: resp.msg,
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// });
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
// uni.navigateTo({
|
||||
// url: "/pages/quizzes/choiceAnswer/choiceAnswer?id=" + id
|
||||
// });
|
||||
// } else {
|
||||
// uni.navigateTo({
|
||||
// url: "/pages/quizzes/answer?id=" + id
|
||||
// });
|
||||
// }
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,416 @@
|
||||
<!--#
|
||||
layout("/mobile/platform.html"){
|
||||
#-->
|
||||
<!--在线调查-->
|
||||
<style>
|
||||
.middle-subject {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background-color: #f6f7f9;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.middle-subject-info-padding {
|
||||
padding: 10px;
|
||||
background-color: #f6f7f9;
|
||||
}
|
||||
|
||||
.middle-subject-info-scroll {
|
||||
/*height: 100%;*/
|
||||
height: calc(100vh - 110px);
|
||||
max-height: calc(100vh - 110px);
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.middle-subject-info-head {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.middle-subject-topic-icon {
|
||||
width: 30px;
|
||||
padding: 2px;
|
||||
font-size: 10px;
|
||||
background-color: #1678ff;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
border-radius: 0 0 5px 5px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
.middle-subject-title {
|
||||
margin-bottom: 1rem;
|
||||
font-weight: bolder;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.middle-subject-other {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.middle-subject-topic {
|
||||
background-color: #FFFFFF;
|
||||
margin-bottom: 1rem;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 2px 2px 12px 4px rgba(0, 0, 0, 0.1);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.middle-subject-topic-title {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
.middle-subject-topic-submit {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.middle-subject-topic-desc {
|
||||
color: rgb(160, 160, 160);
|
||||
text-align: left;
|
||||
margin-left: 20px;
|
||||
font-size: 12px;
|
||||
margin-bottom: 10px;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.itx_field {
|
||||
background-color: #fff;
|
||||
background-image: none;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #dcdfe6;
|
||||
box-sizing: border-box;
|
||||
color: #606266;
|
||||
display: inline-block;
|
||||
font-size: inherit;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
outline: none;
|
||||
padding: 0 15px;
|
||||
transition: border-color .2s cubic-bezier(.645, .045, .355, 1);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.middle-subject-topic-submit .u-btn {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.middle-subject-info-search {
|
||||
position: absolute;
|
||||
bottom: 45%;
|
||||
right: 0;
|
||||
height: 40px;
|
||||
z-index: 999;
|
||||
background-color: #FFF;
|
||||
box-shadow: 0 0 20px rgb(230, 230, 230);
|
||||
border-radius: 20px 0 0 20px;
|
||||
}
|
||||
|
||||
.middle-subject-info-search-icon {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
box-shadow: 0 0 10px #1678ff;
|
||||
border-radius: 20px 0 0 20px;
|
||||
background-color: #FFF;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.middle-subject-info-search-info {
|
||||
padding: 0 10px;
|
||||
display: flex;
|
||||
height: inherit;
|
||||
z-index: 999;
|
||||
align-items: center;
|
||||
box-shadow: 0 0 10px #1678ff;
|
||||
border-radius: 20px 0 0 20px;
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.middle-subject-info-footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
max-height: 64px;
|
||||
background-color: #FFF;
|
||||
box-shadow: 0 0 20px rgb(230, 230, 230);
|
||||
z-index: 999;
|
||||
padding: 10px 20px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.middle-subject-info-footer-save {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.middle-subject-info-footer-save .van-button {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.middle-subject-info-footer-pagination {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 70%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="middle-subject">
|
||||
<van-nav-bar title="在线调查" left-arrow
|
||||
@click-left="history.back()"></van-nav-bar>
|
||||
|
||||
<div class="middle-subject-info">
|
||||
<div class="middle-subject-info-scroll">
|
||||
<div class="middle-subject-info-padding">
|
||||
<div class="middle-subject-info-head">
|
||||
<div class="middle-subject-title">{{ questionData.qtitle }}</div>
|
||||
<div class="middle-subject-other">
|
||||
<template v-if="questionData.qlx!==3">
|
||||
<!-- <span>创建人:{{ questionData.username }}</span>-->
|
||||
<!-- <span>总题数:{{ issueList.length }}</span>-->
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="middle-subject-info-body">
|
||||
<div class="middle-subject-topic" v-for="(issue,issueIndex) in issueList" :key="issue.qid">
|
||||
<div v-if="!issue.iisdx" class="middle-subject-topic-icon">
|
||||
<span>多选</span>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px">
|
||||
<span v-if="issue.iisbd" style="color: red;">*</span>
|
||||
<span class="middle-subject-topic-title">
|
||||
{{ issueIndex + 1 }}.
|
||||
{{ removeHTMLTag(issue.iname) }}
|
||||
<span v-if="issue.iminselect">(最少选择:{{issue.iminselect}})</span>
|
||||
<span v-if="issue.imaxselect">(最多选择:{{issue.imaxselect}})</span>
|
||||
<div v-if="issue.its" class="middle-subject-topic-desc"
|
||||
style="margin-left: 17px;font-size: 12px;font-weight: 500;">
|
||||
{{ issue.its }}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- 选择题 -->
|
||||
<template v-if="issue.itx===1">
|
||||
<!-- 单选题 -->
|
||||
<van-radio-group v-if="issue.iisdx" v-model="issue.rwid" :disabled="replyFinish">
|
||||
<div v-for="(wor,worIndex) in issue.wors" :key="wor.wid">
|
||||
<van-radio :ref="wor.wid" :name="wor.wid">
|
||||
{{ letterList[worIndex] }}. {{ wor.wtxt }}
|
||||
</van-radio>
|
||||
<div class="middle-subject-topic-desc">
|
||||
<van-row gutter="16">
|
||||
<van-col span="8" v-if="wor.wimg">
|
||||
<image style="height: 80px;width: 80px" :src="wor.wimg"
|
||||
mode="aspectFit">
|
||||
</image>
|
||||
</van-col>
|
||||
<van-col span="16" v-if="wor.wsm">
|
||||
{{ wor.wsm }}
|
||||
</van-col>
|
||||
</van-row>
|
||||
</div>
|
||||
</div>
|
||||
</van-radio-group>
|
||||
|
||||
<!-- 多选题 -->
|
||||
<van-checkbox-group v-else-if="!issue.iisdx" v-model="issue.rwid"
|
||||
:disabled="replyFinish"
|
||||
:max="issue.imaxselect ? issue.imaxselect:0">
|
||||
<div v-for="(wor,worIndex) in issue.wors" :key="worIndex">
|
||||
<van-checkbox :ref="wor.wid" :name="wor.wid" shape="square">
|
||||
{{ letterList[worIndex] }}. {{ wor.wtxt }}
|
||||
</van-checkbox>
|
||||
<div class="middle-subject-topic-desc">
|
||||
<van-row gutter="16">
|
||||
<van-col span="8" v-if="wor.wimg">
|
||||
<image style="height: 80px;width: 80px" :src="wor.wimg"
|
||||
mode="aspectFit">
|
||||
</image>
|
||||
</van-col>
|
||||
<van-col span="16" v-if="wor.wsm">
|
||||
{{ wor.wsm }}
|
||||
</van-col>
|
||||
</van-row>
|
||||
</div>
|
||||
</div>
|
||||
</van-checkbox-group>
|
||||
</template>
|
||||
|
||||
<!-- 填空题 -->
|
||||
<template v-if="issue.itx===2">
|
||||
<van-field v-model="issue.rval" type="text" border
|
||||
class="itx_field"
|
||||
cursor-spacing="100"
|
||||
:show-confirmbar="false"
|
||||
:disabled="replyFinish" :auto-height="true" maxlength="2000"/>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="middle-subject-info-footer">
|
||||
<div class="middle-subject-info-footer-save">
|
||||
<van-button size="medium" type="primary" @click="saveAnswer"
|
||||
:disabled="replyFinish">保存
|
||||
</van-button>
|
||||
<van-button size="medium" type="info" :disabled="replyFinish"
|
||||
@click="submitAnswer">
|
||||
提交
|
||||
</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
mixins: [mobileMixins],
|
||||
data() {
|
||||
return {
|
||||
id: null,
|
||||
questionData: {},
|
||||
issueList: [],
|
||||
replyInfo: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
letterList() {
|
||||
const alphabet = Array.from(new Array(26), (ele, index) => {
|
||||
return String.fromCharCode(65 + index);
|
||||
})
|
||||
return alphabet
|
||||
},
|
||||
replyFinish() {
|
||||
return this.replyInfo.some(v => !v.save)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getQuestionData() {
|
||||
const resp = await $.get('/mobile/question/h5/questionInfo/' + this.id)
|
||||
this.questionData = resp.data
|
||||
this.issueList = this.questionData && this.questionData.issues
|
||||
},
|
||||
saveAnswer() {
|
||||
const formData = this.formatFormData()
|
||||
formData.forEach(v => v.save = true)
|
||||
this.$modal.loading('保存中')
|
||||
$.post('/mobile/question/h5/saveAnswer', {repliesArray: JSON.stringify(formData)}).then(res => {
|
||||
this.$modal.closeLoading()
|
||||
if (res.code === 0) {
|
||||
this.$modal.msg('保存成功')
|
||||
this.getReply()
|
||||
} else {
|
||||
this.$modal.msg('保存失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
submitAnswer() {
|
||||
const formData = this.formatFormData()
|
||||
formData.forEach(v => v.save = false)
|
||||
this.$modal.confirm('您确定要提交吗?提交后不能修改!').then(() => {
|
||||
this.$modal.loading('提交中')
|
||||
$.post('/mobile/question/h5/saveAnswer', {repliesArray: JSON.stringify(formData)}).then(res => {
|
||||
this.$modal.closeLoading()
|
||||
if (res.code === 0) {
|
||||
this.$modal.msg('提交成功')
|
||||
this.getReply()
|
||||
} else {
|
||||
this.$modal.msg('提交失败')
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
validAnswer() {
|
||||
|
||||
},
|
||||
|
||||
//格式化提交数据
|
||||
formatFormData() {
|
||||
const formData = []
|
||||
this.issueList.forEach(v => {
|
||||
if (v.itx === 1 && v.iisdx) {
|
||||
//单选
|
||||
if (v.rwid) {
|
||||
formData.push({
|
||||
"rwid": v.rwid,
|
||||
"qid": this.questionData.qid,
|
||||
"issueId": v.iid
|
||||
})
|
||||
}
|
||||
} else if (v.itx === 1 && !v.iisdx) {
|
||||
//多选
|
||||
if (v.rwid) {
|
||||
v.rwid.forEach(r => {
|
||||
formData.push({
|
||||
"rwid": r,
|
||||
"qid": this.questionData.qid,
|
||||
"issueId": v.iid
|
||||
})
|
||||
})
|
||||
}
|
||||
} else if (v.itx === 2) {
|
||||
if (v.rval) {
|
||||
debugger
|
||||
formData.push({
|
||||
"rwid": v.wors[0].wid,
|
||||
"rval": v.rval,
|
||||
"qid": this.questionData.qid,
|
||||
"issueId": v.iid
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
return formData
|
||||
},
|
||||
//获取回答信息并赋值
|
||||
async getReply() {
|
||||
const resp = await $.get('/mobile/question/h5/answerInfo/' + this.id)
|
||||
this.replyInfo = resp.data
|
||||
this.issueList.forEach((issue, issueIndex) => {
|
||||
if (issue.itx === 1 && issue.iisdx) {
|
||||
//单选
|
||||
const rw = this.replyInfo.find(answer => answer.issueId === issue.iid)
|
||||
this.$set(this.issueList[issueIndex], 'rwid', rw ? rw.rwid : null)
|
||||
} else if (issue.itx === 1 && !issue.iisdx) {
|
||||
//多选
|
||||
const rws = this.replyInfo.filter(answer => answer.issueId === issue.iid).map(v => v.rwid)
|
||||
this.$set(this.issueList[issueIndex], 'rwid', rws ? rws : [])
|
||||
} else if (issue.itx === 2) {
|
||||
//填空题
|
||||
const rw = this.replyInfo.find(answer => answer.issueId === issue.iid)
|
||||
this.$set(this.issueList[issueIndex], 'rval', rw ? rw.rval : null)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.id = GetQueryString("id")
|
||||
await this.getQuestionData()
|
||||
await this.getReply()
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
Reference in New Issue
Block a user