questionBankContinue.vue 49 KB

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