questionBankContinue.vue 47 KB

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