Hanzi.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-singleHanzi" v-if="curQue && fn_list_obj">
  4. <div
  5. class="Big-Book-singleHanzi-main"
  6. v-for="(item, index) in curQue.option"
  7. :key="'shz' + index"
  8. >
  9. <p class="Big-Book-pinyin" v-if="item.pinyin">{{ item.pinyin }}</p>
  10. <div class="Big-Book-hanzi">
  11. <template v-if="fn_list_obj.copy">
  12. <Adultstrockred
  13. :index="pageIndex + '_' + curIndex + '_' + queIndex + '_' + index"
  14. :hanzi="item.hanzi"
  15. />
  16. </template>
  17. <template v-else>
  18. <Adultstrockplay
  19. :index="pageIndex + '_' + curIndex + '_' + queIndex + '_' + index"
  20. :hanzi="item.hanzi"
  21. />
  22. </template>
  23. </div>
  24. <template v-if="fn_list_obj.copy">
  25. <div class="Big-Book-clear-bg">
  26. <img src="../../../assets/adult/clear.png" class="Big-Book-clear" />
  27. </div>
  28. </template>
  29. <template v-else>
  30. <div class="Big-Book-en" v-if="item.english">{{ item.english }}</div>
  31. <div class="Big-Book-def" v-if="fn_list_obj.def">更多释义</div>
  32. <div class="Big-Book-fn">
  33. <template v-if="fn_list_obj.spell">
  34. <ul class="Big-Book-btn-list">
  35. <li
  36. class="Big-Book-tone-btn-bg"
  37. v-for="(tItem, tIndex) in tone_list"
  38. :key="'tone' + tIndex"
  39. >
  40. <img :src="tItem" class="Big-Book-tone-img" />
  41. </li>
  42. </ul>
  43. <el-input
  44. type="text"
  45. v-model="answer[index].spell[0]"
  46. style="margin-top: 8px"
  47. ></el-input>
  48. </template>
  49. <template v-else-if="fn_list_obj.input">
  50. <ul
  51. class="Big-Book-btn-list"
  52. style="margin-top: 8px; margin-bottom: 8px"
  53. >
  54. <li class="Big-Book-btn-bg" v-if="item.mp3_list.length > 0">
  55. <img src="../../../assets/adult/play-mp3-blue.png" />
  56. </li>
  57. <li class="Big-Book-btn-bg">
  58. <img
  59. src="../../../assets/adult/coll-icon.png"
  60. style="width: 15px; height: 15px"
  61. />
  62. </li>
  63. <li class="Big-Book-btn-bg">
  64. <img src="../../../assets/adult/exercise-icon.png" />
  65. </li>
  66. </ul>
  67. <el-input type="text" v-model="answer[index].input[0]"></el-input>
  68. </template>
  69. <template v-else-if="fn_list_obj.record">
  70. <ul class="Big-Book-btn-list" style="margin-top: 8px">
  71. <li class="Big-Book-btn-bg">
  72. <img src="../../../assets/adult/play-mp3-black.png" />
  73. </li>
  74. <li class="Big-Book-btn-bg">
  75. <img src="../../../assets/adult/record-icon.png" />
  76. </li>
  77. <li class="Big-Book-btn-bg">
  78. <img src="../../../assets/adult/play-record.png" />
  79. </li>
  80. </ul>
  81. </template>
  82. <template v-else-if="fn_list_obj.judge">
  83. <el-radio-group
  84. v-model="answer[0].judge[index]"
  85. @change="changAnswer(index, 'judge')"
  86. >
  87. <el-radio label="'true'">正确</el-radio>
  88. <el-radio label="'false'">错误</el-radio>
  89. </el-radio-group>
  90. </template>
  91. <template v-else-if="fn_list_obj.checkBox">
  92. <el-checkbox
  93. v-model="item.isChecked"
  94. @change="changAnswer(index, 'checkBox')"
  95. ></el-checkbox>
  96. </template>
  97. <template v-else-if="fn_list_obj.single">
  98. <el-radio
  99. v-model="answer[0].single[0]"
  100. :label="index"
  101. @change="changAnswer(index, 'single')"
  102. ><span></span
  103. ></el-radio>
  104. </template>
  105. <template v-else>
  106. <ul class="Big-Book-btn-list" style="margin-top: 8px">
  107. <li class="Big-Book-btn-bg" v-if="item.mp3_list.length > 0">
  108. <img src="../../../assets/adult/play-mp3-blue.png" />
  109. </li>
  110. <li class="Big-Book-btn-bg">
  111. <img
  112. src="../../../assets/adult/coll-icon.png"
  113. style="width: 15px; height: 15px"
  114. />
  115. </li>
  116. <li class="Big-Book-btn-bg">
  117. <img src="../../../assets/adult/exercise-icon.png" />
  118. </li>
  119. </ul>
  120. </template>
  121. </div>
  122. </template>
  123. </div>
  124. </div>
  125. </template>
  126. <script>
  127. import Adultstrockplay from "./components/Adultstrockplay.vue";
  128. import Adultstrockred from "./components/Adultstrockred.vue";
  129. export default {
  130. components: { Adultstrockplay, Adultstrockred },
  131. props: ["curQue", "pageIndex", "curIndex", "queIndex"],
  132. data() {
  133. return {
  134. fn_list_obj: null,
  135. answer: [],
  136. tone_list: [
  137. require("../../../assets/adult/v1.png"),
  138. require("../../../assets/adult/v2.png"),
  139. require("../../../assets/adult/v2.png"),
  140. require("../../../assets/adult/v2.png"),
  141. ],
  142. };
  143. },
  144. computed: {},
  145. watch: {},
  146. //方法集合
  147. methods: {
  148. handleFnList() {
  149. let obj = {};
  150. this.curQue.fn_list.forEach((item) => {
  151. if (item.isFn) {
  152. obj[item.type] = true;
  153. } else {
  154. obj[item.type] = false;
  155. }
  156. });
  157. this.fn_list_obj = obj;
  158. console.log(this.fn_list_obj);
  159. },
  160. // 修改正确选项中得某一个为正确答案
  161. changAnswer(index, type) {
  162. if (type == "single") {
  163. console.log(this.answer);
  164. } else if (type == "checkBox") {
  165. let correct = [];
  166. this.curQue.option.forEach((item, i) => {
  167. if (item.isChecked) {
  168. correct.push(i);
  169. }
  170. });
  171. this.answer[0].checkBox = correct;
  172. console.log(this.answer);
  173. } else if (type == "judge") {
  174. console.log(this.answer);
  175. }
  176. },
  177. },
  178. //生命周期 - 创建完成(可以访问当前this实例)
  179. created() {},
  180. //生命周期 - 挂载完成(可以访问DOM元素)
  181. mounted() {
  182. if (this.curQue) {
  183. this.handleFnList();
  184. let obj = {
  185. single: [],
  186. checkBox: [],
  187. judge: [],
  188. input: [],
  189. spell: [],
  190. };
  191. this.answer.push(obj);
  192. }
  193. },
  194. beforeCreate() {}, //生命周期 - 创建之前
  195. beforeMount() {}, //生命周期 - 挂载之前
  196. beforeUpdate() {}, //生命周期 - 更新之前
  197. updated() {}, //生命周期 - 更新之后
  198. beforeDestroy() {}, //生命周期 - 销毁之前
  199. destroyed() {}, //生命周期 - 销毁完成
  200. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  201. };
  202. </script>
  203. <style lang='scss' scoped>
  204. //@import url(); 引入公共css类
  205. .Big-Book {
  206. &-singleHanzi {
  207. clear: both;
  208. overflow: hidden;
  209. }
  210. &-clear-bg {
  211. background: #f7f7f7;
  212. border-radius: 4px;
  213. width: 100%;
  214. height: 40px;
  215. display: flex;
  216. justify-content: center;
  217. align-items: center;
  218. cursor: pointer;
  219. }
  220. &-clear {
  221. width: 24px;
  222. height: 24px;
  223. }
  224. &-singleHanzi-main {
  225. width: 160px;
  226. height: 272px;
  227. left: 32px;
  228. top: 77px;
  229. background: #ffffff;
  230. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
  231. border-radius: 8px;
  232. box-sizing: border-box;
  233. padding: 8px;
  234. float: left;
  235. margin: 10px 10px 0 0;
  236. }
  237. &-pinyin {
  238. font-weight: normal;
  239. font-size: 16px;
  240. line-height: 150%;
  241. text-align: center;
  242. color: #000000;
  243. margin-bottom: 8px;
  244. }
  245. &-hanzi {
  246. width: 144px;
  247. height: 144px;
  248. border: 1px solid rgba(0, 0, 0, 0.15);
  249. border-radius: 8px;
  250. margin-bottom: 8px;
  251. box-sizing: border-box;
  252. }
  253. &-en {
  254. font-weight: normal;
  255. font-size: 16px;
  256. line-height: 150%;
  257. text-align: center;
  258. color: #000000;
  259. margin-bottom: 8px;
  260. }
  261. &-def {
  262. font-weight: normal;
  263. font-size: 16px;
  264. line-height: 150%;
  265. text-align: center;
  266. color: #000000;
  267. opacity: 0.5;
  268. cursor: pointer;
  269. }
  270. &-btn-list {
  271. display: flex;
  272. justify-content: space-around;
  273. align-items: center;
  274. margin: 0;
  275. padding: 0;
  276. }
  277. &-tone-btn-bg {
  278. width: 30px;
  279. height: 30px;
  280. background: #f7f7f7;
  281. border-radius: 4px;
  282. display: flex;
  283. justify-content: center;
  284. align-items: center;
  285. cursor: pointer;
  286. }
  287. &-btn-bg {
  288. width: 46px;
  289. height: 40px;
  290. background: #f7f7f7;
  291. border-radius: 4px;
  292. display: flex;
  293. justify-content: center;
  294. align-items: center;
  295. cursor: pointer;
  296. &.hanzi-record {
  297. background: #ffecec;
  298. }
  299. > img {
  300. width: 24px;
  301. background: 24px;
  302. }
  303. }
  304. &-tone-img {
  305. }
  306. }
  307. </style>