| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 |
- <template>
- <view id="questionBank">
- <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
- <swiper-item v-for="(bank,bankIndex) in questionList" :key="bankIndex">
- <view class="pageContent">
- <view class="pad_8 titBox">
- <view class="firstLetter">
- <view class="leftLetters">
- <view class="btnType">
- <text v-if="bank.type==1">单选</text>
- <text v-if="bank.type==2">多选</text>
- <text v-if="bank.type==3">判断</text>
- <text v-if="bank.type==4">简答题</text>
- <text v-if="bank.type==5">案例题</text>
- </view>
- <text>1/{{current}}</text>
- </view>
- <view style="color: #666;font-size: 28rpx;">03:25:06</view>
- <view class="leftLetters"></view>
- </view>
- <view class="titles">
- <rich-text :nodes="bank.content"></rich-text>
- </view>
- <view class="">
- <template v-if="bank.type == 1">
- <view v-if="!ques[bankIndex]">
- <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect" :data-index="index" :data-bindex="bankIndex" :data-optionsId="item.optionsId">
- <view class="activeTI">{{ ast[index] }}</view>
- {{ item.content }}
- </view>
- </view>
- <view v-if="ques[bankIndex]">
- <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
- <text :class="{right:(item.optionsId == ques[bankIndex]) || (item.optionsId == ans[bankIndex]),wrong:(item.optionsId == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</text>
- {{ item.content }}
- </view>
- </view>
- <view v-if="ques[bankIndex]">
- <view class="pad_8 answer">
- <view>正确答案:{{ast[ans[bankIndex]-1]}}</view>
- <view>我的答案:{{ast[ques[bankIndex]-1]}}</view>
- </view>
- <view class="pad_8 answerInfos">
- <view class="answerTitle">答案解析</view>
- <view class="answerContent">
- <rich-text :nodes="bank.analysisContent"></rich-text>
- </view>
- </view>
- </view>
- </template>
-
- <template v-if="bank.type == 2">
- <view v-if="!ques[bankIndex]">
- <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect" :data-index="index" :data-bindex="bankIndex" :data-optionsId="item.optionsId">
- <view :class="{checked:item.checked}" class="activeTI">{{ ast[index] }}</view>
- {{ item.content }}
- </view>
- </view>
- <view v-if="!ques[bankIndex]" class="submit_checkbox" @click="checkboxSubmit" :data-bindex="bankIndex">
- 确认答案
- </view>
- <view v-if="ques[bankIndex]">
- <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
- <text :class="{right:(ques[bankIndex].indexOf(item.optionsId) != -1 ) || (ans[bankIndex].indexOf(item.optionsId) != -1),wrong:(ques[bankIndex].indexOf(item.optionsId) != -1 ) && (ans[bankIndex].indexOf(item.optionsId) == -1)}" class="activeTI">{{ ast[index] }}</text>
- {{ item.content }} {{ques[bankIndex].indexOf(item.optionsId) != -1 }} {{item.optionsId}} {{ans[bankIndex].indexOf(item.optionsId) != -1}}
- </view>
- </view>
- <view v-if="ques[bankIndex]">
- <view class="pad_8 answer">
- <view>正确答案:
- <text v-for="ansItem in ans[bankIndex]">{{ast[ansItem-1]}}</text>
- </view>
- <view>我的答案:
- <text v-for="quesItem in ques[bankIndex]">{{ast[quesItem-1]}}</text>
- </view>
- </view>
- <view class="pad_8 answerInfos">
- <view class="answerTitle">答案解析</view>
- <view class="answerContent">
- <rich-text :nodes="bank.analysisContent"></rich-text>
- </view>
- </view>
- </view>
- </template>
-
- <template v-if="bank.type == 3">
- <view v-if="!ques[bankIndex]">
- <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect" :data-index="index" :data-bindex="bankIndex" >
- <view class="activeTI">{{ ast[index] }}</view>
- {{ item }}
- </view>
- </view>
- <view v-if="ques[bankIndex]">
- <view v-for="(item, index) in judge" :key="index" class="lisSty">
- <text :class="{right:(index == ques[bankIndex]) || (index == ans[bankIndex]),wrong:(index == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</text>
- {{ item }}
- </view>
- </view>
- <view v-if="ques[bankIndex]">
- <view class="pad_8 answer">
- <view>正确答案:{{ast[ans[bankIndex]]}}</view>
- <view>我的答案:{{ast[ques[bankIndex]]}}</view>
- </view>
- <view class="pad_8 answerInfos">
- <view class="answerTitle">答案解析</view>
- <view class="answerContent">
- <rich-text :nodes="bank.analysisContent"></rich-text>
- </view>
- </view>
- </view>
- </template>
- <template v-if="bank.type == 4">
- <view class="ans">
- <view class="ans_input" v-if="!ques[bankIndex]">
- <view class="top flex">
- <image :data-index="bankIndex" class="icon" :data-bindex="bankIndex" @click="chooseImg" src="/static/08-10_032.jpg" mode=""></image>
- <view class="progress">0/4</view>
- <view class="submit" @click="submitAns" :data-bindex="bankIndex" >确认答案</view>
- </view>
- <view class="textarea">
- <textarea v-model="bank.text" placeholder="在此输入答案"></textarea>
- </view>
- <view class="imgs">
- <view class="img" v-for="(img,imgIndex) in bank.imageList" >
- <text @click="deleteImg" :data-imgIndex="imgIndex" :data-bindex="bankIndex">x</text>
- <image :src="img"></image>
- </view>
- </view>
- </view>
- <view class="ans_submit answerInfos" v-if="ques[bankIndex]">
- <view class="answerTitle">答案我的</view>
- {{ques[bankIndex].text}}
- <view class="imgs">
- <image class="img" v-for="ques in ques[bankIndex].imageList" :src="ques"></image>
- </view>
- </view>
- </view>
- <view v-if="ques[bankIndex]">
- <view class="pad_8 answerInfos">
- <view class="answerTitle">答案解析</view>
- <view class="answerContent">
- 这是官方答案解析文本,卡片高度根据内容自动调整,我实在编不出来内容了,我实在编不出来内容了,我实在编不出来内容了,我实在编不出来内容了,就这样吧。
- </view>
- </view>
- </view>
- </template>
-
- <!-- <view v-if="ques[bankIndex] ">
- <view v-for="(item, index) in bank.jsonStr" :key="index"
-
- class="lisSty">
- <view :class="{right:(item.value == ques[bankIndex]) && (ques[bankIndex] == ans[bankIndex]),wrong:(item.value == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</view>
- {{ item.label }}
- </view>
- </view>
- <view v-if="!ques[bankIndex]">
- <view v-for="(item, index) in bank.jsonStr" :key="index" @click="click" :data-value="item.value" class="lisSty">
- <text class="activeTI">{{ ast[index] }}</text>
- {{ item.label }}
- </view>
- </view> -->
-
- </view>
- </view>
-
-
- </view>
- </swiper-item>
- </swiper>
-
- <view class="footer_btn">
- <view @click="collect">收藏</view>
- <view @click="openFooterTab">答题卡</view>
- <view @click="submit">交卷</view>
- </view>
- <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
- <view class="popupView">
- <view class="popupTops">
- <view class="topIcon"></view>
- 点击编号即可跳转至对应题目
- </view>
- <view class="popupContent">
- <scroll-view scroll-y="true" style="height: 506rpx;">
- <view class="boxSty">
- <view v-for="(item, index) in questionList" :key="index" :data-index="index" @click="changeIndex" :class="{disabled:index>=5}" class="liListSty">{{ index + 1 }}</view>
- </view>
- </scroll-view>
- </view>
- </view>
- </u-popup>
-
- <view class="dialog" v-if="showDialog">
- <view class="text">左右滑动切换上下题</view>
- <view class="btn" @click="hideDialog">我知道了</view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- id:'',
- current:0,
- questionList:[],
- ast: ['A', 'B', 'C', 'D','E','F','G'],
- judge:['错误','正确'],
- ans:[],
- ques:[],
- show: false,
- showDialog:true,
- bankList: []
- };
- },
- onLoad(option){
- this.id = option.id;
- this.goodsQuestionList()
- },
- methods: {
- goodsQuestionList() {
- this.$api.goodsQuestionList({
- examId:this.id
- }).then(res => {
- console.log(res)
- res.data.data.forEach((item,index) => {
- item.jsonStr = JSON.parse(item.jsonStr)
-
- if(item.type == 2) { //多选
- item.jsonStr.forEach(str => {
- str.optionsId = ''+str.optionsId;
- })
- let arr = item.answerQuestion.split(',');
- arr.forEach((a,i) => {
- arr[i] = ''+a;
- })
- this.$set(this.ans,index,arr);
- return;
- } else if(item.type == 4) {
- item.text = '';
- item.imageList = [];
- }
-
- this.$set(this.ans,index,item.answerQuestion);
- })
-
- this.questionList = res.data.data;
-
- })
- },
- /**
- * @param {Object} e单选点击
- */
- radioSelect(e) {
- let optionsId = e.currentTarget.dataset.optionsid;
- let bindex = e.currentTarget.dataset.bindex;
- if(this.ques[bindex]) return;
- this.$set(this.ques,bindex,optionsId)
- },
-
-
- /**
- * @param {Object} 多选点击
- */
- checkboxSelect(e) {
- let optionsId = e.currentTarget.dataset.optionsid;
- let bindex = e.currentTarget.dataset.bindex;
- let index = e.currentTarget.dataset.index;
-
- this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
- },
-
- /**
- * @param {Object} 多选确认
- */
- checkboxSubmit(e) {
- let bindex = e.currentTarget.dataset.bindex;
-
- if(this.ques[bindex]) return;
- let arr = [];
- this.questionList[bindex].jsonStr.forEach(item => {
- console.log(item)
- if(item.checked) {
- arr.push(item.optionsId)
- }
- })
-
- this.$set(this.ques,bindex,arr)
-
- console.log(this.ques);
- console.log(this.ans)
- },
-
- judgeSelect(e) {
- let index = e.currentTarget.dataset.index;
- let bindex = e.currentTarget.dataset.bindex;
- if(this.ques[bindex]) return;
- this.$set(this.ques,bindex,index+'')
- },
-
- openFooterTab() {
- this.show = true;
- },
- hideDialog() {
- this.showDialog = false
- },
- changeIndex(e) {
- let index = e.currentTarget.dataset.index
- if(index >= 5) {
- uni.showToast({
- title: '返回详情购买后即可继续',
- duration: 2000,
- icon:'none'
- });
- return;
- }
-
- this.current = e.currentTarget.dataset.index
- },
-
- swiperChange(e) {
- this.current = e.detail.current;
- },
-
- submit() {
- uni.showToast({
- title: '不能试做返回详情购买后即可交卷~',
- duration: 2000,
- icon:'none'
- });
- return;
- },
-
- collect() {
- uni.showToast({
- title: '返回详情购买后即可收藏~',
- duration: 2000,
- icon:'none'
- });
- return;
- },
-
- click(e) {
- if(this.ques[this.current]) return;
- let value = e.currentTarget.dataset.value;
- this.ques[this.current] = value;
- this.ques = Object.assign({},this.ques)
-
- },
-
- deleteImg(e) {
-
- var imgIndex = e.currentTarget.dataset.imgindex;
- var bankIndex = e.currentTarget.dataset.bankindex;
-
- this.questionList[bankIndex].imageList.splice(imgIndex,1)
- },
-
- chooseImg(e) {
- console.log(e.currentTarget.dataset)
- let bankindex = e.currentTarget.dataset.bindex;
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ['original', ], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album','camera'], //从相册选择
- success: (res) => {
- // console.log(JSON.stringify(res.tempFilePaths));
-
- this.questionList[bankindex].imageList.push(res.tempFilePaths)
- }
- })
- },
-
- submitAns(e) {
- let type = e.currentTarget.dataset.type;
- let bankindex = e.currentTarget.dataset.bindex;
-
- console.log(this.questionList[bankindex])
- if(!this.questionList[bankindex].text && !this.questionList[bankindex].imageList.length) {
- uni.showToast({
- title: '请输入内容或上传图片',
- duration: 2000,
- icon:'none'
- });
- return
- }
-
- this.$set(this.ques,bankindex,{
- imageList:this.questionList[bankindex].imageList,
- text:this.questionList[bankindex].text,
- })
-
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .swiper {
- width:100%;
- height:100vh;
- }
- .lisSty {
- margin-bottom: 16rpx;
-
- }
- .activeTI {
- vertical-align: middle;
- display: inline-block;
- border: 1rpx solid #eee;
- border-radius: 50rpx;
- height: 48rpx;
- line-height: 46rpx;
- text-align: center;
- width: 48rpx;
- margin-right: 15rpx;
- color: #666;
- font-size: 30rpx;
-
-
- &.right {
- color:#fff;
- background:green;
- }
-
- &.wrong {
- color:#fff;
- background:red;
- }
-
- &.checked {
- color:#fff;
- background:blue;
- }
- }
- .submit_checkbox {
- margin:20rpx auto;
- width: 526rpx;
- height: 80rpx;
- background: rgba(0, 122, 255, 1);
- color:#fff;
- text-align: center;
- line-height: 80rpx;
- font-size: 30rpx;
- border-radius: 40rpx;
- }
- .titles {
- overflow: hidden;
- margin-bottom: 24rpx;
- }
- .titBox {
- padding: 41rpx 25rpx 24rpx 25rpx;
- }
- .ans {
- margin:8rpx 8rpx 8rpx;
-
- .ans_input {
- border-radius: 16rpx;
- background:#fff;
- .top {
- border-bottom:1rpx solid #EEEEEE;
- padding: 16rpx;
- display: flex;
- align-items: center;
-
- .icon {
- margin-right:20rpx;
- width: 40rpx;
- height: 38rpx;
- }
-
- .progress {
- flex:1;
- }
-
- .submit {
- width: 168rpx;
- height: 48rpx;
- line-height: 48rpx;
- text-align: center;
- color:#fff;
- font-size: 30rpx;
- background: #007AFF;
- border-radius: 24rpx;
- }
- }
-
- .textarea {
- textarea {
- width:100%;
- height:287rpx;
- padding:10rpx;
- }
- }
-
- .imgs {
- overflow: hidden;
- display: flex;
- width:100%;
- .img {
- width: 104rpx;
- height: 104rpx;
- border-radius: 8rpx;
- position:relative;
- margin:20rpx;
-
-
- text {
- position:absolute;
- right:-15rpx;
- top:-15rpx;
- width:30rpx;
- height:30rpx;
- text-align: center;
- line-height: 30rpx;
- color:#fff;
- background:red;
- border-radius:50%;
- }
-
- image {
- width:100%;
- height:100%;
- }
- }
- }
- }
-
- .ans_submit {
- padding:16rpx;
- border-radius: 16rpx;
- background:#fff;
-
- .imgs {
- overflow: hidden;
- display: flex;
- width:100%;
- .img {
- width: 104rpx;
- height: 104rpx;
- border-radius: 8rpx;
- position:relative;
- margin:20rpx;
-
- image {
- width:100%;
- height:100%;
- }
- }
- }
- }
- }
- .firstLetter {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 30rpx;
- .leftLetters {
- display: flex;
- align-items: center;
- width: 220rpx;
- .btnType {
- padding: 5rpx 10rpx;
- border: 1rpx solid #007aff;
- border-radius: 10rpx;
- background-color: rgba(0, 122, 255, 0.1);
- font-size: 28rpx;
- color: #007aff;
- margin-right: 15rpx;
- }
- }
- }
- .popupView {
- height: 100%;
- padding-bottom: 100rpx;
- .popupTops {
- height: 77rpx;
- border-bottom: 1rpx solid #eee;
- text-align: center;
- line-height: 77rpx;
- font-size: 24rpx;
- color: #999;
- position: relative;
- .topIcon {
- position: absolute;
- top: 10rpx;
- left: 50%;
- transform: translateX(-50%);
- width: 80rpx;
- height: 8rpx;
- background-color: #999;
- border-radius: 4rpx;
- }
- }
- .popupContent {
- }
- }
- .pageContent {
- background-color: #eaeef1;
- min-height: 100vh;
- padding-top: 8rpx;
- padding-bottom: 100rpx;
- }
- .pad_8 {
- background-color: #fff;
- margin: 0rpx 8rpx 8rpx;
- border-radius: 16rpx;
- }
- .answer {
- height: 80rpx;
- line-height: 80rpx;
- padding: 0rpx 24rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: #666;
- font-size: 30rpx;
- }
- .footer_btn {
- background-color: #fff;
- z-index: 10078;
- position: fixed;
- bottom: 0rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100%;
- height: 98rpx;
- padding: 0rpx 38rpx;
- border-top: 1rpx solid #eee;
- }
- .boxSty {
- padding: 44rpx 41rpx 0rpx;
- }
- .liListSty {
- width: 88rpx;
- height: 88rpx;
- border-radius: 32rpx;
- background-color: #ff3b30;
- text-align: center;
- line-height: 88rpx;
- color: #fff;
- font-size: 32rpx;
- float: left;
- margin: 20rpx 23rpx;
-
- &.disabled {
- border:1rpx solid #EEEEEE;
- color:#EEEEEE;
- background: none;
- }
- }
- .answerInfos {
- padding: 25rpx 25rpx 25rpx 23rpx;
- }
- .answerTitle {
- margin-bottom: 28rpx;
- color: #666;
- font-size: 30rpx;
- }
- .answerContent {
- font-size: 30rpx;
- color: #666;
- }
- .dialog {
- position: fixed;
- left:0;
- top:0;
- width:100%;
- height:100%;
- background-color: rgba(0,0,0,0.8);
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- z-index: 20000;
-
- .text {
- font-size: 32rpx;
- color: #FFFFFF;
- text-align: center;
- }
-
- .btn {
- width: 242rpx;
- height: 82rpx;
- border: 2rpx solid #FFFFFF;
- border-radius: 16rpx;
- text-align: center;
- line-height: 82rpx;
- margin:41rpx auto;
- color:#fff;
- font-size: 32rpx;
- }
- }
- </style>
|