NewWordShow.vue 8.6 KB

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