questionBankContinue.vue 48 KB

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