survey.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <!-- 原理认知 -->
  3. <view class="myComRoot ylrz-box df fdr">
  4. <!-- 左边导航栏 -->
  5. <view class="leftBox">
  6. <view class="df fdc leftMenu" v-for="(menu1,i) in btnList" :key="i">
  7. <view class="leftMenu-btn1 df fdr aic jcsb" @click="onLeftBtn1Click(i)">
  8. <view class=" df fdr aic ">
  9. <view class="leftMenu-btn1-icon df">
  10. <img :src="menu1.icon_btn1_unchecked"></img>
  11. </view>
  12. <view class="leftMenu-btn1-text" :style="{color:color_unchecked_01}">{{menu1.text}}</view>
  13. </view>
  14. <view class="leftMenu-btn1-arrow df">
  15. <img :src="arrowSrc"></img>
  16. </view>
  17. </view>
  18. <view class="leftMenu-btn2-box2 df fdr aic" v-for="(menu2,m) in menu1.list" :key="m" @click="onLeftBtn2Click(i,m)">
  19. <view class="leftMenu-btn2-icon df">
  20. <img :src="(checkedIndex1==i&& checkedIndex2==m)?icon_btn2_checked:icon_btn2_unchecked"></img>
  21. </view>
  22. <view class="leftMenu-btn2-text" :style="{color:(checkedIndex1==i&& checkedIndex2==m)?color_checked:color_unchecked_02}">{{menu2}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 右边详情页 -->
  27. <view class="rightBox">
  28. <!-- 学习知识点 -->
  29. <view class="right-content df fdc" v-show="checkedIndex1==0">
  30. <view v-for="(content,n) in myData_YLRZ_ZSD[checkedIndex2].content" :key="n">
  31. <view class="right-title df aic" v-show="content.type=='title'">
  32. <view class="right-title-line"></view>
  33. <view class="right-title-text">{{content.details}}</view>
  34. </view>
  35. <view class="right-text" v-show="content.type=='text'">{{content.details}}</view>
  36. <view class="right-pic df jcc" v-show="content.type=='pic'">
  37. <img :src="content.src"></img>
  38. </view>
  39. <view class="right-space" v-show="content.type=='space'"></view>
  40. </view>
  41. <view class="df jcc">
  42. <view class="right-btn-next df aic jcc" @click="onClick_next">下一步</view>
  43. </view>
  44. </view>
  45. <!-- 测验 -->
  46. <view class="ylrz-cy df" v-show="checkedIndex1==1">
  47. <!-- 开始测验 -->
  48. <view class="ylrz-cy df jcc aic" v-show="testIndex==0">
  49. <view class="df fdc ylrz-kscy-box">
  50. <view class="df fdr jcse">
  51. <view class="df fdc aic">
  52. <img src='../../assets/learning/icon_test_01.png'></img>
  53. <view>100%及格率</view>
  54. </view>
  55. <view class="df fdc aic">
  56. <img src='../../assets/learning/icon_test_02.png'></img>
  57. <view>无时间限制</view>
  58. </view>
  59. </view>
  60. <view class="ylrz-kscy-text df aic jcc">{{text_ksdt}}</view>
  61. <view class="df fdr jcse ylrz-kscy-btn">
  62. <view class="ylrz-btn-red df aic jcc" @click="onClick_ksdt">开始答题</view>
  63. <view class="ylrz-btn-gray df aic jcc">取消</view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 答题 -->
  68. <view class="ylrz-cy-dt df fdc" v-show="testIndex==1">
  69. <view class="right-title df aic">
  70. <view class="right-title-line"></view>
  71. <view class="right-title-text">答题</view>
  72. </view>
  73. <!-- 问题 -->
  74. <view class="ylrz-test-q">
  75. {{(curQIndex+1)+'、'+test_YLRZ.list[curQIndex].q}}
  76. </view>
  77. <!-- 答案 -->
  78. <view class="ylrz-test-a-box">
  79. <view class="ylrz-test-a-box2">
  80. <view class="df aic fdr ylrz-test-a" v-for="(answer,answerI) in test_YLRZ.list[curQIndex].a_list" :key="answerI"
  81. @click="onClick_test_a(answerI)">
  82. <img class="ylrz-test-a-img" :src="curCheckedAnswer[answerI]==1?test_answer_icon_checked:test_answer_icon_unchecked"></img>
  83. <view class="ylrz-test-a-text" :style="{color:curCheckedAnswer[answerI]==1?test_answer_color_checked:test_answer_color_unchecked}">
  84. {{test_answer_pre[answerI]+':'+answer}}
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 按钮 -->
  90. <view class="ylrz-test-btn-box df fdr">
  91. <view v-show="curQIndex>0" class="ylrz-test-btn-red df aic jcc" @click="onClick_test_last">上一题</view>
  92. <view v-show="curQIndex<test_YLRZ.list.length-1" class="ylrz-test-btn-red df aic jcc" @click="onClick_test_next">下一题</view>
  93. <view v-show="curQIndex==test_YLRZ.list.length-1" class="ylrz-test-btn-red df aic jcc" @click="onClick_test_finish">完成</view>
  94. </view>
  95. <view class="ylrz-test-btn-exit ylrz-test-btn-red df aic jcc" @click="onClick_test_exit">退出</view>
  96. </view>
  97. </view>
  98. <!-- 结论 -->
  99. <view class="ylrz-cy-jl df" v-show="checkedIndex1==2">
  100. <view class="ylrz-cy-dt df fdc" v-show="testIndex==1">
  101. <view class="right-title df aic">
  102. <view class="right-title-line"></view>
  103. <view class="right-title-text">查看错题</view>
  104. </view>
  105. <view class="df fdc" v-for="(wrong,wrongIndex) in allWrongTest" :key="wrongIndex">
  106. <!-- 问题 -->
  107. <view class="ylrz-test-q">
  108. {{(wrong+1)+'、'+test_YLRZ.list[wrong].q}}
  109. </view>
  110. <!-- 答案 -->
  111. <view class="ylrz-test-a-box">
  112. <view class="ylrz-test-a-box2">
  113. <view class="df aic fdr ylrz-test-a" v-for="(answer2,answerI2) in test_YLRZ.list[wrong].a_list" :key="answerI2">
  114. <img class="ylrz-test-a-img" :src="test_YLRZ.list[wrong].a[answerI2]==1?test_answer_icon_checked:allCheckedAnswer[wrong][answerI2]==1?test_answer_icon_wrong:test_answer_icon_unchecked"></img>
  115. <view class="ylrz-test-a-text" :style="{color:test_YLRZ.list[wrong].a[answerI2]==1?test_answer_color_checked:allCheckedAnswer[wrong][answerI2]==1?test_answer_color_wrong:test_answer_color_unchecked}">
  116. {{test_answer_pre[answerI2]+':'+answer2}}
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <view class="ylrz-test-btn-exit ylrz-test-btn-red df aic jcc" @click="onClick_test_exit">退出</view>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. </template>
  128. <script>
  129. export default {
  130. data() {
  131. return {
  132. isShow: false,
  133. checkedIndex1: 0, //一级目录
  134. checkedIndex2: 0, //二级目录
  135. testIndex: 0, //0开始答题1答题
  136. //当前问题索引
  137. curQIndex: 0,
  138. //玩家当前选择答案0未选中,1选中
  139. curCheckedAnswer: [],
  140. //玩家选择的答案
  141. allCheckedAnswer: [],
  142. //玩家错误的题目序列号
  143. allWrongTest: [],
  144. // ------以下为静态
  145. arrowSrc: require('../../assets/learning/icon_ylrz_arrow.png'),
  146. btnList: [
  147. {
  148. "text": '测验(完成获得10分)',
  149. "icon_btn1_checked": require('../../assets/learning/icon_ylrz_menu_02.png'),
  150. "icon_btn1_unchecked": require('../../assets/learning/icon_ylrz_menu_01.png'),
  151. "list": ['测验']
  152. },
  153. {
  154. "text": '结论',
  155. "icon_btn1_checked": require('../../assets/learning/icon_ylrz_menu_02.png'),
  156. "icon_btn1_unchecked": require('../../assets/learning/icon_ylrz_menu_01.png'),
  157. "list": ['结论']
  158. }
  159. ],
  160. icon_btn2_checked: require('../../assets/learning/icon_ylrz_menu_02.png'),
  161. icon_btn2_unchecked: require('../../assets/learning/icon_ylrz_menu_01.png'),
  162. color_checked: '#EA252C',
  163. color_unchecked_01: '#070707', //1级菜单
  164. color_unchecked_02: '#555555', //2级菜单
  165. myData_YLRZ_ZSD: [
  166. YLRZ_ZSD_01,
  167. YLRZ_ZSD_02,
  168. YLRZ_ZSD_03,
  169. YLRZ_ZSD_04
  170. ],
  171. text_ksdt: '你必须正确回答所有测试问题才能完成课程。测试没有次数限制,也没有惩罚,即使你已经通过测试也可以再次回答。你可以在课程页面上的测试模块中点击“结果‘按钮查看测试结果的详细报告。',
  172. //原理认知测试题
  173. test_YLRZ: myData_test_YLRZ,
  174. //答案小标号
  175. test_answer_pre: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  176. test_answer_icon_checked: require('../../assets/learning/icon_test_03_02.png'),
  177. test_answer_icon_unchecked: require('../../assets/learning/icon_test_03_01.png'),
  178. test_answer_icon_wrong: require('../../assets/learning/icon_test_03_03.png'),
  179. test_answer_color_checked: '#437FFA',
  180. test_answer_color_unchecked: '#1A1A1A',
  181. test_answer_color_wrong: '#EA252C',
  182. }
  183. },
  184. methods: {
  185. initData() {
  186. // this.checkedIndex1 = 0;
  187. // this.checkedIndex2 = 0;
  188. },
  189. onLeftBtn1Click(index) {
  190. if (index != this.checkedIndex1) {
  191. this.checkedIndex2 = 0;
  192. this.checkedIndex1 = index;
  193. }
  194. },
  195. onLeftBtn2Click(index1, index2) {
  196. this.checkedIndex1 = index1;
  197. this.checkedIndex2 = index2;
  198. },
  199. onClick_next() {
  200. if (this.checkedIndex2 < this.btnList[this.checkedIndex1].list.length - 1) {
  201. this.checkedIndex2 += 1;
  202. } else {
  203. if (this.checkedIndex1 + 1 < this.btnList.length) {
  204. this.checkedIndex1 += 1;
  205. this.checkedIndex2 = 0;
  206. } else {
  207. // 先空着
  208. }
  209. }
  210. },
  211. //开始答题
  212. onClick_ksdt() {
  213. this.testIndex = 1;
  214. this.resetTest();
  215. },
  216. resetTest() {
  217. //重置玩家选择的答案
  218. let arr = [];
  219. for (let i = 0; i < this.test_YLRZ.list.length; i++) {
  220. arr.push([]);
  221. }
  222. this.allCheckedAnswer = arr;
  223. this.curQIndex = 0;
  224. this.resetCurCheckedAnswer();
  225. this.allWrongTest = [];
  226. },
  227. resetCurCheckedAnswer() {
  228. let curChecked = []
  229. for (let i = 0; i < this.test_YLRZ.list[this.curQIndex].a_list.length; i++) {
  230. curChecked.push(0);
  231. }
  232. this.curCheckedAnswer = curChecked;
  233. this.allCheckedAnswer[this.curQIndex] = this.curCheckedAnswer;
  234. },
  235. onClick_test_a(answerI) {
  236. // console.log("点击答案");
  237. let answer = this.curCheckedAnswer[answerI] == 1 ? 0 : 1;
  238. this.curCheckedAnswer[answerI] = answer;
  239. this.allCheckedAnswer[this.curQIndex] = this.curCheckedAnswer;
  240. this.$forceUpdate();
  241. },
  242. onClick_test_last() {
  243. this.curQIndex--;
  244. this.resetCurCheckedAnswer();
  245. },
  246. onClick_test_next() {
  247. // console.log("这道题选了什么", this.curCheckedAnswer);
  248. if (this.checkedAnswer() == true) {
  249. this.curQIndex++;
  250. this.resetCurCheckedAnswer();
  251. }else{
  252. alert("必须选择一个答案");
  253. }
  254. },
  255. checkedAnswer(){
  256. let count = 0
  257. let countMax = this.curCheckedAnswer.length
  258. for (let i = 0; i <this.curCheckedAnswer.length ; i++) {
  259. if (this.curCheckedAnswer[i] == 0) {
  260. count++
  261. }
  262. }
  263. if (count == countMax ) {
  264. return false
  265. }else{
  266. return true
  267. }
  268. },
  269. onClick_test_finish() {
  270. console.log("所有答案", this.allCheckedAnswer);
  271. //检验一下答案
  272. for (let i = 0; i < this.test_YLRZ.list.length; i++) {
  273. let isTrue = true;
  274. for (let m = 0; m < this.allCheckedAnswer[i].length; m++) {
  275. if (this.allCheckedAnswer[i][m] != this.test_YLRZ.list[i].a[m]) {
  276. isTrue = false;
  277. this.allWrongTest.push(i);
  278. break;
  279. }
  280. }
  281. }
  282. console.log("检测结果为", this.allWrongTest);
  283. this.checkedIndex1 = 2;
  284. },
  285. onClick_test_exit() {
  286. this.checkedIndex1 = 1;
  287. this.testIndex = 0;
  288. this.resetTest();
  289. }
  290. }
  291. }
  292. </script>
  293. <style lang="scss">
  294. .ylrz-box {
  295. background: #F4F4F4;
  296. }
  297. .leftBox {
  298. background-color: #FFFFFF;
  299. width: px2vw(374);
  300. height: 100%;
  301. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  302. margin-top: px2vw(11);
  303. }
  304. .rightBox {
  305. flex: 1;
  306. height: 100%;
  307. background: #FFFFFF;
  308. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  309. margin-top: px2vw(11);
  310. margin-left: px2vw(11);
  311. }
  312. .leftMenu-btn1 {
  313. width: 100%;
  314. height: px2vw(70);
  315. background: #F2F2F2;
  316. }
  317. .leftMenu-btn1-icon {
  318. margin-left: px2vw(38);
  319. }
  320. .leftMenu-btn1-icon img {
  321. width: px2vw(18);
  322. }
  323. .leftMenu-btn1-text {
  324. margin-left: px2vw(14);
  325. font-size: px2vw(20);
  326. }
  327. .leftMenu-btn2-box1 {
  328. margin-top: px2vw(30);
  329. margin-bottom: px2vw(30);
  330. }
  331. .leftMenu-btn2-box2 {
  332. margin-left: px2vw(48);
  333. margin-top: px2vw(25);
  334. }
  335. .leftMenu-btn2-text {
  336. margin-left: px2vw(14);
  337. font-size: px2vw(20);
  338. }
  339. .leftMenu-btn2-icon img {
  340. width: px2vw(16);
  341. }
  342. .leftMenu-btn1-arrow {
  343. margin-right: px2vw(38);
  344. }
  345. .leftMenu-btn1-arrow img {
  346. width: px2vw(15);
  347. }
  348. .leftMenu {
  349. margin-bottom: px2vw(25);
  350. }
  351. .right-content {
  352. margin-top: px2vw(40);
  353. margin-left: px2vw(50);
  354. margin-bottom: px2vw(40);
  355. margin-right: px2vw(50);
  356. }
  357. .right-title {}
  358. .right-title-line {
  359. width: px2vw(8);
  360. height: px2vw(24);
  361. background: #EA252C;
  362. }
  363. .right-title-text {
  364. font-size: px2vw(24);
  365. margin-left: px2vw(23);
  366. color: #070707;
  367. }
  368. .right-text {
  369. font-size: px2vw(22);
  370. color: #020202;
  371. line-height: px2vw(46);
  372. margin-top: px2vw(40);
  373. }
  374. .right-space {
  375. margin-top: px2vw(50);
  376. }
  377. .right-pic {
  378. margin-top: px2vw(40);
  379. }
  380. .right-pic img {
  381. max-width: px2vw(1397);
  382. }
  383. .right-btn-next {
  384. width: px2vw(200);
  385. height: px2vw(58);
  386. background: #EA252C;
  387. border-radius: px2vw(8);
  388. margin-top: px2vw(60);
  389. font-size: px2vw(24);
  390. color: #FFFFFF;
  391. }
  392. .ylrz-kscy-box {
  393. width: px2vw(1000);
  394. }
  395. .ylrz-kscy-box img {
  396. width: px2vw(110);
  397. }
  398. .ylrz-kscy-text {
  399. width: px2vw(883);
  400. height: px2vw(130);
  401. background: #F4F4F4;
  402. border-radius: px2vw(10);
  403. font-size: px2vw(20);
  404. color: #020202;
  405. line-height: px2vw(41);
  406. padding: px2vw(20) px2vw(60) px2vw(20) px2vw(60);
  407. margin-top: px2vw(54);
  408. }
  409. .ylrz-kscy-btn {
  410. margin-top: px2vw(100);
  411. }
  412. .ylrz-btn-red {
  413. width: px2vw(200);
  414. height: px2vw(58);
  415. background: #EA252C;
  416. border-radius: px2vw(8);
  417. font-size: px2vw(24);
  418. color: #FFFFFF;
  419. line-height: px2vw(31);
  420. }
  421. .ylrz-btn-gray {
  422. width: px2vw(200);
  423. height: px2vw(58);
  424. background: #CCCCCC;
  425. border-radius: px2vw(8);
  426. font-size: px2vw(24);
  427. color: #FFFFFF;
  428. line-height: px2vw(31);
  429. }
  430. .ylrz-cy {
  431. width: 100%;
  432. height: 100%;
  433. }
  434. .ylrz-cy-dt {
  435. width: 100%;
  436. // height: 100%;
  437. margin-left: px2vw(50);
  438. margin-top: px2vw(50);
  439. }
  440. .ylrz-test-q {
  441. margin-top: px2vw(42);
  442. font-size: px2vw(24);
  443. color: #1A1A1A;
  444. line-height: px2vw(31);
  445. }
  446. .ylrz-test-a-box {
  447. width: px2vw(870);
  448. // height: px2vw(274);
  449. background: #F2F2F2;
  450. border-radius: px2vw(10);
  451. font-size: px2vw(20);
  452. color: #1A1A1A;
  453. line-height: px2vw(26);
  454. margin-top: px2vw(40);
  455. }
  456. .ylrz-test-a-box2 {
  457. margin-top: px2vw(18);
  458. margin-bottom: px2vw(18);
  459. margin-left: px2vw(30);
  460. margin-right: px2vw(30);
  461. }
  462. .ylrz-test-a {
  463. margin-top: px2vw(18);
  464. margin-bottom: px2vw(18);
  465. }
  466. .ylrz-test-a-img {
  467. width: px2vw(22);
  468. }
  469. .ylrz-test-a-text {
  470. margin-left: px2vw(18);
  471. }
  472. .ylrz-test-btn-box {
  473. margin-top: px2vw(60);
  474. }
  475. .ylrz-test-btn-red {
  476. width: px2vw(200);
  477. height: px2vw(58);
  478. background: #EA252C;
  479. border-radius: px2vw(8);
  480. font-size: px2vw(24);
  481. color: #FFFFFF;
  482. line-height: px2vw(31);
  483. margin-right: px2vw(30);
  484. }
  485. .ylrz-test-btn-exit {
  486. margin-right: px2vw(47);
  487. position: fixed;
  488. align-self: flex-end;
  489. }
  490. .ylrz-cy-jl{
  491. margin-bottom: px2vw(60);
  492. }
  493. </style>