NewWordShow.vue 8.9 KB

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