questionBank.vue 50 KB

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