questionBankContinue.vue 50 KB

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