NewWordShow.vue 8.5 KB

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