123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463 |
- <template>
- <view class="wrap">
- <u-navbar title="答题详情" :placeholder="true" bgColor="rgba(255,255,255,0.3)" leftText="返回" :autoBack="true" titleStyle="font-weight:bold;color:#7a5831"></u-navbar>
- <view class="main" v-if="hasLoad">
- <view class="process">
- <view class="b-state">
- <view class="b-count">
- <view class="s-tit1">答题进度</view>
- <view class="s-num">{{ state.session_seq }}</view>
- <view class="s-tit2">/{{ state.total_count }}</view>
- </view>
- <view class="b-time">
- <view class="s-tit">花费时间</view>
- <view class="s-time">{{ costTime(state.cost_time) }}</view>
- </view>
- </view>
- <view class="b-bar">
- <view class="s-percent" :style="barPercent"></view>
- </view>
- </view>
- <view class="answer">
- <view class="b-type">{{ state.type_text }}</view>
- <view class="b-title">
- <view class="s-num">{{ state.session_seq }}.</view>
- <text class="s-title">
- {{ state.title }}
- <text class="s-score">({{ state.score }}分)</text>
- </text>
- </view>
- <view class="b-options">
- <view class="b-item" v-for="(item, index) in state.optionList" :key="index" :class="[optionState(index)]">
- <view class="s-num">{{ optionNum(index) }}.</view>
- <view class="s-cont">{{ item.label }}</view>
- <view class="s-state iconfont" :class="[optionIcon(index)]"></view>
- </view>
- </view>
- <view class="b-result" :class="resultIcon">
- <view class="b-right">
- <view class="s-tit">正确答案:</view>
- <view class="s-cont">{{ trueAnswer }}</view>
- </view>
- <view class="b-mine">
- <view class="s-tit">已选答案:</view>
- <view class="s-cont">{{ userAnswer }}</view>
- </view>
- </view>
- <view class="b-explain" v-if="state.explain">
- <text>解析:{{ state.explain }}</text>
- </view>
- <view class="b-action">
- <view class="b-last" :class="{ disabled: disabled.hasLast }" @click="onLast">上一题</view>
- <view class="b-next" :class="{ disabled: disabled.hasNext }" @click="onNext">下一题</view>
- </view>
- <view class="b-home" @click="onHome">回到首页</view>
- </view>
- </view>
- <!-- 加载中 -->
- <load-more :loadingType="loadingType" :loadingText="loadingText" color="#ffffff" :top="500"></load-more>
- </view>
- </template>
- <script>
- import { getResult } from '@/service/api/examine.js';
- import mixinsCommon from '@/mixins/common.js';
- import mixinsAuth from '../../mixins/auth.js';
- export default {
- mixins: [mixinsCommon, mixinsAuth],
- data() {
- return {
- hasLoad: false,
- state: {},
- disabled: {
- hasLast: false,
- hasNext: false
- },
- loadingType: 1,
- loadingText: ''
- };
- },
- onLoad(options) {
- this.loadResult(options.record_id);
- },
- computed: {
- barPercent() {
- return 'width: ' + (this.state.session_seq * 100) / this.state.total_count + '%';
- },
- optionNum() {
- return (index) => {
- return String.fromCharCode(64 + (index + 1));
- };
- },
- optionState() {
- return (index) => {
- console.log('optionState', index);
- let optionRight = false;
- let optionWrong = false;
- if (this.state.state == 2) {
- if (this.state.type === 'radio' || this.state.type === 'yesorno') {
- if (this.state.trueAnswer.includes(index)) {
- optionRight = true;
- } else if (this.state.userAnswer.includes(index)) {
- optionWrong = true;
- }
- } else {
- if (this.state.trueAnswer.includes(index)) {
- optionRight = true;
- } else if (
- (this.state.userAnswer.includes(index) && !this.state.trueAnswer.includes(index)) ||
- (this.state.trueAnswer.includes(index) && !this.state.userAnswer.includes(index))
- ) {
- optionWrong = true;
- }
- }
- }
- let ret = '';
- ret += optionRight ? 'f-right' : '';
- ret += optionWrong ? 'f-wrong' : '';
- return ret;
- // return {
- // 'f-right': optionRight,
- // 'f-wrong': optionWrong
- // }
- };
- },
- optionIcon() {
- return (index) => {
- console.log('optionIcon', index);
- return this.state.userAnswer.includes(index) ? 'icon-roundcheck' : '';
- // return {
- // 'icon-roundcheck': this.state.userAnswer.includes(index),
- // // 'icon-roundcheckfill': this.state.trueAnswer.includes(index),
- // }
- };
- },
- resultIcon() {
- let ret = '';
- ret += this.state.result == 2 ? ' f-right' : '';
- ret += this.state.result == 3 ? ' f-wrong' : '';
- ret += this.state.result == 4 ? ' f-timeout' : '';
- ret += this.state.result == 5 ? ' f-timeout-end' : '';
- return ret;
- // return {
- // 'f-right': this.state.result == 2,
- // 'f-wrong': this.state.result == 3,
- // 'f-timeout': this.state.result == 4,
- // 'f-timeout-end': this.state.result == 5,
- // }
- },
- trueAnswer() {
- let options = this.state.trueAnswer.map((item) => {
- return String.fromCharCode(64 + (parseInt(item) + 1));
- });
- return options.join('、');
- },
- userAnswer() {
- let options = this.state.userAnswer.map((item) => {
- return String.fromCharCode(64 + (parseInt(item) + 1));
- });
- return options.join('、');
- }
- },
- methods: {
- loadResult(recordId) {
- if (!recordId) {
- this.$logic.showToast('没有更多记录');
- return;
- }
- getResult(recordId).then(([err, res]) => {
- console.log('getResult', err, res);
- if (!err) {
- this.hasLoad = true;
- this.loadingType = -1;
- this.state = res;
- if (!res.last_id) {
- this.disabled.hasLast = true;
- } else {
- this.disabled.hasLast = false;
- }
- if (!res.next_id) {
- this.disabled.hasNext = true;
- } else {
- this.disabled.hasNext = false;
- }
- } else {
- if (!this.hasLoad) {
- this.loadingType = 3;
- this.loadingText = err.data.msg || '加载失败';
- }
- }
- });
- },
- onLast() {
- this.loadResult(this.state.last_id);
- },
- onNext() {
- this.loadResult(this.state.next_id);
- },
- onHome() {
- uni.reLaunch({
- url: '/answer_pages/home/index'
- });
- }
- }
- };
- </script>
- <style lang="scss">
- // page {
- // padding-bottom: env(safe-area-inset-bottom);
- // background: #da5650;
- // }
- .wrap {
- background: #da5650;
- }
- .main {
- padding: 40upx;
- }
- .process {
- display: flex;
- flex-direction: column;
- .b-state {
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: #fff;
- .b-count {
- display: flex;
- align-items: center;
- .s-tit1,
- .s-tit2 {
- font-size: 24upx;
- }
- .s-num {
- margin: 0 10upx;
- font-size: 32upx;
- }
- }
- .b-time {
- display: flex;
- align-items: center;
- .s-tit {
- font-size: 24upx;
- }
- .s-time {
- margin-left: 10upx;
- font-size: 28upx;
- }
- }
- }
- .b-bar {
- margin-top: 10upx;
- background: rgba(255, 255, 255, 0.5);
- width: 100%;
- height: 24upx;
- position: relative;
- .s-percent {
- position: absolute;
- left: 0;
- bottom: 0;
- width: 30%;
- height: 24upx;
- display: inline-block;
- background: #fff;
- }
- }
- }
- .answer {
- margin-top: 50upx;
- padding: 40upx;
- background: #fff;
- border-radius: 20upx;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- .b-type {
- width: fit-content;
- background: #da5650;
- padding: 0 20upx;
- font-size: 28upx;
- color: #fff;
- height: 50upx;
- line-height: 50upx;
- }
- .b-title {
- margin-top: 20upx;
- font-size: 30upx;
- display: flex;
- .s-num {
- font-weight: bold;
- }
- .s-title {
- margin-left: 10upx;
- flex: 1;
- color: #333;
- }
- .s-score {
- margin-left: 20upx;
- color: #666;
- }
- }
- .b-options {
- margin-top: 40upx;
- .b-item {
- margin-bottom: 20upx;
- padding: 20upx;
- font-size: 28upx;
- display: flex;
- // align-items: center;
- background: #f7f7f7;
- &:last-child {
- margin-bottom: 0;
- }
- &.f-select {
- background: #ecf3fe;
- color: #338ada;
- }
- &.f-right {
- background: #ecf6f0;
- color: #1eab69;
- }
- &.f-wrong {
- background: #ffebeb;
- color: #d13b42;
- }
- .s-num {
- font-weight: bold;
- }
- .s-cont {
- margin-left: 10upx;
- flex: 1;
- }
- .s-state {
- margin-left: 10upx;
- font-size: 36upx;
- }
- }
- }
- .b-result {
- padding: 80upx 0;
- display: flex;
- align-items: center;
- justify-content: space-between;
- background-repeat: no-repeat;
- background-size: 180upx auto;
- background-position: center center;
- &.f-right {
- background-image: url(https://huli-app.wenlvti.net/app_static/wuyuan/static/wenwu/answer/imgs/result_right.png);
- }
- &.f-wrong {
- background-image: url(https://huli-app.wenlvti.net/app_static/wuyuan/static/wenwu/answer/imgs/result_wrong.png);
- }
- &.f-timeout {
- background-image: url(https://huli-app.wenlvti.net/app_static/wuyuan/static/wenwu/answer/imgs/result_timeout.png);
- }
- &.f-timeout-end {
- background-image: url(https://huli-app.wenlvti.net/app_static/wuyuan/static/wenwu/answer/imgs/result_timeout_end.png);
- }
- .b-right,
- .b-mine {
- display: flex;
- align-items: center;
- .s-tit {
- font-size: 26upx;
- color: #333;
- }
- .s-cont {
- margin-left: 10upx;
- font-weight: bold;
- color: #da5650;
- font-size: 36upx;
- }
- }
- }
- .b-explain {
- font-size: 28upx;
- color: #808080;
- }
- .b-action {
- margin-top: 50upx;
- display: flex;
- .b-last {
- flex: 1;
- height: 78upx;
- line-height: 78upx;
- text-align: center;
- color: #da5650;
- font-size: 32upx;
- border: 1upx solid #da5650;
- border-radius: 50upx;
- letter-spacing: 5upx;
- &.disabled {
- color: #da5650a3;
- border: 1upx solid #da5650a3;
- }
- }
- .b-next {
- margin-left: 50upx;
- flex: 1;
- height: 80upx;
- line-height: 80upx;
- text-align: center;
- color: #fff;
- font-size: 32upx;
- background: #da5650;
- border-radius: 50upx;
- letter-spacing: 5upx;
- &.disabled {
- background: #da5650a3;
- }
- }
- }
- .b-home {
- margin-top: 40upx;
- text-align: center;
- color: #808080;
- font-size: 28upx;
- }
- }
- </style>
|