questionBankTest.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <view id="questionBank">
  3. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  4. <swiper-item v-for="(bank,bankIndex) in questionList">
  5. <view class="pageContent">
  6. <view class="pad_8 titBox">
  7. <view class="firstLetter">
  8. <view class="leftLetters">
  9. <view class="btnType">单选</view>
  10. <text>1/{{current}}</text>
  11. </view>
  12. <view style="color: #666;font-size: 28rpx;">03:25:06</view>
  13. <view class="leftLetters"></view>
  14. </view>
  15. <view class="titles">
  16. <rich-text :nodes="bank.content"></rich-text>
  17. </view>
  18. <view class="">
  19. <template v-if="bank.type == 4">
  20. <view v-if="ques[bankIndex]">
  21. <view v-for="(item, index) in bank.jsonStr[0].optionsList" :key="index"
  22. class="lisSty">
  23. <view :class="{right:(item.value == ques[bankIndex]) && (ques[bankIndex] == ans[bankIndex]),wrong:(item.value == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</view>
  24. {{ item.content }}
  25. </view>
  26. </view>
  27. <!-- <view v-if="!ques[bankIndex]">
  28. <view v-for="(item, index) in bank.jsonStr[0].optionsList" :key="index" @click="click" :data-value="item.value" class="lisSty">
  29. <text class="activeTI">{{ ast[index] }}</text>
  30. {{ item.content }}
  31. </view>
  32. </view> -->
  33. </template>
  34. <view v-if="ques[bankIndex] ">
  35. <view v-for="(item, index) in bank.jsonStr" :key="index"
  36. class="lisSty">
  37. <view :class="{right:(item.value == ques[bankIndex]) && (ques[bankIndex] == ans[bankIndex]),wrong:(item.value == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</view>
  38. {{ item.label }}
  39. </view>
  40. </view>
  41. <view v-if="!ques[bankIndex]">
  42. <view v-for="(item, index) in bank.jsonStr" :key="index" @click="click" :data-value="item.value" class="lisSty">
  43. <text class="activeTI">{{ ast[index] }}</text>
  44. {{ item.label }}
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view v-if="ques[bankIndex]">
  50. <view class="pad_8 answer">
  51. <view>正确答案:{{ans[bankIndex]}}</view>
  52. <view>我的答案:{{ques[bankIndex]}}</view>
  53. </view>
  54. <view class="pad_8 answerInfos">
  55. <view class="answerTitle">答案解析</view>
  56. <view class="answerContent">
  57. <rich-text :nodes="bank.analysisContent"></rich-text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </swiper-item>
  63. </swiper>
  64. <view class="footer_btn">
  65. <view @click="collect">收藏</view>
  66. <view @click="openFooterTab">答题卡</view>
  67. <view @click="submit">交卷</view>
  68. </view>
  69. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  70. <view class="popupView">
  71. <view class="popupTops">
  72. <view class="topIcon"></view>
  73. 点击编号即可跳转至对应题目
  74. </view>
  75. <view class="popupContent">
  76. <scroll-view scroll-y="true" style="height: 506rpx;">
  77. <view class="boxSty">
  78. <view v-for="(item, index) in questionList" :key="index" :data-index="index" @click="changeIndex" :class="{disabled:index>=5}" class="liListSty">{{ index + 1 }}</view>
  79. </view>
  80. </scroll-view>
  81. </view>
  82. </view>
  83. </u-popup>
  84. <view class="dialog" v-if="showDialog">
  85. <view class="text">左右滑动切换上下题</view>
  86. <view class="btn" @click="hideDialog">我知道了</view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. export default {
  92. data() {
  93. return {
  94. id:'',
  95. current:0,
  96. questionList:[],
  97. ast: ['A', 'B', 'C', 'D',],
  98. ans:[1,2,3,4,1],
  99. ques:['','','','',''],
  100. show: false,
  101. showDialog:true,
  102. bankList: [
  103. [
  104. {
  105. label: '1',
  106. value: 1
  107. },
  108. {
  109. label: '2',
  110. value: 2
  111. },
  112. {
  113. label: '3',
  114. value: 3
  115. },
  116. {
  117. label: '4',
  118. value: 4
  119. }
  120. ],
  121. [
  122. {
  123. label: '5',
  124. value: 1
  125. },
  126. {
  127. label: '6',
  128. value: 2
  129. },
  130. {
  131. label: '7',
  132. value: 3
  133. },
  134. {
  135. label: '8',
  136. value: 4
  137. }
  138. ],
  139. [
  140. {
  141. label: '9',
  142. value: 1
  143. },
  144. {
  145. label: '10',
  146. value: 2
  147. },
  148. {
  149. label: '11',
  150. value: 3
  151. },
  152. {
  153. label: '12',
  154. value: 4
  155. }
  156. ],
  157. [
  158. {
  159. label: '13',
  160. value: 1
  161. },
  162. {
  163. label: '14',
  164. value: 2
  165. },
  166. {
  167. label: '15',
  168. value: 3
  169. },
  170. {
  171. label: '17',
  172. value: 4
  173. }
  174. ],
  175. [
  176. {
  177. label: '18',
  178. value: 1
  179. },
  180. {
  181. label: '19',
  182. value: 2
  183. },
  184. {
  185. label: '21',
  186. value: 3
  187. },
  188. {
  189. label: '22',
  190. value: 4
  191. }
  192. ]
  193. ]
  194. };
  195. },
  196. onLoad(option){
  197. this.id = option.id;
  198. this.goodsQuestionList()
  199. },
  200. methods: {
  201. goodsQuestionList() {
  202. this.$api.goodsQuestionList({
  203. examId:this.id
  204. }).then(res => {
  205. console.log(res)
  206. res.data.data.forEach(item => {
  207. item.jsonStr = JSON.parse(item.jsonStr)
  208. })
  209. this.questionList = res.data.data;
  210. console.log(this.questionList[0])
  211. })
  212. },
  213. openFooterTab() {
  214. this.show = true;
  215. },
  216. hideDialog() {
  217. this.showDialog = false
  218. },
  219. changeIndex(e) {
  220. let index = e.currentTarget.dataset.index
  221. if(index >= 5) {
  222. uni.showToast({
  223. title: '返回详情购买后即可继续',
  224. duration: 2000,
  225. icon:'none'
  226. });
  227. return;
  228. }
  229. this.current = e.currentTarget.dataset.index
  230. },
  231. swiperChange(e) {
  232. this.current = e.detail.current;
  233. },
  234. submit() {
  235. uni.showToast({
  236. title: '不能试做返回详情购买后即可交卷~',
  237. duration: 2000,
  238. icon:'none'
  239. });
  240. return;
  241. },
  242. collect() {
  243. uni.showToast({
  244. title: '返回详情购买后即可收藏~',
  245. duration: 2000,
  246. icon:'none'
  247. });
  248. return;
  249. },
  250. click(e) {
  251. if(this.ques[this.current]) return;
  252. let value = e.currentTarget.dataset.value;
  253. this.ques[this.current] = value;
  254. this.ques = Object.assign({},this.ques)
  255. }
  256. }
  257. };
  258. </script>
  259. <style lang="scss" scoped>
  260. .swiper {
  261. width:100%;
  262. height:100vh;
  263. }
  264. .lisSty {
  265. margin-bottom: 16rpx;
  266. }
  267. .activeTI {
  268. vertical-align: middle;
  269. display: inline-block;
  270. border: 1rpx solid #eee;
  271. border-radius: 50rpx;
  272. height: 48rpx;
  273. line-height: 46rpx;
  274. text-align: center;
  275. width: 48rpx;
  276. margin-right: 15rpx;
  277. color: #666;
  278. font-size: 30rpx;
  279. &.right {
  280. color:#fff;
  281. background:green;
  282. }
  283. &.wrong {
  284. color:#fff;
  285. background:red;
  286. }
  287. }
  288. .titles {
  289. margin-bottom: 24rpx;
  290. }
  291. .titBox {
  292. padding: 41rpx 25rpx 24rpx 25rpx;
  293. }
  294. .firstLetter {
  295. display: flex;
  296. justify-content: space-between;
  297. align-items: center;
  298. margin-bottom: 30rpx;
  299. .leftLetters {
  300. display: flex;
  301. align-items: center;
  302. width: 220rpx;
  303. .btnType {
  304. padding: 5rpx 10rpx;
  305. border: 1rpx solid #007aff;
  306. border-radius: 10rpx;
  307. background-color: rgba(0, 122, 255, 0.1);
  308. font-size: 28rpx;
  309. color: #007aff;
  310. margin-right: 15rpx;
  311. }
  312. }
  313. }
  314. .popupView {
  315. height: 100%;
  316. padding-bottom: 100rpx;
  317. .popupTops {
  318. height: 77rpx;
  319. border-bottom: 1rpx solid #eee;
  320. text-align: center;
  321. line-height: 77rpx;
  322. font-size: 24rpx;
  323. color: #999;
  324. position: relative;
  325. .topIcon {
  326. position: absolute;
  327. top: 10rpx;
  328. left: 50%;
  329. transform: translateX(-50%);
  330. width: 80rpx;
  331. height: 8rpx;
  332. background-color: #999;
  333. border-radius: 4rpx;
  334. }
  335. }
  336. .popupContent {
  337. }
  338. }
  339. .pageContent {
  340. background-color: #eaeef1;
  341. min-height: 100vh;
  342. padding-top: 8rpx;
  343. padding-bottom: 100rpx;
  344. }
  345. .pad_8 {
  346. background-color: #fff;
  347. margin: 0rpx 8rpx 8rpx;
  348. border-radius: 16rpx;
  349. }
  350. .answer {
  351. height: 80rpx;
  352. line-height: 80rpx;
  353. padding: 0rpx 24rpx;
  354. display: flex;
  355. align-items: center;
  356. justify-content: space-between;
  357. color: #666;
  358. font-size: 30rpx;
  359. }
  360. .footer_btn {
  361. background-color: #fff;
  362. z-index: 10078;
  363. position: fixed;
  364. bottom: 0rpx;
  365. display: flex;
  366. align-items: center;
  367. justify-content: space-between;
  368. width: 100%;
  369. height: 98rpx;
  370. padding: 0rpx 38rpx;
  371. border-top: 1rpx solid #eee;
  372. }
  373. .boxSty {
  374. padding: 44rpx 41rpx 0rpx;
  375. }
  376. .liListSty {
  377. width: 88rpx;
  378. height: 88rpx;
  379. border-radius: 32rpx;
  380. background-color: #ff3b30;
  381. text-align: center;
  382. line-height: 88rpx;
  383. color: #fff;
  384. font-size: 32rpx;
  385. float: left;
  386. margin: 20rpx 23rpx;
  387. &.disabled {
  388. border:1rpx solid #EEEEEE;
  389. color:#EEEEEE;
  390. background: none;
  391. }
  392. }
  393. .answerInfos {
  394. padding: 25rpx 25rpx 25rpx 23rpx;
  395. }
  396. .answerTitle {
  397. margin-bottom: 28rpx;
  398. color: #666;
  399. font-size: 30rpx;
  400. }
  401. .answerContent {
  402. font-size: 30rpx;
  403. color: #666;
  404. }
  405. .dialog {
  406. position: fixed;
  407. left:0;
  408. top:0;
  409. width:100%;
  410. height:100%;
  411. background-color: rgba(0,0,0,0.8);
  412. display: flex;
  413. flex-direction: column;
  414. align-items: center;
  415. justify-content: center;
  416. z-index: 20000;
  417. .text {
  418. font-size: 32rpx;
  419. color: #FFFFFF;
  420. text-align: center;
  421. }
  422. .btn {
  423. width: 242rpx;
  424. height: 82rpx;
  425. border: 2rpx solid #FFFFFF;
  426. border-radius: 16rpx;
  427. text-align: center;
  428. line-height: 82rpx;
  429. margin:41rpx auto;
  430. color:#fff;
  431. font-size: 32rpx;
  432. }
  433. }
  434. </style>