questionBankContinue.vue 50 KB

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