|
@@ -1,216 +1,297 @@
|
|
|
<template>
|
|
|
- <div class="datiing">
|
|
|
- <div class="jishi">
|
|
|
- <div class="bar">
|
|
|
- <div
|
|
|
- :style="{ width: (1 - current / daojishi) * 100 + '%' }"
|
|
|
- class="activeLine"
|
|
|
- ></div>
|
|
|
- <div
|
|
|
- :style="{ left: (1 - current / daojishi) * 100 + '%' }"
|
|
|
- class="dot"
|
|
|
- ></div>
|
|
|
+ <div>
|
|
|
+ <div class="datiing" v-if="!isMobile">
|
|
|
+ <div class="jishi">
|
|
|
+ <div class="bar">
|
|
|
+ <div
|
|
|
+ :style="{ width: (1 - current / daojishi) * 100 + '%' }"
|
|
|
+ class="activeLine"
|
|
|
+ ></div>
|
|
|
+ <div
|
|
|
+ :style="{ left: (1 - current / daojishi) * 100 + '%' }"
|
|
|
+ class="dot"
|
|
|
+ ></div>
|
|
|
+ </div>
|
|
|
+ <span class="time">00:{{ fixNum }}</span>
|
|
|
</div>
|
|
|
- <span class="time">00:{{ fixNum }}</span>
|
|
|
- </div>
|
|
|
- <div class="dcon" v-if="tiku.length > 0 && status == '答题中'">
|
|
|
- <p>{{ currentIdx + 1 + "、" + currentTimu.title }}</p>
|
|
|
- <div class="qlist">
|
|
|
- <div class="qline"></div>
|
|
|
- <ul>
|
|
|
- <li
|
|
|
- :class="{ active: active == item.id }"
|
|
|
- @click="active = item.id"
|
|
|
- v-for="(item, i) in currentTimu.answer"
|
|
|
- :key="i"
|
|
|
- >
|
|
|
- <span>{{ item.id }}、{{ item.txt }}</span>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- <span>第 {{ currentIdx + 1 }} 题 / 共 {{ tiku.length }} 题</span>
|
|
|
+ <div class="dcon" v-if="tiku.length > 0 && status == '答题中'">
|
|
|
+ <p>{{ currentIdx + 1 + "、" + currentTimu.title }}</p>
|
|
|
+ <div class="qlist">
|
|
|
+ <div class="qline"></div>
|
|
|
+ <ul>
|
|
|
+ <li
|
|
|
+ :class="{ active: active == item.id }"
|
|
|
+ @click="active = item.id"
|
|
|
+ v-for="(item, i) in currentTimu.answer"
|
|
|
+ :key="i"
|
|
|
+ >
|
|
|
+ <span>{{ item.id }}、{{ item.txt }}</span>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ <span>第 {{ currentIdx + 1 }} 题 / 共 {{ tiku.length }} 题</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
- <div class="tipscon" v-else>
|
|
|
- <img
|
|
|
- :src="
|
|
|
- require(`@/assets/images/question/${
|
|
|
- status == '答题完成' ? 'success' : 'error'
|
|
|
- }.png`)
|
|
|
- "
|
|
|
- alt=""
|
|
|
- />
|
|
|
- <div v-if="tips[status]">
|
|
|
- <p>{{ tips[status].title }}</p>
|
|
|
- <span>{{ tips[status].desc }}</span>
|
|
|
+ <div class="tipscon" v-else>
|
|
|
+ <img
|
|
|
+ :src="
|
|
|
+ require(`@/assets/images/question/${
|
|
|
+ status == '答题完成' ? 'success' : 'error'
|
|
|
+ }.png`)
|
|
|
+ "
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ <div v-if="tips[status]">
|
|
|
+ <p>{{ tips[status].title }}</p>
|
|
|
+ <span>{{ tips[status].desc }}</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
- <template v-if="status == '答题中'">
|
|
|
- <div class="qbtn" v-if="currentIdx < 9" @click="next">
|
|
|
- <span>下一题</span>
|
|
|
+ <template v-if="status == '答题中'">
|
|
|
+ <div class="qbtn" v-if="currentIdx < 9" @click="next">
|
|
|
+ <span>下一题</span>
|
|
|
+ </div>
|
|
|
+ <div class="qbtn primary" @click="next" v-else>
|
|
|
+ <span>提交</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div
|
|
|
+ class="qbtn"
|
|
|
+ @click="requestion"
|
|
|
+ v-else-if="status == '答题错误' || status == '答题超时'"
|
|
|
+ >
|
|
|
+ <span>重新答题</span>
|
|
|
</div>
|
|
|
- <div class="qbtn primary" @click="next" v-else>
|
|
|
- <span>提交</span>
|
|
|
+
|
|
|
+ <div class="datifinish" v-else>
|
|
|
+ <div class="qbtn" @click="requestion">
|
|
|
+ <span>分享好友</span>
|
|
|
+ </div>
|
|
|
+ <div class="qbtn primary" @click="lingjiang">
|
|
|
+ <span>领取奖励</span>
|
|
|
+ </div>
|
|
|
+ <div class="qbtn" @click="requestion">
|
|
|
+ <span>继续答题</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </template>
|
|
|
- <div
|
|
|
- class="qbtn"
|
|
|
- @click="requestion"
|
|
|
- v-else-if="status == '答题错误' || status == '答题超时'"
|
|
|
- >
|
|
|
- <span>重新答题</span>
|
|
|
</div>
|
|
|
+ <!-- 移动端 -->
|
|
|
+ <div class="datiing" v-if="isMobile">
|
|
|
+ <div class="jishi">
|
|
|
+ <div class="bar">
|
|
|
+ <div
|
|
|
+ :style="{ width: (1 - current / daojishi) * 100 + '%' }"
|
|
|
+ class="activeLine"
|
|
|
+ ></div>
|
|
|
+ <div
|
|
|
+ :style="{ left: (1 - current / daojishi) * 100 + '%' }"
|
|
|
+ class="dot"
|
|
|
+ ></div>
|
|
|
+ </div>
|
|
|
+ <div class="time">00:{{ fixNum }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="dcon" v-if="tiku.length > 0 && status == '答题中'">
|
|
|
+ <p>{{ currentIdx + 1 + "、" + currentTimu.title }}</p>
|
|
|
+ <div class="qlist">
|
|
|
+ <div class="qline"></div>
|
|
|
+ <ul>
|
|
|
+ <li
|
|
|
+ :class="{ active: active == item.id }"
|
|
|
+ @click="active = item.id"
|
|
|
+ v-for="(item, i) in currentTimu.answer"
|
|
|
+ :key="i"
|
|
|
+ >
|
|
|
+ <span>{{ item.id }}、{{ item.txt }}</span>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ <span
|
|
|
+ >第 {{ currentIdx + 1 }} 题 / 共 {{ tiku.length }}</span
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <template v-if="status == '答题中'">
|
|
|
+ <div class="qbtn" v-if="currentIdx < 9" @click="next">
|
|
|
+ <span>下一题</span>
|
|
|
+ </div>
|
|
|
+ <div class="qbtn primary" @click="next" v-else>
|
|
|
+ <span>提交</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="datifinish" v-else>
|
|
|
- <div class="qbtn" @click="requestion">
|
|
|
- <span>分享好友</span>
|
|
|
+ <div class="tipscon" v-else>
|
|
|
+ <img
|
|
|
+ :src="
|
|
|
+ require(`@/assets/images/question/${
|
|
|
+ status == '答题完成' ? 'success' : 'error'
|
|
|
+ }.png`)
|
|
|
+ "
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ <div v-if="tips[status]">
|
|
|
+ <p>{{ tips[status].title }}</p>
|
|
|
+ <span>{{ tips[status].desc }}</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class="qbtn primary" @click="lingjiang">
|
|
|
- <span>领取奖励</span>
|
|
|
+
|
|
|
+ <div
|
|
|
+ class="qbtn"
|
|
|
+ @click="requestion"
|
|
|
+ v-if="status == '答题错误' || status == '答题超时'"
|
|
|
+ >
|
|
|
+ <span>重新答题</span>
|
|
|
</div>
|
|
|
- <div class="qbtn" @click="requestion">
|
|
|
- <span>继续答题</span>
|
|
|
+
|
|
|
+ <div class="datifinish" v-if="status == '答题完成'">
|
|
|
+ <div class="qbtn" @click="requestion">
|
|
|
+ <span>分享好友</span>
|
|
|
+ </div>
|
|
|
+ <div class="qbtn" @click="requestion">
|
|
|
+ <span>继续答题</span>
|
|
|
+ </div>
|
|
|
+ <div class="qbtn primary" @click="lingjiang">
|
|
|
+ <span>领取奖励</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { questions } from './data'
|
|
|
-
|
|
|
+import { questions } from "./data";
|
|
|
+import browser from "@/util/browser";
|
|
|
let random = function (min, max) {
|
|
|
- var range = max - min
|
|
|
- var rand = Math.random()
|
|
|
- var num = min + Math.round(rand * range)
|
|
|
+ var range = max - min;
|
|
|
+ var rand = Math.random();
|
|
|
+ var num = min + Math.round(rand * range);
|
|
|
|
|
|
- return num
|
|
|
-}
|
|
|
+ return num;
|
|
|
+};
|
|
|
|
|
|
let getNorepeatNum = function (min, max, num) {
|
|
|
- let arr = []
|
|
|
+ let arr = [];
|
|
|
|
|
|
while (arr.length < num) {
|
|
|
- let ran = random(min, max)
|
|
|
+ let ran = random(min, max);
|
|
|
if (!arr.includes(ran)) {
|
|
|
- arr.push(ran)
|
|
|
+ arr.push(ran);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return arr
|
|
|
-}
|
|
|
+ return arr;
|
|
|
+};
|
|
|
|
|
|
let tips = {
|
|
|
答题超时: {
|
|
|
- title: '答题超时',
|
|
|
- desc: '不要气馁,再接再厉~'
|
|
|
+ title: "答题超时",
|
|
|
+ desc: "不要气馁,再接再厉~",
|
|
|
},
|
|
|
答题错误: {
|
|
|
- title: '答题错误',
|
|
|
- desc: '不要气馁,再接再厉~'
|
|
|
+ title: "答题错误",
|
|
|
+ desc: "不要气馁,再接再厉~",
|
|
|
},
|
|
|
答题完成: {
|
|
|
- title: '完成挑战',
|
|
|
- desc: '本次答对10道题'
|
|
|
- }
|
|
|
-}
|
|
|
+ title: "完成挑战",
|
|
|
+ desc: "本次答对10道题",
|
|
|
+ },
|
|
|
+};
|
|
|
|
|
|
export default {
|
|
|
- data () {
|
|
|
+ data() {
|
|
|
return {
|
|
|
daojishi: 20,
|
|
|
current: 20,
|
|
|
inter: null,
|
|
|
currentIdx: 0,
|
|
|
- active: '',
|
|
|
+ active: "",
|
|
|
questions,
|
|
|
tiku: [],
|
|
|
reloadTimu: false,
|
|
|
- status: '答题中',
|
|
|
- tips
|
|
|
- }
|
|
|
+ status: "答题中",
|
|
|
+ tips,
|
|
|
+ isMobile: browser.mobile,
|
|
|
+ };
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
- clearInter () {
|
|
|
- this.active = ''
|
|
|
- clearInterval(this.inter)
|
|
|
- this.inter = null
|
|
|
+ clearInter() {
|
|
|
+ this.active = "";
|
|
|
+ clearInterval(this.inter);
|
|
|
+ this.inter = null;
|
|
|
},
|
|
|
- requestion () {
|
|
|
- this.reloadTimu = true
|
|
|
- this.currentIdx = 0
|
|
|
+ requestion() {
|
|
|
+ this.reloadTimu = true;
|
|
|
+ this.currentIdx = 0;
|
|
|
},
|
|
|
- next () {
|
|
|
+ next() {
|
|
|
if (this.currentTimu.correct === this.active) {
|
|
|
- this.currentIdx++
|
|
|
+ this.currentIdx++;
|
|
|
if (this.currentIdx > 9) {
|
|
|
- this.status = '答题完成'
|
|
|
- return
|
|
|
+ this.status = "答题完成";
|
|
|
+ return;
|
|
|
}
|
|
|
- this.startInter()
|
|
|
+ this.startInter();
|
|
|
} else {
|
|
|
- this.status = '答题错误'
|
|
|
+ this.status = "答题错误";
|
|
|
}
|
|
|
},
|
|
|
- lingjiang () {
|
|
|
- this.$emit('lingjiang', true)
|
|
|
+ lingjiang() {
|
|
|
+ this.$emit("lingjiang", true);
|
|
|
},
|
|
|
- startInter () {
|
|
|
- this.clearInter()
|
|
|
- this.current = this.daojishi
|
|
|
+ startInter() {
|
|
|
+ this.clearInter();
|
|
|
+ this.current = this.daojishi;
|
|
|
this.inter = setInterval(() => {
|
|
|
if (this.current === 0) {
|
|
|
- this.status = '答题超时'
|
|
|
- return
|
|
|
+ this.status = "答题超时";
|
|
|
+ return;
|
|
|
}
|
|
|
this.current--
|
|
|
- }, 1000)
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ getTimu() {
|
|
|
+ let idxarr = getNorepeatNum(0, 40, 10);
|
|
|
+ this.tiku = idxarr.map((item) => {
|
|
|
+ return questions[item];
|
|
|
+ });
|
|
|
+ this.reloadTimu = false;
|
|
|
+ this.status = "答题中";
|
|
|
+ this.startInter();
|
|
|
},
|
|
|
- getTimu () {
|
|
|
- let idxarr = getNorepeatNum(0, 40, 10)
|
|
|
- this.tiku = idxarr.map(item => {
|
|
|
- return questions[item]
|
|
|
- })
|
|
|
- this.reloadTimu = false
|
|
|
- this.status = '答题中'
|
|
|
- this.startInter()
|
|
|
- }
|
|
|
},
|
|
|
computed: {
|
|
|
- fixNum () {
|
|
|
- return String(this.current).padStart(2, '0')
|
|
|
+ fixNum() {
|
|
|
+ return String(this.current).padStart(2, "0");
|
|
|
+ },
|
|
|
+ currentTimu() {
|
|
|
+ return this.tiku[this.currentIdx];
|
|
|
},
|
|
|
- currentTimu () {
|
|
|
- return this.tiku[this.currentIdx]
|
|
|
- }
|
|
|
},
|
|
|
watch: {
|
|
|
- status (newVal) {
|
|
|
- if (newVal !== '答题中') {
|
|
|
- this.clearInter()
|
|
|
+ status(newVal) {
|
|
|
+ if (newVal !== "答题中") {
|
|
|
+ this.clearInter();
|
|
|
}
|
|
|
},
|
|
|
- reloadTimu (newVal) {
|
|
|
+ reloadTimu(newVal) {
|
|
|
if (newVal) {
|
|
|
- this.getTimu()
|
|
|
+ this.getTimu();
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
- beforeDestroy () {
|
|
|
- this.clearInter()
|
|
|
+ beforeDestroy() {
|
|
|
+ this.clearInter();
|
|
|
},
|
|
|
- mounted () {
|
|
|
+ mounted() {
|
|
|
this.$nextTick(() => {
|
|
|
- this.getTimu()
|
|
|
- })
|
|
|
- }
|
|
|
-}
|
|
|
+ this.getTimu();
|
|
|
+ });
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
<style lang="less" scoped>
|
|
|
@color: #fa3800;
|
|
|
.datiing {
|
|
|
width: 80%;
|
|
|
- transform: translate(-50%,-50%);
|
|
|
+ transform: translate(-50%, -50%);
|
|
|
position: absolute;
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
@@ -362,14 +443,14 @@ export default {
|
|
|
min-height: 200px;
|
|
|
position: relative;
|
|
|
> img {
|
|
|
- width: 40%;
|
|
|
+ width: 70%;
|
|
|
margin-top: 10px;
|
|
|
}
|
|
|
> div {
|
|
|
color: #54320b;
|
|
|
position: absolute;
|
|
|
- top: 140px;
|
|
|
- left: 41%;
|
|
|
+ top: 112px;
|
|
|
+ left: 30%;
|
|
|
> p {
|
|
|
font-size: 18px;
|
|
|
margin-bottom: 6px;
|
|
@@ -391,4 +472,88 @@ export default {
|
|
|
justify-items: center;
|
|
|
}
|
|
|
}
|
|
|
+.qmobile .datiing {
|
|
|
+ width: 95%;
|
|
|
+ top: 40px;
|
|
|
+ transform: translateX(-50%);
|
|
|
+ height:calc(100% - 50px);
|
|
|
+ overflow-y: hidden;
|
|
|
+ .jishi {
|
|
|
+ display: block;
|
|
|
+ width: 80%;
|
|
|
+ margin: 5px auto;
|
|
|
+ .bar {
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+ .time {
|
|
|
+ display: block;
|
|
|
+ text-align: center;
|
|
|
+ width: 100%;
|
|
|
+ margin: 16px 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .dcon {
|
|
|
+ overflow-y: auto;
|
|
|
+ margin-top: 0;
|
|
|
+ max-height:90%;
|
|
|
+ padding: 18px;
|
|
|
+ >p {
|
|
|
+ max-height: 124px;
|
|
|
+ overflow-y:auto;
|
|
|
+ }
|
|
|
+ >.qbtn {
|
|
|
+ background: rgba(250, 56, 0, 1);
|
|
|
+ margin:21px auto 3px;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ >.qlist {
|
|
|
+
|
|
|
+ >ul {
|
|
|
+ height: auto;
|
|
|
+ max-height:247px;
|
|
|
+ overflow-y:auto;
|
|
|
+ >li {
|
|
|
+ margin:27px 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .tipscon {
|
|
|
+ >img {
|
|
|
+ width: 80%;
|
|
|
+ margin-left: 8%;
|
|
|
+ }
|
|
|
+ >div {
|
|
|
+ top:50%;
|
|
|
+ left: 30%;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ >.qbtn {
|
|
|
+ width: 280px;
|
|
|
+ height: 60px;
|
|
|
+ line-height: 60px;
|
|
|
+ font-size: 24px;
|
|
|
+ font-family: Microsoft YaHei;
|
|
|
+ color: #FFFFFF;
|
|
|
+ font-weight: 400;
|
|
|
+ margin-top:80px;
|
|
|
+ }
|
|
|
+ .datifinish {
|
|
|
+ display: block;
|
|
|
+ width: 100%;
|
|
|
+ margin-top:34px;
|
|
|
+ max-height: 30%;
|
|
|
+ overflow-y: auto;
|
|
|
+ overflow-x:hidden;
|
|
|
+ >.qbtn {
|
|
|
+ width: 286px;
|
|
|
+ height: 55px;
|
|
|
+ margin:0 auto;
|
|
|
+ }
|
|
|
+ >.qbtn:nth-of-type(2) {
|
|
|
+ margin:16px auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|