questionBank.vue 48 KB

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