questionBankContinue.vue 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929
  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. allScore += item.score;
  819. if (item.ques && item.ques.length) {
  820. doQuestionNum++;
  821. doQuestionIds.push(item.questionId)
  822. }
  823. } else if (item.type == 5) {
  824. allScore += item.score;
  825. if (item.ques && (item.ques.imageList || item.ques.text)) {
  826. doQuestionNum++;
  827. doQuestionIds.push(item.questionId)
  828. }
  829. }
  830. })
  831. //大于及格
  832. if(score >= passScore) {
  833. reportStatus = 1
  834. } else {
  835. reportStatus = 0
  836. }
  837. this.$api.examRecordEdit({
  838. examId:this.id,
  839. goodsId:this.goodsId,
  840. reportStatus:reportStatus,
  841. totalScore:allScore,
  842. recordId: this.recordId,
  843. rightQuestionNum:number,
  844. status:1,
  845. moduleExamId:this.moduleId || 0,
  846. chapterExamId:this.chapterId || 0,
  847. doQuestionIds:doQuestionIds.join(','),
  848. rightQuestionIds:rightQuestionIds.join(','),
  849. doQuestionNum: doQuestionNum,
  850. performance: score,
  851. historyExamJson:JSON.stringify(this.questionList)
  852. }).then(res => {
  853. this.isSubmit = true;
  854. if(res.data.code == 200) {
  855. uni.showToast({
  856. title: '交卷成功',
  857. duration: 2000,
  858. icon:'none'
  859. });
  860. setTimeout(() => {
  861. uni.redirectTo({
  862. url:'/pages2/bank/question_report?id='+this.recordId+'&examId='+this.id
  863. })
  864. },2000)
  865. }
  866. })
  867. //错题集id提交(客观题)
  868. this.$api.examWrongRecord({
  869. examId: this.id,
  870. goodsId: this.goodsId,
  871. questionIds: doWrongQuestionIds,
  872. recordId: this.recordId
  873. }).then(res => {
  874. });
  875. },
  876. isCheckboxChecked(arr) {
  877. return arr.some(item => {
  878. if (item.checked) {
  879. return true;
  880. }
  881. });
  882. },
  883. /**
  884. * @param {Object} 多选确认
  885. */
  886. checkboxSubmit(bindex) {
  887. if(this.questionList[bindex].ques) return;
  888. let arr = [];
  889. this.questionList[bindex].jsonStr.forEach(item => {
  890. if(item.checked) {
  891. arr.push(item.optionsId)
  892. }
  893. })
  894. if(!arr.length) {
  895. uni.showToast({
  896. title:'请选择答案',
  897. icon:'none'
  898. })
  899. return;
  900. }
  901. this.$set(this.questionList[bindex],'ques',arr)
  902. this.isDoOver()
  903. },
  904. /**
  905. * @param {Object} 多选确认
  906. */
  907. checkboxSubmitChild(bindex,ansIndex) {
  908. if(this.questionList[bindex].ques[ansIndex]) return;
  909. let arr = [];
  910. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  911. if(item.checked) {
  912. arr.push(item.optionsId)
  913. }
  914. })
  915. if(!arr.length) {
  916. uni.showToast({
  917. title:'请选择答案',
  918. icon:'none'
  919. })
  920. return;
  921. }
  922. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  923. this.isDoOver()
  924. },
  925. judgeSelect(index,bindex) {
  926. if(this.questionList[bindex].ques) return;
  927. this.$set(this.questionList[bindex],'ques',index+'')
  928. this.isDoOver()
  929. },
  930. judgeSelectChild(ansindex,childindex,bindex) {
  931. if(this.questionList[bindex].ques[ansindex]) return;
  932. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  933. this.isDoOver()
  934. },
  935. /**
  936. * 立即离开并交卷
  937. */
  938. leaveNow() {
  939. this.needBack = false;
  940. this.isSubmit = true;
  941. uni.navigateBack({
  942. delta: 1
  943. });
  944. let score = 0; //计算总分
  945. let reportStatus = 0;
  946. let number = 0; //做对的题目数量
  947. let doQuestionNum = 0; //做过的题目数量
  948. let allScore = 0; //总分
  949. let passScore = 0;
  950. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  951. let doQuestionIds = []; //做过的题目id
  952. let rightQuestionIds = []; //做对的题目id
  953. this.questionList.forEach((item, index) => {
  954. // passScore = item.passScore
  955. if (item.type == 1) {
  956. //正确
  957. if (item.ques == item.ans) {
  958. item.scoreResult = item.score;
  959. score += item.score;
  960. number++;
  961. rightQuestionIds.push(item.questionId)
  962. } else { //错误
  963. item.scoreResult = 0;
  964. doWrongQuestionIds.push(item.questionId)
  965. }
  966. allScore += item.score;
  967. if (item.ques) {
  968. doQuestionNum++;
  969. doQuestionIds.push(item.questionId)
  970. }
  971. } else if (item.type == 2) {
  972. let isRight =
  973. item.ans &&
  974. item.ans.every((quesItem, quesIndex) => {
  975. if(item.ques) {
  976. return item.ques[quesIndex] == item.ans[quesIndex];
  977. } else {
  978. return false;
  979. }
  980. });
  981. if (isRight) {
  982. score += item.score;
  983. number++;
  984. item.scoreResult = item.score;
  985. rightQuestionIds.push(item.questionId)
  986. } else {
  987. let checkboxScore = item.score; //获取单题总分数
  988. item.ques && item.ques.forEach((ques,quesIndex) => {
  989. //选错一个全扣
  990. if(item.ques) {
  991. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  992. checkboxScore = 0;
  993. }
  994. } else {
  995. checkboxScore = 0;
  996. }
  997. })
  998. console.log(checkboxScore)
  999. //没选错
  1000. if(checkboxScore) {
  1001. item.ans.forEach((ans,quesIndex) => {
  1002. //漏选扣一部分
  1003. if(item.ques) {
  1004. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1005. checkboxScore = item.partScore;
  1006. }
  1007. } else {
  1008. checkboxScore = 0;
  1009. }
  1010. })
  1011. }
  1012. if(checkboxScore <= 0) { //0分
  1013. item.scoreResult = 0;
  1014. doWrongQuestionIds.push(item.questionId)
  1015. } else { //部分分
  1016. number++;
  1017. item.scoreResult = checkboxScore;
  1018. score += checkboxScore;
  1019. rightQuestionIds.push(item.questionId)
  1020. }
  1021. }
  1022. allScore += item.score;
  1023. if (item.ques && item.ques.length) {
  1024. doQuestionNum++;
  1025. doQuestionIds.push(item.questionId)
  1026. }
  1027. } else if (item.type == 3) {
  1028. if (item.ques == item.ans) {
  1029. item.scoreResult = item.score;
  1030. score += item.score;
  1031. number++;
  1032. rightQuestionIds.push(item.questionId)
  1033. } else {
  1034. item.scoreResult = 0;
  1035. doWrongQuestionIds.push(item.questionId)
  1036. }
  1037. allScore += item.score;
  1038. if (item.ques) {
  1039. doQuestionNum++;
  1040. doQuestionIds.push(item.questionId)
  1041. }
  1042. } else if (item.type == 4) {
  1043. if (item.ques && item.ques.length) {
  1044. doQuestionNum++;
  1045. doQuestionIds.push(item.questionId)
  1046. }
  1047. } else if (item.type == 5) {
  1048. if (item.ques && (item.ques.imageList || item.ques.text)) {
  1049. doQuestionNum++;
  1050. doQuestionIds.push(item.questionId)
  1051. }
  1052. }
  1053. });
  1054. //大于60分及格
  1055. if(score >= 60) {
  1056. reportStatus = 1
  1057. } else {
  1058. reportStatus = 0
  1059. }
  1060. //交卷
  1061. this.$api
  1062. .examRecordEdit({
  1063. examId: this.id,
  1064. goodsId: this.goodsId,
  1065. reportStatus:reportStatus,
  1066. recordId: this.recordId,
  1067. rightQuestionNum: number,
  1068. status: 1,
  1069. moduleExamId:this.moduleId || 0,
  1070. chapterExamId:this.chapterId || 0,
  1071. doQuestionIds:doQuestionIds.join(','),
  1072. rightQuestionIds:rightQuestionIds.join(','),
  1073. doQuestionNum: doQuestionNum,
  1074. performance: score,
  1075. totalScore: allScore,
  1076. examTime: parseInt(this.allTimes),
  1077. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1078. historyExamJson: JSON.stringify(this.questionList)
  1079. })
  1080. .then(res => {
  1081. this.isSubmit = true;
  1082. if (res.data.code == 200) {
  1083. }
  1084. });
  1085. //错题集id提交(客观题)
  1086. this.$api.examWrongRecord({
  1087. moduleExamId:this.moduleId || 0,
  1088. chapterExamId:this.chapterId || 0,
  1089. examId: this.id,
  1090. goodsId: this.goodsId,
  1091. questionIds: doWrongQuestionIds,
  1092. recordId: this.recordId
  1093. }).then(res => {
  1094. });
  1095. },
  1096. openFooterTab() {
  1097. this.show = true;
  1098. },
  1099. hideDialog() {
  1100. this.showDialog = false
  1101. },
  1102. changeIndex(index) {
  1103. this.current = index
  1104. },
  1105. swiperChange(e) {
  1106. this.current = e.detail.current;
  1107. },
  1108. deleteImg(imgIndex,bankIndex) {
  1109. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  1110. },
  1111. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  1112. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  1113. },
  1114. chooseImg(bankindex) {
  1115. uni.chooseImage({
  1116. count: 1, //默认9
  1117. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  1118. sourceType: ['album','camera'], //从相册选择
  1119. success: (res) => {
  1120. let self = this;
  1121. // console.log(JSON.stringify(res.tempFilePaths));
  1122. let img = res.tempFilePaths[0];
  1123. uni.getImageInfo({
  1124. src: img,
  1125. success: async res => {
  1126. let canvasWidth = res.width; //图片原始长宽
  1127. let canvasHeight = res.height;
  1128. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1129. uni.compressImage({
  1130. src: img,
  1131. quality: 75,
  1132. width: '50%',
  1133. height: '50%',
  1134. success: async rest => {
  1135. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1136. this.questionList[bankindex].ansText.imageList.push(dir)
  1137. }
  1138. });
  1139. } else {
  1140. const dir = await self.uploadFile(img, 0);
  1141. this.questionList[bankindex].ansText.imageList.push(dir)
  1142. }
  1143. }
  1144. });
  1145. }
  1146. })
  1147. },
  1148. chooseImgChild(bankindex,ansindex) {
  1149. uni.chooseImage({
  1150. count: 1, //默认9
  1151. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  1152. sourceType: ['album','camera'], //从相册选择
  1153. success: (res) => {
  1154. let self = this;
  1155. // console.log(JSON.stringify(res.tempFilePaths));
  1156. let img = res.tempFilePaths[0];
  1157. uni.getImageInfo({
  1158. src: img,
  1159. success: async res => {
  1160. let canvasWidth = res.width; //图片原始长宽
  1161. let canvasHeight = res.height;
  1162. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1163. uni.compressImage({
  1164. src: img,
  1165. quality: 75,
  1166. width: '50%',
  1167. height: '50%',
  1168. success: async rest => {
  1169. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1170. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  1171. }
  1172. });
  1173. } else {
  1174. const dir = await self.uploadFile(img, 0);
  1175. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  1176. }
  1177. }
  1178. });
  1179. }
  1180. })
  1181. },
  1182. uploadFile(options, int) {
  1183. var self = this;
  1184. return new Promise((resolve, reject) => {
  1185. var data = {
  1186. imageStatus: int
  1187. };
  1188. self.$api.aliyunpolicy(data).then(res => {
  1189. console.log(res.data,6)
  1190. if(res.data.code!=200){
  1191. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  1192. return
  1193. }
  1194. var ossToken = res.data.data.resultContent;
  1195. if(ossToken.host==null||ossToken.host==undefined){
  1196. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  1197. return
  1198. }
  1199. uni.uploadFile({
  1200. url: ossToken.host,
  1201. name: 'file',
  1202. filePath: options,
  1203. fileType: 'image',
  1204. header: {
  1205. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1206. },
  1207. formData: {
  1208. key: ossToken.dir,
  1209. OSSAccessKeyId: ossToken.accessid,
  1210. policy: ossToken.policy,
  1211. Signature: ossToken.signature,
  1212. callback: ossToken.callback,
  1213. success_action_status: 200
  1214. },
  1215. success: result => {
  1216. if (result.statusCode === 200) {
  1217. resolve(ossToken.dir);
  1218. } else {
  1219. uni.showToast({
  1220. title: '上传失败',
  1221. icon: 'none'
  1222. });
  1223. return;
  1224. }
  1225. },
  1226. fail: error => {
  1227. uni.showToast({
  1228. title: '上传接口报错'+error,
  1229. icon: 'none'
  1230. });
  1231. return;
  1232. }
  1233. });
  1234. });
  1235. });
  1236. },
  1237. submitAns(bankindex) {
  1238. console.log(this.questionList[bankindex])
  1239. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1240. uni.showToast({
  1241. title: '请输入内容或上传图片',
  1242. duration: 2000,
  1243. icon:'none'
  1244. });
  1245. return
  1246. }
  1247. this.$set(this.questionList[bankindex],'ques',{
  1248. imageList:this.questionList[bankindex].ansText.imageList,
  1249. text:this.questionList[bankindex].ansText.text,
  1250. })
  1251. this.isDoOver()
  1252. },
  1253. submitAnsChild(bankindex,ansindex) {
  1254. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1255. uni.showToast({
  1256. title: '请输入内容或上传图片',
  1257. duration: 2000,
  1258. icon:'none'
  1259. });
  1260. return
  1261. }
  1262. this.$set(this.questionList[bankindex].ques,ansindex,{
  1263. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1264. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  1265. })
  1266. this.isDoOver()
  1267. },
  1268. isRight(item,index) {
  1269. //单选
  1270. if(this.questionList[index].ques) {
  1271. if(item.type == 1) {
  1272. return this.questionList[index].ques == this.questionList[index].ans;
  1273. //多选
  1274. } else if(item.type == 2) {
  1275. //每一项都相等
  1276. return this.questionList[index].ques.every((item,i) => {
  1277. console.log(item == this.questionList[index].ans[i])
  1278. return item == this.questionList[index].ans[i];
  1279. })
  1280. //判断
  1281. } else if(item.type == 3) {
  1282. return this.questionList[index].ques == this.questionList[index].ans;
  1283. } else {
  1284. return false;
  1285. }
  1286. } else {
  1287. return false;
  1288. }
  1289. },
  1290. right(bankIndex,ansIndex,option) {
  1291. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1292. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  1293. return true
  1294. } else {
  1295. return false;
  1296. }
  1297. } else {
  1298. return false;
  1299. }
  1300. },
  1301. wrong(bankIndex,ansIndex,option) {
  1302. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1303. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  1304. return true;
  1305. } else {
  1306. return false;
  1307. }
  1308. } else {
  1309. return false;
  1310. }
  1311. },
  1312. isWrong(item,index) {
  1313. if(this.questionList[index].ques) {
  1314. //单选
  1315. if(item.type == 1) {
  1316. return this.questionList[index].ques != this.questionList[index].ans;
  1317. //多选
  1318. } else if(item.type == 2) {
  1319. //每一项都相等
  1320. return this.questionList[index].ques.some((item,i) => {
  1321. return item != this.questionList[index].ans[i];
  1322. })
  1323. //判断
  1324. } else if(item.type == 3) {
  1325. return this.questionList[index].ques != this.questionList[index].ans;
  1326. } else {
  1327. return false;
  1328. }
  1329. } else {
  1330. return false;
  1331. }
  1332. },
  1333. tabSelect(index,bankindex) {
  1334. this.$set(this.questionList[bankindex],'current',index)
  1335. },
  1336. }
  1337. };
  1338. </script>
  1339. <style lang="scss" scoped>
  1340. .questionBank {
  1341. width:100%;
  1342. height:100vh;
  1343. display: flex;
  1344. flex-direction: column;
  1345. }
  1346. .swiper {
  1347. width:100%;
  1348. flex:1;
  1349. }
  1350. .lisSty {
  1351. margin-bottom: 16rpx;
  1352. display: flex;
  1353. align-items: center;
  1354. .flex_auto {
  1355. flex:1;
  1356. }
  1357. }
  1358. .activeTI {
  1359. vertical-align: middle;
  1360. display: inline-block;
  1361. border: 1rpx solid #eee;
  1362. border-radius: 50rpx;
  1363. height: 48rpx;
  1364. line-height: 46rpx;
  1365. text-align: center;
  1366. width: 48rpx;
  1367. margin-right: 15rpx;
  1368. color: #666;
  1369. font-size: 30rpx;
  1370. &.right {
  1371. color:#fff;
  1372. background:#36C75A;
  1373. }
  1374. &.wrong {
  1375. color:#fff;
  1376. background:#FF3B30;
  1377. }
  1378. &.checked {
  1379. color:#fff;
  1380. background:#007AFF;
  1381. }
  1382. }
  1383. .submit_checkbox {
  1384. position:fixed;
  1385. left:0;
  1386. right:0;
  1387. bottom:120rpx;
  1388. margin: 20rpx auto;
  1389. left:0;
  1390. right:0;
  1391. bottom:120rpx;
  1392. margin: 20rpx auto;
  1393. width: 526rpx;
  1394. height: 80rpx;
  1395. background: rgba(0, 122, 255, 1);
  1396. color:#fff;
  1397. text-align: center;
  1398. line-height: 80rpx;
  1399. font-size: 30rpx;
  1400. border-radius: 40rpx;
  1401. &.disabled {
  1402. opacity: 0.6;
  1403. }
  1404. }
  1405. .titles {
  1406. overflow: hidden;
  1407. margin-bottom: 24rpx;
  1408. }
  1409. .titBox {
  1410. padding: 41rpx 25rpx 24rpx 25rpx;
  1411. }
  1412. .titBox_title {
  1413. padding: 21rpx;
  1414. }
  1415. .tabs {
  1416. margin:10rpx;
  1417. display: flex;
  1418. .tab {
  1419. margin: 0 4rpx;
  1420. padding:10rpx 13rpx;
  1421. text-align: center;
  1422. color: #007aff;
  1423. font-size: 28rpx;
  1424. border-radius: 16rpx;
  1425. background:#fff;
  1426. &.current {
  1427. color:#fff;
  1428. background: #007AFF;
  1429. }
  1430. }
  1431. }
  1432. .ans {
  1433. margin:8rpx 8rpx 8rpx;
  1434. .ans_input {
  1435. border-radius: 16rpx;
  1436. background:#fff;
  1437. .top {
  1438. border-bottom:1rpx solid #EEEEEE;
  1439. padding: 16rpx;
  1440. display: flex;
  1441. align-items: center;
  1442. .icon {
  1443. margin-right:20rpx;
  1444. width: 40rpx;
  1445. height: 38rpx;
  1446. }
  1447. .progress {
  1448. flex:1;
  1449. }
  1450. .submit {
  1451. width: 168rpx;
  1452. height: 48rpx;
  1453. line-height: 48rpx;
  1454. text-align: center;
  1455. color:#fff;
  1456. font-size: 30rpx;
  1457. background: #007AFF;
  1458. border-radius: 24rpx;
  1459. &.disabled {
  1460. opacity: 0.6;
  1461. }
  1462. }
  1463. }
  1464. .textarea {
  1465. textarea {
  1466. width:100%;
  1467. height:287rpx;
  1468. padding:10rpx;
  1469. }
  1470. }
  1471. .imgs {
  1472. overflow: hidden;
  1473. display: flex;
  1474. width:100%;
  1475. .img {
  1476. width: 104rpx;
  1477. height: 104rpx;
  1478. border-radius: 8rpx;
  1479. position:relative;
  1480. margin:20rpx;
  1481. text {
  1482. position:absolute;
  1483. right:-15rpx;
  1484. top:-15rpx;
  1485. width:30rpx;
  1486. height:30rpx;
  1487. text-align: center;
  1488. line-height: 30rpx;
  1489. color:#fff;
  1490. background:#FF3B30;
  1491. border-radius:50%;
  1492. }
  1493. image {
  1494. width:100%;
  1495. height:100%;
  1496. }
  1497. }
  1498. }
  1499. }
  1500. .ans_submit {
  1501. padding:16rpx;
  1502. border-radius: 16rpx;
  1503. background:#fff;
  1504. .imgs {
  1505. overflow: hidden;
  1506. display: flex;
  1507. width:100%;
  1508. .img {
  1509. width: 104rpx;
  1510. height: 104rpx;
  1511. border-radius: 8rpx;
  1512. position:relative;
  1513. margin:20rpx;
  1514. image {
  1515. width:100%;
  1516. height:100%;
  1517. }
  1518. }
  1519. }
  1520. }
  1521. }
  1522. .leftLetters {
  1523. display: flex;
  1524. align-items: center;
  1525. width: 220rpx;
  1526. .btnType {
  1527. padding: 5rpx 10rpx;
  1528. border: 1rpx solid #007aff;
  1529. border-radius: 10rpx;
  1530. background-color: rgba(0, 122, 255, 0.1);
  1531. font-size: 28rpx;
  1532. color: #007aff;
  1533. margin-right: 15rpx;
  1534. }
  1535. }
  1536. .firstLetter {
  1537. display: flex;
  1538. justify-content: space-between;
  1539. align-items: center;
  1540. margin-bottom: 30rpx;
  1541. }
  1542. .popupView {
  1543. height: 100%;
  1544. padding-bottom: 100rpx;
  1545. .popupTops {
  1546. height: 77rpx;
  1547. border-bottom: 1rpx solid #eee;
  1548. text-align: center;
  1549. line-height: 77rpx;
  1550. font-size: 24rpx;
  1551. color: #999;
  1552. position: relative;
  1553. .topIcon {
  1554. position: absolute;
  1555. top: 10rpx;
  1556. left: 50%;
  1557. transform: translateX(-50%);
  1558. width: 80rpx;
  1559. height: 8rpx;
  1560. background-color: #999;
  1561. border-radius: 4rpx;
  1562. }
  1563. }
  1564. .popupContent {
  1565. }
  1566. }
  1567. .pageContent {
  1568. position:relative;
  1569. background-color: #eaeef1;
  1570. height: 100%;
  1571. overflow-y: scroll;
  1572. padding-top: 8rpx;
  1573. padding-bottom: 100rpx;
  1574. }
  1575. .pad_8 {
  1576. background-color: #fff;
  1577. margin: 0rpx 8rpx 8rpx;
  1578. border-radius: 16rpx;
  1579. &.no-margin {
  1580. margin-top:-16rpx;
  1581. border-radius: 0 0 16rpx 16rpx;
  1582. }
  1583. }
  1584. .answer {
  1585. height: 80rpx;
  1586. line-height: 80rpx;
  1587. padding: 0rpx 24rpx;
  1588. display: flex;
  1589. align-items: center;
  1590. justify-content: space-between;
  1591. color: #666;
  1592. font-size: 30rpx;
  1593. }
  1594. .footer_btn {
  1595. background-color: #fff;
  1596. z-index: 10078;
  1597. position: fixed;
  1598. bottom: 0rpx;
  1599. display: flex;
  1600. align-items: center;
  1601. justify-content: space-between;
  1602. width: 100%;
  1603. height: 98rpx;
  1604. padding: 0rpx 38rpx;
  1605. border-top: 1rpx solid #eee;
  1606. .flex_center {
  1607. flex:1;
  1608. display: flex;
  1609. justify-content: center;
  1610. align-items: center;
  1611. flex-direction: column;
  1612. margin:0 200rpx;
  1613. font-size: 24rpx;
  1614. color: #999999;
  1615. .up-icon {
  1616. margin-bottom:18rpx;
  1617. width:100%;
  1618. display: flex;
  1619. justify-content: center;
  1620. image {
  1621. width:58rpx;
  1622. height:21rpx;
  1623. }
  1624. }
  1625. }
  1626. .collect {
  1627. visibility: hidden;
  1628. width:100rpx;
  1629. &.show {
  1630. visibility: visible;
  1631. }
  1632. >view {
  1633. display: flex;
  1634. flex-direction: column;
  1635. align-items: center;
  1636. justify-content: center;
  1637. image {
  1638. width:32rpx;
  1639. height:32rpx;
  1640. margin-bottom:6rpx;
  1641. }
  1642. view {
  1643. font-size: 24rpx;
  1644. color: #999999;
  1645. }
  1646. }
  1647. }
  1648. }
  1649. .boxSty {
  1650. padding: 44rpx 41rpx 0rpx;
  1651. }
  1652. .liListSty {
  1653. border:1rpx solid #EEEEEE;
  1654. width: 88rpx;
  1655. height: 88rpx;
  1656. border-radius: 32rpx;
  1657. text-align: center;
  1658. line-height: 88rpx;
  1659. color: #333;
  1660. font-size: 32rpx;
  1661. float: left;
  1662. margin: 20rpx 23rpx;
  1663. &.isRight {
  1664. border:1rpx solid #EEEEEE;
  1665. color:#fff;
  1666. background: #36C75A;
  1667. }
  1668. &.isWrong {
  1669. border:1rpx solid #EEEEEE;
  1670. color:#fff;
  1671. background: #FF3B30;
  1672. }
  1673. }
  1674. .answerInfos {
  1675. padding: 25rpx 25rpx 25rpx 23rpx;
  1676. }
  1677. .answerTitle {
  1678. margin-bottom: 28rpx;
  1679. color: #666;
  1680. font-size: 30rpx;
  1681. }
  1682. .answerContent {
  1683. font-size: 30rpx;
  1684. color: #666;
  1685. }
  1686. .textChild {
  1687. display: inline-block;
  1688. vertical-align: middle;
  1689. }
  1690. .dialog {
  1691. position: fixed;
  1692. left:0;
  1693. top:0;
  1694. width:100%;
  1695. height:100%;
  1696. background-color: rgba(0,0,0,0.8);
  1697. display: flex;
  1698. flex-direction: column;
  1699. align-items: center;
  1700. justify-content: center;
  1701. z-index: 20000;
  1702. .pointer {
  1703. width:338rpx;
  1704. height:240rpx;
  1705. }
  1706. .text {
  1707. font-size: 32rpx;
  1708. color: #FFFFFF;
  1709. text-align: center;
  1710. }
  1711. .btn {
  1712. width: 242rpx;
  1713. height: 82rpx;
  1714. border: 2rpx solid #FFFFFF;
  1715. border-radius: 16rpx;
  1716. text-align: center;
  1717. line-height: 82rpx;
  1718. margin:41rpx auto;
  1719. color:#fff;
  1720. font-size: 32rpx;
  1721. }
  1722. }
  1723. .popboxs {
  1724. width: 100%;
  1725. height: 100%;
  1726. display: flex;
  1727. flex-direction: column;
  1728. align-items: center;
  1729. }
  1730. .classTops {
  1731. flex-shrink: 0;
  1732. padding: 39rpx 0rpx 4rpx;
  1733. font-weight: bold;
  1734. color: #333;
  1735. font-size: 30rpx;
  1736. }
  1737. .textStys {
  1738. width: 100%;
  1739. flex: 1;
  1740. padding: 36rpx;
  1741. }
  1742. .classFootsty {
  1743. flex-shrink: 0;
  1744. display: flex;
  1745. align-items: center;
  1746. justify-content: center;
  1747. padding: 10rpx 0rpx 40rpx;
  1748. .btnsty {
  1749. width: 200rpx;
  1750. height: 80rpx;
  1751. border-radius: 40rpx;
  1752. font-weight: bold;
  1753. font-size: 30rpx;
  1754. text-align: center;
  1755. line-height: 80rpx;
  1756. }
  1757. .btns1 {
  1758. background-color: #f5f5f5;
  1759. color: #007aff;
  1760. }
  1761. .btns2 {
  1762. margin-left: 40rpx;
  1763. background-color: #007aff;
  1764. color: #ffffff;
  1765. }
  1766. }
  1767. </style>