NewWordShow.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-prev-Textdes NewWordShow" v-if="curQue">
  4. <h2 v-if="curQue.title">{{ curQue.title }}</h2>
  5. <div class="item-box">
  6. <div class="item" v-for="(item, index) in curQue.option" :key="index">
  7. <p v-if="item.pinyin">{{ item.pinyin }}</p>
  8. <div class="con-box">
  9. <template v-if="item.imgOrText == 'text'">
  10. <template v-if="item.con">
  11. <div
  12. :key="conindex"
  13. class="strockplay"
  14. v-for="(conItem, conindex) in item.con"
  15. @click="writeWord(conItem, item.pinyin)"
  16. >
  17. <Strockplayredline
  18. :Book_text="conItem"
  19. :playStorkes="true"
  20. :targetDiv="'bwcHanziIntp' + index + conItem + conindex"
  21. />
  22. <div
  23. class="bwc-line"
  24. v-if="conindex < item.con.length - 1"
  25. ></div>
  26. </div>
  27. </template>
  28. <template v-else>
  29. <div class="blank-item" @click="freeWrite('', index)">
  30. <img :src="freeImg[index]" v-if="freeImg[index]" />
  31. </div>
  32. </template>
  33. </template>
  34. <template v-else>
  35. <div
  36. class="img-box"
  37. v-for="(imgItem, imgIndex) in item.img_list"
  38. :key="imgIndex"
  39. @click="freeWrite(imgItem.url, imgIndex)"
  40. >
  41. <el-image :src="imgItem.url" fit="scale-down" class="img_url">
  42. <div slot="placeholder" class="image-slot">
  43. <img src="../../../assets/common/icon-imgloading.png" />
  44. </div>
  45. </el-image>
  46. </div>
  47. </template>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="practiceBox practiceBoxStrock" v-if="isPraShow">
  52. <Practice
  53. :changePraShow="changePraShow"
  54. :cur="curData"
  55. :themeColor="themeColor"
  56. />
  57. </div>
  58. <div class="practiceBox practiceBoxStrock" v-if="ifFreeShow">
  59. <FreePaint
  60. :changePraShow="changePraShow"
  61. :cur="curDataImg"
  62. ref="freePaint"
  63. :themeColor="themeColor"
  64. />
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import Strockplayredline from "../preview/components/Strockplayredline.vue";
  70. import Practice from "../preview/components/Practice.vue";
  71. import FreePaint from "../preview/components/FreePaint.vue";
  72. export default {
  73. components: { Strockplayredline, Practice, FreePaint },
  74. props: ["curQue", "themeColor"],
  75. data() {
  76. return {
  77. isPraShow: false,
  78. curData: null,
  79. ifFreeShow: false,
  80. freeImg: [],
  81. activeIndex: null,
  82. };
  83. },
  84. computed: {},
  85. watch: {},
  86. //方法集合
  87. methods: {
  88. // 处理数据
  89. handleData() {
  90. let _this = this;
  91. _this.freeImg = [];
  92. _this.curQue.option.forEach((item) => {
  93. _this.freeImg.push("");
  94. });
  95. },
  96. changePraShow() {
  97. this.isPraShow = false;
  98. this.ifFreeShow = false;
  99. this.freeImg[this.activeIndex] = this.$refs.freePaint.imgSrc;
  100. },
  101. writeWord(words, pinyin) {
  102. this.isPraShow = true;
  103. this.activeIndex = null;
  104. this.curData = {
  105. stem: [
  106. {
  107. con: words ? words : "",
  108. pinyin: pinyin && pinyin ? pinyin : "",
  109. mp3_url: "",
  110. },
  111. ],
  112. };
  113. },
  114. freeWrite(imgUrl, index) {
  115. this.ifFreeShow = true;
  116. this.curDataImg = imgUrl;
  117. this.activeIndex = imgUrl ? null : index;
  118. },
  119. },
  120. //生命周期 - 创建完成(可以访问当前this实例)
  121. created() {},
  122. //生命周期 - 挂载完成(可以访问DOM元素)
  123. mounted() {},
  124. beforeCreate() {}, //生命周期 - 创建之前
  125. beforeMount() {}, //生命周期 - 挂载之前
  126. beforeUpdate() {}, //生命周期 - 更新之前
  127. updated() {}, //生命周期 - 更新之后
  128. beforeDestroy() {}, //生命周期 - 销毁之前
  129. destroyed() {}, //生命周期 - 销毁完成
  130. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  131. };
  132. </script>
  133. <style lang='scss' scoped>
  134. //@import url(); 引入公共css类
  135. .NewWordShow {
  136. width: 100%;
  137. h2 {
  138. margin: 16px 0 0;
  139. font-weight: 500;
  140. font-size: 16px;
  141. line-height: 24px;
  142. color: #000000;
  143. margin-bottom: 16px;
  144. }
  145. .item-box {
  146. display: flex;
  147. flex-flow: wrap;
  148. padding-bottom: 8px;
  149. padding: 0 4px;
  150. background: #f7f7f7;
  151. border: 1px solid rgba(0, 0, 0, 0.1);
  152. border-radius: 8px;
  153. .item {
  154. display: flex;
  155. align-items: flex-end;
  156. justify-content: center;
  157. flex-flow: wrap;
  158. margin: 9px 20px;
  159. box-sizing: border-box;
  160. width: 66px;
  161. cursor: pointer;
  162. > p {
  163. color: #2c2c2c;
  164. font-size: 14px;
  165. line-height: 130%;
  166. font-family: "GB-PINYINOK-B";
  167. width: 100%;
  168. text-align: center;
  169. margin: 0 0 8px 0;
  170. }
  171. .strockplay {
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. position: relative;
  176. width: 64px;
  177. height: 64px;
  178. }
  179. .strockplayRedInner {
  180. width: 64px;
  181. height: 64px;
  182. }
  183. .bwc-line {
  184. width: 1px;
  185. height: 62px;
  186. background: #de4444;
  187. }
  188. }
  189. .con-box {
  190. display: flex;
  191. border: 1px solid #de4444;
  192. border-radius: 8px;
  193. overflow: hidden;
  194. .img-box {
  195. background: #fff url("../../../assets/NPC/chinaTianRed.png") center
  196. no-repeat;
  197. background-size: cover;
  198. .img_url {
  199. width: 64px;
  200. height: 64px;
  201. }
  202. }
  203. .blank-item {
  204. width: 64px;
  205. height: 64px;
  206. background: #fff url("../../../assets/NPC/chinaTianRed.png") center
  207. no-repeat;
  208. background-size: cover;
  209. img {
  210. width: 100%;
  211. height: 100%;
  212. }
  213. }
  214. }
  215. }
  216. .practiceBox {
  217. position: fixed;
  218. left: 0;
  219. top: 0;
  220. z-index: 999;
  221. width: 100%;
  222. height: 100vh;
  223. background: rgba(0, 0, 0, 0.19);
  224. padding-top: 32px;
  225. box-sizing: border-box;
  226. overflow: hidden;
  227. overflow-y: auto;
  228. &.practiceBoxStrock {
  229. display: flex;
  230. justify-content: center;
  231. align-items: center;
  232. padding-top: 0px;
  233. }
  234. }
  235. }
  236. .NNPE-Big-Book-preview-brown {
  237. .NewWordShow {
  238. .item-box {
  239. .item {
  240. .bwc-line {
  241. background: #bf875e;
  242. }
  243. }
  244. .con-box {
  245. border: 1px solid #bf875e;
  246. .img-box {
  247. background: #fff url("../../../assets/NPC/chinaTianYellow.png") center
  248. no-repeat;
  249. background-size: cover;
  250. }
  251. .blank-item {
  252. background: #fff url("../../../assets/NPC/chinaTianYellow.png") center
  253. no-repeat;
  254. background-size: cover;
  255. }
  256. }
  257. }
  258. }
  259. }
  260. .NNPE-Big-Book-preview-green {
  261. .NewWordShow {
  262. .item-box {
  263. .item {
  264. .bwc-line {
  265. background: #24b99e;
  266. }
  267. }
  268. .con-box {
  269. border: 1px solid #24b99e;
  270. .img-box {
  271. background: #fff url("../../../assets/NPC/chinaTianGreen.png") center
  272. no-repeat;
  273. background-size: cover;
  274. }
  275. .blank-item {
  276. background: #fff url("../../../assets/NPC/chinaTianGreen.png") center
  277. no-repeat;
  278. background-size: cover;
  279. }
  280. }
  281. }
  282. }
  283. }
  284. </style>
  285. <style lang="scss">
  286. .NNPE-Big-Book-preview-red {
  287. .NewWordShow {
  288. .strock-play-box {
  289. width: 22px;
  290. height: 22px;
  291. right: -2px;
  292. top: 0;
  293. background: url("../../../assets/NPC/strock-play-red-click.png") center
  294. no-repeat;
  295. background-size: cover;
  296. }
  297. .character-target-div {
  298. // background-color: initial;
  299. }
  300. }
  301. }
  302. .NNPE-Big-Book-preview-green {
  303. .NewWordShow {
  304. .strock-play-box {
  305. width: 22px;
  306. height: 22px;
  307. right: -2px;
  308. top: 0;
  309. background: url("../../../assets/NPC/strock-play-green-click.png") center
  310. no-repeat;
  311. background-size: cover;
  312. }
  313. .character-target-div {
  314. // background-color: initial;
  315. }
  316. }
  317. }
  318. .NNPE-Big-Book-preview-brown {
  319. .NewWordShow {
  320. .strock-play-box {
  321. width: 22px;
  322. height: 22px;
  323. right: -2px;
  324. top: 0;
  325. background: url("../../../assets/NPC/strock-play-yellow-click.png") center
  326. no-repeat;
  327. background-size: cover;
  328. }
  329. .character-target-div {
  330. // background-color: initial;
  331. }
  332. }
  333. }
  334. </style>