questionBank.vue 50 KB

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