NewWordShow.vue 9.1 KB

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