questionBankExplain.vue 49 KB

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