questionBank.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915
  1. <template>
  2. <view id="questionBank">
  3. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" :statusBar="true" title="试卷"></uni-nav-bar>
  4. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  5. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  6. <view class="pageContent">
  7. <view class="pad_8 titBox">
  8. <view class="firstLetter">
  9. <view class="leftLetters">
  10. <view class="btnType">
  11. <text v-if="bank.type == 1">单选</text>
  12. <text v-if="bank.type == 2">多选</text>
  13. <text v-if="bank.type == 3">判断</text>
  14. <text v-if="bank.type == 4">案例题</text>
  15. <text v-if="bank.type == 5">简答题</text>
  16. </view>
  17. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  18. </view>
  19. <view style="color: #666;font-size: 28rpx;">{{ countdown(lastTime) }}</view>
  20. <view class="leftLetters"></view>
  21. </view>
  22. <view class="titles"><rich-text :nodes="bank.content"></rich-text></view>
  23. </view>
  24. <view class="pad_8 titBox">
  25. <template v-if="bank.type == 1">
  26. <view v-if="!bank.ques">
  27. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId, bankIndex)">
  28. <view class="activeTI">{{ ast[index] }}</view>
  29. <view class="flex_auto">{{ item.content }}</view>
  30. </view>
  31. </view>
  32. <view v-if="bank.ques">
  33. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  34. <text
  35. :class="{ right: item.optionsId == bank.ques || item.optionsId == bank.ans, wrong: item.optionsId == bank.ques && bank.ques != bank.ans }"
  36. class="activeTI"
  37. >
  38. {{ ast[index] }}
  39. </text>
  40. <view class="flex_auto">{{ item.content }}</view>
  41. </view>
  42. </view>
  43. <view v-if="bank.ques">
  44. <view class="pad_8 answer">
  45. <view>正确答案:{{ ast[bank.ans - 1] }}</view>
  46. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  47. </view>
  48. <view class="pad_8 answerInfos">
  49. <view class="answerTitle">答案解析</view>
  50. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  51. </view>
  52. </view>
  53. </template>
  54. <template v-if="bank.type == 2">
  55. <view v-if="!bank.ques">
  56. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId, bankIndex, index)">
  57. <view :class="{ checked: item.checked }" class="activeTI">{{ ast[index] }}</view>
  58. <view class="flex_auto">{{ item.content }}</view>
  59. </view>
  60. </view>
  61. <view v-if="!bank.ques" class="submit_checkbox" @click="checkboxSubmit(bankIndex)">确认答案</view>
  62. <view v-if="bank.ques">
  63. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  64. <text
  65. :class="{
  66. right: bank.ques.indexOf(item.optionsId) != -1 || bank.ans.indexOf(item.optionsId) != -1,
  67. wrong: bank.ques.indexOf(item.optionsId) != -1 && bank.ans.indexOf(item.optionsId) == -1
  68. }"
  69. class="activeTI"
  70. >
  71. {{ ast[index] }}
  72. </text>
  73. <view class="flex_auto">{{ item.content }}</view>
  74. </view>
  75. </view>
  76. <view v-if="bank.ques">
  77. <view class="pad_8 answer">
  78. <view>
  79. 正确答案:
  80. <text v-for="ansItem in bank.ans">{{ ast[ansItem - 1] }}</text>
  81. </view>
  82. <view>
  83. 我的答案:
  84. <text v-for="quesItem in bank.ques">{{ ast[quesItem - 1] }}</text>
  85. </view>
  86. </view>
  87. <view class="pad_8 answerInfos">
  88. <view class="answerTitle">答案解析</view>
  89. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  90. </view>
  91. </view>
  92. </template>
  93. <template v-if="bank.type == 3">
  94. <view v-if="!bank.ques">
  95. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index, bankIndex)">
  96. <view class="activeTI">{{ ast[index] }}</view>
  97. {{ item }}
  98. </view>
  99. </view>
  100. <view v-if="bank.ques">
  101. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  102. <text :class="{ right: index == bank.ques || index == bank.ans, wrong: index == bank.ques && bank.ques != bank.ans }" class="activeTI">
  103. {{ ast[index] }}
  104. </text>
  105. {{ item }}
  106. </view>
  107. </view>
  108. <view v-if="bank.ques">
  109. <view class="pad_8 answer">
  110. <view>正确答案:{{ ast[bank.ans] }}</view>
  111. <view>我的答案:{{ ast[bank.ques] }}</view>
  112. </view>
  113. <view class="pad_8 answerInfos">
  114. <view class="answerTitle">答案解析</view>
  115. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  116. </view>
  117. </view>
  118. </template>
  119. <!-- 简答题 -->
  120. <template v-if="bank.type == 5">
  121. <view class="ans">
  122. <view class="ans_input" v-if="!bank.ques">
  123. <view class="top flex">
  124. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/08-10_032.jpg" mode=""></image>
  125. <view class="progress">0/4</view>
  126. <view class="submit" @click="submitAns(bankIndex)">确认答案</view>
  127. </view>
  128. <view class="textarea"><textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea></view>
  129. <view class="imgs">
  130. <view class="img" v-for="(img, imgIndex) in bank.ansText.imageList">
  131. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  132. <image :src="$method.splitImgHost(img, true)"></image>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="ans_submit answerInfos" v-if="bank.ques">
  137. <view class="answerTitle">答案我的</view>
  138. {{ bank.ques.text }}
  139. <view class="imgs"><image class="img" v-for="ques in bank.ques.imageList" :src="$method.splitImgHost(ques, true)"></image></view>
  140. </view>
  141. </view>
  142. <view v-if="bank.ques">
  143. <view class="pad_8 answerInfos">
  144. <view class="answerTitle">答案解析</view>
  145. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  146. </view>
  147. </view>
  148. </template>
  149. <!-- 案例题 -->
  150. <template v-if="bank.type == 4">
  151. <view class="tabs">
  152. <view
  153. class="tab"
  154. :class="{ current: tabIndex == bank.current }"
  155. :key="tabIndex"
  156. v-for="(tab, tabIndex) in bank.jsonStr"
  157. @click="tabSelect(tabIndex, bankIndex)"
  158. >
  159. 问题{{ tabIndex }}
  160. </view>
  161. </view>
  162. <view v-for="(ansItem, ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  163. <view class="titles"><rich-text :nodes="ansItem.content"></rich-text></view>
  164. <template v-if="ansItem.type == 1">
  165. <view v-if="!bank.ques[ansIndex]">
  166. <view
  167. v-for="(option, childIndex) in ansItem.optionsList"
  168. :key="childIndex"
  169. class="lisSty"
  170. @click="radioSelectChild(option.optionsId, ansIndex, bankIndex)"
  171. >
  172. <view class="activeTI">{{ ast[childIndex] }}</view>
  173. <rich-text class="textChild" :nodes="option.content"></rich-text>
  174. </view>
  175. </view>
  176. <view v-if="bank.ques[ansIndex]">
  177. <view v-for="(option, childIndex) in ansItem.optionsList" :key="index" class="lisSty">
  178. <text
  179. :class="{
  180. right: option.optionsId == bank.ques[ansIndex] || option.optionsId == bank.ans[ansIndex],
  181. wrong: option.optionsId == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  182. }"
  183. class="activeTI"
  184. >
  185. {{ ast[childIndex] }}
  186. </text>
  187. <rich-text :nodes="option.content"></rich-text>
  188. </view>
  189. </view>
  190. <view v-if="bank.ques[ansIndex]">
  191. <view class="pad_8 answer">
  192. <view>正确答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  193. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  194. </view>
  195. <view class="pad_8 answerInfos">
  196. <view class="answerTitle">答案解析</view>
  197. <view class="answerContent"><rich-text :nodes="option.analysisContent"></rich-text></view>
  198. </view>
  199. </view>
  200. </template>
  201. <template v-if="ansItem.type == 2">
  202. <view v-if="!bank.ques[ansIndex]">
  203. <view
  204. v-for="(option, childindex) in ansItem.optionsList"
  205. :key="childindex"
  206. class="lisSty"
  207. @click="checkboxSelectChild(bankIndex, ansIndex, childindex)"
  208. >
  209. <view :class="{ checked: option.checked }" class="activeTI">{{ ast[childindex] }}</view>
  210. <rich-text :nodes="option.content"></rich-text>
  211. </view>
  212. </view>
  213. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" @click="checkboxSubmitChild(bankIndex, ansIndex)">确认答案</view>
  214. <view v-if="bank.ques && bank.ques[ansIndex]">
  215. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  216. <text :class="{ right: right(bankIndex, ansIndex, option), wrong: wrong(bankIndex, ansIndex, option) }" class="activeTI">
  217. {{ ast[childindex] }}
  218. </text>
  219. <rich-text :nodes="option.content"></rich-text>
  220. </view>
  221. </view>
  222. <view v-if="bank.ques[ansIndex]">
  223. <view class="pad_8 answer">
  224. <view>
  225. 正确答案:
  226. <text v-for="ansItem1 in bank.ans[ansIndex]">{{ ast[ansItem1 - 1] }}</text>
  227. </view>
  228. <view>
  229. 我的答案:
  230. <text v-for="quesItem in bank.ques[ansIndex]">{{ ast[quesItem - 1] }}</text>
  231. </view>
  232. </view>
  233. <view class="pad_8 answerInfos">
  234. <view class="answerTitle">答案解析</view>
  235. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  236. </view>
  237. </view>
  238. </template>
  239. <template v-if="ansItem.type == 3">
  240. <view v-if="!bank.ques[ansIndex]">
  241. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex, childindex, bankIndex)">
  242. <view class="activeTI">{{ ast[childindex] }}</view>
  243. {{ option }}
  244. </view>
  245. </view>
  246. <view v-if="bank.ques[ansIndex]">
  247. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  248. <text
  249. :class="{
  250. right: childindex == bank.ques[ansIndex] || childindex == bank.ans[ansIndex],
  251. wrong: childindex == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  252. }"
  253. class="activeTI"
  254. >
  255. {{ ast[childindex] }}
  256. </text>
  257. {{ option }}
  258. </view>
  259. </view>
  260. <view v-if="bank.ques[ansIndex]">
  261. <view class="pad_8 answer">
  262. <view>正确答案:{{ ast[bank.ans[ansIndex]] }}</view>
  263. <view>我的答案:{{ ast[bank.ques[ansIndex]] }}</view>
  264. </view>
  265. <view class="pad_8 answerInfos">
  266. <view class="answerTitle">答案解析</view>
  267. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  268. </view>
  269. </view>
  270. </template>
  271. <!-- 简答题 -->
  272. <template v-if="ansItem.type == 5">
  273. <view class="ans">
  274. <view class="ans_input" v-if="!bank.ques[ansIndex]">
  275. <view class="top flex">
  276. <image class="icon" @click="chooseImgChild(bankIndex, ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  277. <view class="progress">0/4</view>
  278. <view class="submit" @click="submitAnsChild(bankIndex, ansIndex)">确认答案</view>
  279. </view>
  280. <view class="textarea"><textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea></view>
  281. <view class="imgs">
  282. <view class="img" v-for="(img, imgIndex) in ansItem.ansText.imageList">
  283. <text @click="deleteImgChild(imgIndex, bankIndex, ansIndex)">x</text>
  284. <image :src="$method.splitImgHost(img, true)"></image>
  285. </view>
  286. </view>
  287. </view>
  288. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex]">
  289. <view class="answerTitle">答案我的</view>
  290. {{ bank.ques[ansIndex].text }}
  291. <view class="imgs">
  292. <image class="img" v-for="ques in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques, true)"></image>
  293. </view>
  294. </view>
  295. </view>
  296. <view v-if="bank.ques[ansIndex]">
  297. <view class="pad_8 answerInfos">
  298. <view class="answerTitle">答案解析</view>
  299. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  300. </view>
  301. </view>
  302. </template>
  303. </view>
  304. </template>
  305. </view>
  306. <view class="footer_btn">
  307. <view class="collect" :class="{ show: goodsId ? true : false }" @click="collect(collectList[bankIndex], bankIndex)">
  308. {{ collectList[bankIndex] ? '已收藏' : '未收藏' }}
  309. </view>
  310. <view @click="openFooterTab">答题卡</view>
  311. <view @click="pdsubmit">交卷</view>
  312. </view>
  313. </view>
  314. </swiper-item>
  315. </swiper>
  316. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  317. <view class="popupView">
  318. <view class="popupTops">
  319. <view class="topIcon"></view>
  320. 点击编号即可跳转至对应题目
  321. </view>
  322. <view class="popupContent">
  323. <scroll-view scroll-y="true" style="height: 506rpx;">
  324. <view class="boxSty">
  325. <view
  326. v-for="(item, index) in questionList"
  327. :key="index"
  328. @click="changeIndex(index)"
  329. :class="{ isRight: isRight(item, index), isWrong: isWrong(item, index) }"
  330. class="liListSty"
  331. >
  332. {{ index + 1 }}
  333. </view>
  334. </view>
  335. </scroll-view>
  336. </view>
  337. </view>
  338. </u-popup>
  339. <view class="dialog" v-if="showDialog">
  340. <view class="text">左右滑动切换上下题</view>
  341. <view class="btn" @click="hideDialog">我知道了</view>
  342. </view>
  343. <view class="dialog_wrap" v-if="testOver">
  344. <view class="bg"></view>
  345. <view class="dialog">
  346. <view class="title">温馨提示</view>
  347. <view class="content">
  348. <view>您已完成所有题目,</view>
  349. <view>快去交卷吧!</view>
  350. </view>
  351. <view class="btns">
  352. <view class="btn" @click="noSubmit()">暂不交卷</view>
  353. <view class="btn active" @click="submitNow()">立即交卷</view>
  354. </view>
  355. </view>
  356. </view>
  357. <view class="dialog_wrap" v-if="isLastCount">
  358. <view class="bg"></view>
  359. <view class="dialog">
  360. <view class="title">温馨提示</view>
  361. <view class="content">
  362. <view>您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view>
  363. </view>
  364. <view class="btns">
  365. <view class="btn" @click="noLeave()">暂不离开</view>
  366. <view class="btn active" @click="leaveNow()">继续离开</view>
  367. </view>
  368. </view>
  369. </view>
  370. <u-popup v-model="showpopups" mode="center" border-radius="24" height="439rpx" width="640rpx" :mask-close-able="false">
  371. <view class="popboxs">
  372. <view class="classTops">温馨提示</view>
  373. <view class="textStys">
  374. {{
  375. cgType === 7
  376. ? '您还未交卷,确定结束做题吗?'
  377. : cgType === 8
  378. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  379. : cgType === 6
  380. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  381. : ''
  382. }}
  383. </view>
  384. <view class="classFootsty" v-if="cgType === 6">
  385. <view class="btnsty btns1" @click="submit">立即交卷</view>
  386. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  387. </view>
  388. <view class="classFootsty" v-if="cgType === 7">
  389. <view class="btnsty btns1" @click="showpopups = false">下次继续</view>
  390. <view class="btnsty btns2" @click="backPages">结束做题</view>
  391. </view>
  392. <view class="classFootsty" v-if="cgType === 8">
  393. <view class="btnsty btns1" @click="submit">立即交卷</view>
  394. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  395. </view>
  396. </view>
  397. </u-popup>
  398. </view>
  399. </template>
  400. <script>
  401. export default {
  402. data() {
  403. return {
  404. showpopups: false,
  405. id: '',
  406. current: 0,
  407. questionList: [],
  408. ast: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  409. judge: ['错误', '正确'],
  410. ans: [],
  411. ques: [],
  412. show: false,
  413. showDialog: true,
  414. bankList: [],
  415. collectList: [],
  416. goodsId: '',
  417. recordId: '',
  418. isSubmit: false,
  419. lastTime: 0,
  420. timer: null,
  421. wrongList: [],
  422. bankType: 0, //试卷类型
  423. needBack: false, //是否是考试
  424. testOver: false,
  425. isLastCount: false, //是否有未答题目
  426. lastCount: 0, //剩余没有回答的题目数
  427. chapterId: 0,
  428. moduleId: 0,
  429. cgType: 0 //对应设计稿弹窗编码
  430. };
  431. },
  432. onLoad(option) {
  433. this.id = option.id;
  434. this.goodsId = option.goodsid;
  435. this.chapterId = option.chapterId;
  436. this.moduleId = option.moduleId;
  437. let isBack = option.isback;
  438. if (isBack) {
  439. console.log(getApp());
  440. let app = getApp();
  441. let globalData = app.globalData;
  442. for (var k in globalData.bankData) {
  443. this[k] = globalData.bankData[k];
  444. }
  445. } else {
  446. this.goodsQuestionList();
  447. // this.wrongRecordExamQuestionList();
  448. this.bankExam();
  449. }
  450. },
  451. onUnload() {
  452. if (this.isSubmit) {
  453. return;
  454. }
  455. //考试试卷 阻止ios手势返回,自动跳回答题页
  456. if (this.needBack) {
  457. let app = getApp();
  458. app.globalData.bankData = this.$data;
  459. uni.navigateTo({
  460. url: '/pages2/bank/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
  461. });
  462. } else {
  463. //点击返回按钮确认允许退出,记录答题记录
  464. this.examRecordEdit();
  465. }
  466. },
  467. methods: {
  468. bankExam() {
  469. this.$api.bankExam(this.id).then(res => {
  470. this.bankType = res.data.data.doType;
  471. if (this.bankType == 2) {
  472. this.needBack = true;
  473. }
  474. });
  475. },
  476. /**
  477. * 获取错题集
  478. */
  479. wrongRecordExamQuestionList() {
  480. this.$api
  481. .wrongRecordExamQuestionList({
  482. examId: this.id,
  483. goodsId: this.goodsId
  484. })
  485. .then(res => {
  486. this.wrongList = res.data.rows;
  487. });
  488. },
  489. /**
  490. * 点击后退按钮
  491. */
  492. clickLeft() {
  493. if (this.bankType == 1) {
  494. let ansCount = this.questionOverNum(); //已答题数
  495. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  496. //所有题目答完
  497. if (this.lastCount == 0) {
  498. // this.testOver = true;
  499. this.cgType = 7;
  500. //未答完
  501. } else {
  502. this.cgType = 8;
  503. // this.isLastCount = true;
  504. }
  505. this.showpopups = true;
  506. } else if (this.bankType == 2) {
  507. let ansCount = this.questionOverNum(); //已答题数
  508. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  509. //所有题目答完
  510. if (this.lastCount == 0) {
  511. this.testOver = true;
  512. //未答完
  513. } else {
  514. this.isLastCount = true;
  515. }
  516. }
  517. },
  518. /**
  519. * 返回上一页
  520. */
  521. backPages() {
  522. this.needBack = false;
  523. uni.navigateBack({
  524. delta: 1
  525. });
  526. },
  527. /**
  528. * 获取已经回答的题目数
  529. */
  530. questionOverNum() {
  531. let count = 0;
  532. this.questionList.forEach(item => {
  533. if (item.type == 1 || item.type == 2 || item.type == 3) {
  534. if (item.ques) {
  535. count++;
  536. }
  537. } else if (item.type == 4) {
  538. //案例题
  539. console.log(item.jsonStr)
  540. let isOver = item.jsonStr.every(jsonItem => {
  541. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  542. if (jsonItem.ques) {
  543. return true;
  544. } else {
  545. return false;
  546. }
  547. } else if (jsonItem.type == 5) {
  548. if (jsonItem.ansText.text.length || jsonItem.ansText.imageList.length) {
  549. return true;
  550. } else {
  551. return false;
  552. }
  553. }
  554. });
  555. if (isOver) {
  556. count++;
  557. console.log(item,444)
  558. }
  559. } else if (item.type == 5) {
  560. //简答题
  561. if (item.ansText.text.length || item.ansText.imageList.length) {
  562. count++;
  563. }
  564. }
  565. });
  566. return count;
  567. },
  568. /**
  569. * 暂不交卷
  570. */
  571. noSubmit() {
  572. //设为允许退出页面
  573. this.needBack = false;
  574. uni.navigateBack({
  575. delta: 1
  576. });
  577. },
  578. /**
  579. * 不离开
  580. */
  581. noLeave() {
  582. this.isLastCount = false;
  583. },
  584. /**
  585. * 立即离开并交卷
  586. */
  587. leaveNow() {
  588. this.needBack = false;
  589. uni.navigateBack({
  590. delta: 1
  591. });
  592. let score = 0; //计算总分
  593. let reportStatus = 0;
  594. let number = 0;
  595. this.questionList.forEach((item, index) => {
  596. if (item.type == 1) {
  597. if (item.ques == item.ans) {
  598. score += item.score;
  599. number++;
  600. }
  601. } else if (item.type == 2) {
  602. let isRight =
  603. item.ques &&
  604. item.ques.every((quesItem, quesIndex) => {
  605. return item.ques[quesIndex] == item.ans[quesIndex];
  606. });
  607. if (isRight) {
  608. score += item.score;
  609. number++;
  610. }
  611. } else if (item.type == 3) {
  612. if (item.ques == item.ans) {
  613. score += item.score;
  614. number++;
  615. }
  616. }
  617. });
  618. // if(score >= 60) {
  619. // reportStatus = 1
  620. // } else {
  621. // reportStatus = 0
  622. // }
  623. this.$api
  624. .examRecordEdit({
  625. examId: this.id,
  626. goodsId: this.goodsId,
  627. // reportStatus:reportStatus,
  628. doQuestionNum: this.questionOverNum(),
  629. recordId: this.recordId,
  630. rightQuestionNum: number,
  631. status: 1,
  632. score: score,
  633. historyExamJson: JSON.stringify(this.questionList)
  634. })
  635. .then(res => {});
  636. },
  637. /**
  638. * 立即交卷
  639. */
  640. submitNow() {
  641. this.showpopups = false;
  642. this.needBack = false;
  643. this.submit();
  644. },
  645. /**
  646. * 离开页面统计回答正确题数
  647. */
  648. examRecordEdit() {
  649. if(!this.isSubmit) {
  650. let number = 0;
  651. let score = 0;
  652. let doQuestionNum = 0;
  653. this.questionList.forEach((item,index) => {
  654. if(item.type == 1) {
  655. if(item.ques == item.ans) {
  656. score += item.score;
  657. number++
  658. }
  659. if(item.ques) {
  660. doQuestionNum++;
  661. }
  662. } else if(item.type == 2) {
  663. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  664. return item.ques[quesIndex] == item.ans[quesIndex]
  665. })
  666. if(isRight) {
  667. score += item.score;
  668. number++
  669. }
  670. if(item.ques && item.ques.length) {
  671. doQuestionNum++;
  672. }
  673. } else if(item.type == 3) {
  674. if(item.ques == item.ans) {
  675. score += item.score;
  676. number++
  677. }
  678. if(item.ques) {
  679. doQuestionNum++;
  680. }
  681. } else if(item == 4) {
  682. if(item.ques.length) {
  683. doQuestionNum++;
  684. }
  685. } else if(item.type == 5) {
  686. if(item.ques) {
  687. doQuestionNum++;
  688. }
  689. }
  690. })
  691. this.$api.examRecordEdit({
  692. examId:this.id,
  693. goodsId:this.goodsId,
  694. recordId: this.recordId,
  695. rightQuestionNum:number,
  696. status:0,
  697. doQuestionNum:doQuestionNum,
  698. historyExamJson:JSON.stringify(this.questionList)
  699. }).then(res => {
  700. })
  701. }
  702. },
  703. /**
  704. * 记录总题数
  705. */
  706. examRecord() {
  707. this.$api
  708. .examRecord({
  709. chapterExamId: this.chapterId || 0,
  710. moduleExamId: this.moduleId || 0,
  711. examId: this.id,
  712. goodsId: this.goodsId,
  713. totalQuestionNum: this.questionList.length
  714. })
  715. .then(res => {
  716. this.recordId = res.data.data;
  717. });
  718. },
  719. /**
  720. * @param {Object} second倒计时过滤器
  721. */
  722. countdown(second) {
  723. if (second) {
  724. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  725. let m = parseInt((second / 60) % 60); // 计算分数
  726. let s = parseInt(second % 60); // 计算当前秒数
  727. if (h < 10) h = '0' + h;
  728. if (m < 10) m = '0' + m;
  729. if (s < 10) s = '0' + s;
  730. return h + ':' + m + ':' + s;
  731. } else {
  732. return '';
  733. }
  734. },
  735. /**
  736. * 请求题目列表
  737. */
  738. goodsQuestionList() {
  739. this.$api
  740. .goodsQuestionList({
  741. examId: this.id
  742. })
  743. .then(res => {
  744. this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  745. //考试时间到了自动交卷
  746. if (this.lastTime) {
  747. this.timer = setInterval(() => {
  748. if (this.lastTime <= 0) {
  749. clearInterval(this.timer);
  750. uni.showModal({
  751. title: '提示',
  752. content: '考试时间到,自动交卷',
  753. confirmText: '确定',
  754. showCancel: false,
  755. success: res => {
  756. this.submit();
  757. }
  758. });
  759. return;
  760. }
  761. this.lastTime--;
  762. }, 1000);
  763. } else {
  764. }
  765. res.data.data.forEach((item, index) => {
  766. if (typeof item.jsonStr == 'string') {
  767. item.jsonStr = JSON.parse(item.jsonStr);
  768. if (item.type == 2) {
  769. //多选
  770. item.jsonStr.forEach(str => {
  771. str.optionsId = '' + str.optionsId;
  772. });
  773. let arr = item.answerQuestion.split(',');
  774. arr.forEach((a, i) => {
  775. arr[i] = '' + a;
  776. });
  777. item.ans = arr;
  778. return;
  779. } else if (item.type == 5) {
  780. //简答题
  781. item.ansText = {
  782. text: '',
  783. imageList: []
  784. };
  785. } else if (item.type == 4) {
  786. //案例题
  787. console.log(item.jsonStr);
  788. item.ques = [];
  789. item.current = 0;
  790. let ansArr = [];
  791. item.jsonStr.forEach((json, index) => {
  792. if (json.type == 1) {
  793. json.ques = []
  794. ansArr[index] = json.answerQuestion;
  795. } else if (json.type == 2) {
  796. json.ques = []
  797. json.optionsList.forEach(str => {
  798. str.optionsId = '' + str.optionsId;
  799. });
  800. let arr = json.answerQuestion.split(',');
  801. arr.forEach((a, i) => {
  802. arr[i] = '' + a;
  803. });
  804. ansArr[index] = arr;
  805. } else if (json.type == 3) {
  806. json.ques = []
  807. ansArr[index] = json.answerQuestion;
  808. } else if (json.type == 5) {
  809. ansArr[index] = {
  810. text: '',
  811. imageList: []
  812. };
  813. json.ansText = {
  814. text: '',
  815. imageList: []
  816. };
  817. }
  818. });
  819. item.ans = ansArr;
  820. return;
  821. }
  822. item.ans = item.answerQuestion;
  823. }
  824. });
  825. this.questionList = res.data.data;
  826. this.lastCount = this.questionList.length;
  827. this.examRecord();
  828. this.getCollectInfo(this.current);
  829. });
  830. },
  831. /**
  832. * @param {Object} e单选点击
  833. */
  834. radioSelect(optionsId, bindex) {
  835. if (this.questionList[bindex].ques) return;
  836. this.$set(this.questionList[bindex], 'ques', optionsId);
  837. // 回答错误
  838. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  839. this.$api
  840. .examWrongRecord({
  841. examId: this.id,
  842. goodsId: this.goodsId,
  843. questionId: this.questionList[bindex].questionId,
  844. recordId: this.recordId
  845. })
  846. .then(res => {});
  847. } else {
  848. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  849. // if(question) {
  850. // this.$api.wrongRecordDelete({
  851. // "examId": +this.id,
  852. // "goodsId": +this.goodsId,
  853. // "questionId": this.questionList[bindex].questionId,
  854. // }).then(res => {
  855. // })
  856. // }
  857. }
  858. },
  859. /**
  860. * @param {Object} e案例单选点击
  861. */
  862. radioSelectChild(optionsId, ansIndex, bindex) {
  863. if (this.questionList[bindex].ques[ansIndex]) return;
  864. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  865. },
  866. /**
  867. * @param {Object} 多选点击
  868. */
  869. checkboxSelect(optionsId, bindex, index) {
  870. this.$set(this.questionList[bindex].jsonStr[index], 'checked', !this.questionList[bindex].jsonStr[index].checked);
  871. },
  872. /**
  873. * @param {Object} 案例多选点击
  874. */
  875. checkboxSelectChild(bindex, ansIndex, childIndex) {
  876. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex], 'checked', !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked);
  877. },
  878. /**
  879. * @param {Object} 多选确认
  880. */
  881. checkboxSubmit(bindex) {
  882. if (this.questionList[bindex].ques) return;
  883. let arr = [];
  884. this.questionList[bindex].jsonStr.forEach(item => {
  885. if (item.checked) {
  886. arr.push(item.optionsId);
  887. }
  888. });
  889. this.$set(this.questionList[bindex], 'ques', arr);
  890. let isWrong = this.questionList[bindex].ques.some((quesItem, quesIndex) => {
  891. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex];
  892. });
  893. // 回答错误
  894. if (isWrong) {
  895. this.$api
  896. .examWrongRecord({
  897. examId: this.id,
  898. goodsId: this.goodsId,
  899. questionId: this.questionList[bindex].questionId,
  900. recordId: this.recordId
  901. })
  902. .then(res => {});
  903. } else {
  904. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  905. // if(question) {
  906. // this.$api.wrongRecordDelete({
  907. // "examId": +this.id,
  908. // "goodsId": +this.goodsId,
  909. // "questionId": this.questionList[bindex].questionId,
  910. // }).then(res => {
  911. // })
  912. // }
  913. }
  914. },
  915. /**
  916. * @param {Object} 案例多选确认
  917. */
  918. checkboxSubmitChild(bindex, ansIndex) {
  919. if (this.questionList[bindex].ques[ansIndex]) return;
  920. let arr = [];
  921. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  922. if (item.checked) {
  923. arr.push(item.optionsId);
  924. }
  925. });
  926. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  927. },
  928. /**
  929. * @param {Object} index
  930. * @param {Object} bindex
  931. * 判断题
  932. */
  933. judgeSelect(index, bindex) {
  934. if (this.questionList[bindex].ques) return;
  935. this.$set(this.questionList[bindex], 'ques', index + '');
  936. // 回答错误
  937. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  938. this.$api
  939. .examWrongRecord({
  940. examId: this.id,
  941. goodsId: this.goodsId,
  942. questionId: this.questionList[bindex].questionId,
  943. recordId: this.recordId
  944. })
  945. .then(res => {});
  946. } else {
  947. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  948. // if(question) {
  949. // this.$api.wrongRecordDelete({
  950. // "examId": +this.id,
  951. // "goodsId": +this.goodsId,
  952. // "questionId": this.questionList[bindex].questionId,
  953. // }).then(res => {
  954. // })
  955. // }
  956. }
  957. },
  958. /**
  959. * @param {Object} ansindex
  960. * @param {Object} childindex
  961. * @param {Object} bindex
  962. * 案例判断题
  963. */
  964. judgeSelectChild(ansindex, childindex, bindex) {
  965. if (this.questionList[bindex].ques[ansindex]) return;
  966. this.$set(this.questionList[bindex].ques, ansindex, childindex + '');
  967. },
  968. openFooterTab() {
  969. this.show = true;
  970. },
  971. hideDialog() {
  972. this.showDialog = false;
  973. },
  974. changeIndex(index) {
  975. this.current = index;
  976. },
  977. swiperChange(e) {
  978. this.current = e.detail.current;
  979. this.getCollectInfo(this.current);
  980. },
  981. /**
  982. * @param {Object} current
  983. * 获取收藏信息
  984. */
  985. getCollectInfo(current) {
  986. this.$api
  987. .getCollectInfo({
  988. examId: this.id,
  989. questionId: this.questionList[current].questionId,
  990. goodsId: this.goodsId
  991. })
  992. .then(res => {
  993. if (res.data.code == 500) {
  994. this.$set(this.collectList, current, false);
  995. } else if (res.data.code == 200) {
  996. this.$set(this.collectList, current, res.data.data);
  997. }
  998. });
  999. },
  1000. pdsubmit(){
  1001. if (this.bankType == 1) {
  1002. let ansCount = this.questionOverNum(); //已答题数
  1003. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1004. //没有答完
  1005. if (this.lastCount !== 0) {
  1006. this.cgType = 6;
  1007. this.showpopups = true;
  1008. return
  1009. }
  1010. }
  1011. this.submit()
  1012. },
  1013. /**
  1014. * 提交数据
  1015. */
  1016. submit() {
  1017. let score = 0; //计算总分
  1018. let reportStatus = 0;
  1019. let number = 0;
  1020. let doQuestionNum = 0;
  1021. this.questionList.forEach((item,index) => {
  1022. if(item.type == 1) {
  1023. if(item.ques == item.ans) {
  1024. score += item.score;
  1025. number++
  1026. }
  1027. if(item.ques) {
  1028. doQuestionNum++;
  1029. }
  1030. } else if(item.type == 2) {
  1031. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  1032. return item.ques[quesIndex] == item.ans[quesIndex]
  1033. })
  1034. if(isRight) {
  1035. score += item.score;
  1036. number++
  1037. }
  1038. if(item.ques && item.ques.length) {
  1039. doQuestionNum++;
  1040. }
  1041. } else if(item.type == 3) {
  1042. if(item.ques == item.ans) {
  1043. score += item.score;
  1044. number++
  1045. }
  1046. if(item.ques) {
  1047. doQuestionNum++;
  1048. }
  1049. } else if(item.type == 4) {
  1050. if(item.ques && item.ques.length) {
  1051. doQuestionNum++;
  1052. }
  1053. } else if(item.type == 5) {
  1054. if(item.ques) {
  1055. doQuestionNum++;
  1056. }
  1057. }
  1058. })
  1059. // if(score >= 60) {
  1060. // reportStatus = 1
  1061. // } else {
  1062. // reportStatus = 0
  1063. // }
  1064. this.$api.examRecordEdit({
  1065. examId:this.id,
  1066. goodsId:this.goodsId,
  1067. // reportStatus:reportStatus,
  1068. recordId: this.recordId,
  1069. rightQuestionNum:number,
  1070. status:1,
  1071. doQuestionNum:doQuestionNum,
  1072. score:score,
  1073. historyExamJson:JSON.stringify(this.questionList)
  1074. }).then(res => {
  1075. this.isSubmit = true;
  1076. if(res.data.code == 200) {
  1077. uni.showToast({
  1078. title: '交卷成功',
  1079. duration: 2000,
  1080. icon:'none'
  1081. });
  1082. setTimeout(() => {
  1083. uni.redirectTo({
  1084. url:'/pages2/bank/question_report?id='+this.recordId
  1085. })
  1086. },2000)
  1087. }
  1088. })
  1089. },
  1090. /**
  1091. * @param {Object} state
  1092. * @param {Object} index
  1093. * 收藏
  1094. */
  1095. collect(state, index) {
  1096. if (!state) {
  1097. this.$api
  1098. .collectQuestion({
  1099. examId: this.id,
  1100. questionId: this.questionList[index].questionId,
  1101. goodsId: this.goodsId || ''
  1102. })
  1103. .then(res => {
  1104. if (res.data.code == 200) {
  1105. this.$set(this.collectList, index, true);
  1106. uni.showToast({
  1107. title: '收藏成功',
  1108. duration: 2000,
  1109. icon: 'none'
  1110. });
  1111. }
  1112. });
  1113. } else {
  1114. this.$api.deleteCollectQuestion(this.collectList[index].collectQuestionId).then(res => {
  1115. if (res.data.code == 200) {
  1116. this.$set(this.collectList, index, false);
  1117. uni.showToast({
  1118. title: '取消收藏成功',
  1119. duration: 2000,
  1120. icon: 'none'
  1121. });
  1122. }
  1123. });
  1124. }
  1125. return;
  1126. },
  1127. /**
  1128. * @param {Object} imgIndex
  1129. * @param {Object} bankIndex
  1130. * 删除简答图片
  1131. */
  1132. deleteImg(imgIndex, bankIndex) {
  1133. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1134. },
  1135. /**
  1136. * @param {Object} imgIndex
  1137. * @param {Object} bankIndex
  1138. * @param {Object} ansIndex
  1139. * 删除案例题简答图片
  1140. */
  1141. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1142. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex, 1);
  1143. },
  1144. /**
  1145. * @param {Object} bankindex
  1146. * 选择上传图片
  1147. */
  1148. chooseImg(bankindex) {
  1149. uni.chooseImage({
  1150. count: 1, //默认9
  1151. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1152. sourceType: ['album', 'camera'], //从相册选择
  1153. success: res => {
  1154. let self = this;
  1155. // console.log(JSON.stringify(res.tempFilePaths));
  1156. let img = res.tempFilePaths[0];
  1157. uni.getImageInfo({
  1158. src: img,
  1159. success: async res => {
  1160. let canvasWidth = res.width; //图片原始长宽
  1161. let canvasHeight = res.height;
  1162. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1163. uni.compressImage({
  1164. src: img,
  1165. quality: 75,
  1166. width: '50%',
  1167. height: '50%',
  1168. success: async rest => {
  1169. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1170. this.questionList[bankindex].ansText.imageList.push(dir);
  1171. }
  1172. });
  1173. } else {
  1174. const dir = await self.uploadFile(img, 0);
  1175. this.questionList[bankindex].ansText.imageList.push(dir);
  1176. }
  1177. }
  1178. });
  1179. }
  1180. });
  1181. },
  1182. /**
  1183. * @param {Object} bankindex
  1184. * @param {Object} ansindex
  1185. * 案例题选择上传图片
  1186. */
  1187. chooseImgChild(bankindex, ansindex) {
  1188. uni.chooseImage({
  1189. count: 1, //默认9
  1190. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1191. sourceType: ['album', 'camera'], //从相册选择
  1192. success: res => {
  1193. let self = this;
  1194. // console.log(JSON.stringify(res.tempFilePaths));
  1195. let img = res.tempFilePaths[0];
  1196. uni.getImageInfo({
  1197. src: img,
  1198. success: async res => {
  1199. let canvasWidth = res.width; //图片原始长宽
  1200. let canvasHeight = res.height;
  1201. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1202. uni.compressImage({
  1203. src: img,
  1204. quality: 75,
  1205. width: '50%',
  1206. height: '50%',
  1207. success: async rest => {
  1208. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1209. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1210. }
  1211. });
  1212. } else {
  1213. const dir = await self.uploadFile(img, 0);
  1214. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1215. }
  1216. }
  1217. });
  1218. }
  1219. });
  1220. },
  1221. uploadFile(options, int) {
  1222. var self = this;
  1223. return new Promise((resolve, reject) => {
  1224. var data = {
  1225. imageStatus: int
  1226. };
  1227. self.$api.aliyunpolicy(data).then(res => {
  1228. console.log(res.data, 6);
  1229. if (res.data.code != 200) {
  1230. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  1231. return;
  1232. }
  1233. var ossToken = res.data.data.resultContent;
  1234. if (ossToken.host == null || ossToken.host == undefined) {
  1235. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  1236. return;
  1237. }
  1238. uni.uploadFile({
  1239. url: ossToken.host,
  1240. name: 'file',
  1241. filePath: options,
  1242. fileType: 'image',
  1243. header: {
  1244. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1245. },
  1246. formData: {
  1247. key: ossToken.dir,
  1248. OSSAccessKeyId: ossToken.accessid,
  1249. policy: ossToken.policy,
  1250. Signature: ossToken.signature,
  1251. callback: ossToken.callback,
  1252. success_action_status: 200
  1253. },
  1254. success: result => {
  1255. if (result.statusCode === 200) {
  1256. resolve(ossToken.dir);
  1257. } else {
  1258. uni.showToast({
  1259. title: '上传失败',
  1260. icon: 'none'
  1261. });
  1262. return;
  1263. }
  1264. },
  1265. fail: error => {
  1266. uni.showToast({
  1267. title: '上传接口报错' + error,
  1268. icon: 'none'
  1269. });
  1270. return;
  1271. }
  1272. });
  1273. });
  1274. });
  1275. },
  1276. /**
  1277. * @param {Object} type
  1278. * @param {Object} bankindex
  1279. * 简答题答案确认
  1280. */
  1281. submitAns(bankindex) {
  1282. console.log(this.questionList[bankindex]);
  1283. if (!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1284. uni.showToast({
  1285. title: '请输入内容或上传图片',
  1286. duration: 2000,
  1287. icon: 'none'
  1288. });
  1289. return;
  1290. }
  1291. this.$set(this.questionList[bankindex], 'ques', {
  1292. imageList: this.questionList[bankindex].ansText.imageList,
  1293. text: this.questionList[bankindex].ansText.text
  1294. });
  1295. },
  1296. /**
  1297. * @param {Object} bankindex
  1298. * @param {Object} ansindex
  1299. * 案例题简答答案确认
  1300. */
  1301. submitAnsChild(bankindex, ansindex) {
  1302. if (!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1303. uni.showToast({
  1304. title: '请输入内容或上传图片',
  1305. duration: 2000,
  1306. icon: 'none'
  1307. });
  1308. return;
  1309. }
  1310. this.$set(this.questionList[bankindex].ques, ansindex, {
  1311. imageList: this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1312. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text
  1313. });
  1314. },
  1315. isRight(item, index) {
  1316. //单选
  1317. if (this.questionList[index].ques) {
  1318. if (item.type == 1) {
  1319. return this.questionList[index].ques == this.questionList[index].ans;
  1320. //多选
  1321. } else if (item.type == 2) {
  1322. //每一项都相等
  1323. return this.questionList[index].ques.every((item, i) => {
  1324. return item == this.questionList[index].ans[i];
  1325. });
  1326. //判断
  1327. } else if (item.type == 3) {
  1328. return this.questionList[index].ques == this.questionList[index].ans;
  1329. } else {
  1330. return false;
  1331. }
  1332. } else {
  1333. return false;
  1334. }
  1335. },
  1336. right(bankIndex, ansIndex, option) {
  1337. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1338. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 || this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1) {
  1339. return true;
  1340. } else {
  1341. return false;
  1342. }
  1343. } else {
  1344. return false;
  1345. }
  1346. },
  1347. wrong(bankIndex, ansIndex, option) {
  1348. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1349. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 && this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1) {
  1350. return true;
  1351. } else {
  1352. return false;
  1353. }
  1354. } else {
  1355. return false;
  1356. }
  1357. },
  1358. isWrong(item, index) {
  1359. if (this.questionList[index].ques) {
  1360. //单选
  1361. if (item.type == 1) {
  1362. return this.questionList[index].ques != this.questionList[index].ans;
  1363. //多选
  1364. } else if (item.type == 2) {
  1365. //每一项都相等
  1366. return this.questionList[index].ques.some((item, index) => {
  1367. return item != this.questionList[index].ans;
  1368. });
  1369. //判断
  1370. } else if (item.type == 3) {
  1371. return this.questionList[index].ques != this.questionList[index].ans;
  1372. } else {
  1373. return false;
  1374. }
  1375. } else {
  1376. return false;
  1377. }
  1378. },
  1379. tabSelect(index, bankindex) {
  1380. this.$set(this.questionList[bankindex], 'current', index);
  1381. }
  1382. }
  1383. };
  1384. </script>
  1385. <style lang="scss" scoped>
  1386. .swiper {
  1387. width: 100%;
  1388. height: calc(100vh - 44px);
  1389. }
  1390. .lisSty {
  1391. margin-bottom: 16rpx;
  1392. display: flex;
  1393. .flex_auto {
  1394. flex: 1;
  1395. }
  1396. }
  1397. .activeTI {
  1398. vertical-align: middle;
  1399. display: inline-block;
  1400. border: 1rpx solid #eee;
  1401. border-radius: 50rpx;
  1402. height: 48rpx;
  1403. line-height: 46rpx;
  1404. text-align: center;
  1405. width: 48rpx;
  1406. margin-right: 15rpx;
  1407. color: #666;
  1408. font-size: 30rpx;
  1409. &.right {
  1410. color: #fff;
  1411. background: green;
  1412. }
  1413. &.wrong {
  1414. color: #fff;
  1415. background: red;
  1416. }
  1417. &.checked {
  1418. color: #fff;
  1419. background: blue;
  1420. }
  1421. }
  1422. .submit_checkbox {
  1423. margin: 20rpx auto;
  1424. width: 526rpx;
  1425. height: 80rpx;
  1426. background: rgba(0, 122, 255, 1);
  1427. color: #fff;
  1428. text-align: center;
  1429. line-height: 80rpx;
  1430. font-size: 30rpx;
  1431. border-radius: 40rpx;
  1432. }
  1433. .titles {
  1434. overflow: hidden;
  1435. margin-bottom: 24rpx;
  1436. }
  1437. .titBox {
  1438. padding: 41rpx 25rpx 24rpx 25rpx;
  1439. }
  1440. .tabs {
  1441. margin: 10rpx;
  1442. display: flex;
  1443. .tab {
  1444. margin: 0 10rpx;
  1445. width: 96rpx;
  1446. height: 48rpx;
  1447. line-height: 48rpx;
  1448. text-align: center;
  1449. color: #007aff;
  1450. font-size: 28rpx;
  1451. border-radius: 16rpx;
  1452. &.current {
  1453. color: #fff;
  1454. background: #007aff;
  1455. }
  1456. }
  1457. }
  1458. .ans {
  1459. margin: 8rpx 8rpx 8rpx;
  1460. .ans_input {
  1461. border-radius: 16rpx;
  1462. background: #fff;
  1463. .top {
  1464. border-bottom: 1rpx solid #eeeeee;
  1465. padding: 16rpx;
  1466. display: flex;
  1467. align-items: center;
  1468. .icon {
  1469. margin-right: 20rpx;
  1470. width: 40rpx;
  1471. height: 38rpx;
  1472. }
  1473. .progress {
  1474. flex: 1;
  1475. }
  1476. .submit {
  1477. width: 168rpx;
  1478. height: 48rpx;
  1479. line-height: 48rpx;
  1480. text-align: center;
  1481. color: #fff;
  1482. font-size: 30rpx;
  1483. background: #007aff;
  1484. border-radius: 24rpx;
  1485. }
  1486. }
  1487. .textarea {
  1488. textarea {
  1489. width: 100%;
  1490. height: 287rpx;
  1491. padding: 10rpx;
  1492. }
  1493. }
  1494. .imgs {
  1495. overflow: hidden;
  1496. display: flex;
  1497. width: 100%;
  1498. .img {
  1499. width: 104rpx;
  1500. height: 104rpx;
  1501. border-radius: 8rpx;
  1502. position: relative;
  1503. margin: 20rpx;
  1504. text {
  1505. position: absolute;
  1506. right: -15rpx;
  1507. top: -15rpx;
  1508. width: 30rpx;
  1509. height: 30rpx;
  1510. text-align: center;
  1511. line-height: 30rpx;
  1512. color: #fff;
  1513. background: red;
  1514. border-radius: 50%;
  1515. }
  1516. image {
  1517. width: 100%;
  1518. height: 100%;
  1519. }
  1520. }
  1521. }
  1522. }
  1523. .ans_submit {
  1524. padding: 16rpx;
  1525. border-radius: 16rpx;
  1526. background: #fff;
  1527. .imgs {
  1528. overflow: hidden;
  1529. display: flex;
  1530. width: 100%;
  1531. .img {
  1532. width: 104rpx;
  1533. height: 104rpx;
  1534. border-radius: 8rpx;
  1535. position: relative;
  1536. margin: 20rpx;
  1537. image {
  1538. width: 100%;
  1539. height: 100%;
  1540. }
  1541. }
  1542. }
  1543. }
  1544. }
  1545. .firstLetter {
  1546. display: flex;
  1547. justify-content: space-between;
  1548. align-items: center;
  1549. margin-bottom: 30rpx;
  1550. .leftLetters {
  1551. display: flex;
  1552. align-items: center;
  1553. width: 220rpx;
  1554. .btnType {
  1555. padding: 5rpx 10rpx;
  1556. border: 1rpx solid #007aff;
  1557. border-radius: 10rpx;
  1558. background-color: rgba(0, 122, 255, 0.1);
  1559. font-size: 28rpx;
  1560. color: #007aff;
  1561. margin-right: 15rpx;
  1562. }
  1563. }
  1564. }
  1565. .popupView {
  1566. height: 100%;
  1567. padding-bottom: 100rpx;
  1568. .popupTops {
  1569. height: 77rpx;
  1570. border-bottom: 1rpx solid #eee;
  1571. text-align: center;
  1572. line-height: 77rpx;
  1573. font-size: 24rpx;
  1574. color: #999;
  1575. position: relative;
  1576. .topIcon {
  1577. position: absolute;
  1578. top: 10rpx;
  1579. left: 50%;
  1580. transform: translateX(-50%);
  1581. width: 80rpx;
  1582. height: 8rpx;
  1583. background-color: #999;
  1584. border-radius: 4rpx;
  1585. }
  1586. }
  1587. .popupContent {
  1588. }
  1589. }
  1590. .pageContent {
  1591. position: relative;
  1592. background-color: #eaeef1;
  1593. min-height: 100vh;
  1594. padding-top: 8rpx;
  1595. padding-bottom: 100rpx;
  1596. }
  1597. .pad_8 {
  1598. background-color: #fff;
  1599. margin: 0rpx 8rpx 8rpx;
  1600. border-radius: 16rpx;
  1601. }
  1602. .answer {
  1603. height: 80rpx;
  1604. line-height: 80rpx;
  1605. padding: 0rpx 24rpx;
  1606. display: flex;
  1607. align-items: center;
  1608. justify-content: space-between;
  1609. color: #666;
  1610. font-size: 30rpx;
  1611. }
  1612. .footer_btn {
  1613. background-color: #fff;
  1614. z-index: 10078;
  1615. position: fixed;
  1616. bottom: 0rpx;
  1617. display: flex;
  1618. align-items: center;
  1619. justify-content: space-between;
  1620. width: 100%;
  1621. height: 98rpx;
  1622. padding: 0rpx 38rpx;
  1623. border-top: 1rpx solid #eee;
  1624. .collect {
  1625. visibility: hidden;
  1626. &.show {
  1627. visibility: visible;
  1628. }
  1629. }
  1630. }
  1631. .boxSty {
  1632. padding: 44rpx 41rpx 0rpx;
  1633. }
  1634. .liListSty {
  1635. border: 1rpx solid #eeeeee;
  1636. width: 88rpx;
  1637. height: 88rpx;
  1638. border-radius: 32rpx;
  1639. text-align: center;
  1640. line-height: 88rpx;
  1641. color: #333;
  1642. font-size: 32rpx;
  1643. float: left;
  1644. margin: 20rpx 23rpx;
  1645. &.isRight {
  1646. border: 1rpx solid #eeeeee;
  1647. color: #fff;
  1648. background: green;
  1649. }
  1650. &.isWrong {
  1651. border: 1rpx solid #eeeeee;
  1652. color: #fff;
  1653. background: red;
  1654. }
  1655. }
  1656. .answerInfos {
  1657. padding: 25rpx 25rpx 25rpx 23rpx;
  1658. }
  1659. .answerTitle {
  1660. margin-bottom: 28rpx;
  1661. color: #666;
  1662. font-size: 30rpx;
  1663. }
  1664. .answerContent {
  1665. font-size: 30rpx;
  1666. color: #666;
  1667. }
  1668. .textChild {
  1669. display: inline-block;
  1670. vertical-align: middle;
  1671. }
  1672. .dialog {
  1673. position: fixed;
  1674. left: 0;
  1675. top: 0;
  1676. width: 100%;
  1677. height: 100%;
  1678. background-color: rgba(0, 0, 0, 0.8);
  1679. display: flex;
  1680. flex-direction: column;
  1681. align-items: center;
  1682. justify-content: center;
  1683. z-index: 20000;
  1684. .text {
  1685. font-size: 32rpx;
  1686. color: #ffffff;
  1687. text-align: center;
  1688. }
  1689. .btn {
  1690. width: 242rpx;
  1691. height: 82rpx;
  1692. border: 2rpx solid #ffffff;
  1693. border-radius: 16rpx;
  1694. text-align: center;
  1695. line-height: 82rpx;
  1696. margin: 41rpx auto;
  1697. color: #fff;
  1698. font-size: 32rpx;
  1699. }
  1700. }
  1701. .dialog_wrap {
  1702. position: fixed;
  1703. left: 0;
  1704. top: 0;
  1705. width: 100%;
  1706. height: 100%;
  1707. z-index: 9999999999;
  1708. .bg {
  1709. background: rgba(0, 0, 0, 0.3);
  1710. position: absolute;
  1711. left: 0;
  1712. top: 0;
  1713. width: 100%;
  1714. height: 100%;
  1715. }
  1716. .dialog {
  1717. position: absolute;
  1718. left: 50%;
  1719. top: 50%;
  1720. transform: translate3D(-50%, -50%, 0);
  1721. width: 640rpx;
  1722. height: 439rpx;
  1723. background: #ffffff;
  1724. border-radius: 24rpx;
  1725. .title {
  1726. font-size: 30rpx;
  1727. font-weight: bold;
  1728. color: #333333;
  1729. line-height: 48rpx;
  1730. text-align: center;
  1731. margin-top: 40rpx;
  1732. }
  1733. .content {
  1734. margin: 35rpx 35rpx 0;
  1735. font-size: 30rpx;
  1736. color: #666666;
  1737. line-height: 48rpx;
  1738. }
  1739. .btns {
  1740. margin-top: 35rpx;
  1741. display: flex;
  1742. align-items: center;
  1743. justify-content: center;
  1744. .btn {
  1745. width: 200rpx;
  1746. height: 80rpx;
  1747. line-height: 80rpx;
  1748. text-align: center;
  1749. background: #f5f5f5;
  1750. border-radius: 40rpx;
  1751. font-size: 30rpx;
  1752. color: rgba(0, 122, 255, 1);
  1753. background: #f5f5f5;
  1754. margin: 0 20rpx;
  1755. &.active {
  1756. color: #f5f5f5;
  1757. background: rgba(0, 122, 255, 1);
  1758. }
  1759. }
  1760. }
  1761. }
  1762. }
  1763. .popboxs {
  1764. width: 100%;
  1765. height: 100%;
  1766. display: flex;
  1767. flex-direction: column;
  1768. align-items: center;
  1769. }
  1770. .classTops {
  1771. flex-shrink: 0;
  1772. padding: 39rpx 0rpx 4rpx;
  1773. font-weight: bold;
  1774. color: #333;
  1775. font-size: 30rpx;
  1776. }
  1777. .textStys {
  1778. width: 100%;
  1779. flex: 1;
  1780. padding: 36rpx;
  1781. }
  1782. .classFootsty {
  1783. flex-shrink: 0;
  1784. display: flex;
  1785. align-items: center;
  1786. justify-content: center;
  1787. padding: 10rpx 0rpx 40rpx;
  1788. .btnsty {
  1789. width: 200rpx;
  1790. height: 80rpx;
  1791. border-radius: 40rpx;
  1792. font-weight: bold;
  1793. font-size: 30rpx;
  1794. text-align: center;
  1795. line-height: 80rpx;
  1796. }
  1797. .btns1 {
  1798. background-color: #f5f5f5;
  1799. color: #007aff;
  1800. }
  1801. .btns2 {
  1802. margin-left: 40rpx;
  1803. background-color: #007aff;
  1804. color: #ffffff;
  1805. }
  1806. }
  1807. </style>