questionBank.vue 53 KB

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