questionBank.vue 48 KB

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