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. item.ans.forEach((ans,quesIndex) => {
  793. //漏选扣一部分
  794. if(item.ques) {
  795. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  796. checkboxScore = item.partScore;
  797. }
  798. } else {
  799. checkboxScore = 0;
  800. }
  801. })
  802. }
  803. if(checkboxScore <= 0) { //0分
  804. item.scoreResult = 0;
  805. doWrongQuestionIds.push(item.questionId)
  806. } else { //部分分
  807. // number++;
  808. doWrongQuestionIds.push(item.questionId)
  809. item.scoreResult = checkboxScore;
  810. score += checkboxScore;
  811. // rightQuestionIds.push(item.questionId)
  812. }
  813. }
  814. allScore += item.score;
  815. if (item.ques && item.ques.length) {
  816. doQuestionNum++;
  817. doQuestionIds.push(item.questionId)
  818. }
  819. } else if(item.type == 3) {
  820. if(item.ques == item.ans) {
  821. score += item.score;
  822. number++
  823. rightQuestionIds.push(item.questionId)
  824. } else {
  825. doWrongQuestionIds.push(item.questionId)
  826. }
  827. allScore += item.score;
  828. if (item.ques) {
  829. doQuestionNum++;
  830. doQuestionIds.push(item.questionId)
  831. }
  832. } else if (item.type == 4) {
  833. allScore += item.score;
  834. if (item.ques && item.ques.length) {
  835. doQuestionNum++;
  836. doQuestionIds.push(item.questionId)
  837. }
  838. } else if (item.type == 5) {
  839. allScore += item.score;
  840. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  841. doQuestionNum++;
  842. doQuestionIds.push(item.questionId)
  843. }
  844. }
  845. })
  846. //大于及格
  847. if(score >= passScore) {
  848. reportStatus = 1
  849. } else {
  850. reportStatus = 0
  851. }
  852. this.$api.examRecordEdit({
  853. examId:this.id,
  854. goodsId:this.goodsId,
  855. orderGoodsId:this.orderGoodsId,
  856. reportStatus:reportStatus,
  857. totalScore:allScore,
  858. recordId: this.recordId,
  859. rightQuestionNum:number,
  860. status:1,
  861. moduleExamId:this.moduleId || 0,
  862. chapterExamId:this.chapterId || 0,
  863. doQuestionIds:doQuestionIds.join(','),
  864. rightQuestionIds:rightQuestionIds.join(','),
  865. doQuestionNum: doQuestionNum,
  866. performance: score,
  867. historyExamJson:JSON.stringify(this.questionList)
  868. }).then(res => {
  869. this.isSubmit = true;
  870. if(res.data.code == 200) {
  871. uni.showToast({
  872. title: '交卷成功',
  873. duration: 2000,
  874. icon:'none'
  875. });
  876. setTimeout(() => {
  877. uni.redirectTo({
  878. url:'/pages2/bank/question_report?orderGoodsId='+this.orderGoodsId+'&id='+this.recordId+'&examId='+this.id
  879. })
  880. },2000)
  881. }
  882. })
  883. //错题集id提交(客观题)
  884. this.$api.examWrongRecord({
  885. examId: this.id,
  886. goodsId: this.goodsId,
  887. questionIds: doWrongQuestionIds,
  888. recordId: this.recordId,
  889. orderGoodsId:this.orderGoodsId
  890. }).then(res => {
  891. });
  892. },
  893. isCheckboxChecked(arr) {
  894. return arr.some(item => {
  895. if (item.checked) {
  896. return true;
  897. }
  898. });
  899. },
  900. /**
  901. * @param {Object} 多选确认
  902. */
  903. checkboxSubmit(bindex) {
  904. if(this.questionList[bindex].ques) return;
  905. let arr = [];
  906. this.questionList[bindex].jsonStr.forEach(item => {
  907. if(item.checked) {
  908. arr.push(item.optionsId)
  909. }
  910. })
  911. if(!arr.length) {
  912. uni.showToast({
  913. title:'请选择答案',
  914. icon:'none'
  915. })
  916. return;
  917. }
  918. this.$set(this.questionList[bindex],'ques',arr)
  919. this.isDoOver()
  920. },
  921. /**
  922. * @param {Object} 多选确认
  923. */
  924. checkboxSubmitChild(bindex,ansIndex) {
  925. if(this.questionList[bindex].ques[ansIndex]) return;
  926. let arr = [];
  927. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  928. if(item.checked) {
  929. arr.push(item.optionsId)
  930. }
  931. })
  932. if(!arr.length) {
  933. uni.showToast({
  934. title:'请选择答案',
  935. icon:'none'
  936. })
  937. return;
  938. }
  939. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  940. this.isDoOver()
  941. },
  942. judgeSelect(index,bindex) {
  943. if(this.questionList[bindex].ques) return;
  944. this.$set(this.questionList[bindex],'ques',index+'')
  945. this.isDoOver()
  946. },
  947. judgeSelectChild(ansindex,childindex,bindex) {
  948. if(this.questionList[bindex].ques[ansindex]) return;
  949. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  950. this.isDoOver()
  951. },
  952. /**
  953. * 立即离开并交卷
  954. */
  955. leaveNow() {
  956. this.needBack = false;
  957. this.isSubmit = true;
  958. uni.navigateBack({
  959. delta: 1
  960. });
  961. let score = 0; //计算总分
  962. let reportStatus = 0;
  963. let number = 0; //做对的题目数量
  964. let doQuestionNum = 0; //做过的题目数量
  965. let allScore = 0; //总分
  966. let passScore = 0;
  967. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  968. let doQuestionIds = []; //做过的题目id
  969. let rightQuestionIds = []; //做对的题目id
  970. this.questionList.forEach((item, index) => {
  971. // passScore = item.passScore
  972. if (item.type == 1) {
  973. //正确
  974. if (item.ques == item.ans) {
  975. item.scoreResult = item.score;
  976. score += item.score;
  977. number++;
  978. rightQuestionIds.push(item.questionId)
  979. } else { //错误
  980. item.scoreResult = 0;
  981. doWrongQuestionIds.push(item.questionId)
  982. }
  983. allScore += item.score;
  984. if (item.ques) {
  985. doQuestionNum++;
  986. doQuestionIds.push(item.questionId)
  987. }
  988. } else if (item.type == 2) {
  989. let isRight =
  990. item.ans &&
  991. item.ans.every((quesItem, quesIndex) => {
  992. if(item.ques) {
  993. return item.ques[quesIndex] == item.ans[quesIndex];
  994. } else {
  995. return false;
  996. }
  997. });
  998. if (isRight) {
  999. score += item.score;
  1000. number++;
  1001. item.scoreResult = item.score;
  1002. rightQuestionIds.push(item.questionId)
  1003. } else {
  1004. let checkboxScore = item.score; //获取单题总分数
  1005. item.ques && item.ques.forEach((ques,quesIndex) => {
  1006. //选错一个全扣
  1007. if(item.ques) {
  1008. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1009. checkboxScore = 0;
  1010. }
  1011. } else {
  1012. checkboxScore = 0;
  1013. }
  1014. })
  1015. console.log(checkboxScore)
  1016. //没选错
  1017. if(checkboxScore) {
  1018. item.ans.forEach((ans,quesIndex) => {
  1019. //漏选扣一部分
  1020. if(item.ques) {
  1021. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1022. checkboxScore = item.partScore;
  1023. }
  1024. } else {
  1025. checkboxScore = 0;
  1026. }
  1027. })
  1028. }
  1029. if(checkboxScore <= 0) { //0分
  1030. item.scoreResult = 0;
  1031. doWrongQuestionIds.push(item.questionId)
  1032. } else { //部分分
  1033. // number++;
  1034. doWrongQuestionIds.push(item.questionId)
  1035. item.scoreResult = checkboxScore;
  1036. score += checkboxScore;
  1037. // rightQuestionIds.push(item.questionId)
  1038. }
  1039. }
  1040. allScore += item.score;
  1041. if (item.ques && item.ques.length) {
  1042. doQuestionNum++;
  1043. doQuestionIds.push(item.questionId)
  1044. }
  1045. } else if (item.type == 3) {
  1046. if (item.ques == item.ans) {
  1047. item.scoreResult = item.score;
  1048. score += item.score;
  1049. number++;
  1050. rightQuestionIds.push(item.questionId)
  1051. } else {
  1052. item.scoreResult = 0;
  1053. doWrongQuestionIds.push(item.questionId)
  1054. }
  1055. allScore += item.score;
  1056. if (item.ques) {
  1057. doQuestionNum++;
  1058. doQuestionIds.push(item.questionId)
  1059. }
  1060. } else if (item.type == 4) {
  1061. if (item.ques && item.ques.length) {
  1062. doQuestionNum++;
  1063. doQuestionIds.push(item.questionId)
  1064. }
  1065. } else if (item.type == 5) {
  1066. if (item.ques && (item.ques.imageList || item.ques.text)) {
  1067. doQuestionNum++;
  1068. doQuestionIds.push(item.questionId)
  1069. }
  1070. }
  1071. });
  1072. //大于60分及格
  1073. if(score >= 60) {
  1074. reportStatus = 1
  1075. } else {
  1076. reportStatus = 0
  1077. }
  1078. //交卷
  1079. this.$api
  1080. .examRecordEdit({
  1081. examId: this.id,
  1082. goodsId: this.goodsId,
  1083. orderGoodsId:this.orderGoodsId,
  1084. reportStatus:reportStatus,
  1085. recordId: this.recordId,
  1086. rightQuestionNum: number,
  1087. status: 1,
  1088. moduleExamId:this.moduleId || 0,
  1089. chapterExamId:this.chapterId || 0,
  1090. doQuestionIds:doQuestionIds.join(','),
  1091. rightQuestionIds:rightQuestionIds.join(','),
  1092. doQuestionNum: doQuestionNum,
  1093. performance: score,
  1094. totalScore: allScore,
  1095. examTime: parseInt(this.allTimes),
  1096. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1097. historyExamJson: JSON.stringify(this.questionList)
  1098. })
  1099. .then(res => {
  1100. this.isSubmit = true;
  1101. if (res.data.code == 200) {
  1102. }
  1103. });
  1104. //错题集id提交(客观题)
  1105. this.$api.examWrongRecord({
  1106. moduleExamId:this.moduleId || 0,
  1107. chapterExamId:this.chapterId || 0,
  1108. examId: this.id,
  1109. goodsId: this.goodsId,
  1110. orderGoodsId:this.orderGoodsId,
  1111. questionIds: doWrongQuestionIds,
  1112. recordId: this.recordId
  1113. }).then(res => {
  1114. });
  1115. },
  1116. openFooterTab() {
  1117. this.show = true;
  1118. },
  1119. hideDialog() {
  1120. this.showDialog = false
  1121. },
  1122. changeIndex(index) {
  1123. this.current = index
  1124. },
  1125. swiperChange(e) {
  1126. this.current = e.detail.current;
  1127. },
  1128. deleteImg(imgIndex,bankIndex) {
  1129. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  1130. },
  1131. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  1132. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  1133. },
  1134. chooseImg(bankindex) {
  1135. uni.chooseImage({
  1136. count: 1, //默认9
  1137. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  1138. sourceType: ['album','camera'], //从相册选择
  1139. success: (res) => {
  1140. let self = this;
  1141. // console.log(JSON.stringify(res.tempFilePaths));
  1142. let img = res.tempFilePaths[0];
  1143. uni.getImageInfo({
  1144. src: img,
  1145. success: async res => {
  1146. let canvasWidth = res.width; //图片原始长宽
  1147. let canvasHeight = res.height;
  1148. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1149. uni.compressImage({
  1150. src: img,
  1151. quality: 75,
  1152. width: '50%',
  1153. height: '50%',
  1154. success: async rest => {
  1155. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1156. this.questionList[bankindex].ansText.imageList.push(dir)
  1157. }
  1158. });
  1159. } else {
  1160. const dir = await self.uploadFile(img, 0);
  1161. this.questionList[bankindex].ansText.imageList.push(dir)
  1162. }
  1163. }
  1164. });
  1165. }
  1166. })
  1167. },
  1168. chooseImgChild(bankindex,ansindex) {
  1169. uni.chooseImage({
  1170. count: 1, //默认9
  1171. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  1172. sourceType: ['album','camera'], //从相册选择
  1173. success: (res) => {
  1174. let self = this;
  1175. // console.log(JSON.stringify(res.tempFilePaths));
  1176. let img = res.tempFilePaths[0];
  1177. uni.getImageInfo({
  1178. src: img,
  1179. success: async res => {
  1180. let canvasWidth = res.width; //图片原始长宽
  1181. let canvasHeight = res.height;
  1182. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1183. uni.compressImage({
  1184. src: img,
  1185. quality: 75,
  1186. width: '50%',
  1187. height: '50%',
  1188. success: async rest => {
  1189. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1190. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  1191. }
  1192. });
  1193. } else {
  1194. const dir = await self.uploadFile(img, 0);
  1195. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  1196. }
  1197. }
  1198. });
  1199. }
  1200. })
  1201. },
  1202. uploadFile(options, int) {
  1203. var self = this;
  1204. return new Promise((resolve, reject) => {
  1205. var data = {
  1206. orderGoodsId:this.orderGoodsId,
  1207. imageStatus: int
  1208. };
  1209. self.$api.aliyunpolicy(data).then(res => {
  1210. console.log(res.data,6)
  1211. if(res.data.code!=200){
  1212. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  1213. return
  1214. }
  1215. var ossToken = res.data.data.resultContent;
  1216. if(ossToken.host==null||ossToken.host==undefined){
  1217. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  1218. return
  1219. }
  1220. uni.uploadFile({
  1221. url: ossToken.host,
  1222. name: 'file',
  1223. filePath: options,
  1224. fileType: 'image',
  1225. header: {
  1226. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1227. },
  1228. formData: {
  1229. key: ossToken.dir,
  1230. OSSAccessKeyId: ossToken.accessid,
  1231. policy: ossToken.policy,
  1232. Signature: ossToken.signature,
  1233. callback: ossToken.callback,
  1234. success_action_status: 200
  1235. },
  1236. success: result => {
  1237. if (result.statusCode === 200) {
  1238. resolve(ossToken.dir);
  1239. } else {
  1240. uni.showToast({
  1241. title: '上传失败',
  1242. icon: 'none'
  1243. });
  1244. return;
  1245. }
  1246. },
  1247. fail: error => {
  1248. uni.showToast({
  1249. title: '上传接口报错'+error,
  1250. icon: 'none'
  1251. });
  1252. return;
  1253. }
  1254. });
  1255. });
  1256. });
  1257. },
  1258. submitAns(bankindex) {
  1259. console.log(this.questionList[bankindex])
  1260. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1261. uni.showToast({
  1262. title: '请输入内容或上传图片',
  1263. duration: 2000,
  1264. icon:'none'
  1265. });
  1266. return
  1267. }
  1268. this.$set(this.questionList[bankindex],'ques',{
  1269. imageList:this.questionList[bankindex].ansText.imageList,
  1270. text:this.questionList[bankindex].ansText.text,
  1271. })
  1272. this.isDoOver()
  1273. },
  1274. submitAnsChild(bankindex,ansindex) {
  1275. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1276. uni.showToast({
  1277. title: '请输入内容或上传图片',
  1278. duration: 2000,
  1279. icon:'none'
  1280. });
  1281. return
  1282. }
  1283. this.$set(this.questionList[bankindex].ques,ansindex,{
  1284. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1285. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  1286. })
  1287. this.isDoOver()
  1288. },
  1289. isRight(item,index) {
  1290. //单选
  1291. if(this.questionList[index].ques) {
  1292. if(item.type == 1) {
  1293. return this.questionList[index].ques == this.questionList[index].ans;
  1294. //多选
  1295. } else if(item.type == 2) {
  1296. //每一项都相等
  1297. return this.questionList[index].ans.every((item,i) => {
  1298. return item == this.questionList[index].ques[i];
  1299. })
  1300. //判断
  1301. } else if(item.type == 3) {
  1302. return this.questionList[index].ques == this.questionList[index].ans;
  1303. } else {
  1304. return false;
  1305. }
  1306. } else {
  1307. return false;
  1308. }
  1309. },
  1310. right(bankIndex,ansIndex,option) {
  1311. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1312. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  1313. return true
  1314. } else {
  1315. return false;
  1316. }
  1317. } else {
  1318. return false;
  1319. }
  1320. },
  1321. wrong(bankIndex,ansIndex,option) {
  1322. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1323. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  1324. return true;
  1325. } else {
  1326. return false;
  1327. }
  1328. } else {
  1329. return false;
  1330. }
  1331. },
  1332. isWrong(item,index) {
  1333. if(this.questionList[index].ques) {
  1334. //单选
  1335. if(item.type == 1) {
  1336. return this.questionList[index].ques != this.questionList[index].ans;
  1337. //多选
  1338. } else if(item.type == 2) {
  1339. //每一项都相等
  1340. return this.questionList[index].ans.some((item,i) => {
  1341. return item != this.questionList[index].ques[i];
  1342. })
  1343. //判断
  1344. } else if(item.type == 3) {
  1345. return this.questionList[index].ques != this.questionList[index].ans;
  1346. } else {
  1347. return false;
  1348. }
  1349. } else {
  1350. return false;
  1351. }
  1352. },
  1353. isOver(item,index) {
  1354. if(this.questionList[index].ques) {
  1355. if (item.type == 4) { //案例题
  1356. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1357. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  1358. if (item.ques[indexs]) {
  1359. return true;
  1360. } else {
  1361. return false;
  1362. }
  1363. } else if (jsonItem.type == 5) {
  1364. if (item.ques[indexs] && (item.ques[indexs].text || item.ques[indexs].imageList.length)) {
  1365. console.log('chil')
  1366. return true;
  1367. } else {
  1368. return false;
  1369. }
  1370. }
  1371. });
  1372. if (isOver) {
  1373. return true;
  1374. } else {
  1375. return false;
  1376. }
  1377. } else if (item.type == 5) { //简答题
  1378. //每一项都相等
  1379. if(item.ques && (item.ques.imageList.length || item.ques.text)) {
  1380. return true;
  1381. }
  1382. //判断
  1383. } else {
  1384. return false;
  1385. }
  1386. } else {
  1387. return false;
  1388. }
  1389. },
  1390. tabSelect(index,bankindex) {
  1391. this.$set(this.questionList[bankindex],'current',index)
  1392. },
  1393. showPhoto(contentStr) {
  1394. if(contentStr && typeof contentStr == 'string') {
  1395. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  1396. let strArr = contentStr.match(reg);
  1397. strArr.forEach((str,index) => {
  1398. strArr[index] = str.replace(reg,'$1')
  1399. })
  1400. // 预览图片
  1401. uni.previewImage({
  1402. urls: strArr,
  1403. longPressActions: {
  1404. itemList: ['发送给朋友', '保存图片', '收藏'],
  1405. success: function(data) {
  1406. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  1407. },
  1408. fail: function(err) {
  1409. console.log(err.errMsg);
  1410. }
  1411. }
  1412. });
  1413. }
  1414. }
  1415. }
  1416. };
  1417. </script>
  1418. <style lang="scss" scoped>
  1419. .questionBank {
  1420. width:100%;
  1421. height:100vh;
  1422. display: flex;
  1423. flex-direction: column;
  1424. }
  1425. .swiper {
  1426. width:100%;
  1427. flex:1;
  1428. }
  1429. .lisSty {
  1430. margin-bottom: 16rpx;
  1431. display: flex;
  1432. align-items: center;
  1433. .flex_auto {
  1434. flex:1;
  1435. }
  1436. }
  1437. .activeTI {
  1438. vertical-align: middle;
  1439. display: inline-block;
  1440. border: 1rpx solid #eee;
  1441. border-radius: 50rpx;
  1442. height: 48rpx;
  1443. line-height: 46rpx;
  1444. text-align: center;
  1445. width: 48rpx;
  1446. margin-right: 15rpx;
  1447. color: #666;
  1448. font-size: 30rpx;
  1449. &.right {
  1450. color:#fff;
  1451. background:#36C75A;
  1452. }
  1453. &.wrong {
  1454. color:#fff;
  1455. background:#FF3B30;
  1456. }
  1457. &.checked {
  1458. color:#fff;
  1459. background:#007AFF;
  1460. }
  1461. }
  1462. .submit_checkbox {
  1463. position:fixed;
  1464. left:0;
  1465. right:0;
  1466. bottom:120rpx;
  1467. margin: 20rpx auto;
  1468. left:0;
  1469. right:0;
  1470. bottom:120rpx;
  1471. margin: 20rpx auto;
  1472. width: 526rpx;
  1473. height: 80rpx;
  1474. background: rgba(0, 122, 255, 1);
  1475. color:#fff;
  1476. text-align: center;
  1477. line-height: 80rpx;
  1478. font-size: 30rpx;
  1479. border-radius: 40rpx;
  1480. &.disabled {
  1481. opacity: 0.6;
  1482. }
  1483. }
  1484. .titles {
  1485. overflow: hidden;
  1486. margin-bottom: 24rpx;
  1487. }
  1488. .titBox {
  1489. padding: 41rpx 25rpx 24rpx 25rpx;
  1490. }
  1491. .titBox_title {
  1492. padding: 21rpx;
  1493. }
  1494. .tabs {
  1495. margin:10rpx;
  1496. display: flex;
  1497. .tab {
  1498. margin: 0 4rpx;
  1499. padding:10rpx 13rpx;
  1500. text-align: center;
  1501. color: #007aff;
  1502. font-size: 28rpx;
  1503. border-radius: 16rpx;
  1504. background:#fff;
  1505. &.current {
  1506. color:#fff;
  1507. background: #007AFF;
  1508. }
  1509. }
  1510. }
  1511. .ans {
  1512. margin:8rpx 8rpx 8rpx;
  1513. .ans_input {
  1514. border-radius: 16rpx;
  1515. background:#fff;
  1516. .top {
  1517. border-bottom:1rpx solid #EEEEEE;
  1518. padding: 16rpx;
  1519. display: flex;
  1520. align-items: center;
  1521. .icon {
  1522. margin-right:20rpx;
  1523. width: 40rpx;
  1524. height: 38rpx;
  1525. }
  1526. .progress {
  1527. flex:1;
  1528. }
  1529. .submit {
  1530. width: 168rpx;
  1531. height: 48rpx;
  1532. line-height: 48rpx;
  1533. text-align: center;
  1534. color:#fff;
  1535. font-size: 30rpx;
  1536. background: #007AFF;
  1537. border-radius: 24rpx;
  1538. &.disabled {
  1539. opacity: 0.6;
  1540. }
  1541. }
  1542. }
  1543. .textarea {
  1544. textarea {
  1545. width:100%;
  1546. height:287rpx;
  1547. padding:10rpx;
  1548. }
  1549. }
  1550. .imgs {
  1551. overflow: hidden;
  1552. display: flex;
  1553. width:100%;
  1554. .img {
  1555. width: 104rpx;
  1556. height: 104rpx;
  1557. border-radius: 8rpx;
  1558. position:relative;
  1559. margin:20rpx;
  1560. text {
  1561. position:absolute;
  1562. right:-15rpx;
  1563. top:-15rpx;
  1564. width:30rpx;
  1565. height:30rpx;
  1566. text-align: center;
  1567. line-height: 30rpx;
  1568. color:#fff;
  1569. background:#FF3B30;
  1570. border-radius:50%;
  1571. }
  1572. image {
  1573. width:100%;
  1574. height:100%;
  1575. }
  1576. }
  1577. }
  1578. }
  1579. .ans_submit {
  1580. padding:16rpx;
  1581. border-radius: 16rpx;
  1582. background:#fff;
  1583. .imgs {
  1584. overflow: hidden;
  1585. display: flex;
  1586. width:100%;
  1587. .img {
  1588. width: 104rpx;
  1589. height: 104rpx;
  1590. border-radius: 8rpx;
  1591. position:relative;
  1592. margin:20rpx;
  1593. image {
  1594. width:100%;
  1595. height:100%;
  1596. }
  1597. }
  1598. }
  1599. }
  1600. }
  1601. .leftLetters {
  1602. display: flex;
  1603. align-items: center;
  1604. width: 220rpx;
  1605. .btnType {
  1606. padding: 5rpx 10rpx;
  1607. border: 1rpx solid #007aff;
  1608. border-radius: 10rpx;
  1609. background-color: rgba(0, 122, 255, 0.1);
  1610. font-size: 28rpx;
  1611. color: #007aff;
  1612. margin-right: 15rpx;
  1613. }
  1614. }
  1615. .firstLetter {
  1616. display: flex;
  1617. justify-content: space-between;
  1618. align-items: center;
  1619. margin-bottom: 30rpx;
  1620. }
  1621. .popupView {
  1622. height: 100%;
  1623. padding-bottom: 100rpx;
  1624. .popupTops {
  1625. height: 77rpx;
  1626. border-bottom: 1rpx solid #eee;
  1627. text-align: center;
  1628. line-height: 77rpx;
  1629. font-size: 24rpx;
  1630. color: #999;
  1631. position: relative;
  1632. .topIcon {
  1633. position: absolute;
  1634. top: 10rpx;
  1635. left: 50%;
  1636. transform: translateX(-50%);
  1637. width: 80rpx;
  1638. height: 8rpx;
  1639. background-color: #999;
  1640. border-radius: 4rpx;
  1641. }
  1642. }
  1643. .popupContent {
  1644. }
  1645. }
  1646. .pageContent {
  1647. position:relative;
  1648. background-color: #eaeef1;
  1649. height: 100%;
  1650. overflow-y: scroll;
  1651. padding-top: 8rpx;
  1652. padding-bottom: 100rpx;
  1653. }
  1654. .pad_8 {
  1655. background-color: #fff;
  1656. margin: 0rpx 8rpx 8rpx;
  1657. border-radius: 16rpx;
  1658. &.no-margin {
  1659. margin-top:-16rpx;
  1660. border-radius: 0 0 16rpx 16rpx;
  1661. }
  1662. }
  1663. .answer {
  1664. height: 80rpx;
  1665. line-height: 80rpx;
  1666. padding: 0rpx 24rpx;
  1667. display: flex;
  1668. align-items: center;
  1669. justify-content: space-between;
  1670. color: #666;
  1671. font-size: 30rpx;
  1672. }
  1673. .footer_btn {
  1674. background-color: #fff;
  1675. z-index: 10078;
  1676. position: fixed;
  1677. bottom: 0rpx;
  1678. display: flex;
  1679. align-items: center;
  1680. justify-content: space-between;
  1681. width: 100%;
  1682. height: 98rpx;
  1683. padding: 0rpx 38rpx;
  1684. border-top: 1rpx solid #eee;
  1685. .flex_center {
  1686. flex:1;
  1687. display: flex;
  1688. justify-content: center;
  1689. align-items: center;
  1690. flex-direction: column;
  1691. margin:0 200rpx;
  1692. font-size: 24rpx;
  1693. color: #999999;
  1694. .up-icon {
  1695. margin-bottom:18rpx;
  1696. width:100%;
  1697. display: flex;
  1698. justify-content: center;
  1699. image {
  1700. width:58rpx;
  1701. height:21rpx;
  1702. }
  1703. }
  1704. }
  1705. .collect {
  1706. visibility: hidden;
  1707. width:100rpx;
  1708. &.show {
  1709. visibility: visible;
  1710. }
  1711. >view {
  1712. display: flex;
  1713. flex-direction: column;
  1714. align-items: center;
  1715. justify-content: center;
  1716. image {
  1717. width:32rpx;
  1718. height:32rpx;
  1719. margin-bottom:6rpx;
  1720. }
  1721. view {
  1722. font-size: 24rpx;
  1723. color: #999999;
  1724. }
  1725. }
  1726. }
  1727. }
  1728. .boxSty {
  1729. padding: 44rpx 41rpx 0rpx;
  1730. }
  1731. .liListSty {
  1732. border:1rpx solid #EEEEEE;
  1733. width: 88rpx;
  1734. height: 88rpx;
  1735. border-radius: 32rpx;
  1736. text-align: center;
  1737. line-height: 88rpx;
  1738. color: #333;
  1739. font-size: 32rpx;
  1740. float: left;
  1741. margin: 20rpx 23rpx;
  1742. &.isRight {
  1743. border:1rpx solid #EEEEEE;
  1744. color:#fff;
  1745. background: #36C75A;
  1746. }
  1747. &.isWrong {
  1748. border:1rpx solid #EEEEEE;
  1749. color:#fff;
  1750. background: #FF3B30;
  1751. }
  1752. &.isOver {
  1753. border: 1rpx solid #eeeeee;
  1754. color: #fff;
  1755. background: blue;
  1756. }
  1757. }
  1758. .answerInfos {
  1759. padding: 25rpx 25rpx 25rpx 23rpx;
  1760. }
  1761. .answerTitle {
  1762. margin-bottom: 28rpx;
  1763. color: #666;
  1764. font-size: 30rpx;
  1765. }
  1766. .answerContent {
  1767. font-size: 30rpx;
  1768. color: #666;
  1769. }
  1770. .textChild {
  1771. display: inline-block;
  1772. vertical-align: middle;
  1773. }
  1774. .dialog {
  1775. position: fixed;
  1776. left:0;
  1777. top:0;
  1778. width:100%;
  1779. height:100%;
  1780. background-color: rgba(0,0,0,0.8);
  1781. display: flex;
  1782. flex-direction: column;
  1783. align-items: center;
  1784. justify-content: center;
  1785. z-index: 20000;
  1786. .pointer {
  1787. width:338rpx;
  1788. height:240rpx;
  1789. }
  1790. .text {
  1791. font-size: 32rpx;
  1792. color: #FFFFFF;
  1793. text-align: center;
  1794. }
  1795. .btn {
  1796. width: 242rpx;
  1797. height: 82rpx;
  1798. border: 2rpx solid #FFFFFF;
  1799. border-radius: 16rpx;
  1800. text-align: center;
  1801. line-height: 82rpx;
  1802. margin:41rpx auto;
  1803. color:#fff;
  1804. font-size: 32rpx;
  1805. }
  1806. }
  1807. .popboxs {
  1808. width: 100%;
  1809. height: 100%;
  1810. display: flex;
  1811. flex-direction: column;
  1812. align-items: center;
  1813. }
  1814. .classTops {
  1815. flex-shrink: 0;
  1816. padding: 39rpx 0rpx 4rpx;
  1817. font-weight: bold;
  1818. color: #333;
  1819. font-size: 30rpx;
  1820. }
  1821. .textStys {
  1822. width: 100%;
  1823. flex: 1;
  1824. padding: 36rpx;
  1825. }
  1826. .classFootsty {
  1827. flex-shrink: 0;
  1828. display: flex;
  1829. align-items: center;
  1830. justify-content: center;
  1831. padding: 10rpx 0rpx 40rpx;
  1832. .btnsty {
  1833. width: 200rpx;
  1834. height: 80rpx;
  1835. border-radius: 40rpx;
  1836. font-weight: bold;
  1837. font-size: 30rpx;
  1838. text-align: center;
  1839. line-height: 80rpx;
  1840. }
  1841. .btns1 {
  1842. background-color: #f5f5f5;
  1843. color: #007aff;
  1844. }
  1845. .btns2 {
  1846. margin-left: 40rpx;
  1847. background-color: #007aff;
  1848. color: #ffffff;
  1849. }
  1850. }
  1851. </style>