survey.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. this.curQIndex++;
  248. this.resetCurCheckedAnswer();
  249. },
  250. onClick_test_finish() {
  251. console.log("所有答案", this.allCheckedAnswer);
  252. //检验一下答案
  253. for (let i = 0; i < this.test_YLRZ.list.length; i++) {
  254. let isTrue = true;
  255. for (let m = 0; m < this.allCheckedAnswer[i].length; m++) {
  256. if (this.allCheckedAnswer[i][m] != this.test_YLRZ.list[i].a[m]) {
  257. isTrue = false;
  258. this.allWrongTest.push(i);
  259. break;
  260. }
  261. }
  262. }
  263. console.log("检测结果为", this.allWrongTest);
  264. this.checkedIndex1 = 2;
  265. },
  266. onClick_test_exit() {
  267. this.checkedIndex1 = 1;
  268. this.testIndex = 0;
  269. this.resetTest();
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang="scss">
  275. .ylrz-box {
  276. background: #F4F4F4;
  277. }
  278. .leftBox {
  279. background-color: #FFFFFF;
  280. width: px2vw(374);
  281. height: 100%;
  282. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  283. margin-top: px2vw(11);
  284. }
  285. .rightBox {
  286. flex: 1;
  287. height: 100%;
  288. background: #FFFFFF;
  289. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  290. margin-top: px2vw(11);
  291. margin-left: px2vw(11);
  292. }
  293. .leftMenu-btn1 {
  294. width: 100%;
  295. height: px2vw(70);
  296. background: #F2F2F2;
  297. }
  298. .leftMenu-btn1-icon {
  299. margin-left: px2vw(38);
  300. }
  301. .leftMenu-btn1-icon img {
  302. width: px2vw(18);
  303. }
  304. .leftMenu-btn1-text {
  305. margin-left: px2vw(14);
  306. font-size: px2vw(20);
  307. }
  308. .leftMenu-btn2-box1 {
  309. margin-top: px2vw(30);
  310. margin-bottom: px2vw(30);
  311. }
  312. .leftMenu-btn2-box2 {
  313. margin-left: px2vw(48);
  314. margin-top: px2vw(25);
  315. }
  316. .leftMenu-btn2-text {
  317. margin-left: px2vw(14);
  318. font-size: px2vw(20);
  319. }
  320. .leftMenu-btn2-icon img {
  321. width: px2vw(16);
  322. }
  323. .leftMenu-btn1-arrow {
  324. margin-right: px2vw(38);
  325. }
  326. .leftMenu-btn1-arrow img {
  327. width: px2vw(15);
  328. }
  329. .leftMenu {
  330. margin-bottom: px2vw(25);
  331. }
  332. .right-content {
  333. margin-top: px2vw(40);
  334. margin-left: px2vw(50);
  335. margin-bottom: px2vw(40);
  336. margin-right: px2vw(50);
  337. }
  338. .right-title {}
  339. .right-title-line {
  340. width: px2vw(8);
  341. height: px2vw(24);
  342. background: #EA252C;
  343. }
  344. .right-title-text {
  345. font-size: px2vw(24);
  346. margin-left: px2vw(23);
  347. color: #070707;
  348. }
  349. .right-text {
  350. font-size: px2vw(22);
  351. color: #020202;
  352. line-height: px2vw(46);
  353. margin-top: px2vw(40);
  354. }
  355. .right-space {
  356. margin-top: px2vw(50);
  357. }
  358. .right-pic {
  359. margin-top: px2vw(40);
  360. }
  361. .right-pic img {
  362. max-width: px2vw(1397);
  363. }
  364. .right-btn-next {
  365. width: px2vw(200);
  366. height: px2vw(58);
  367. background: #EA252C;
  368. border-radius: px2vw(8);
  369. margin-top: px2vw(60);
  370. font-size: px2vw(24);
  371. color: #FFFFFF;
  372. }
  373. .ylrz-kscy-box {
  374. width: px2vw(1000);
  375. }
  376. .ylrz-kscy-box img {
  377. width: px2vw(110);
  378. }
  379. .ylrz-kscy-text {
  380. width: px2vw(883);
  381. height: px2vw(130);
  382. background: #F4F4F4;
  383. border-radius: px2vw(10);
  384. font-size: px2vw(20);
  385. color: #020202;
  386. line-height: px2vw(41);
  387. padding: px2vw(20) px2vw(60) px2vw(20) px2vw(60);
  388. margin-top: px2vw(54);
  389. }
  390. .ylrz-kscy-btn {
  391. margin-top: px2vw(100);
  392. }
  393. .ylrz-btn-red {
  394. width: px2vw(200);
  395. height: px2vw(58);
  396. background: #EA252C;
  397. border-radius: px2vw(8);
  398. font-size: px2vw(24);
  399. color: #FFFFFF;
  400. line-height: px2vw(31);
  401. }
  402. .ylrz-btn-gray {
  403. width: px2vw(200);
  404. height: px2vw(58);
  405. background: #CCCCCC;
  406. border-radius: px2vw(8);
  407. font-size: px2vw(24);
  408. color: #FFFFFF;
  409. line-height: px2vw(31);
  410. }
  411. .ylrz-cy {
  412. width: 100%;
  413. height: 100%;
  414. }
  415. .ylrz-cy-dt {
  416. width: 100%;
  417. // height: 100%;
  418. margin-left: px2vw(50);
  419. margin-top: px2vw(50);
  420. }
  421. .ylrz-test-q {
  422. margin-top: px2vw(42);
  423. font-size: px2vw(24);
  424. color: #1A1A1A;
  425. line-height: px2vw(31);
  426. }
  427. .ylrz-test-a-box {
  428. width: px2vw(870);
  429. // height: px2vw(274);
  430. background: #F2F2F2;
  431. border-radius: px2vw(10);
  432. font-size: px2vw(20);
  433. color: #1A1A1A;
  434. line-height: px2vw(26);
  435. margin-top: px2vw(40);
  436. }
  437. .ylrz-test-a-box2 {
  438. margin-top: px2vw(18);
  439. margin-bottom: px2vw(18);
  440. margin-left: px2vw(30);
  441. margin-right: px2vw(30);
  442. }
  443. .ylrz-test-a {
  444. margin-top: px2vw(18);
  445. margin-bottom: px2vw(18);
  446. }
  447. .ylrz-test-a-img {
  448. width: px2vw(22);
  449. }
  450. .ylrz-test-a-text {
  451. margin-left: px2vw(18);
  452. }
  453. .ylrz-test-btn-box {
  454. margin-top: px2vw(60);
  455. }
  456. .ylrz-test-btn-red {
  457. width: px2vw(200);
  458. height: px2vw(58);
  459. background: #EA252C;
  460. border-radius: px2vw(8);
  461. font-size: px2vw(24);
  462. color: #FFFFFF;
  463. line-height: px2vw(31);
  464. margin-right: px2vw(30);
  465. }
  466. .ylrz-test-btn-exit {
  467. margin-right: px2vw(47);
  468. position: fixed;
  469. align-self: flex-end;
  470. }
  471. .ylrz-cy-jl{
  472. margin-bottom: px2vw(60);
  473. }
  474. </style>