questionBank.vue 50 KB

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