123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- <template>
- <div>
- <view class="bank-control fl_b">
- <view class="fl_b left">
- <view class="btn-item" style="" @click="openFooterTab">
- <image src="/static/icon_sheet.png"></image>
- <text>答题卡</text>
- </view>
- <view class="btn-item" @click="$emit('submit')">
- <image src="/static/icon_paper.png" mode=""></image>
- <text @click="$emit('submit')">交卷</text>
- </view>
- </view>
- <view class="fl">
- <view class="tab up" @click="prev">上一题</view>
- <view class="tab down" @click="next">下一题</view>
- </view>
- <view class="collect" @click="collect" v-if="isShowCollect">
- <image v-if="true" src="/static/icon_star.png"></image>
- <image v-else src="/static/icon_star_sel.png"></image>
- </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"
- @click="changeIndex(index)"
- :class="{
- isRight: bankType == 1 && isRight(item, index),
- isWrong: bankType == 1 && isWrong(item, index),
- isPart: bankType == 1 && isPart(item, index),
- isOver: bankType == 1 && isOver(item, index),
- check_ans: bankType == 2 && isCheck(item, index),
- }"
- class="liListSty"
- >
- {{ index + 1 }}
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </u-popup>
- </div>
- </template>
- <script>
- export default {
- name: "SaasMiniprogramBankBom",
- props: {
- isShowCollect: {
- type: Boolean,
- default: true,
- },
- isCollect: {
- type: Boolean,
- default: false,
- },
- questionList: {
- type: Array,
- default: () => {
- return [];
- },
- },
- bankType: {
- type: Number,
- },
- current: {
- type: Number,
- },
- },
- data() {
- return {
- show: false,
- };
- },
- mounted() {},
- methods: {
- changeIndex(index) {
- this.$emit("update:current", index);
- },
- prev() {
- if (this.current == 0) {
- uni.showToast({
- icon: "none",
- title: "已经是第一题了!",
- });
- return;
- }
- this.changeIndex(this.current - 1);
- },
- next() {
- if (this.current >= this.questionList.length - 1) {
- uni.showToast({
- icon: "none",
- title: "已经是最后一题了!",
- });
- return;
- }
- this.changeIndex(this.current + 1);
- },
- collect() {
- if (!this.isCollect) {
- this.$api
- .collectQuestion({
- examId: this.id,
- questionId: this.questionList[index].questionId,
- goodsId: this.goodsId || "",
- orderGoodsId: this.orderGoodsId,
- doMode: 1, //做题模式 1章卷 2随机练习
- })
- .then((res) => {
- if (res.data.code == 200) {
- this.$set(this.collectList, index, true);
- uni.showToast({
- title: "收藏成功",
- duration: 2000,
- icon: "none",
- });
- this.getCollectInfo(index);
- }
- });
- } else {
- this.$api
- .deleteCollectQuestion(this.collectList[index].collectQuestionId)
- .then((res) => {
- if (res.data.code == 200) {
- this.$set(this.collectList, index, false);
- uni.showToast({
- title: "取消收藏成功",
- duration: 2000,
- icon: "none",
- });
- }
- });
- }
- return;
- },
- openFooterTab() {
- this.show = true;
- },
- isCheck(item, index) {
- // 案例题处理
- let { ques, type, ans } = item;
- if (type == 4) {
- return ans.length == ques.length;
- }
- if (ques) {
- return true;
- }
- },
- isRight(item, index) {
- //单选
- if (this.questionList[index].ques) {
- if (item.type == 1) {
- return this.questionList[index].ques == this.questionList[index].ans;
- //多选
- } else if (item.type == 2) {
- //每一项都相等
- return this.questionList[index].ans.every((item, i) => {
- return item == this.questionList[index].ques[i];
- });
- //判断
- } else if (item.type == 3) {
- return this.questionList[index].ques == this.questionList[index].ans;
- // } else if (item.type == 5) {
- // if(this.questionList[index].ques.text){
- // return true
- // }else{
- // return false
- // }
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- isWrong(item, index) {
- if (this.questionList[index].ques) {
- //单选
- if (item.type == 1) {
- return this.questionList[index].ques != this.questionList[index].ans;
- //多选
- } else if (item.type == 2) {
- //每一项都相等
- return this.questionList[index].ques.some((item, i) => {
- return this.questionList[index].ans.indexOf(item) == -1;
- });
- //判断
- } else if (item.type == 3) {
- return this.questionList[index].ques != this.questionList[index].ans;
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- isPart(item, index) {
- if (this.questionList[index].ques) {
- if (item.type == 2) {
- let isWrong = this.questionList[index].ques.some((item, i) => {
- return this.questionList[index].ans.indexOf(item) == -1;
- });
- let isRight = this.questionList[index].ans.every((item, i) => {
- return item == this.questionList[index].ques[i];
- });
- if (!isRight && !isWrong) {
- return true;
- }
- }
- } else {
- return false;
- }
- },
- isOver(item, index) {
- if (this.questionList[index].ques) {
- if (item.type == 4) {
- //案例题
- let isOver = item.jsonStr.every((jsonItem, indexs) => {
- if (
- jsonItem.type == 1 ||
- jsonItem.type == 2 ||
- jsonItem.type == 3
- ) {
- if (item.ques[indexs]) {
- return true;
- } else {
- return false;
- }
- } else if (jsonItem.type == 5) {
- if (
- item.ques[indexs] &&
- (item.ques[indexs].text || item.ques[indexs].imageList.length)
- ) {
- console.log("chil");
- return true;
- } else {
- return false;
- }
- }
- });
- if (isOver) {
- return true;
- } else {
- return false;
- }
- } else if (item.type == 5) {
- //简答题
- //每一项都相等
- if (item.ques && (item.ques.imageList.length || item.ques.text)) {
- return true;
- }
- //判断
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .bank-control {
- background-color: #fff;
- z-index: 10078;
- position: fixed;
- bottom: 0rpx;
- width: 100%;
- height: 120rpx;
- padding: 16rpx 28rpx 16rpx 48rpx;
- .left {
- width: 180rpx;
- }
- .btn-item {
- text {
- color: #333333;
- font-size: 24rpx;
- margin-top: 10rpx;
- display: block;
- }
- }
- image {
- width: 40rpx;
- height: 40rpx;
- display: block;
- margin: 0 auto;
- }
- .tab {
- height: 88rpx;
- line-height: 88rpx;
- text-align: center;
- border-radius: 16rpx;
- font-size: 30rpx;
- padding: 0 56rpx;
- }
- .up {
- background: #e5f1ff;
- color: #498afe;
- }
- .down {
- background: #498afe;
- color: #ffffff;
- margin-left: 28rpx;
- }
- .collect {
- position: fixed;
- top: 50rpx;
- right: 42rpx;
- }
- }
- .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;
- }
- }
- .boxSty {
- padding: 44rpx 41rpx 0rpx;
- }
- .liListSty {
- border: 1rpx solid #eeeeee;
- width: 88rpx;
- height: 88rpx;
- border-radius: 32rpx;
- text-align: center;
- line-height: 88rpx;
- color: #333;
- font-size: 32rpx;
- float: left;
- margin: 20rpx 23rpx;
- &.isRight {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: #36c75a;
- }
- &.isWrong {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: #ff3b30;
- }
- &.isPart {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: #ffc53d;
- }
- &.isOver {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: blue;
- }
- &.check_ans {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: #007aff;
- }
- }
- }
- </style>
|