BankBom.vue 8.1 KB

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