questionBank.vue 48 KB

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