123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <view class="ques-content">
- <view class="ques-content-tit" v-show="openCommentStatus!=1">问答题</view>
- <view v-for="(item,index) in quesList" :key="index">
- <view class="ques-title">
- <text>{{index + 1}}.</text>
- <view class="ques-type" v-show="item.type == 1 || item.type == 2">
- {{item.type == 1 ? '单选' : item.type == 2 ? '多选' : ''}}
- </view>
- <text>{{item.title}}</text>
- </view>
- <view :class="isAnswer(item,option.name) ?'ques-option ques-option-active':'ques-option'"
- v-for="(option,idx) in item.questionOption" :key="idx" @click="handleAnswer(item,option)">
- <view>
- {{numberToLetter(idx)}}.
- </view>
- <view>{{option.name}}</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: ['quesList','openCommentStatus'],
- data() {
- return {
-
- }
- },
- computed: {
- isAnswer() {
- return (item, name) => {
- if (item.type == 1) {
- return item.answer == name
- } else if (item.type == 2) {
- const array = item.answer.split(',')
- return array.some(i => i == name)
- } else {
- return false
- }
- }
- }
- },
- methods: {
- numberToLetter(num) {
- // 将数字转换为字母的 ASCII 码
- let letterCode = num + 65;
- // 将 ASCII 码转换为大写字母
- let letter = String.fromCharCode(letterCode);
- return letter;
- },
- handleAnswer(item, option) {
- const param = {
- item,
- option
- }
- this.$emit("handleAnswer", param)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @mixin u-flex($flexD, $alignI, $justifyC) {
- display: flex;
- flex-direction: $flexD;
- align-items: $alignI;
- justify-content: $justifyC;
- }
- .ques-content {
- background-color: #fff;
- padding: 24rpx 32rpx 116rpx 32rpx;
- box-sizing: border-box;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 28rpx;
- color: #222222;
- }
- .ques-content-tit {
- font-family: PingFang SC, PingFang SC;
- font-weight: 600;
- font-size: 36rpx;
- color: #222222;
- }
- .ques-title {
- margin: 48rpx 0 34rpx 0;
- font-weight: 500;
- font-size: 32rpx;
- white-space: normal;
- }
- .ques-type {
- flex-shrink: 0;
- min-width: 72rpx;
- min-height: 40rpx;
- padding: 0 12rpx;
- margin: 0 12rpx;
- box-sizing: border-box;
- background: #FF5C03;
- border-radius: 8rpx 8rpx 8rpx 8rpx;
- line-height: 40rpx;
- text-align: center;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 24rpx;
- color: #FFFFFF;
- display: inline-block;
- }
- .ques-option {
- min-height: 88rpx;
- padding: 24rpx 32rpx;
- box-sizing: border-box;
- margin-bottom: 24rpx;
- background: #F5F7FA;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- display: flex;
- align-items: center;
- &-active {
- color: #FF5C03 !important;
- background: #FCF0E7 !important;
- }
- }
- </style>
|