BankBom.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div>
  3. <view class="bank-control fl_b">
  4. <view class="fl_b left">
  5. <view class="btn-item" style="" @click="openFooterTab">
  6. <image src="/static/icon_sheet.png"></image>
  7. <text>答题卡</text>
  8. </view>
  9. <view class="btn-item" @click="$emit('submit')">
  10. <image src="/static/icon_paper.png" mode=""></image>
  11. <text @click="$emit('submit')">交卷</text>
  12. </view>
  13. </view>
  14. <view class="fl">
  15. <view class="tab up" @click="prev">上一题</view>
  16. <view class="tab down" @click="next">下一题</view>
  17. </view>
  18. <view class="collect" @click="collect" v-if="isShowCollect">
  19. <image v-if="true" src="/static/icon_star.png"></image>
  20. <image v-else src="/static/icon_star_sel.png"></image>
  21. </view>
  22. </view>
  23. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  24. <view class="popupView">
  25. <view class="popupTops">
  26. <view class="topIcon"></view>
  27. 点击编号即可跳转至对应题目
  28. </view>
  29. <view class="popupContent">
  30. <scroll-view scroll-y="true" style="height: 506rpx">
  31. <view class="boxSty">
  32. <view
  33. v-for="(item, index) in questionList"
  34. :key="index"
  35. @click="changeIndex(index)"
  36. :class="{
  37. isRight: bankType == 1 && isRight(item, index),
  38. isWrong: bankType == 1 && isWrong(item, index),
  39. isPart: bankType == 1 && isPart(item, index),
  40. isOver: bankType == 1 && isOver(item, index),
  41. check_ans: bankType == 2 && isCheck(item, index),
  42. }"
  43. class="liListSty"
  44. >
  45. {{ index + 1 }}
  46. </view>
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </view>
  51. </u-popup>
  52. </div>
  53. </template>
  54. <script>
  55. export default {
  56. name: "SaasMiniprogramBankBom",
  57. props: {
  58. isShowCollect: {
  59. type: Boolean,
  60. default: true,
  61. },
  62. isCollect: {
  63. type: Boolean,
  64. default: false,
  65. },
  66. questionList: {
  67. type: Array,
  68. default: () => {
  69. return [];
  70. },
  71. },
  72. bankType: {
  73. type: Number,
  74. },
  75. current: {
  76. type: Number,
  77. },
  78. },
  79. data() {
  80. return {
  81. show: false,
  82. };
  83. },
  84. mounted() {},
  85. methods: {
  86. changeIndex(index) {
  87. this.$emit("update:current", index);
  88. },
  89. prev() {
  90. if (this.current == 0) {
  91. uni.showToast({
  92. icon: "none",
  93. title: "已经是第一题了!",
  94. });
  95. return;
  96. }
  97. this.changeIndex(this.current - 1);
  98. },
  99. next() {
  100. if (this.current >= this.questionList.length - 1) {
  101. uni.showToast({
  102. icon: "none",
  103. title: "已经是最后一题了!",
  104. });
  105. return;
  106. }
  107. this.changeIndex(this.current + 1);
  108. },
  109. collect() {
  110. if (!this.isCollect) {
  111. this.$api
  112. .collectQuestion({
  113. examId: this.id,
  114. questionId: this.questionList[index].questionId,
  115. goodsId: this.goodsId || "",
  116. orderGoodsId: this.orderGoodsId,
  117. doMode: 1, //做题模式 1章卷 2随机练习
  118. })
  119. .then((res) => {
  120. if (res.data.code == 200) {
  121. this.$set(this.collectList, index, true);
  122. uni.showToast({
  123. title: "收藏成功",
  124. duration: 2000,
  125. icon: "none",
  126. });
  127. this.getCollectInfo(index);
  128. }
  129. });
  130. } else {
  131. this.$api
  132. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  133. .then((res) => {
  134. if (res.data.code == 200) {
  135. this.$set(this.collectList, index, false);
  136. uni.showToast({
  137. title: "取消收藏成功",
  138. duration: 2000,
  139. icon: "none",
  140. });
  141. }
  142. });
  143. }
  144. return;
  145. },
  146. openFooterTab() {
  147. this.show = true;
  148. },
  149. isCheck(item, index) {
  150. // 案例题处理
  151. let { ques, type, ans } = item;
  152. if (type == 4) {
  153. return ans.length == ques.length;
  154. }
  155. if (ques) {
  156. return true;
  157. }
  158. },
  159. isRight(item, index) {
  160. //单选
  161. if (this.questionList[index].ques) {
  162. if (item.type == 1) {
  163. return this.questionList[index].ques == this.questionList[index].ans;
  164. //多选
  165. } else if (item.type == 2) {
  166. //每一项都相等
  167. return this.questionList[index].ans.every((item, i) => {
  168. return item == this.questionList[index].ques[i];
  169. });
  170. //判断
  171. } else if (item.type == 3) {
  172. return this.questionList[index].ques == this.questionList[index].ans;
  173. // } else if (item.type == 5) {
  174. // if(this.questionList[index].ques.text){
  175. // return true
  176. // }else{
  177. // return false
  178. // }
  179. } else {
  180. return false;
  181. }
  182. } else {
  183. return false;
  184. }
  185. },
  186. isWrong(item, index) {
  187. if (this.questionList[index].ques) {
  188. //单选
  189. if (item.type == 1) {
  190. return this.questionList[index].ques != this.questionList[index].ans;
  191. //多选
  192. } else if (item.type == 2) {
  193. //每一项都相等
  194. return this.questionList[index].ques.some((item, i) => {
  195. return this.questionList[index].ans.indexOf(item) == -1;
  196. });
  197. //判断
  198. } else if (item.type == 3) {
  199. return this.questionList[index].ques != this.questionList[index].ans;
  200. } else {
  201. return false;
  202. }
  203. } else {
  204. return false;
  205. }
  206. },
  207. isPart(item, index) {
  208. if (this.questionList[index].ques) {
  209. if (item.type == 2) {
  210. let isWrong = this.questionList[index].ques.some((item, i) => {
  211. return this.questionList[index].ans.indexOf(item) == -1;
  212. });
  213. let isRight = this.questionList[index].ans.every((item, i) => {
  214. return item == this.questionList[index].ques[i];
  215. });
  216. if (!isRight && !isWrong) {
  217. return true;
  218. }
  219. }
  220. } else {
  221. return false;
  222. }
  223. },
  224. isOver(item, index) {
  225. if (this.questionList[index].ques) {
  226. if (item.type == 4) {
  227. //案例题
  228. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  229. if (
  230. jsonItem.type == 1 ||
  231. jsonItem.type == 2 ||
  232. jsonItem.type == 3
  233. ) {
  234. if (item.ques[indexs]) {
  235. return true;
  236. } else {
  237. return false;
  238. }
  239. } else if (jsonItem.type == 5) {
  240. if (
  241. item.ques[indexs] &&
  242. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  243. ) {
  244. console.log("chil");
  245. return true;
  246. } else {
  247. return false;
  248. }
  249. }
  250. });
  251. if (isOver) {
  252. return true;
  253. } else {
  254. return false;
  255. }
  256. } else if (item.type == 5) {
  257. //简答题
  258. //每一项都相等
  259. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  260. return true;
  261. }
  262. //判断
  263. } else {
  264. return false;
  265. }
  266. } else {
  267. return false;
  268. }
  269. },
  270. },
  271. };
  272. </script>
  273. <style lang="scss" scoped>
  274. .bank-control {
  275. background-color: #fff;
  276. z-index: 10078;
  277. position: fixed;
  278. bottom: 0rpx;
  279. width: 100%;
  280. height: 120rpx;
  281. padding: 16rpx 28rpx 16rpx 48rpx;
  282. .left {
  283. width: 180rpx;
  284. }
  285. .btn-item {
  286. text {
  287. color: #333333;
  288. font-size: 24rpx;
  289. margin-top: 10rpx;
  290. display: block;
  291. }
  292. }
  293. image {
  294. width: 40rpx;
  295. height: 40rpx;
  296. display: block;
  297. margin: 0 auto;
  298. }
  299. .tab {
  300. height: 88rpx;
  301. line-height: 88rpx;
  302. text-align: center;
  303. border-radius: 16rpx;
  304. font-size: 30rpx;
  305. padding: 0 56rpx;
  306. }
  307. .up {
  308. background: #e5f1ff;
  309. color: #498afe;
  310. }
  311. .down {
  312. background: #498afe;
  313. color: #ffffff;
  314. margin-left: 28rpx;
  315. }
  316. .collect {
  317. position: fixed;
  318. top: 50rpx;
  319. right: 42rpx;
  320. }
  321. }
  322. .popupView {
  323. height: 100%;
  324. padding-bottom: 100rpx;
  325. .popupTops {
  326. height: 77rpx;
  327. border-bottom: 1rpx solid #eee;
  328. text-align: center;
  329. line-height: 77rpx;
  330. font-size: 24rpx;
  331. color: #999;
  332. position: relative;
  333. .topIcon {
  334. position: absolute;
  335. top: 10rpx;
  336. left: 50%;
  337. transform: translateX(-50%);
  338. width: 80rpx;
  339. height: 8rpx;
  340. background-color: #999;
  341. border-radius: 4rpx;
  342. }
  343. }
  344. .boxSty {
  345. padding: 44rpx 41rpx 0rpx;
  346. }
  347. .liListSty {
  348. border: 1rpx solid #eeeeee;
  349. width: 88rpx;
  350. height: 88rpx;
  351. border-radius: 32rpx;
  352. text-align: center;
  353. line-height: 88rpx;
  354. color: #333;
  355. font-size: 32rpx;
  356. float: left;
  357. margin: 20rpx 23rpx;
  358. &.isRight {
  359. border: 1rpx solid #eeeeee;
  360. color: #fff;
  361. background: #36c75a;
  362. }
  363. &.isWrong {
  364. border: 1rpx solid #eeeeee;
  365. color: #fff;
  366. background: #ff3b30;
  367. }
  368. &.isPart {
  369. border: 1rpx solid #eeeeee;
  370. color: #fff;
  371. background: #ffc53d;
  372. }
  373. &.isOver {
  374. border: 1rpx solid #eeeeee;
  375. color: #fff;
  376. background: blue;
  377. }
  378. &.check_ans {
  379. border: 1rpx solid #eeeeee;
  380. color: #fff;
  381. background: #007aff;
  382. }
  383. }
  384. }
  385. </style>