SentenceEn.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <!-- -->
  2. <template>
  3. <div class="sentence">
  4. <div class="sent-top">
  5. <div class="sent-top-left">
  6. <span class="num">{{ index + 1 }}.</span>
  7. <template v-if="mp3">
  8. <AudioLineSentence
  9. :key="'sent' + index"
  10. :mp3="mp3"
  11. :getCurTime="getCurTime"
  12. ref="audioLineSent"
  13. :audioId="'artPraAudioId' + index"
  14. :stopAudio="stopAudio"
  15. :width="120"
  16. :hideSlider="true"
  17. :bg="bg"
  18. :ed="ed"
  19. />
  20. </template>
  21. </div>
  22. <div class="cancle-coll" @click="cancleColl">
  23. <span class="coll-icon"></span>
  24. <span class="coll-text">取消收藏</span>
  25. </div>
  26. </div>
  27. <div class="vc-main" v-if="item">
  28. <div class="NNPE-words-box">
  29. <div
  30. class="NNPE-words"
  31. v-for="(pItem, pIndex) in item"
  32. :key="'wordsList' + pIndex"
  33. :class="[pItem.wordIndex == 0 ? 'textLeft' : 'textCenter']"
  34. >
  35. <template v-if="pItem.isShow">
  36. <template
  37. v-if="
  38. item[pIndex + 1] &&
  39. item[pIndex + 1].en &&
  40. enFhList.indexOf(item[pIndex + 1].en.word_bt) > -1
  41. "
  42. >
  43. <span class="NNPE-words-box NNPE-words-box-Both">
  44. <span
  45. :class="[]"
  46. >
  47. <span class="NNPE-words-box">
  48. <span
  49. :class="[pItem.timeList &&
  50. pItem.timeList[pItem.leg - 1] &&
  51. curTime >= pItem.timeList[pItem.leg - 1].wordBg &&
  52. curTime <= ed
  53. ? 'active'
  54. : '',]"
  55. >
  56. {{pItem.en.word_bt}}
  57. </span>
  58. </span>
  59. <span
  60. :class="[pItem.timeList[pItem.leg - 1] &&
  61. curTime >= pItem.timeList[pItem.leg - 1].wordBg &&
  62. curTime <= ed
  63. ? 'active'
  64. : '',
  65. ]"
  66. >{{ item[pIndex + 1].en.word_bt }}</span
  67. >
  68. </span>
  69. </span>
  70. </template>
  71. <template v-else>
  72. <span class="NNPE-words-box NNPE-words-box-single">
  73. <span
  74. :class="[
  75. pItem.padding? 'padding' : '',
  76. pItem.timeList &&
  77. pItem.timeList[pItem.leg - 1] &&
  78. curTime >= pItem.timeList[pItem.leg - 1].wordBg &&
  79. curTime <= ed
  80. ? 'active'
  81. : '',
  82. ]"
  83. >
  84. {{pItem.en.word_bt}}
  85. </span>
  86. </span>
  87. </template>
  88. </template>
  89. </div>
  90. </div>
  91. <div style="clear: both; overflow: hidden"></div>
  92. <div v-if="item.enwords" class="enwords">
  93. {{ item.enwords }}
  94. </div>
  95. </div>
  96. <div class="sent-bottom">
  97. <span class="create_time">{{ sItem.create_time }}</span>
  98. <span class="resource" v-if="sItem.resource"
  99. >来自:{{ sItem.resource }}</span
  100. >
  101. </div>
  102. </div>
  103. </template>
  104. <script>
  105. import AudioLineSentence from "./AudioLineSentence.vue";
  106. import { getLearnWebContent } from "@/api/ajax";
  107. export default {
  108. name: "sentence",
  109. components: {
  110. AudioLineSentence,
  111. },
  112. props: ["sItem", "index"],
  113. data() {
  114. return {
  115. item: null,
  116. bg: 0,
  117. ed: 0,
  118. mp3: "",
  119. stopAudio: false,
  120. chsFhList: [",", "。", "“", ":", "》", "《", "?", "!", ";"],
  121. enFhList: [",", ".", ";", "?", "!", ":", ">", "<"],
  122. noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "/"],
  123. NumberList: [
  124. "①",
  125. "②",
  126. "③",
  127. "④",
  128. "⑤",
  129. "⑥",
  130. "⑦",
  131. "⑧",
  132. "⑨",
  133. "⑩",
  134. "⑪",
  135. "⑫",
  136. "⑬",
  137. "⑭",
  138. "⑮",
  139. "⑯",
  140. "⑰",
  141. "⑱",
  142. "⑲",
  143. "⑳",
  144. ],
  145. pyPosition: "top",
  146. curTime: 0,
  147. };
  148. },
  149. computed: {},
  150. watch: {},
  151. //方法集合
  152. methods: {
  153. handleData() {
  154. let sentence_json = JSON.parse(this.sItem.sentence.sentence_json);
  155. if (sentence_json) {
  156. this.item = JSON.parse(sentence_json.item);
  157. this.bg = sentence_json.bg;
  158. this.ed = sentence_json.ed;
  159. this.pyPosition = sentence_json.pyPosition;
  160. this.mp3 = sentence_json.mp3;
  161. }
  162. },
  163. getCurTime(curTime) {
  164. let _this = this;
  165. _this.curTime = curTime * 1000;
  166. },
  167. pauseAudio() {
  168. let audio = document.getElementsByTagName("audio");
  169. audio.forEach((item) => {
  170. item.pause();
  171. });
  172. },
  173. cancleColl() {
  174. let data = {
  175. id_list: [this.sItem.id],
  176. };
  177. let MethodName = "order-collection_manager-DeleteMyCollection";
  178. getLearnWebContent(MethodName, data).then((res) => {
  179. this.$message.success("取消成功!");
  180. this.$emit("getMyCollectionList");
  181. });
  182. },
  183. },
  184. //生命周期 - 创建完成(可以访问当前this实例)
  185. created() {},
  186. //生命周期 - 挂载完成(可以访问DOM元素)
  187. mounted() {
  188. this.handleData();
  189. },
  190. beforeCreate() {}, //生命周期 - 创建之前
  191. beforeMount() {}, //生命周期 - 挂载之前
  192. beforeUpdate() {}, //生命周期 - 更新之前
  193. updated() {}, //生命周期 - 更新之后
  194. beforeDestroy() {}, //生命周期 - 销毁之前
  195. destroyed() {}, //生命周期 - 销毁完成
  196. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  197. };
  198. </script>
  199. <style lang='scss' scoped>
  200. //@import url(); 引入公共css类
  201. .sentence {
  202. width: 100%;
  203. .sent-top {
  204. display: flex;
  205. justify-content: space-between;
  206. align-items: center;
  207. width: 100%;
  208. margin-bottom: 8px;
  209. &-left {
  210. display: flex;
  211. justify-content: flex-start;
  212. align-items: center;
  213. .num {
  214. font-size: 14px;
  215. line-height: 22px;
  216. color: #000000;
  217. min-width: 22px;
  218. margin-right: 8px;
  219. }
  220. }
  221. .cancle-coll {
  222. float: right;
  223. padding: 0 12px;
  224. height: 32px;
  225. display: flex;
  226. justify-content: flex-start;
  227. align-items: center;
  228. cursor: pointer;
  229. border: 1px solid rgba(0, 0, 0, 0.1);
  230. box-sizing: border-box;
  231. border-radius: 4px;
  232. > .coll-icon {
  233. width: 16px;
  234. height: 16px;
  235. background: url("../../assets/starfill-16-normal-red.png") no-repeat
  236. left top;
  237. background-size: 100% 100%;
  238. margin-right: 4px;
  239. }
  240. > .coll-text {
  241. font-size: 14px;
  242. line-height: 22px;
  243. color: #000000;
  244. }
  245. }
  246. }
  247. .sent-bottom {
  248. > span {
  249. font-size: 14px;
  250. line-height: 22px;
  251. color: #2c2c2c;
  252. opacity: 0.5;
  253. margin-right: 8px;
  254. }
  255. }
  256. }
  257. .vc-main {
  258. width: 100%;
  259. margin-bottom: 8px;
  260. .enwords {
  261. font-size: 12px;
  262. line-height: 20px;
  263. color: rgba(0, 0, 0, 0.85);
  264. font-family: "robot";
  265. }
  266. }
  267. .NNPE-words {
  268. float: left;
  269. user-select: none;
  270. -webkit-user-select: none;
  271. -moz-user-select: none;
  272. -ms-user-select: none;
  273. &-box {
  274. float: left;
  275. > span {
  276. display: block;
  277. &.NNPE-pinyin {
  278. font-family: "GB-PINYINOK-B";
  279. font-weight: normal;
  280. font-size: 14px;
  281. line-height: 22px;
  282. box-sizing: border-box;
  283. color: rgba(0, 0, 0, 0.85);
  284. &.noFont {
  285. font-family: initial;
  286. }
  287. &.textLeft {
  288. text-align: left;
  289. }
  290. &.font-white {
  291. color: #fff;
  292. }
  293. &.wordBlank {
  294. color: rgba(0, 0, 0, 0.85);
  295. }
  296. }
  297. &.NNPE-chs {
  298. font-family: "FZJCGFKTK";
  299. font-size: 20px;
  300. line-height: 24px;
  301. color: rgba(0, 0, 0, 0.85);
  302. .font-white {
  303. color: #fff;
  304. }
  305. .active {
  306. color: #de4444;
  307. &-yellow {
  308. color: #ffc600;
  309. }
  310. }
  311. .wordActive {
  312. color: #de4444;
  313. }
  314. .wordActive-blue {
  315. color: #ffc600;
  316. }
  317. }
  318. // &.padding {
  319. // padding-right: 6px;
  320. // }
  321. }
  322. }
  323. &.textLeft {
  324. text-align: left;
  325. }
  326. &.textCenter {
  327. text-align: center;
  328. }
  329. .active {
  330. color: #de4444;
  331. }
  332. > span {
  333. display: block;
  334. margin-right: 6px;
  335. font-size: 18px;
  336. color: rgba(0, 0, 0, 0.85);
  337. }
  338. }
  339. </style>