questionBankContinue.vue 49 KB

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