TextProblem.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-prev-Textdes Textproblem" v-if="curQue">
  4. <h2 v-if="curQue.title">{{ curQue.title }}</h2>
  5. <ul>
  6. <li v-for="(item, index) in curQue.option" :key="index">
  7. <b v-if="item.number">{{ item.number }}</b>
  8. <div class="content-right">
  9. <template v-if="item.detail.wordsList.length > 0">
  10. <div class="con-box">
  11. <div
  12. :class="['con-item', indexCon === 0 ? 'con-item-0' : '']"
  13. v-for="(itemCon, indexCon) in item.detail.resArr"
  14. :key="indexCon"
  15. v-show="itemCon.isShow"
  16. >
  17. <template
  18. v-if="
  19. item.detail.wordsList[indexCon + 1] &&
  20. item.detail.wordsList[indexCon + 1].chs &&
  21. chsFhList.indexOf(
  22. item.detail.wordsList[indexCon + 1].chs
  23. ) > -1
  24. "
  25. >
  26. <div class="synthesis-box">
  27. <div>
  28. <span
  29. class="pinyin"
  30. :class="[
  31. noFont.indexOf(itemCon.pinyin) > -1 ? 'noFont' : ''
  32. ]"
  33. v-if="item.detail.pyPosition == 'top'"
  34. >{{ itemCon.pinyin }}</span
  35. >
  36. <span
  37. class="hanzi content-con"
  38. :style="wordStyle(itemCon.config)"
  39. >{{ itemCon.chs }}</span
  40. >
  41. <span
  42. class="pinyin"
  43. :class="[
  44. noFont.indexOf(itemCon.pinyin) > -1 ? 'noFont' : ''
  45. ]"
  46. v-if="item.detail.pyPosition == 'bottom'"
  47. >{{ itemCon.pinyin }}</span
  48. >
  49. </div>
  50. <div style="text-align: left">
  51. <span
  52. class="pinyin"
  53. :class="[
  54. noFont.indexOf(
  55. item.detail.wordsList[indexCon + 1].pinyin
  56. ) > -1
  57. ? 'noFont'
  58. : ''
  59. ]"
  60. v-if="item.detail.pyPosition == 'top'"
  61. >{{ item.detail.wordsList[indexCon + 1].pinyin }}</span
  62. >
  63. <span
  64. class="hanzi content-con"
  65. :style="
  66. wordStyle(item.detail.wordsList[indexCon + 1].config)
  67. "
  68. >{{ item.detail.wordsList[indexCon + 1].chs }}</span
  69. >
  70. <span
  71. class="pinyin"
  72. :class="[
  73. noFont.indexOf(
  74. item.detail.wordsList[indexCon + 1].pinyin
  75. ) > -1
  76. ? 'noFont'
  77. : ''
  78. ]"
  79. v-if="item.detail.pyPosition == 'bottom'"
  80. >{{ item.detail.wordsList[indexCon + 1].pinyin }}</span
  81. >
  82. </div>
  83. </div>
  84. </template>
  85. <template v-else>
  86. <span
  87. class="pinyin"
  88. :class="[
  89. noFont.indexOf(itemCon.pinyin) > -1 ? 'noFont' : ''
  90. ]"
  91. v-if="item.detail.pyPosition == 'top'"
  92. >{{ itemCon.pinyin }}</span
  93. >
  94. <span
  95. class="hanzi content-con"
  96. :style="wordStyle(itemCon.config)"
  97. >{{ itemCon.chs }}</span
  98. >
  99. <span
  100. class="pinyin"
  101. :class="[
  102. noFont.indexOf(itemCon.pinyin) > -1 ? 'noFont' : ''
  103. ]"
  104. v-if="item.detail.pyPosition == 'bottom'"
  105. >{{ itemCon.pinyin }}</span
  106. >
  107. </template>
  108. </div>
  109. </div>
  110. </template>
  111. <template v-else>
  112. <p class="hanzi content-con">
  113. {{ item.detail.sentence }}
  114. </p>
  115. </template>
  116. <span class="english" v-if="item.en">{{ item.en }}</span>
  117. </div>
  118. </li>
  119. </ul>
  120. </div>
  121. </template>
  122. <script>
  123. export default {
  124. components: {},
  125. props: ["curQue"],
  126. data() {
  127. return {
  128. chsFhList: [",", "。", "“", ":", "》", "?", "!", ";"],
  129. noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")"] // 对应不要拼音字体
  130. };
  131. },
  132. computed: {
  133. wordStyle() {
  134. return function(config) {
  135. if (config) {
  136. let sizeVal = config.fontSize.replace("px", "");
  137. return {
  138. minHeight: Number(sizeVal) + 9 + "px",
  139. lineHeight: Number(sizeVal) + 8 + "px",
  140. fontSize: config.fontSize,
  141. fontFamily: config.fontFamily
  142. };
  143. }
  144. };
  145. }
  146. },
  147. watch: {},
  148. //方法集合
  149. methods: {
  150. // 处理数据
  151. handleData() {
  152. let _this = this;
  153. let curQue = JSON.parse(JSON.stringify(this.curQue));
  154. curQue.option.forEach((dItem, dIndex) => {
  155. let paraArr = [];
  156. if (dItem.detail) {
  157. dItem.detail.wordsList.forEach((sItem, sIndex) => {
  158. this.mergeWordSymbol(dItem.detail.wordsList, sItem, sIndex);
  159. let obj = {
  160. pinyin: sItem.pinyin,
  161. chs: sItem.chs,
  162. isShow: sItem.isShow,
  163. config: {
  164. fontColor: sItem.fontColor,
  165. fontFamily: sItem.fontFamily,
  166. fontSize: sItem.fontSize,
  167. underLine: sItem.underLine,
  168. wordPadding: sItem.wordPadding
  169. }
  170. };
  171. paraArr.push(obj);
  172. });
  173. }
  174. this.$set(_this.curQue.option[dIndex].detail, "resArr", paraArr);
  175. });
  176. },
  177. //词和标点合一起
  178. mergeWordSymbol(sItem, wItem, curIndex) {
  179. let leg = sItem.length;
  180. if (curIndex < leg - 1) {
  181. if (this.chsFhList.indexOf(wItem.chs) > -1) {
  182. wItem.isShow = false;
  183. } else {
  184. wItem.isShow = true;
  185. }
  186. } else {
  187. wItem.isShow = true;
  188. }
  189. }
  190. },
  191. //生命周期 - 创建完成(可以访问当前this实例)
  192. created() {
  193. this.handleData();
  194. },
  195. //生命周期 - 挂载完成(可以访问DOM元素)
  196. mounted() {},
  197. beforeCreate() {}, //生命周期 - 创建之前
  198. beforeMount() {}, //生命周期 - 挂载之前
  199. beforeUpdate() {}, //生命周期 - 更新之前
  200. updated() {}, //生命周期 - 更新之后
  201. beforeDestroy() {}, //生命周期 - 销毁之前
  202. destroyed() {}, //生命周期 - 销毁完成
  203. activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
  204. };
  205. </script>
  206. <style lang="scss" scoped>
  207. //@import url(); 引入公共css类
  208. .Textproblem {
  209. width: 100%;
  210. padding: 8px 24px;
  211. background: #f7f7f7;
  212. border: 1px solid rgba(0, 0, 0, 0.1);
  213. border-radius: 8px;
  214. margin-bottom: 24px;
  215. h2 {
  216. margin: 16px 0 0;
  217. font-weight: 500;
  218. font-size: 16px;
  219. line-height: 24px;
  220. color: #000000;
  221. }
  222. ul {
  223. padding-top: 16px;
  224. li {
  225. display: flex;
  226. margin-bottom: 16px;
  227. b {
  228. color: rgba(0, 0, 0, 0.85);
  229. font-size: 16px;
  230. line-height: 24px;
  231. font-family: "楷体", "FZJCGFKTK";
  232. margin-right: 4px;
  233. font-weight: normal;
  234. }
  235. .content-right {
  236. flex: 1;
  237. .content-con {
  238. font-size: 16px;
  239. line-height: 24px;
  240. color: #000000;
  241. font-family: "楷体", "FZJCGFKTK";
  242. margin: 0;
  243. &.content-con-small {
  244. font-size: 16px;
  245. }
  246. }
  247. .con-box {
  248. display: flex;
  249. flex-flow: wrap;
  250. .con-item {
  251. text-align: center;
  252. padding: 0 1px;
  253. &.con-item-0 {
  254. text-align: left;
  255. padding-left: 0;
  256. }
  257. }
  258. span {
  259. display: block;
  260. }
  261. .pinyin {
  262. font-family: "GB-PINYINOK-B";
  263. font-size: 12px;
  264. line-height: 20px;
  265. color: #000000;
  266. height: 20px;
  267. &.noFont {
  268. font-family: initial;
  269. }
  270. }
  271. .synthesis-box {
  272. display: flex;
  273. }
  274. }
  275. .english {
  276. color: rgba(0, 0, 0, 0.85);
  277. font-size: 14px;
  278. line-height: 150%;
  279. font-family: "robot";
  280. display: block;
  281. word-break: break-word;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. </style>