questionBankTest.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  1. <template>
  2. <view id="questionBank">
  3. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  4. <swiper-item v-for="(bank,bankIndex) in questionList" :key="bankIndex">
  5. <view class="pageContent">
  6. <view class="pad_8 titBox" >
  7. <view class="firstLetter">
  8. <view class="leftLetters">
  9. <view class="btnType">
  10. <text v-if="bank.type==1">单选</text>
  11. <text v-if="bank.type==2">多选</text>
  12. <text v-if="bank.type==3">判断</text>
  13. <text v-if="bank.type==4">案例题</text>
  14. <text v-if="bank.type==5">简答题</text>
  15. </view>
  16. <text>{{bankIndex+1}}/{{questionList.length}}</text>
  17. </view>
  18. <view class="leftLetters"></view>
  19. </view>
  20. <view class="titles">
  21. <rich-text :nodes="bank.content"></rich-text>
  22. </view>
  23. </view>
  24. <template v-if="bank.type == 1">
  25. <view class="pad_8 titBox no-margin">
  26. <view v-if="!bank.ques">
  27. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId,bankIndex)">
  28. <view class="activeTI">{{ ast[index] }}</view>
  29. <view class="flex_auto">{{ item.content }}</view>
  30. </view>
  31. </view>
  32. <view v-if="bank.ques">
  33. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  34. <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>
  35. <view class="flex_auto">{{ item.content }}</view>
  36. </view>
  37. </view>
  38. </view>
  39. <view v-if="bank.ques">
  40. <view class="pad_8 answer">
  41. <view>正确答案:{{ast[bank.ans-1]}}</view>
  42. <view>我的答案:{{ast[bank.ques-1]}}</view>
  43. </view>
  44. <view class="pad_8 answerInfos">
  45. <view class="answerTitle">答案解析</view>
  46. <view class="answerContent">
  47. <rich-text :nodes="bank.analysisContent"></rich-text>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <template v-if="bank.type == 2">
  53. <view class="pad_8 titBox no-margin">
  54. <view v-if="!bank.ques">
  55. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId,bankIndex,index)">
  56. <view :class="{checked:item.checked}" class="activeTI">{{ ast[index] }}</view>
  57. <view class="flex_auto">{{ item.content }}</view>
  58. </view>
  59. </view>
  60. <view v-if="!bank.ques" class="submit_checkbox" :class="{disabled:!isCheckboxChecked(bank.jsonStr)}" @click="checkboxSubmit(bankIndex)">
  61. 确认答案
  62. </view>
  63. <view v-if="bank.ques">
  64. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  65. <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>
  66. <view class="flex_auto">{{ item.content }}</view>
  67. </view>
  68. </view>
  69. </view>
  70. <view v-if="bank.ques">
  71. <view class="pad_8 answer">
  72. <view>正确答案:
  73. <text :key="ansItemIndex" v-for="(ansItem,ansItemIndex) in bank.ans">{{ast[ansItem-1]}}</text>
  74. </view>
  75. <view>我的答案:
  76. <text :key="quesItemIndex" v-for="(quesItem,quesItemIndex) in bank.ques">{{ast[quesItem-1]}}</text>
  77. </view>
  78. </view>
  79. <view class="pad_8 answerInfos">
  80. <view class="answerTitle">答案解析</view>
  81. <view class="answerContent">
  82. <rich-text :nodes="bank.analysisContent"></rich-text>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <template v-if="bank.type == 3">
  88. <view class="pad_8 titBox no-margin">
  89. <view v-if="!bank.ques">
  90. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index,bankIndex)">
  91. <view class="activeTI">{{ ast[index] }}</view>
  92. {{ item }}
  93. </view>
  94. </view>
  95. <view v-if="bank.ques">
  96. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  97. <text :class="{right:(index == bank.ques) || (index == bank.ans),wrong:(index == bank.ques) && (bank.ques != bank.ans)}" class="activeTI">{{ ast[index] }}</text>
  98. {{ item }}
  99. </view>
  100. </view>
  101. </view>
  102. <view v-if="bank.ques">
  103. <view class="pad_8 answer">
  104. <view>正确答案:{{ast[bank.ans]}}</view>
  105. <view>我的答案:{{ast[bank.ques]}}</view>
  106. </view>
  107. <view class="pad_8 answerInfos">
  108. <view class="answerTitle">答案解析</view>
  109. <view class="answerContent">
  110. <rich-text :nodes="bank.analysisContent"></rich-text>
  111. </view>
  112. </view>
  113. </view>
  114. </template>
  115. <!-- 简答题 -->
  116. <template v-if="bank.type == 5">
  117. <view class="pad_8 titBox">
  118. <view class="ans">
  119. <view class="ans_input" v-if="!bank.ques">
  120. <view class="top flex">
  121. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/08-10_032.jpg" mode=""></image>
  122. <view class="progress">{{bank.ansText.imageList.length || '0'}}/4</view>
  123. <view class="submit" :class="{disabled:!bank.ansText.text && hasImgs(bank)}" @click="submitAns(bankIndex)" >确认答案</view>
  124. </view>
  125. <view class="textarea">
  126. <textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea>
  127. </view>
  128. <view class="imgs">
  129. <view class="img" v-for="(img,imgIndex) in bank.ansText.imageList" :key="imgIndex" >
  130. <text @click="deleteImg(imgIndex,bankIndex)">x</text>
  131. <image :src="$method.splitImgHost(img, true)"></image>
  132. </view>
  133. </view>
  134. </view>
  135. <view class="ans_submit answerInfos" v-if="bank.ques">
  136. <view class="answerTitle">我的答案:</view>
  137. {{bank.ques.text}}
  138. <view class="imgs">
  139. <image class="img" :key="quesIndex" v-for="(ques,quesIndex) in bank.ques.imageList" :src="$method.splitImgHost(ques,true)"></image>
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. <view v-if="bank.ques">
  145. <view class="pad_8 answerInfos">
  146. <view class="answerTitle">答案解析:</view>
  147. <view class="answerContent">
  148. <rich-text :nodes="bank.analysisContent"></rich-text>
  149. </view>
  150. </view>
  151. </view>
  152. </template>
  153. <!-- 案例题 -->
  154. <template v-if="bank.type == 4">
  155. <view class="tabs">
  156. <view class="tab" :class="{current:tabIndex == bank.current}" :key="tabIndex" v-for="(tab,tabIndex) in bank.jsonStr" @click="tabSelect(tabIndex,bankIndex)">问题{{tabIndex+1}}</view>
  157. </view>
  158. <view v-for="(ansItem,ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  159. <template v-if="ansItem.type == 1">
  160. <view class="pad_8 titBox">
  161. <view class="titles">
  162. <rich-text :nodes="ansItem.content"></rich-text>
  163. </view>
  164. <view v-if="!bank.ques[ansIndex]">
  165. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty" @click="radioSelectChild(option.optionsId,ansIndex,bankIndex)">
  166. <view class="activeTI">{{ ast[childIndex] }}</view>
  167. <rich-text class="textChild" :nodes="option.content"></rich-text>
  168. </view>
  169. </view>
  170. <view v-if="bank.ques[ansIndex]">
  171. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty">
  172. <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>
  173. <rich-text :nodes="option.content"></rich-text>
  174. </view>
  175. </view>
  176. </view>
  177. <view v-if="bank.ques[ansIndex]">
  178. <view class="pad_8 answer">
  179. <view>正确答案:{{ast[bank.ans[ansIndex]-1]}}</view>
  180. <view>我的答案:{{ast[bank.ques[ansIndex]-1]}}</view>
  181. </view>
  182. <view class="pad_8 answerInfos">
  183. <view class="answerTitle">答案解析</view>
  184. <view class="answerContent">
  185. <rich-text :nodes="option.analysisContent"></rich-text>
  186. </view>
  187. </view>
  188. </view>
  189. </template>
  190. <template v-if="ansItem.type == 2">
  191. <view class="pad_8 titBox">
  192. <view class="titles">
  193. <rich-text :nodes="ansItem.content"></rich-text>
  194. </view>
  195. <view v-if="!bank.ques[ansIndex]">
  196. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty" @click="checkboxSelectChild(bankIndex,ansIndex,childindex)">
  197. <view :class="{checked:option.checked}" class="activeTI">{{ ast[childindex] }}</view>
  198. <rich-text :nodes="option.content"></rich-text>
  199. </view>
  200. </view>
  201. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" :class="{disabled:!isCheckboxChecked(ansItem.optionsList)}" @click="checkboxSubmitChild(bankIndex,ansIndex)">
  202. 确认答案
  203. </view>
  204. <view v-if="bank.ques && bank.ques[ansIndex]">
  205. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  206. <text :class="{right:right(bankIndex,ansIndex,option),wrong:wrong(bankIndex,ansIndex,option)}" class="activeTI">{{ ast[childindex] }}</text>
  207. <rich-text :nodes="option.content"></rich-text>
  208. </view>
  209. </view>
  210. </view>
  211. <view v-if="bank.ques[ansIndex]">
  212. <view class="pad_8 answer">
  213. <view>正确答案:
  214. <text :key="ansItemIndex1" v-for="(ansItem1,ansItemIndex1) in bank.ans[ansIndex]">{{ast[ansItem1-1]}}</text>
  215. </view>
  216. <view>我的答案:
  217. <text :key="quesItemIndex" v-for="(quesItem,quesItemIndex) in bank.ques[ansIndex]">{{ast[quesItem-1]}}</text>
  218. </view>
  219. </view>
  220. <view class="pad_8 answerInfos">
  221. <view class="answerTitle">答案解析</view>
  222. <view class="answerContent">
  223. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  224. </view>
  225. </view>
  226. </view>
  227. </template>
  228. <template v-if="ansItem.type == 3">
  229. <view class="pad_8 titBox">
  230. <view class="titles">
  231. <rich-text :nodes="ansItem.content"></rich-text>
  232. </view>
  233. <view v-if="!bank.ques[ansIndex]">
  234. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex,childindex,bankIndex)">
  235. <view class="activeTI">{{ ast[childindex] }}</view>
  236. {{ option }}
  237. </view>
  238. </view>
  239. <view v-if="bank.ques[ansIndex]">
  240. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  241. <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>
  242. {{ option }}
  243. </view>
  244. </view>
  245. </view>
  246. <view v-if="bank.ques[ansIndex]">
  247. <view class="pad_8 answer">
  248. <view>正确答案:{{ast[bank.ans[ansIndex]]}}</view>
  249. <view>我的答案:{{ast[bank.ques[ansIndex]]}}</view>
  250. </view>
  251. <view class="pad_8 answerInfos">
  252. <view class="answerTitle">答案解析:</view>
  253. <view class="answerContent">
  254. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  255. </view>
  256. </view>
  257. </view>
  258. </template>
  259. <!-- 简答题 -->
  260. <template v-if="ansItem.type == 5">
  261. <view class="pad_8 titBox_title">
  262. <view class="titles">
  263. <rich-text :nodes="ansItem.content"></rich-text>
  264. </view>
  265. </view>
  266. <view class="pad_8 titBox_title">
  267. <view class="ans">
  268. <view class="ans_input" v-if="!bank.ques[ansIndex]">
  269. <view class="top flex">
  270. <image class="icon" @click="chooseImgChild(bankIndex,ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  271. <view class="progress">{{ansItem.ansText.imageList.length || '0'}}/4</view>
  272. <view class="submit" :class="{disabled:!ansItem.ansText.text && hasImgs(ansItem)}" @click="submitAnsChild(bankIndex,ansIndex)">确认答案</view>
  273. </view>
  274. <view class="textarea">
  275. <textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea>
  276. </view>
  277. <view class="imgs">
  278. <view class="img" v-for="(img,imgIndex) in ansItem.ansText.imageList" :key="imgIndex" >
  279. <text @click="deleteImgChild(imgIndex,bankIndex,ansIndex)">x</text>
  280. <image :src="$method.splitImgHost(img, true)"></image>
  281. </view>
  282. </view>
  283. </view>
  284. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex]">
  285. <view class="answerTitle">我的答案:</view>
  286. {{bank.ques[ansIndex].text}}
  287. <view class="imgs">
  288. <image class="img" :key="quesIndex" v-for="(ques,quesIndex) in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques,true)"></image>
  289. </view>
  290. </view>
  291. </view>
  292. </view>
  293. <view v-if="bank.ques[ansIndex]">
  294. <view class="pad_8 answerInfos">
  295. <view class="answerTitle">答案解析:</view>
  296. <view class="answerContent">
  297. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  298. </view>
  299. </view>
  300. </view>
  301. </template>
  302. </view>
  303. </template>
  304. <view class="footer_btn">
  305. <view class="collect" @click="collect">
  306. <view>
  307. <image src="/static/icon/collect.png" mode="widthFix"></image>
  308. <view>收藏</view>
  309. </view>
  310. </view>
  311. <view class="flex_center" @click="openFooterTab">
  312. <view class="up-icon">
  313. <image src="/static/up.png"></image>
  314. </view>
  315. 答题卡
  316. </view>
  317. <view class="collect show" @click="submit">
  318. <view>
  319. <image src="/static/jj.png" mode=""></image>
  320. <view>交卷</view>
  321. </view>
  322. </view>
  323. </view>
  324. </view>
  325. </swiper-item>
  326. </swiper>
  327. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  328. <view class="popupView">
  329. <view class="popupTops">
  330. <view class="topIcon"></view>
  331. 点击编号即可跳转至对应题目
  332. </view>
  333. <view class="popupContent">
  334. <scroll-view scroll-y="true" style="height: 506rpx;">
  335. <view class="boxSty">
  336. <view v-for="(item, index) in questionList" :key="index" @click="changeIndex(index)" :class="{isRight:isRight(item,index),isWrong:isWrong(item,index),disabled:index > (num - 1)}" class="liListSty">{{ index + 1 }}</view>
  337. </view>
  338. </scroll-view>
  339. </view>
  340. </view>
  341. </u-popup>
  342. <view class="dialog" v-if="showDialog">
  343. <image class="pointer" src="/static/pointer.png"></image>
  344. <view class="text">左右滑动切换上下题</view>
  345. <view class="btn" @click="hideDialog">我知道了</view>
  346. </view>
  347. </view>
  348. </template>
  349. <script>
  350. export default {
  351. data() {
  352. return {
  353. id:'',
  354. current:0,
  355. questionList:[],
  356. ast: ['A', 'B', 'C', 'D','E','F','G'],
  357. judge:['错误','正确'],
  358. show: false,
  359. showDialog:false,
  360. bankList: [],
  361. collectList:[],
  362. goodsId:'',
  363. num:0,
  364. };
  365. },
  366. onLoad(option){
  367. this.id = option.id;
  368. this.goodsId = option.goodsid;
  369. this.num = +option.num;
  370. let showDialog = uni.getStorageSync('showDialog');
  371. if(showDialog) {
  372. this.showDialog = false;
  373. } else {
  374. this.showDialog = true;
  375. uni.setStorageSync('showDialog','1');
  376. }
  377. this.goodsQuestionList();
  378. },
  379. onUnload() {
  380. },
  381. methods: {
  382. /**
  383. * 是否有上传图片
  384. */
  385. hasImgs(bank) {
  386. return bank.ansText.imageList.length == 0;
  387. },
  388. /**
  389. * 请求题目列表
  390. */
  391. goodsQuestionList() {
  392. this.$api.goodsQuestionList({
  393. examId:this.id
  394. }).then(res => {
  395. res.data.data.forEach((item,index) => {
  396. if(typeof item.jsonStr == 'string') {
  397. item.jsonStr = JSON.parse(item.jsonStr)
  398. if(item.type == 2) { //多选
  399. item.jsonStr.forEach(str => {
  400. str.optionsId = ''+str.optionsId;
  401. })
  402. let arr = item.answerQuestion.split(',');
  403. arr.forEach((a,i) => {
  404. arr[i] = ''+a;
  405. })
  406. item.ans = arr;
  407. return;
  408. } else if(item.type == 5) { //简答题
  409. item.ansText = {
  410. text: '',
  411. imageList: []
  412. }
  413. } else if(item.type == 4) { //案例题
  414. console.log(item.jsonStr)
  415. item.ques = []
  416. item.current = 0;
  417. let ansArr = [];
  418. item.jsonStr.forEach((json,index) => {
  419. if(json.type == 1) {
  420. ansArr[index] = json.answerQuestion;
  421. } else if(json.type == 2) {
  422. json.optionsList.forEach(str => {
  423. str.optionsId = ''+str.optionsId;
  424. })
  425. let arr = json.answerQuestion.split(',');
  426. arr.forEach((a,i) => {
  427. arr[i] = ''+a;
  428. })
  429. ansArr[index] = arr
  430. } else if(json.type == 3) {
  431. ansArr[index] = json.answerQuestion;
  432. } else if(json.type == 5) {
  433. ansArr[index] = {
  434. text: '',
  435. imageList: []
  436. }
  437. json.ansText = {
  438. text: '',
  439. imageList: []
  440. }
  441. }
  442. })
  443. item.ans = ansArr
  444. return;
  445. }
  446. item.ans = item.answerQuestion
  447. }
  448. })
  449. this.questionList = res.data.data;
  450. })
  451. },
  452. /**
  453. * @param {Object} e单选点击
  454. */
  455. radioSelect(optionsId,bindex) {
  456. if(this.questionList[bindex].ques) return;
  457. this.$set(this.questionList[bindex],'ques',optionsId)
  458. },
  459. /**
  460. * @param {Object} e案例单选点击
  461. */
  462. radioSelectChild(optionsId,ansIndex,bindex) {
  463. if(this.questionList[bindex].ques[ansIndex]) return;
  464. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  465. },
  466. /**
  467. * @param {Object} 多选点击
  468. */
  469. checkboxSelect(optionsId,bindex,index) {
  470. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  471. },
  472. /**
  473. * @param {Object} 案例多选点击
  474. */
  475. checkboxSelectChild(bindex,ansIndex,childIndex) {
  476. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  477. },
  478. isCheckboxChecked(arr) {
  479. return arr.some(item => {
  480. if (item.checked) {
  481. return true;
  482. }
  483. });
  484. },
  485. /**
  486. * @param {Object} 多选确认
  487. */
  488. checkboxSubmit(bindex) {
  489. if(this.questionList[bindex].ques) return;
  490. let arr = [];
  491. this.questionList[bindex].jsonStr.forEach(item => {
  492. if(item.checked) {
  493. arr.push(item.optionsId)
  494. }
  495. })
  496. if(!arr.length) {
  497. uni.showToast({
  498. title:'请选择答案',
  499. icon:'none'
  500. })
  501. return;
  502. }
  503. this.$set(this.questionList[bindex],'ques',arr)
  504. },
  505. /**
  506. * @param {Object} 案例多选确认
  507. */
  508. checkboxSubmitChild(bindex,ansIndex) {
  509. if(this.questionList[bindex].ques[ansIndex]) return;
  510. let arr = [];
  511. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  512. if(item.checked) {
  513. arr.push(item.optionsId)
  514. }
  515. })
  516. if(!arr.length) {
  517. uni.showToast({
  518. title:'请选择答案',
  519. icon:'none'
  520. })
  521. return;
  522. }
  523. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  524. },
  525. /**
  526. * @param {Object} index
  527. * @param {Object} bindex
  528. * 判断题
  529. */
  530. judgeSelect(index,bindex) {
  531. if(this.questionList[bindex].ques) return;
  532. this.$set(this.questionList[bindex],'ques',index+'')
  533. },
  534. /**
  535. * @param {Object} ansindex
  536. * @param {Object} childindex
  537. * @param {Object} bindex
  538. * 案例判断题
  539. */
  540. judgeSelectChild(ansindex,childindex,bindex) {
  541. if(this.questionList[bindex].ques[ansindex]) return;
  542. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  543. },
  544. openFooterTab() {
  545. this.show = true;
  546. },
  547. hideDialog() {
  548. this.showDialog = false;
  549. },
  550. changeIndex(index) {
  551. if(index <= (this.num-1)) {
  552. this.current = index
  553. } else {
  554. uni.showModal({
  555. title: '提示',
  556. content: '试做题目已结束,够买题卷可作答所有题目',
  557. cancelText:'返回详情',
  558. cancelColor:'',
  559. confirmText:'继续作答',
  560. confirmColor:'',
  561. success: (res) => {
  562. if (res.confirm) {
  563. } else if (res.cancel) {
  564. uni.navigateBack({
  565. delta:1
  566. })
  567. console.log('返回详情');
  568. }
  569. }
  570. });
  571. }
  572. },
  573. swiperChange(e) {
  574. this.current = e.detail.current;
  575. if(this.current > this.num -1) {
  576. uni.showModal({
  577. title: '提示',
  578. content: '试做题目已结束,够买题卷可作答所有题目',
  579. cancelText:'返回详情',
  580. cancelColor:'',
  581. confirmText:'继续作答',
  582. confirmColor:'',
  583. success: (res) => {
  584. if (res.confirm) {
  585. this.current = this.num - 1;
  586. } else if (res.cancel) {
  587. uni.navigateBack({
  588. delta:1
  589. })
  590. console.log('返回详情');
  591. }
  592. }
  593. });
  594. }
  595. },
  596. /**
  597. * 提交数据
  598. */
  599. submit() {
  600. uni.showToast({
  601. title: '不能试做返回详情购买后即可交卷~',
  602. duration: 2000,
  603. icon:'none'
  604. });
  605. return;
  606. },
  607. /**
  608. * @param {Object} state
  609. * @param {Object} index
  610. * 收藏
  611. */
  612. collect(state,index) {
  613. uni.showToast({
  614. title: '返回详情购买后即可收藏~',
  615. duration: 2000,
  616. icon:'none'
  617. });
  618. return;
  619. },
  620. /**
  621. * @param {Object} imgIndex
  622. * @param {Object} bankIndex
  623. * 删除简答图片
  624. */
  625. deleteImg(imgIndex,bankIndex) {
  626. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  627. },
  628. /**
  629. * @param {Object} imgIndex
  630. * @param {Object} bankIndex
  631. * @param {Object} ansIndex
  632. * 删除案例题简答图片
  633. */
  634. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  635. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  636. },
  637. /**
  638. * @param {Object} bankindex
  639. * 选择上传图片
  640. */
  641. chooseImg(bankindex) {
  642. uni.chooseImage({
  643. count: 1, //默认9
  644. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  645. sourceType: ['album','camera'], //从相册选择
  646. success: (res) => {
  647. let self = this;
  648. // console.log(JSON.stringify(res.tempFilePaths));
  649. let img = res.tempFilePaths[0];
  650. uni.getImageInfo({
  651. src: img,
  652. success: async res => {
  653. let canvasWidth = res.width; //图片原始长宽
  654. let canvasHeight = res.height;
  655. if (canvasWidth > 1000 || canvasHeight > 1000) {
  656. uni.compressImage({
  657. src: img,
  658. quality: 75,
  659. width: '50%',
  660. height: '50%',
  661. success: async rest => {
  662. const dir = await self.uploadFile(rest.tempFilePath, 0);
  663. this.questionList[bankindex].ansText.imageList.push(dir)
  664. }
  665. });
  666. } else {
  667. const dir = await self.uploadFile(img, 0);
  668. this.questionList[bankindex].ansText.imageList.push(dir)
  669. }
  670. }
  671. });
  672. }
  673. })
  674. },
  675. /**
  676. * @param {Object} bankindex
  677. * @param {Object} ansindex
  678. * 案例题选择上传图片
  679. */
  680. chooseImgChild(bankindex,ansindex) {
  681. uni.chooseImage({
  682. count: 1, //默认9
  683. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  684. sourceType: ['album','camera'], //从相册选择
  685. success: (res) => {
  686. let self = this;
  687. // console.log(JSON.stringify(res.tempFilePaths));
  688. let img = res.tempFilePaths[0];
  689. uni.getImageInfo({
  690. src: img,
  691. success: async res => {
  692. let canvasWidth = res.width; //图片原始长宽
  693. let canvasHeight = res.height;
  694. if (canvasWidth > 1000 || canvasHeight > 1000) {
  695. uni.compressImage({
  696. src: img,
  697. quality: 75,
  698. width: '50%',
  699. height: '50%',
  700. success: async rest => {
  701. const dir = await self.uploadFile(rest.tempFilePath, 0);
  702. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  703. }
  704. });
  705. } else {
  706. const dir = await self.uploadFile(img, 0);
  707. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  708. }
  709. }
  710. });
  711. }
  712. })
  713. },
  714. uploadFile(options, int) {
  715. var self = this;
  716. return new Promise((resolve, reject) => {
  717. var data = {
  718. imageStatus: int
  719. };
  720. self.$api.aliyunpolicy(data).then(res => {
  721. console.log(res.data,6)
  722. if(res.data.code!=200){
  723. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  724. return
  725. }
  726. var ossToken = res.data.data.resultContent;
  727. if(ossToken.host==null||ossToken.host==undefined){
  728. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  729. return
  730. }
  731. uni.uploadFile({
  732. url: ossToken.host,
  733. name: 'file',
  734. filePath: options,
  735. fileType: 'image',
  736. header: {
  737. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  738. },
  739. formData: {
  740. key: ossToken.dir,
  741. OSSAccessKeyId: ossToken.accessid,
  742. policy: ossToken.policy,
  743. Signature: ossToken.signature,
  744. callback: ossToken.callback,
  745. success_action_status: 200
  746. },
  747. success: result => {
  748. if (result.statusCode === 200) {
  749. resolve(ossToken.dir);
  750. } else {
  751. uni.showToast({
  752. title: '上传失败',
  753. icon: 'none'
  754. });
  755. return;
  756. }
  757. },
  758. fail: error => {
  759. uni.showToast({
  760. title: '上传接口报错'+error,
  761. icon: 'none'
  762. });
  763. return;
  764. }
  765. });
  766. });
  767. });
  768. },
  769. /**
  770. * @param {Object} type
  771. * @param {Object} bankindex
  772. * 简答题答案确认
  773. */
  774. submitAns(bankindex) {
  775. console.log(this.questionList[bankindex])
  776. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  777. uni.showToast({
  778. title: '请输入内容或上传图片',
  779. duration: 2000,
  780. icon:'none'
  781. });
  782. return
  783. }
  784. this.$set(this.questionList[bankindex],'ques',{
  785. imageList:this.questionList[bankindex].ansText.imageList,
  786. text:this.questionList[bankindex].ansText.text,
  787. })
  788. },
  789. /**
  790. * @param {Object} bankindex
  791. * @param {Object} ansindex
  792. * 案例题简答答案确认
  793. */
  794. submitAnsChild(bankindex,ansindex) {
  795. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  796. uni.showToast({
  797. title: '请输入内容或上传图片',
  798. duration: 2000,
  799. icon:'none'
  800. });
  801. return
  802. }
  803. this.$set(this.questionList[bankindex].ques,ansindex,{
  804. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  805. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  806. })
  807. },
  808. isRight(item,index) {
  809. //单选
  810. if(this.questionList[index].ques) {
  811. if(item.type == 1) {
  812. return this.questionList[index].ques == this.questionList[index].ans;
  813. //多选
  814. } else if(item.type == 2) {
  815. //每一项都相等
  816. return this.questionList[index].ques.every((item,i) => {
  817. return item == this.questionList[index].ans[i];
  818. })
  819. //判断
  820. } else if(item.type == 3) {
  821. return this.questionList[index].ques == this.questionList[index].ans;
  822. } else {
  823. return false;
  824. }
  825. } else {
  826. return false;
  827. }
  828. },
  829. right(bankIndex,ansIndex,option) {
  830. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  831. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  832. return true
  833. } else {
  834. return false;
  835. }
  836. } else {
  837. return false;
  838. }
  839. },
  840. wrong(bankIndex,ansIndex,option) {
  841. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  842. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  843. return true;
  844. } else {
  845. return false;
  846. }
  847. } else {
  848. return false;
  849. }
  850. },
  851. isWrong(item,index) {
  852. if(this.questionList[index].ques) {
  853. //单选
  854. if(item.type == 1) {
  855. return this.questionList[index].ques != this.questionList[index].ans;
  856. //多选
  857. } else if(item.type == 2) {
  858. //每一项都相等
  859. return this.questionList[index].ques.some((item,index) => {
  860. return item != this.questionList[index].ans;
  861. })
  862. //判断
  863. } else if(item.type == 3) {
  864. return this.questionList[index].ques != this.questionList[index].ans;
  865. } else {
  866. return false;
  867. }
  868. } else {
  869. return false;
  870. }
  871. },
  872. tabSelect(index,bankindex) {
  873. this.$set(this.questionList[bankindex],'current',index)
  874. },
  875. }
  876. };
  877. </script>
  878. <style lang="scss" scoped>
  879. .swiper {
  880. width:100%;
  881. height:100vh;
  882. }
  883. .lisSty {
  884. margin-bottom: 16rpx;
  885. display: flex;
  886. align-items: center;
  887. .flex_auto {
  888. flex:1;
  889. }
  890. }
  891. .activeTI {
  892. vertical-align: middle;
  893. display: inline-block;
  894. border: 1rpx solid #eee;
  895. border-radius: 50rpx;
  896. height: 48rpx;
  897. line-height: 46rpx;
  898. text-align: center;
  899. width: 48rpx;
  900. margin-right: 15rpx;
  901. color: #666;
  902. font-size: 30rpx;
  903. &.right {
  904. color:#fff;
  905. background:green;
  906. }
  907. &.wrong {
  908. color:#fff;
  909. background:red;
  910. }
  911. &.checked {
  912. color:#fff;
  913. background:#007AFF;
  914. }
  915. }
  916. .submit_checkbox {
  917. margin:20rpx auto;
  918. width: 526rpx;
  919. height: 80rpx;
  920. background: rgba(0, 122, 255, 1);
  921. color:#fff;
  922. text-align: center;
  923. line-height: 80rpx;
  924. font-size: 30rpx;
  925. border-radius: 40rpx;
  926. &.disabled {
  927. opacity: 0.6;
  928. }
  929. }
  930. .titles {
  931. overflow: hidden;
  932. margin-bottom: 24rpx;
  933. }
  934. .titBox {
  935. padding: 41rpx 25rpx 24rpx 25rpx;
  936. }
  937. .titBox_title {
  938. padding: 21rpx;
  939. }
  940. .tabs {
  941. margin:10rpx;
  942. display: flex;
  943. .tab {
  944. margin: 0 4rpx;
  945. padding:10rpx 13rpx;
  946. text-align: center;
  947. color: #007aff;
  948. font-size: 28rpx;
  949. border-radius: 16rpx;
  950. background:#fff;
  951. &.current {
  952. color:#fff;
  953. background: #007AFF;
  954. }
  955. }
  956. }
  957. .ans {
  958. margin:8rpx 8rpx 8rpx;
  959. .ans_input {
  960. border-radius: 16rpx;
  961. background:#fff;
  962. .top {
  963. border-bottom:1rpx solid #EEEEEE;
  964. padding: 16rpx;
  965. display: flex;
  966. align-items: center;
  967. .icon {
  968. margin-right:20rpx;
  969. width: 40rpx;
  970. height: 38rpx;
  971. }
  972. .progress {
  973. flex:1;
  974. }
  975. .submit {
  976. width: 168rpx;
  977. height: 48rpx;
  978. line-height: 48rpx;
  979. text-align: center;
  980. color:#fff;
  981. font-size: 30rpx;
  982. background: #007AFF;
  983. border-radius: 24rpx;
  984. &.disabled {
  985. opacity: 0.6;
  986. }
  987. }
  988. }
  989. .textarea {
  990. textarea {
  991. width:100%;
  992. height:287rpx;
  993. padding:10rpx;
  994. }
  995. }
  996. .imgs {
  997. overflow: hidden;
  998. display: flex;
  999. width:100%;
  1000. .img {
  1001. width: 104rpx;
  1002. height: 104rpx;
  1003. border-radius: 8rpx;
  1004. position:relative;
  1005. margin:20rpx;
  1006. text {
  1007. position:absolute;
  1008. right:-15rpx;
  1009. top:-15rpx;
  1010. width:30rpx;
  1011. height:30rpx;
  1012. text-align: center;
  1013. line-height: 30rpx;
  1014. color:#fff;
  1015. background:red;
  1016. border-radius:50%;
  1017. }
  1018. image {
  1019. width:100%;
  1020. height:100%;
  1021. }
  1022. }
  1023. }
  1024. }
  1025. .ans_submit {
  1026. padding:16rpx;
  1027. border-radius: 16rpx;
  1028. background:#fff;
  1029. .imgs {
  1030. overflow: hidden;
  1031. display: flex;
  1032. width:100%;
  1033. .img {
  1034. width: 104rpx;
  1035. height: 104rpx;
  1036. border-radius: 8rpx;
  1037. position:relative;
  1038. margin:20rpx;
  1039. image {
  1040. width:100%;
  1041. height:100%;
  1042. }
  1043. }
  1044. }
  1045. }
  1046. }
  1047. .firstLetter {
  1048. display: flex;
  1049. justify-content: space-between;
  1050. align-items: center;
  1051. margin-bottom: 30rpx;
  1052. .leftLetters {
  1053. display: flex;
  1054. align-items: center;
  1055. width: 220rpx;
  1056. .btnType {
  1057. padding: 5rpx 10rpx;
  1058. border: 1rpx solid #007aff;
  1059. border-radius: 10rpx;
  1060. background-color: rgba(0, 122, 255, 0.1);
  1061. font-size: 28rpx;
  1062. color: #007aff;
  1063. margin-right: 15rpx;
  1064. }
  1065. }
  1066. }
  1067. .popupView {
  1068. height: 100%;
  1069. padding-bottom: 100rpx;
  1070. .popupTops {
  1071. height: 77rpx;
  1072. border-bottom: 1rpx solid #eee;
  1073. text-align: center;
  1074. line-height: 77rpx;
  1075. font-size: 24rpx;
  1076. color: #999;
  1077. position: relative;
  1078. .topIcon {
  1079. position: absolute;
  1080. top: 10rpx;
  1081. left: 50%;
  1082. transform: translateX(-50%);
  1083. width: 80rpx;
  1084. height: 8rpx;
  1085. background-color: #999;
  1086. border-radius: 4rpx;
  1087. }
  1088. }
  1089. .popupContent {
  1090. }
  1091. }
  1092. .pageContent {
  1093. position:relative;
  1094. background-color: #eaeef1;
  1095. min-height: 100vh;
  1096. padding-top: 8rpx;
  1097. padding-bottom: 100rpx;
  1098. }
  1099. .pad_8 {
  1100. background-color: #fff;
  1101. margin: 0rpx 8rpx 8rpx;
  1102. border-radius: 16rpx;
  1103. &.no-margin {
  1104. margin-top:-16rpx;
  1105. border-radius: 0 0 16rpx 16rpx;
  1106. }
  1107. }
  1108. .answer {
  1109. height: 80rpx;
  1110. line-height: 80rpx;
  1111. padding: 0rpx 24rpx;
  1112. display: flex;
  1113. align-items: center;
  1114. justify-content: space-between;
  1115. color: #666;
  1116. font-size: 30rpx;
  1117. }
  1118. .footer_btn {
  1119. background-color: #fff;
  1120. position: fixed;
  1121. bottom: 0rpx;
  1122. display: flex;
  1123. align-items: center;
  1124. justify-content: space-between;
  1125. width: 100%;
  1126. height: 98rpx;
  1127. padding: 0rpx 38rpx;
  1128. border-top: 1rpx solid #eee;
  1129. z-index: 9999999;
  1130. .flex_center {
  1131. flex:1;
  1132. display: flex;
  1133. justify-content: center;
  1134. align-items: center;
  1135. flex-direction: column;
  1136. margin:0 200rpx;
  1137. font-size: 24rpx;
  1138. color: #999999;
  1139. .up-icon {
  1140. margin-bottom:18rpx;
  1141. width:100%;
  1142. display: flex;
  1143. justify-content: center;
  1144. image {
  1145. width:58rpx;
  1146. height:21rpx;
  1147. }
  1148. }
  1149. }
  1150. .collect {
  1151. >view {
  1152. display: flex;
  1153. flex-direction: column;
  1154. align-items: center;
  1155. justify-content: center;
  1156. image {
  1157. width:32rpx;
  1158. height:32rpx;
  1159. margin-bottom:6rpx;
  1160. }
  1161. view {
  1162. font-size: 24rpx;
  1163. color: #999999;
  1164. }
  1165. }
  1166. }
  1167. }
  1168. .boxSty {
  1169. padding: 44rpx 41rpx 0rpx;
  1170. }
  1171. .liListSty {
  1172. border:1rpx solid #EEEEEE;
  1173. width: 88rpx;
  1174. height: 88rpx;
  1175. border-radius: 32rpx;
  1176. text-align: center;
  1177. line-height: 88rpx;
  1178. color: #333;
  1179. font-size: 32rpx;
  1180. float: left;
  1181. margin: 20rpx 23rpx;
  1182. &.isRight {
  1183. border:0;
  1184. color:#fff;
  1185. background: green;
  1186. }
  1187. &.isWrong {
  1188. border:0;
  1189. color:#fff;
  1190. background: red;
  1191. }
  1192. &.disabled {
  1193. color:#EEEEEE;
  1194. }
  1195. }
  1196. .answerInfos {
  1197. padding: 25rpx 25rpx 25rpx 23rpx;
  1198. }
  1199. .answerTitle {
  1200. margin-bottom: 28rpx;
  1201. color: #666;
  1202. font-size: 30rpx;
  1203. }
  1204. .answerContent {
  1205. font-size: 30rpx;
  1206. color: #666;
  1207. }
  1208. .textChild {
  1209. display: inline-block;
  1210. vertical-align: middle;
  1211. }
  1212. .dialog {
  1213. position: fixed;
  1214. left:0;
  1215. top:0;
  1216. width:100%;
  1217. height:100%;
  1218. background-color: rgba(0,0,0,0.8);
  1219. display: flex;
  1220. flex-direction: column;
  1221. align-items: center;
  1222. justify-content: center;
  1223. z-index: 20000;
  1224. .pointer {
  1225. width:338rpx;
  1226. height:240rpx;
  1227. }
  1228. .text {
  1229. font-size: 32rpx;
  1230. color: #FFFFFF;
  1231. text-align: center;
  1232. }
  1233. .btn {
  1234. width: 242rpx;
  1235. height: 82rpx;
  1236. border: 2rpx solid #FFFFFF;
  1237. border-radius: 16rpx;
  1238. text-align: center;
  1239. line-height: 82rpx;
  1240. margin:41rpx auto;
  1241. color:#fff;
  1242. font-size: 32rpx;
  1243. }
  1244. }
  1245. </style>