questionBankContinue.vue 52 KB

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