questionBankContinue.vue 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" :statusBar="true" :title="examData.examName"></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" @click="showPhoto(bank.content)">
  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. examData:{},
  450. cgType: 0 //对应设计稿弹窗编码
  451. };
  452. },
  453. onLoad(option){
  454. this.id = option.id || '';
  455. this.goodsId = option.goodsid || '';
  456. this.chapterId = option.chapterId || '';
  457. this.moduleId = option.moduleId || '';
  458. this.recordId = option.recordId || '';
  459. let showDialog = uni.getStorageSync('showDialog');
  460. if(showDialog) {
  461. this.showDialog = false;
  462. } else {
  463. this.showDialog = true;
  464. uni.setStorageSync('showDialog','1');
  465. }
  466. this.goodsQuestionList();
  467. },
  468. onUnload() {
  469. if(this.isSubmit) {
  470. return
  471. }
  472. this.examRecordEdit();
  473. },
  474. methods: {
  475. /**
  476. * 是否有上传图片
  477. */
  478. hasImgs(bank) {
  479. return bank.ansText.imageList.length == 0;
  480. },
  481. /**
  482. * @param {Object} state
  483. * @param {Object} index
  484. * 收藏
  485. */
  486. collect(state, index) {
  487. if (!state) {
  488. this.$api
  489. .collectQuestion({
  490. examId: this.id,
  491. questionId: this.questionList[index].questionId,
  492. goodsId: this.goodsId || ''
  493. })
  494. .then(res => {
  495. if (res.data.code == 200) {
  496. this.$set(this.collectList, index, true);
  497. uni.showToast({
  498. title: '收藏成功',
  499. duration: 2000,
  500. icon: 'none'
  501. });
  502. this.getCollectInfo(index)
  503. }
  504. });
  505. } else {
  506. this.$api.deleteCollectQuestion(this.collectList[index].collectQuestionId).then(res => {
  507. if (res.data.code == 200) {
  508. this.$set(this.collectList, index, false);
  509. uni.showToast({
  510. title: '取消收藏成功',
  511. duration: 2000,
  512. icon: 'none'
  513. });
  514. }
  515. });
  516. }
  517. return;
  518. },
  519. /**
  520. * 点击后退按钮
  521. */
  522. clickLeft() {
  523. let ansCount = this.questionOverNum(true); //已答题数
  524. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  525. //所有题目答完
  526. if (this.lastCount == 0) {
  527. // this.testOver = true;
  528. this.cgType = 7;
  529. //未答完
  530. } else {
  531. this.cgType = 8;
  532. // this.isLastCount = true;
  533. }
  534. this.showpopups = true;
  535. },
  536. /**
  537. * 获取已经回答的题目数
  538. * hasSpecail (是否包含简答和案例)
  539. */
  540. questionOverNum(hasSpecail) {
  541. let count = 0;
  542. this.questionList.forEach(item => {
  543. if (item.type == 1 || item.type == 2 || item.type == 3) {
  544. if (item.ques) {
  545. count++;
  546. }
  547. } else if (item.type == 4) {
  548. //案例题
  549. if(hasSpecail) {
  550. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  551. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  552. if (item.ques[indexs]) {
  553. return true;
  554. } else {
  555. return false;
  556. }
  557. } else if (jsonItem.type == 5) {
  558. if (item.ques[indexs] && (item.ques[indexs].text.length || item.ques[indexs].imageList.length)) {
  559. return true;
  560. } else {
  561. return false;
  562. }
  563. }
  564. });
  565. if (isOver) {
  566. count++;
  567. console.log(item, 444);
  568. }
  569. }
  570. } else if (item.type == 5) {
  571. //简答题
  572. if(hasSpecail) {
  573. if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  574. count++;
  575. }
  576. }
  577. }
  578. });
  579. return count;
  580. },
  581. /**
  582. * 返回上一页
  583. */
  584. backPages() {
  585. uni.navigateBack({
  586. delta: 1
  587. });
  588. },
  589. /**
  590. * 是否做完所有题目
  591. */
  592. isDoOver() {
  593. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  594. if(this.questionList.length == questionOverNum) { //全部做完弹窗
  595. this.cgType = 9;
  596. this.showpopups = true;
  597. }
  598. },
  599. pdsubmit() {
  600. // if (this.bankType == 1) {
  601. let ansCount = this.questionOverNum(true); //已答题数
  602. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  603. //没有答完
  604. if (this.lastCount !== 0) {
  605. this.cgType = 6;
  606. this.showpopups = true;
  607. return;
  608. }
  609. // }
  610. this.submit();
  611. },
  612. goodsQuestionList() {
  613. //继续答题
  614. console.log("继续做题")
  615. this.$api.examReport(this.recordId).then(res => {
  616. let json = JSON.parse(res.data.data.historyExamJson)
  617. this.examData = res.data.data;
  618. this.questionList = json;
  619. })
  620. },
  621. /**
  622. * @param {Object} current
  623. * 获取收藏信息
  624. */
  625. getCollectInfo(current) {
  626. this.$api
  627. .getCollectInfo({
  628. examId: this.id,
  629. questionId: this.questionList[current].questionId,
  630. goodsId: this.goodsId
  631. })
  632. .then(res => {
  633. if (res.data.code == 500) {
  634. this.$set(this.collectList, current, false);
  635. } else if (res.data.code == 200) {
  636. this.$set(this.collectList, current, res.data.data);
  637. }
  638. });
  639. },
  640. /**
  641. * @param {Object} e单选点击
  642. */
  643. radioSelect(optionsId,bindex) {
  644. if(this.questionList[bindex].ques) return;
  645. this.$set(this.questionList[bindex],'ques',optionsId)
  646. this.isDoOver()
  647. },
  648. examRecordEdit() {
  649. if(!this.isSubmit) {
  650. let number = 0;
  651. let score = 0;
  652. let doQuestionNum = 0;
  653. let doQuestionIds = []; //做过的题目id
  654. this.questionList.length && this.questionList.forEach((item,index) => {
  655. if(item.type == 1) {
  656. if(item.ques == item.ans) {
  657. score += item.score;
  658. number++
  659. }
  660. if (item.ques) {
  661. doQuestionNum++;
  662. doQuestionIds.push(item.questionId)
  663. }
  664. } else if(item.type == 2) {
  665. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  666. return item.ques[quesIndex] == item.ans[quesIndex]
  667. })
  668. if(isRight) {
  669. score += item.score;
  670. number++
  671. }
  672. if (item.ques && item.ques.length) {
  673. doQuestionNum++;
  674. doQuestionIds.push(item.questionId)
  675. }
  676. } else if(item.type == 3) {
  677. if(item.ques == item.ans) {
  678. score += item.score;
  679. number++
  680. }
  681. if (item.ques) {
  682. doQuestionNum++;
  683. doQuestionIds.push(item.questionId)
  684. }
  685. } else if (item == 4) {
  686. if (item.ques.length) {
  687. doQuestionNum++;
  688. doQuestionIds.push(item.questionId)
  689. }
  690. } else if (item.type == 5) {
  691. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  692. doQuestionNum++;
  693. doQuestionIds.push(item.questionId)
  694. }
  695. }
  696. })
  697. this.$api.examRecordEdit({
  698. moduleExamId:this.moduleId || 0,
  699. chapterExamId:this.chapterId || 0,
  700. examId:this.id,
  701. doQuestionIds:doQuestionIds.join(''),
  702. goodsId:this.goodsId,
  703. recordId: this.recordId,
  704. rightQuestionNum:number,
  705. status:0,
  706. doQuestionNum: doQuestionNum,
  707. historyExamJson:JSON.stringify(this.questionList)
  708. }).then(res => {
  709. })
  710. }
  711. },
  712. /**
  713. * @param {Object} e单选点击
  714. */
  715. radioSelectChild(optionsId,ansIndex,bindex) {
  716. if(this.questionList[bindex].ques[ansIndex]) return;
  717. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  718. this.isDoOver()
  719. },
  720. /**
  721. * @param {Object} 多选点击
  722. */
  723. checkboxSelect(optionsId,bindex,index) {
  724. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  725. },
  726. /**
  727. * @param {Object} 多选点击
  728. */
  729. checkboxSelectChild(bindex,ansIndex,childIndex) {
  730. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  731. },
  732. /**
  733. * 提交数据
  734. */
  735. submit() {
  736. let score = 0; //计算总分
  737. let reportStatus = 0;
  738. let number = 0;
  739. let allScore = 0;
  740. let passScore = 0;
  741. let doQuestionNum = 0;
  742. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  743. let doQuestionIds = []; //做过的题目id
  744. let rightQuestionIds = []; //做对的题目id
  745. this.questionList.forEach((item,index) => {
  746. passScore = item.passScore
  747. if(item.type == 1) {
  748. if(item.ques == item.ans) {
  749. score += item.score;
  750. number++
  751. rightQuestionIds.push(item.questionId)
  752. } else { //错误
  753. doWrongQuestionIds.push(item.questionId)
  754. }
  755. allScore += item.score
  756. if (item.ques) {
  757. doQuestionNum++;
  758. doQuestionIds.push(item.questionId)
  759. }
  760. } else if(item.type == 2) {
  761. let isRight = item.ans && item.ans.every((quesItem,quesIndex) => {
  762. if(item.ques) {
  763. return item.ques[quesIndex] == item.ans[quesIndex]
  764. } else {
  765. return false;
  766. }
  767. })
  768. if(isRight) {
  769. score += item.score;
  770. number++
  771. rightQuestionIds.push(item.questionId)
  772. } else {
  773. let checkboxScore = item.score; //获取单题总分数
  774. item.ques && item.ques.forEach((ques,quesIndex) => {
  775. //选错一个全扣
  776. if(item.ques) {
  777. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  778. checkboxScore = 0;
  779. }
  780. } else {
  781. checkboxScore = 0;
  782. }
  783. })
  784. console.log(checkboxScore)
  785. //没选错
  786. if(checkboxScore) {
  787. item.ans.forEach((ans,quesIndex) => {
  788. //漏选扣一部分
  789. if(item.ques) {
  790. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  791. checkboxScore = item.partScore;
  792. }
  793. } else {
  794. checkboxScore = 0;
  795. }
  796. })
  797. }
  798. if(checkboxScore <= 0) { //0分
  799. item.scoreResult = 0;
  800. doWrongQuestionIds.push(item.questionId)
  801. } else { //部分分
  802. // number++;
  803. doWrongQuestionIds.push(item.questionId)
  804. item.scoreResult = checkboxScore;
  805. score += checkboxScore;
  806. // rightQuestionIds.push(item.questionId)
  807. }
  808. }
  809. allScore += item.score;
  810. if (item.ques && item.ques.length) {
  811. doQuestionNum++;
  812. doQuestionIds.push(item.questionId)
  813. }
  814. } else if(item.type == 3) {
  815. if(item.ques == item.ans) {
  816. score += item.score;
  817. number++
  818. rightQuestionIds.push(item.questionId)
  819. } else {
  820. doWrongQuestionIds.push(item.questionId)
  821. }
  822. allScore += item.score;
  823. if (item.ques) {
  824. doQuestionNum++;
  825. doQuestionIds.push(item.questionId)
  826. }
  827. } else if (item.type == 4) {
  828. allScore += item.score;
  829. if (item.ques && item.ques.length) {
  830. doQuestionNum++;
  831. doQuestionIds.push(item.questionId)
  832. }
  833. } else if (item.type == 5) {
  834. allScore += item.score;
  835. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  836. doQuestionNum++;
  837. doQuestionIds.push(item.questionId)
  838. }
  839. }
  840. })
  841. //大于及格
  842. if(score >= passScore) {
  843. reportStatus = 1
  844. } else {
  845. reportStatus = 0
  846. }
  847. this.$api.examRecordEdit({
  848. examId:this.id,
  849. goodsId:this.goodsId,
  850. reportStatus:reportStatus,
  851. totalScore:allScore,
  852. recordId: this.recordId,
  853. rightQuestionNum:number,
  854. status:1,
  855. moduleExamId:this.moduleId || 0,
  856. chapterExamId:this.chapterId || 0,
  857. doQuestionIds:doQuestionIds.join(','),
  858. rightQuestionIds:rightQuestionIds.join(','),
  859. doQuestionNum: doQuestionNum,
  860. performance: score,
  861. historyExamJson:JSON.stringify(this.questionList)
  862. }).then(res => {
  863. this.isSubmit = true;
  864. if(res.data.code == 200) {
  865. uni.showToast({
  866. title: '交卷成功',
  867. duration: 2000,
  868. icon:'none'
  869. });
  870. setTimeout(() => {
  871. uni.redirectTo({
  872. url:'/pages2/bank/question_report?id='+this.recordId+'&examId='+this.id
  873. })
  874. },2000)
  875. }
  876. })
  877. //错题集id提交(客观题)
  878. this.$api.examWrongRecord({
  879. examId: this.id,
  880. goodsId: this.goodsId,
  881. questionIds: doWrongQuestionIds,
  882. recordId: this.recordId
  883. }).then(res => {
  884. });
  885. },
  886. isCheckboxChecked(arr) {
  887. return arr.some(item => {
  888. if (item.checked) {
  889. return true;
  890. }
  891. });
  892. },
  893. /**
  894. * @param {Object} 多选确认
  895. */
  896. checkboxSubmit(bindex) {
  897. if(this.questionList[bindex].ques) return;
  898. let arr = [];
  899. this.questionList[bindex].jsonStr.forEach(item => {
  900. if(item.checked) {
  901. arr.push(item.optionsId)
  902. }
  903. })
  904. if(!arr.length) {
  905. uni.showToast({
  906. title:'请选择答案',
  907. icon:'none'
  908. })
  909. return;
  910. }
  911. this.$set(this.questionList[bindex],'ques',arr)
  912. this.isDoOver()
  913. },
  914. /**
  915. * @param {Object} 多选确认
  916. */
  917. checkboxSubmitChild(bindex,ansIndex) {
  918. if(this.questionList[bindex].ques[ansIndex]) return;
  919. let arr = [];
  920. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  921. if(item.checked) {
  922. arr.push(item.optionsId)
  923. }
  924. })
  925. if(!arr.length) {
  926. uni.showToast({
  927. title:'请选择答案',
  928. icon:'none'
  929. })
  930. return;
  931. }
  932. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  933. this.isDoOver()
  934. },
  935. judgeSelect(index,bindex) {
  936. if(this.questionList[bindex].ques) return;
  937. this.$set(this.questionList[bindex],'ques',index+'')
  938. this.isDoOver()
  939. },
  940. judgeSelectChild(ansindex,childindex,bindex) {
  941. if(this.questionList[bindex].ques[ansindex]) return;
  942. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  943. this.isDoOver()
  944. },
  945. /**
  946. * 立即离开并交卷
  947. */
  948. leaveNow() {
  949. this.needBack = false;
  950. this.isSubmit = true;
  951. uni.navigateBack({
  952. delta: 1
  953. });
  954. let score = 0; //计算总分
  955. let reportStatus = 0;
  956. let number = 0; //做对的题目数量
  957. let doQuestionNum = 0; //做过的题目数量
  958. let allScore = 0; //总分
  959. let passScore = 0;
  960. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  961. let doQuestionIds = []; //做过的题目id
  962. let rightQuestionIds = []; //做对的题目id
  963. this.questionList.forEach((item, index) => {
  964. // passScore = item.passScore
  965. if (item.type == 1) {
  966. //正确
  967. if (item.ques == item.ans) {
  968. item.scoreResult = item.score;
  969. score += item.score;
  970. number++;
  971. rightQuestionIds.push(item.questionId)
  972. } else { //错误
  973. item.scoreResult = 0;
  974. doWrongQuestionIds.push(item.questionId)
  975. }
  976. allScore += item.score;
  977. if (item.ques) {
  978. doQuestionNum++;
  979. doQuestionIds.push(item.questionId)
  980. }
  981. } else if (item.type == 2) {
  982. let isRight =
  983. item.ans &&
  984. item.ans.every((quesItem, quesIndex) => {
  985. if(item.ques) {
  986. return item.ques[quesIndex] == item.ans[quesIndex];
  987. } else {
  988. return false;
  989. }
  990. });
  991. if (isRight) {
  992. score += item.score;
  993. number++;
  994. item.scoreResult = item.score;
  995. rightQuestionIds.push(item.questionId)
  996. } else {
  997. let checkboxScore = item.score; //获取单题总分数
  998. item.ques && item.ques.forEach((ques,quesIndex) => {
  999. //选错一个全扣
  1000. if(item.ques) {
  1001. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1002. checkboxScore = 0;
  1003. }
  1004. } else {
  1005. checkboxScore = 0;
  1006. }
  1007. })
  1008. console.log(checkboxScore)
  1009. //没选错
  1010. if(checkboxScore) {
  1011. item.ans.forEach((ans,quesIndex) => {
  1012. //漏选扣一部分
  1013. if(item.ques) {
  1014. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1015. checkboxScore = item.partScore;
  1016. }
  1017. } else {
  1018. checkboxScore = 0;
  1019. }
  1020. })
  1021. }
  1022. if(checkboxScore <= 0) { //0分
  1023. item.scoreResult = 0;
  1024. doWrongQuestionIds.push(item.questionId)
  1025. } else { //部分分
  1026. // number++;
  1027. doWrongQuestionIds.push(item.questionId)
  1028. item.scoreResult = checkboxScore;
  1029. score += checkboxScore;
  1030. // rightQuestionIds.push(item.questionId)
  1031. }
  1032. }
  1033. allScore += item.score;
  1034. if (item.ques && item.ques.length) {
  1035. doQuestionNum++;
  1036. doQuestionIds.push(item.questionId)
  1037. }
  1038. } else if (item.type == 3) {
  1039. if (item.ques == item.ans) {
  1040. item.scoreResult = item.score;
  1041. score += item.score;
  1042. number++;
  1043. rightQuestionIds.push(item.questionId)
  1044. } else {
  1045. item.scoreResult = 0;
  1046. doWrongQuestionIds.push(item.questionId)
  1047. }
  1048. allScore += item.score;
  1049. if (item.ques) {
  1050. doQuestionNum++;
  1051. doQuestionIds.push(item.questionId)
  1052. }
  1053. } else if (item.type == 4) {
  1054. if (item.ques && item.ques.length) {
  1055. doQuestionNum++;
  1056. doQuestionIds.push(item.questionId)
  1057. }
  1058. } else if (item.type == 5) {
  1059. if (item.ques && (item.ques.imageList || item.ques.text)) {
  1060. doQuestionNum++;
  1061. doQuestionIds.push(item.questionId)
  1062. }
  1063. }
  1064. });
  1065. //大于60分及格
  1066. if(score >= 60) {
  1067. reportStatus = 1
  1068. } else {
  1069. reportStatus = 0
  1070. }
  1071. //交卷
  1072. this.$api
  1073. .examRecordEdit({
  1074. examId: this.id,
  1075. goodsId: this.goodsId,
  1076. reportStatus:reportStatus,
  1077. recordId: this.recordId,
  1078. rightQuestionNum: number,
  1079. status: 1,
  1080. moduleExamId:this.moduleId || 0,
  1081. chapterExamId:this.chapterId || 0,
  1082. doQuestionIds:doQuestionIds.join(','),
  1083. rightQuestionIds:rightQuestionIds.join(','),
  1084. doQuestionNum: doQuestionNum,
  1085. performance: score,
  1086. totalScore: allScore,
  1087. examTime: parseInt(this.allTimes),
  1088. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1089. historyExamJson: JSON.stringify(this.questionList)
  1090. })
  1091. .then(res => {
  1092. this.isSubmit = true;
  1093. if (res.data.code == 200) {
  1094. }
  1095. });
  1096. //错题集id提交(客观题)
  1097. this.$api.examWrongRecord({
  1098. moduleExamId:this.moduleId || 0,
  1099. chapterExamId:this.chapterId || 0,
  1100. examId: this.id,
  1101. goodsId: this.goodsId,
  1102. questionIds: doWrongQuestionIds,
  1103. recordId: this.recordId
  1104. }).then(res => {
  1105. });
  1106. },
  1107. openFooterTab() {
  1108. this.show = true;
  1109. },
  1110. hideDialog() {
  1111. this.showDialog = false
  1112. },
  1113. changeIndex(index) {
  1114. this.current = index
  1115. },
  1116. swiperChange(e) {
  1117. this.current = e.detail.current;
  1118. },
  1119. deleteImg(imgIndex,bankIndex) {
  1120. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  1121. },
  1122. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  1123. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  1124. },
  1125. chooseImg(bankindex) {
  1126. uni.chooseImage({
  1127. count: 1, //默认9
  1128. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  1129. sourceType: ['album','camera'], //从相册选择
  1130. success: (res) => {
  1131. let self = this;
  1132. // console.log(JSON.stringify(res.tempFilePaths));
  1133. let img = res.tempFilePaths[0];
  1134. uni.getImageInfo({
  1135. src: img,
  1136. success: async res => {
  1137. let canvasWidth = res.width; //图片原始长宽
  1138. let canvasHeight = res.height;
  1139. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1140. uni.compressImage({
  1141. src: img,
  1142. quality: 75,
  1143. width: '50%',
  1144. height: '50%',
  1145. success: async rest => {
  1146. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1147. this.questionList[bankindex].ansText.imageList.push(dir)
  1148. }
  1149. });
  1150. } else {
  1151. const dir = await self.uploadFile(img, 0);
  1152. this.questionList[bankindex].ansText.imageList.push(dir)
  1153. }
  1154. }
  1155. });
  1156. }
  1157. })
  1158. },
  1159. chooseImgChild(bankindex,ansindex) {
  1160. uni.chooseImage({
  1161. count: 1, //默认9
  1162. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  1163. sourceType: ['album','camera'], //从相册选择
  1164. success: (res) => {
  1165. let self = this;
  1166. // console.log(JSON.stringify(res.tempFilePaths));
  1167. let img = res.tempFilePaths[0];
  1168. uni.getImageInfo({
  1169. src: img,
  1170. success: async res => {
  1171. let canvasWidth = res.width; //图片原始长宽
  1172. let canvasHeight = res.height;
  1173. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1174. uni.compressImage({
  1175. src: img,
  1176. quality: 75,
  1177. width: '50%',
  1178. height: '50%',
  1179. success: async rest => {
  1180. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1181. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  1182. }
  1183. });
  1184. } else {
  1185. const dir = await self.uploadFile(img, 0);
  1186. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  1187. }
  1188. }
  1189. });
  1190. }
  1191. })
  1192. },
  1193. uploadFile(options, int) {
  1194. var self = this;
  1195. return new Promise((resolve, reject) => {
  1196. var data = {
  1197. imageStatus: int
  1198. };
  1199. self.$api.aliyunpolicy(data).then(res => {
  1200. console.log(res.data,6)
  1201. if(res.data.code!=200){
  1202. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  1203. return
  1204. }
  1205. var ossToken = res.data.data.resultContent;
  1206. if(ossToken.host==null||ossToken.host==undefined){
  1207. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  1208. return
  1209. }
  1210. uni.uploadFile({
  1211. url: ossToken.host,
  1212. name: 'file',
  1213. filePath: options,
  1214. fileType: 'image',
  1215. header: {
  1216. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1217. },
  1218. formData: {
  1219. key: ossToken.dir,
  1220. OSSAccessKeyId: ossToken.accessid,
  1221. policy: ossToken.policy,
  1222. Signature: ossToken.signature,
  1223. callback: ossToken.callback,
  1224. success_action_status: 200
  1225. },
  1226. success: result => {
  1227. if (result.statusCode === 200) {
  1228. resolve(ossToken.dir);
  1229. } else {
  1230. uni.showToast({
  1231. title: '上传失败',
  1232. icon: 'none'
  1233. });
  1234. return;
  1235. }
  1236. },
  1237. fail: error => {
  1238. uni.showToast({
  1239. title: '上传接口报错'+error,
  1240. icon: 'none'
  1241. });
  1242. return;
  1243. }
  1244. });
  1245. });
  1246. });
  1247. },
  1248. submitAns(bankindex) {
  1249. console.log(this.questionList[bankindex])
  1250. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1251. uni.showToast({
  1252. title: '请输入内容或上传图片',
  1253. duration: 2000,
  1254. icon:'none'
  1255. });
  1256. return
  1257. }
  1258. this.$set(this.questionList[bankindex],'ques',{
  1259. imageList:this.questionList[bankindex].ansText.imageList,
  1260. text:this.questionList[bankindex].ansText.text,
  1261. })
  1262. this.isDoOver()
  1263. },
  1264. submitAnsChild(bankindex,ansindex) {
  1265. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1266. uni.showToast({
  1267. title: '请输入内容或上传图片',
  1268. duration: 2000,
  1269. icon:'none'
  1270. });
  1271. return
  1272. }
  1273. this.$set(this.questionList[bankindex].ques,ansindex,{
  1274. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1275. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  1276. })
  1277. this.isDoOver()
  1278. },
  1279. isRight(item,index) {
  1280. //单选
  1281. if(this.questionList[index].ques) {
  1282. if(item.type == 1) {
  1283. return this.questionList[index].ques == this.questionList[index].ans;
  1284. //多选
  1285. } else if(item.type == 2) {
  1286. //每一项都相等
  1287. return this.questionList[index].ans.every((item,i) => {
  1288. return item == this.questionList[index].ques[i];
  1289. })
  1290. //判断
  1291. } else if(item.type == 3) {
  1292. return this.questionList[index].ques == this.questionList[index].ans;
  1293. } else {
  1294. return false;
  1295. }
  1296. } else {
  1297. return false;
  1298. }
  1299. },
  1300. right(bankIndex,ansIndex,option) {
  1301. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1302. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  1303. return true
  1304. } else {
  1305. return false;
  1306. }
  1307. } else {
  1308. return false;
  1309. }
  1310. },
  1311. wrong(bankIndex,ansIndex,option) {
  1312. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1313. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  1314. return true;
  1315. } else {
  1316. return false;
  1317. }
  1318. } else {
  1319. return false;
  1320. }
  1321. },
  1322. isWrong(item,index) {
  1323. if(this.questionList[index].ques) {
  1324. //单选
  1325. if(item.type == 1) {
  1326. return this.questionList[index].ques != this.questionList[index].ans;
  1327. //多选
  1328. } else if(item.type == 2) {
  1329. //每一项都相等
  1330. return this.questionList[index].ans.some((item,i) => {
  1331. return item != this.questionList[index].ques[i];
  1332. })
  1333. //判断
  1334. } else if(item.type == 3) {
  1335. return this.questionList[index].ques != this.questionList[index].ans;
  1336. } else {
  1337. return false;
  1338. }
  1339. } else {
  1340. return false;
  1341. }
  1342. },
  1343. tabSelect(index,bankindex) {
  1344. this.$set(this.questionList[bankindex],'current',index)
  1345. },
  1346. showPhoto(contentStr) {
  1347. if(contentStr && typeof contentStr == 'string') {
  1348. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  1349. let strArr = contentStr.match(reg);
  1350. strArr.forEach((str,index) => {
  1351. strArr[index] = str.replace(reg,'$1')
  1352. })
  1353. // 预览图片
  1354. uni.previewImage({
  1355. urls: strArr,
  1356. longPressActions: {
  1357. itemList: ['发送给朋友', '保存图片', '收藏'],
  1358. success: function(data) {
  1359. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  1360. },
  1361. fail: function(err) {
  1362. console.log(err.errMsg);
  1363. }
  1364. }
  1365. });
  1366. }
  1367. }
  1368. }
  1369. };
  1370. </script>
  1371. <style lang="scss" scoped>
  1372. .questionBank {
  1373. width:100%;
  1374. height:100vh;
  1375. display: flex;
  1376. flex-direction: column;
  1377. }
  1378. .swiper {
  1379. width:100%;
  1380. flex:1;
  1381. }
  1382. .lisSty {
  1383. margin-bottom: 16rpx;
  1384. display: flex;
  1385. align-items: center;
  1386. .flex_auto {
  1387. flex:1;
  1388. }
  1389. }
  1390. .activeTI {
  1391. vertical-align: middle;
  1392. display: inline-block;
  1393. border: 1rpx solid #eee;
  1394. border-radius: 50rpx;
  1395. height: 48rpx;
  1396. line-height: 46rpx;
  1397. text-align: center;
  1398. width: 48rpx;
  1399. margin-right: 15rpx;
  1400. color: #666;
  1401. font-size: 30rpx;
  1402. &.right {
  1403. color:#fff;
  1404. background:#36C75A;
  1405. }
  1406. &.wrong {
  1407. color:#fff;
  1408. background:#FF3B30;
  1409. }
  1410. &.checked {
  1411. color:#fff;
  1412. background:#007AFF;
  1413. }
  1414. }
  1415. .submit_checkbox {
  1416. position:fixed;
  1417. left:0;
  1418. right:0;
  1419. bottom:120rpx;
  1420. margin: 20rpx auto;
  1421. left:0;
  1422. right:0;
  1423. bottom:120rpx;
  1424. margin: 20rpx auto;
  1425. width: 526rpx;
  1426. height: 80rpx;
  1427. background: rgba(0, 122, 255, 1);
  1428. color:#fff;
  1429. text-align: center;
  1430. line-height: 80rpx;
  1431. font-size: 30rpx;
  1432. border-radius: 40rpx;
  1433. &.disabled {
  1434. opacity: 0.6;
  1435. }
  1436. }
  1437. .titles {
  1438. overflow: hidden;
  1439. margin-bottom: 24rpx;
  1440. }
  1441. .titBox {
  1442. padding: 41rpx 25rpx 24rpx 25rpx;
  1443. }
  1444. .titBox_title {
  1445. padding: 21rpx;
  1446. }
  1447. .tabs {
  1448. margin:10rpx;
  1449. display: flex;
  1450. .tab {
  1451. margin: 0 4rpx;
  1452. padding:10rpx 13rpx;
  1453. text-align: center;
  1454. color: #007aff;
  1455. font-size: 28rpx;
  1456. border-radius: 16rpx;
  1457. background:#fff;
  1458. &.current {
  1459. color:#fff;
  1460. background: #007AFF;
  1461. }
  1462. }
  1463. }
  1464. .ans {
  1465. margin:8rpx 8rpx 8rpx;
  1466. .ans_input {
  1467. border-radius: 16rpx;
  1468. background:#fff;
  1469. .top {
  1470. border-bottom:1rpx solid #EEEEEE;
  1471. padding: 16rpx;
  1472. display: flex;
  1473. align-items: center;
  1474. .icon {
  1475. margin-right:20rpx;
  1476. width: 40rpx;
  1477. height: 38rpx;
  1478. }
  1479. .progress {
  1480. flex:1;
  1481. }
  1482. .submit {
  1483. width: 168rpx;
  1484. height: 48rpx;
  1485. line-height: 48rpx;
  1486. text-align: center;
  1487. color:#fff;
  1488. font-size: 30rpx;
  1489. background: #007AFF;
  1490. border-radius: 24rpx;
  1491. &.disabled {
  1492. opacity: 0.6;
  1493. }
  1494. }
  1495. }
  1496. .textarea {
  1497. textarea {
  1498. width:100%;
  1499. height:287rpx;
  1500. padding:10rpx;
  1501. }
  1502. }
  1503. .imgs {
  1504. overflow: hidden;
  1505. display: flex;
  1506. width:100%;
  1507. .img {
  1508. width: 104rpx;
  1509. height: 104rpx;
  1510. border-radius: 8rpx;
  1511. position:relative;
  1512. margin:20rpx;
  1513. text {
  1514. position:absolute;
  1515. right:-15rpx;
  1516. top:-15rpx;
  1517. width:30rpx;
  1518. height:30rpx;
  1519. text-align: center;
  1520. line-height: 30rpx;
  1521. color:#fff;
  1522. background:#FF3B30;
  1523. border-radius:50%;
  1524. }
  1525. image {
  1526. width:100%;
  1527. height:100%;
  1528. }
  1529. }
  1530. }
  1531. }
  1532. .ans_submit {
  1533. padding:16rpx;
  1534. border-radius: 16rpx;
  1535. background:#fff;
  1536. .imgs {
  1537. overflow: hidden;
  1538. display: flex;
  1539. width:100%;
  1540. .img {
  1541. width: 104rpx;
  1542. height: 104rpx;
  1543. border-radius: 8rpx;
  1544. position:relative;
  1545. margin:20rpx;
  1546. image {
  1547. width:100%;
  1548. height:100%;
  1549. }
  1550. }
  1551. }
  1552. }
  1553. }
  1554. .leftLetters {
  1555. display: flex;
  1556. align-items: center;
  1557. width: 220rpx;
  1558. .btnType {
  1559. padding: 5rpx 10rpx;
  1560. border: 1rpx solid #007aff;
  1561. border-radius: 10rpx;
  1562. background-color: rgba(0, 122, 255, 0.1);
  1563. font-size: 28rpx;
  1564. color: #007aff;
  1565. margin-right: 15rpx;
  1566. }
  1567. }
  1568. .firstLetter {
  1569. display: flex;
  1570. justify-content: space-between;
  1571. align-items: center;
  1572. margin-bottom: 30rpx;
  1573. }
  1574. .popupView {
  1575. height: 100%;
  1576. padding-bottom: 100rpx;
  1577. .popupTops {
  1578. height: 77rpx;
  1579. border-bottom: 1rpx solid #eee;
  1580. text-align: center;
  1581. line-height: 77rpx;
  1582. font-size: 24rpx;
  1583. color: #999;
  1584. position: relative;
  1585. .topIcon {
  1586. position: absolute;
  1587. top: 10rpx;
  1588. left: 50%;
  1589. transform: translateX(-50%);
  1590. width: 80rpx;
  1591. height: 8rpx;
  1592. background-color: #999;
  1593. border-radius: 4rpx;
  1594. }
  1595. }
  1596. .popupContent {
  1597. }
  1598. }
  1599. .pageContent {
  1600. position:relative;
  1601. background-color: #eaeef1;
  1602. height: 100%;
  1603. overflow-y: scroll;
  1604. padding-top: 8rpx;
  1605. padding-bottom: 100rpx;
  1606. }
  1607. .pad_8 {
  1608. background-color: #fff;
  1609. margin: 0rpx 8rpx 8rpx;
  1610. border-radius: 16rpx;
  1611. &.no-margin {
  1612. margin-top:-16rpx;
  1613. border-radius: 0 0 16rpx 16rpx;
  1614. }
  1615. }
  1616. .answer {
  1617. height: 80rpx;
  1618. line-height: 80rpx;
  1619. padding: 0rpx 24rpx;
  1620. display: flex;
  1621. align-items: center;
  1622. justify-content: space-between;
  1623. color: #666;
  1624. font-size: 30rpx;
  1625. }
  1626. .footer_btn {
  1627. background-color: #fff;
  1628. z-index: 10078;
  1629. position: fixed;
  1630. bottom: 0rpx;
  1631. display: flex;
  1632. align-items: center;
  1633. justify-content: space-between;
  1634. width: 100%;
  1635. height: 98rpx;
  1636. padding: 0rpx 38rpx;
  1637. border-top: 1rpx solid #eee;
  1638. .flex_center {
  1639. flex:1;
  1640. display: flex;
  1641. justify-content: center;
  1642. align-items: center;
  1643. flex-direction: column;
  1644. margin:0 200rpx;
  1645. font-size: 24rpx;
  1646. color: #999999;
  1647. .up-icon {
  1648. margin-bottom:18rpx;
  1649. width:100%;
  1650. display: flex;
  1651. justify-content: center;
  1652. image {
  1653. width:58rpx;
  1654. height:21rpx;
  1655. }
  1656. }
  1657. }
  1658. .collect {
  1659. visibility: hidden;
  1660. width:100rpx;
  1661. &.show {
  1662. visibility: visible;
  1663. }
  1664. >view {
  1665. display: flex;
  1666. flex-direction: column;
  1667. align-items: center;
  1668. justify-content: center;
  1669. image {
  1670. width:32rpx;
  1671. height:32rpx;
  1672. margin-bottom:6rpx;
  1673. }
  1674. view {
  1675. font-size: 24rpx;
  1676. color: #999999;
  1677. }
  1678. }
  1679. }
  1680. }
  1681. .boxSty {
  1682. padding: 44rpx 41rpx 0rpx;
  1683. }
  1684. .liListSty {
  1685. border:1rpx solid #EEEEEE;
  1686. width: 88rpx;
  1687. height: 88rpx;
  1688. border-radius: 32rpx;
  1689. text-align: center;
  1690. line-height: 88rpx;
  1691. color: #333;
  1692. font-size: 32rpx;
  1693. float: left;
  1694. margin: 20rpx 23rpx;
  1695. &.isRight {
  1696. border:1rpx solid #EEEEEE;
  1697. color:#fff;
  1698. background: #36C75A;
  1699. }
  1700. &.isWrong {
  1701. border:1rpx solid #EEEEEE;
  1702. color:#fff;
  1703. background: #FF3B30;
  1704. }
  1705. }
  1706. .answerInfos {
  1707. padding: 25rpx 25rpx 25rpx 23rpx;
  1708. }
  1709. .answerTitle {
  1710. margin-bottom: 28rpx;
  1711. color: #666;
  1712. font-size: 30rpx;
  1713. }
  1714. .answerContent {
  1715. font-size: 30rpx;
  1716. color: #666;
  1717. }
  1718. .textChild {
  1719. display: inline-block;
  1720. vertical-align: middle;
  1721. }
  1722. .dialog {
  1723. position: fixed;
  1724. left:0;
  1725. top:0;
  1726. width:100%;
  1727. height:100%;
  1728. background-color: rgba(0,0,0,0.8);
  1729. display: flex;
  1730. flex-direction: column;
  1731. align-items: center;
  1732. justify-content: center;
  1733. z-index: 20000;
  1734. .pointer {
  1735. width:338rpx;
  1736. height:240rpx;
  1737. }
  1738. .text {
  1739. font-size: 32rpx;
  1740. color: #FFFFFF;
  1741. text-align: center;
  1742. }
  1743. .btn {
  1744. width: 242rpx;
  1745. height: 82rpx;
  1746. border: 2rpx solid #FFFFFF;
  1747. border-radius: 16rpx;
  1748. text-align: center;
  1749. line-height: 82rpx;
  1750. margin:41rpx auto;
  1751. color:#fff;
  1752. font-size: 32rpx;
  1753. }
  1754. }
  1755. .popboxs {
  1756. width: 100%;
  1757. height: 100%;
  1758. display: flex;
  1759. flex-direction: column;
  1760. align-items: center;
  1761. }
  1762. .classTops {
  1763. flex-shrink: 0;
  1764. padding: 39rpx 0rpx 4rpx;
  1765. font-weight: bold;
  1766. color: #333;
  1767. font-size: 30rpx;
  1768. }
  1769. .textStys {
  1770. width: 100%;
  1771. flex: 1;
  1772. padding: 36rpx;
  1773. }
  1774. .classFootsty {
  1775. flex-shrink: 0;
  1776. display: flex;
  1777. align-items: center;
  1778. justify-content: center;
  1779. padding: 10rpx 0rpx 40rpx;
  1780. .btnsty {
  1781. width: 200rpx;
  1782. height: 80rpx;
  1783. border-radius: 40rpx;
  1784. font-weight: bold;
  1785. font-size: 30rpx;
  1786. text-align: center;
  1787. line-height: 80rpx;
  1788. }
  1789. .btns1 {
  1790. background-color: #f5f5f5;
  1791. color: #007aff;
  1792. }
  1793. .btns2 {
  1794. margin-left: 40rpx;
  1795. background-color: #007aff;
  1796. color: #ffffff;
  1797. }
  1798. }
  1799. </style>