questionBank.vue 49 KB

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