questionBankContinue.vue 48 KB

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