questionBankContinue.vue 48 KB

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