huDongWenDa.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <template>
  2. <view class="body">
  3. <view class="header">
  4. <view class="tit">湖里文化遗产保护中心</view>
  5. <view class="thumbnail_1">
  6. <image style="width: 100%; height: 100%" src="/static/img/img_seal@2x.png"></image>
  7. </view>
  8. </view>
  9. <view class="box">
  10. <view class="box_tit">
  11. <image style="width: 100%; height: 100%" src="/static/img/img_tit.png"></image>
  12. </view>
  13. <view class="box_tit_2">
  14. <view class="">文物守护者</view>
  15. <view class="" style="margin: 0 30rpx 0 30rpx">保护文物</view>
  16. <view class="">留下历史</view>
  17. </view>
  18. <!-- 答题按钮 -->
  19. <view class="dati">
  20. <view class="dt">
  21. <image style="width: 100%; height: 100%" src="/static/img/img_left@2x.png"></image>
  22. </view>
  23. <view class="dt_box" @click="starBtn">开始答题</view>
  24. <view class="dt">
  25. <image style="width: 100%; height: 100%" src="/static/img/img_right@2x.png"></image>
  26. </view>
  27. </view>
  28. <!-- 昵称弹层 -->
  29. <view class="nc_box" v-if="starShow">
  30. <view class="">
  31. <view class="nc">请留下您的昵称</view>
  32. <input v-model.trim="iptVal" class="ipt" type="text" placeholder="请输入您的昵称" />
  33. </view>
  34. <view class="qr" @click="isOk">确认</view>
  35. </view>
  36. <!-- 排行榜 -->
  37. <view class="ph_box" v-if="rankinglShow">
  38. <view class="ph_box2">
  39. <view class="phb">排行榜</view>
  40. <view class="phb_box" v-for="item in rankingList" :key="item.name">
  41. <view class="phb_item">
  42. <view class="phb_pm">
  43. <image style="width: 100%; height: 100%" src="/static/img/img_no1@2x.png"></image>
  44. </view>
  45. <view class="phb_tx">
  46. <image style="width: 100%; height: 100%" src="/static/img/img_avatar@2x(1).png"></image>
  47. </view>
  48. <view class="phb_nc">{{ item.name }}</view>
  49. </view>
  50. <view style="display: flex; align-items: center">
  51. <view class="fenshu">{{ item.score }}分</view>
  52. <view class="shijian">{{ item.cost_time }}</view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 开始答题弹层 -->
  59. <view class="star_box" v-if="answerShow">
  60. <view class="star_box2">
  61. <!-- 开始答题 -->
  62. <view class="" v-if="resultShow">
  63. <view class="tm_box">
  64. <view @click="answerShow = false" style="position: absolute; top: -36rpx; left: 10rpx" class="">
  65. <image style="width: 80rpx; height: 80rpx" src="/static/img/icon_back@2x.png"></image>
  66. </view>
  67. <view class="tihao">{{ i }}</view>
  68. <view class="wenti">{{ list.title }}</view>
  69. </view>
  70. <!-- 答案 -->
  71. <view class="daAn_box">
  72. <!-- -->
  73. <view @click="selectBtn(index)" v-for="(item, index) in list.optionList" :key="item.label" class="daAn_item" :class="{ active: index == selectTab2 }">
  74. {{ item.label }}
  75. </view>
  76. </view>
  77. <view class="tjDn">
  78. <view @click="completeBtn" v-if="abNiu" class="tjDn2">完成答题</view>
  79. <view v-else class="tjDn2" @click="nextBtn">下一题</view>
  80. </view>
  81. </view>
  82. </view>
  83. <!-- 答题结果 -->
  84. <view class="jieGuo" v-if="jieGuoShow">
  85. <view class="tm_box">
  86. <view class="dt_end">答题结束</view>
  87. </view>
  88. <view class="fraction">
  89. <text style="font-size: 38rpx">{{ recordNumber * 10 }}分</text>
  90. </view>
  91. <view class="txt_box">
  92. <view class="txt_">共计{{ anNiuList.length }}题,您答对了 {{ recordNumber }} 道题!</view>
  93. <view class="txt_">恭喜您!耗时 1分30秒 完成!</view>
  94. </view>
  95. <!-- 重新答题按钮 -->
  96. <view class="restart" @click="restartBtn">
  97. <view class="dt">
  98. <image style="width: 100%; height: 100%" src="/static/img/img_left@2x.png"></image>
  99. </view>
  100. <view class="dt_box">重新开始</view>
  101. <view class="dt">
  102. <image style="width: 100%; height: 100%" src="/static/img/img_right@2x.png"></image>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. <!-- 菜单按钮 -->
  108. <view class="caidan" @click="navBtn">
  109. <image class="img" src="../../../static/img/icon_menu@2x.png"></image>
  110. <view class="dh">导航</view>
  111. </view>
  112. <!-- 菜单弹层 -->
  113. <u-popup :show="show" @close="close" mode="left" bgColor="#f8efe1" customStyle="width:500rpx">
  114. <LeftNav></LeftNav>
  115. </u-popup>
  116. </view>
  117. </template>
  118. <script>
  119. import { login } from '../../../config/api';
  120. let that;
  121. export default {
  122. data() {
  123. return {
  124. i: 0,
  125. recordNumber: 0 /* 记录对的题数 */,
  126. activeTab: '',
  127. selectTab: true,
  128. selectTab2: null,
  129. iptVal: '',
  130. show: false,
  131. starShow: false,
  132. answerShow: false,
  133. jieGuoShow: false,
  134. rankinglShow: false,
  135. resultShow: true,
  136. list: {},
  137. anNiuList: {},
  138. optionList: [] /* 答案选项 */,
  139. rankingList: [] /* 排行榜 */
  140. };
  141. },
  142. onLoad() {
  143. that = this;
  144. },
  145. computed: {
  146. abNiu() {
  147. return this.anNiuList.length == this.list.seq;
  148. },
  149. ceshi() {
  150. return this.activeTab == 'answer' ? true : false;
  151. }
  152. },
  153. methods: {
  154. navBtn() {
  155. this.show = true;
  156. },
  157. // 开始答题
  158. starBtn() {
  159. this.answerShow = true;
  160. this.$api.startChallenge({}, function (res) {
  161. that.anNiuList = res.data.question_data;
  162. console.log(that.anNiuList.length, '开始答题');
  163. });
  164. setTimeout(() => {
  165. that.nextBtn();
  166. }, 200);
  167. },
  168. // 下一题
  169. nextBtn() {
  170. if (this.selectTab) {
  171. this.i++;
  172. }
  173. if (!this.selectTab) {
  174. this.$common.normalToShow('还未选择答案');
  175. return false;
  176. }
  177. // 下一题
  178. this.$api.getNew({}, function (res) {
  179. // console.log(res, 11);
  180. that.list = res.data;
  181. });
  182. // 判断对错
  183. this.$api.submitAnswer({ answer: this.selectTab2 }, function (res) {
  184. // console.log(res, '提交');
  185. // 为对错答案添加样式
  186. // ceshi ? 'active2' : 'active3'
  187. // that.activeTab = res.data;
  188. // console.log(that.ceshi, 'activeTab');
  189. if (res.data == 'answer') {
  190. that.recordNumber++;
  191. console.log(that.recordNumber * 10, '对了');
  192. }
  193. });
  194. this.selectTab = null;
  195. this.selectTab2 = null;
  196. },
  197. // 选择答案
  198. selectBtn(i) {
  199. if (i !== '' && i !== undefined) {
  200. this.selectTab = true;
  201. } else {
  202. this.selectTab = false;
  203. }
  204. this.selectTab2 = i;
  205. },
  206. // 完成答题
  207. completeBtn() {
  208. // console.log(this.selectTab, '56565656');
  209. if (!this.selectTab) {
  210. this.$common.normalToShow('还未选择答案');
  211. return false;
  212. }
  213. this.answerShow = false;
  214. this.starShow = true;
  215. this.i = 0;
  216. if (this.iptVal !== '' && this.iptVal !== undefined) {
  217. this.starShow = false;
  218. }
  219. // 昵称
  220. this.$api.complete({ name: this.iptVal }, function (res) {
  221. console.log(res, 'name');
  222. });
  223. },
  224. // 昵称确认
  225. isOk() {
  226. if (this.iptVal == '' && this.iptVal.length <= 0) {
  227. this.$common.normalToShow('昵称不能为空');
  228. } else {
  229. setTimeout(() => {
  230. this.$common.successToShow('提交成功');
  231. }, 500);
  232. this.starShow = false;
  233. this.resultShow = true;
  234. // this.answerShow = true;
  235. this.rankinglShow = true;
  236. // this.jieGuoShow = true;
  237. this.$api.getTopList({}, function (res) {
  238. console.log(res, '排行');
  239. that.rankingList = res.data;
  240. });
  241. }
  242. },
  243. // 重新答题
  244. restartBtn() {
  245. this.starBtn();
  246. // this.nextBtn();
  247. // this.jieGuoShow = false;
  248. // this.resultShow = true;
  249. },
  250. close() {
  251. this.show = false;
  252. // console.log('close');
  253. }
  254. }
  255. };
  256. </script>
  257. <style>
  258. .active {
  259. background-image: linear-gradient(270deg, rgba(188, 95, 41, 1) 0, rgba(91, 60, 41, 1) 100%);
  260. -webkit-background-clip: text;
  261. -webkit-text-fill-color: transparent;
  262. border: 1px solid #563530;
  263. }
  264. .active2 {
  265. border: 2px solid #5ac725 !important;
  266. }
  267. .active3 {
  268. border: 2px solid #f56c6c !important;
  269. }
  270. .body {
  271. padding-top: 100rpx;
  272. height: 1825rpx;
  273. }
  274. .header {
  275. margin-left: 10%;
  276. width: 960rpx;
  277. height: 96rpx;
  278. align-items: center;
  279. display: flex;
  280. }
  281. .jieGuo {
  282. position: absolute;
  283. top: 0;
  284. left: 15%;
  285. }
  286. .box {
  287. width: 1800rpx;
  288. height: 1180rpx;
  289. margin: auto;
  290. margin-top: 10rpx;
  291. }
  292. .box_tit {
  293. margin: auto;
  294. width: 1400rpx;
  295. height: 160rpx;
  296. }
  297. .box_tit_2 {
  298. width: 700rpx;
  299. display: flex;
  300. font-size: 38rpx;
  301. margin: auto;
  302. margin-top: 60rpx;
  303. color: #563530;
  304. letter-spacing: 0.2em;
  305. }
  306. .tit {
  307. background-image: linear-gradient(270deg, rgba(188, 95, 41, 1) 0, rgba(91, 60, 41, 1) 100%);
  308. height: 96rpx;
  309. font-size: 48rpx;
  310. letter-spacing: 0.3em;
  311. font-weight: NaN;
  312. text-align: left;
  313. white-space: nowrap;
  314. line-height: 100rpx;
  315. -webkit-background-clip: text;
  316. -webkit-text-fill-color: transparent;
  317. }
  318. .thumbnail_1 {
  319. width: 16rpx;
  320. height: 60rpx;
  321. }
  322. .caidan {
  323. margin-left: 10%;
  324. margin-top: 2%;
  325. display: flex;
  326. width: 180rpx;
  327. align-items: center;
  328. }
  329. .img {
  330. width: 80rpx;
  331. height: 80rpx;
  332. }
  333. .dh {
  334. margin-left: 10rpx;
  335. font-size: 36rpx;
  336. color: #563530;
  337. }
  338. .dati {
  339. display: flex;
  340. align-items: center;
  341. margin: auto;
  342. width: 200px;
  343. line-height: 18rpx;
  344. margin-top: 100rpx;
  345. }
  346. .restart {
  347. display: flex;
  348. align-items: center;
  349. margin: auto;
  350. width: 200px;
  351. line-height: 18rpx;
  352. margin-top: 260rpx;
  353. }
  354. .dt_box {
  355. width: 300rpx;
  356. height: 80rpx;
  357. font-size: 48rpx;
  358. text-align: center;
  359. line-height: 80rpx;
  360. margin: 0 20rpx 0 20rpx;
  361. background-image: linear-gradient(270deg, rgba(188, 95, 41, 1) 0, rgba(91, 60, 41, 1) 100%);
  362. -webkit-background-clip: text;
  363. -webkit-text-fill-color: transparent;
  364. border: 1px solid #563530;
  365. }
  366. .dt {
  367. width: 60rpx;
  368. height: 16rpx;
  369. }
  370. .ph_box {
  371. margin: auto;
  372. margin-top: 50rpx;
  373. width: 1000rpx;
  374. height: 740rpx;
  375. border: 3px solid #563530;
  376. }
  377. .ph_box2 {
  378. width: 980rpx;
  379. height: 720rpx;
  380. margin: auto;
  381. margin-top: 10rpx;
  382. overflow: scroll;
  383. box-sizing: border-box;
  384. padding: 0 40rpx 0 40rpx;
  385. border: 1px solid #563530;
  386. }
  387. .phb {
  388. width: 160rpx;
  389. font-size: 48rpx;
  390. margin: auto;
  391. margin-top: 20rpx;
  392. background: linear-gradient(180deg, #bc5f29 0%, #5b3c29 100%);
  393. -webkit-background-clip: text;
  394. -webkit-text-fill-color: transparent;
  395. }
  396. .phb_box {
  397. display: flex;
  398. align-items: center;
  399. justify-content: space-between;
  400. margin-bottom: 30rpx;
  401. }
  402. .phb_pm {
  403. width: 84rpx;
  404. height: 84rpx;
  405. }
  406. .phb_tx {
  407. margin-left: 40rpx;
  408. width: 120rpx;
  409. height: 120rpx;
  410. }
  411. .phb_nc {
  412. margin-left: 20rpx;
  413. font-size: 40rpx;
  414. color: #563530;
  415. letter-spacing: 0.2em;
  416. }
  417. .fenshu {
  418. font-size: 48rpx;
  419. background: linear-gradient(270deg, #bc5f29 0%, #5b3c29 100%);
  420. -webkit-background-clip: text;
  421. -webkit-text-fill-color: transparent;
  422. }
  423. .phb_item {
  424. display: flex;
  425. align-items: center;
  426. }
  427. .shijian {
  428. font-size: 36rpx;
  429. margin-left: 20rpx;
  430. color: #563530;
  431. }
  432. .star_box {
  433. position: absolute;
  434. top: 20%;
  435. left: 23%;
  436. width: 2000rpx;
  437. height: 1100rpx;
  438. border: 3px solid #563530;
  439. }
  440. .star_box2 {
  441. width: 1980rpx;
  442. height: 1080rpx;
  443. margin: auto;
  444. margin-top: 10rpx;
  445. border: 1px solid #563530;
  446. background-color: #f8efe1;
  447. padding: 60rpx;
  448. padding-top: 0;
  449. box-sizing: border-box;
  450. }
  451. .nc_box {
  452. position: absolute;
  453. display: flex;
  454. top: 27%;
  455. left: 33%;
  456. /* width: 900rpx;
  457. height: 240rpx; */
  458. }
  459. .nc {
  460. font-size: 36rpx;
  461. background: linear-gradient(180deg, #bc5f29 0%, #5b3c29 100%);
  462. -webkit-background-clip: text;
  463. -webkit-text-fill-color: transparent;
  464. letter-spacing: 0.2em;
  465. }
  466. .qr {
  467. width: 100rpx;
  468. height: 90rpx;
  469. font-size: 42rpx;
  470. margin-top: 50rpx;
  471. text-align: center;
  472. line-height: 100rpx;
  473. border: #a65729 1px solid;
  474. background: linear-gradient(180deg, #bc5f29 0%, #5b3c29 100%);
  475. -webkit-background-clip: text;
  476. -webkit-text-fill-color: transparent;
  477. }
  478. .ipt {
  479. width: 1200rpx;
  480. height: 100rpx;
  481. background-color: #fff9ec;
  482. border: none;
  483. color: #563530;
  484. }
  485. /deep/.uni-input-placeholder {
  486. color: #ccbeb4 !important;
  487. letter-spacing: 0.3em;
  488. text-indent: 1em;
  489. font-size: 42rpx;
  490. }
  491. .tm_box {
  492. display: flex;
  493. position: relative;
  494. justify-content: space-around;
  495. align-items: center;
  496. width: 100%;
  497. margin-top: 60rpx;
  498. height: 260rpx;
  499. border-bottom: 1px solid #ddd0c4;
  500. }
  501. .tihao {
  502. width: 90rpx;
  503. height: 80rpx;
  504. position: absolute;
  505. left: 0;
  506. font-size: 36rpx;
  507. text-align: center;
  508. line-height: 80rpx;
  509. margin-right: 50rpx;
  510. color: #563530;
  511. border: 1px solid #563530;
  512. }
  513. .wenti {
  514. font-size: 36rpx;
  515. color: #563530;
  516. margin-left: 160rpx;
  517. letter-spacing: 0.2em;
  518. }
  519. .daAn_box {
  520. width: 80%;
  521. margin: auto;
  522. display: flex;
  523. align-items: center;
  524. flex-flow: wrap;
  525. justify-content: space-between;
  526. }
  527. .daAn_item {
  528. width: 520rpx;
  529. height: 120rpx;
  530. font-size: 36rpx;
  531. color: #563530;
  532. margin-top: 50rpx;
  533. border: 1px solid #563530;
  534. background-color: #fff9ec;
  535. }
  536. .tjDn2 {
  537. width: 280rpx;
  538. height: 90rpx;
  539. margin: auto;
  540. font-size: 40rpx;
  541. text-align: center;
  542. line-height: 90rpx;
  543. letter-spacing: 0.2em;
  544. background-image: linear-gradient(270deg, rgba(188, 95, 41, 1) 0, rgba(91, 60, 41, 1) 100%);
  545. -webkit-background-clip: text;
  546. -webkit-text-fill-color: transparent;
  547. border: 1px solid #563530;
  548. }
  549. .tjDn {
  550. display: flex;
  551. width: 1000rpx;
  552. height: 110rpx;
  553. margin: auto;
  554. margin-top: 160rpx;
  555. padding-top: 10rpx;
  556. }
  557. .dt_end {
  558. font-size: 52rpx;
  559. letter-spacing: 0.3em;
  560. background-image: linear-gradient(270deg, rgba(188, 95, 41, 1) 0, rgba(91, 60, 41, 1) 100%);
  561. -webkit-background-clip: text;
  562. -webkit-text-fill-color: transparent;
  563. }
  564. .fraction {
  565. margin: auto;
  566. margin-top: 60rpx;
  567. width: 200rpx;
  568. height: 80rpx;
  569. font-size: 56rpx;
  570. letter-spacing: 0.3em;
  571. background: linear-gradient(270deg, #bc5f29 0%, #5b3c29 100%);
  572. -webkit-background-clip: text;
  573. -webkit-text-fill-color: transparent;
  574. }
  575. .txt_box {
  576. width: 1400rpx;
  577. height: 100rpx;
  578. margin: auto;
  579. }
  580. .txt_ {
  581. margin-top: 60rpx;
  582. font-size: 36rpx;
  583. color: #563530;
  584. height: 100rpx;
  585. line-height: 100rpx;
  586. letter-spacing: 0.3em;
  587. text-align: center;
  588. background-color: #efe6d8;
  589. }
  590. </style>