TextProblem.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 :class="['con-item',indexCon===0?'con-item-0':'']" v-for="(itemCon,indexCon) in item.detail.resArr" :key="indexCon" v-show="itemCon.isShow">
  12. <template v-if="item.detail.wordsList[indexCon + 1] && item.detail.wordsList[indexCon + 1].chs && chsFhList.indexOf(item.detail.wordsList[indexCon + 1].chs) > -1">
  13. <div class="synthesis-box">
  14. <div>
  15. <span class="pinyin" :class="[noFont.indexOf(itemCon.pinyin)>-1?'noFont':'']" v-if="item.detail.pyPosition=='top'">{{itemCon.pinyin}}</span>
  16. <span class="hanzi content-con">{{itemCon.chs}}</span>
  17. <span class="pinyin" :class="[noFont.indexOf(itemCon.pinyin)>-1?'noFont':'']" v-if="item.detail.pyPosition=='bottom'">{{itemCon.pinyin}}</span>
  18. </div>
  19. <div style="text-align: left">
  20. <span class="pinyin" :class="[noFont.indexOf(items.detail.wordsList[indexCon + 1].pinyin)>-1?'noFont':'']" v-if="item.detail.pyPosition=='top'">{{item.detail.wordsList[indexCon + 1].pinyin}}</span>
  21. <span class="hanzi content-con">{{item.detail.wordsList[indexCon + 1].chs}}</span>
  22. <span class="pinyin" :class="[noFont.indexOf(items.detail.wordsList[indexCon + 1].pinyin)>-1?'noFont':'']" v-if="item.detail.pyPosition=='bottom'">{{item.detail.wordsList[indexCon + 1].pinyin}}</span>
  23. </div>
  24. </div>
  25. </template>
  26. <template v-else>
  27. <span class="pinyin" :class="[noFont.indexOf(itemCon.pinyin)>-1?'noFont':'']" v-if="item.detail.pyPosition=='top'">{{itemCon.pinyin}}</span>
  28. <span class="hanzi content-con">{{itemCon.chs}}</span>
  29. <span class="pinyin" :class="[noFont.indexOf(itemCon.pinyin)>-1?'noFont':'']" v-if="item.detail.pyPosition=='bottom'">{{itemCon.pinyin}}</span>
  30. </template>
  31. </div>
  32. </div>
  33. </template>
  34. <template v-else>
  35. <p class="hanzi content-con">
  36. {{item.detail.sentence}}
  37. </p>
  38. </template>
  39. <span class="english" v-if="item.en">{{item.en}}</span>
  40. </div>
  41. </li>
  42. </ul>
  43. </div>
  44. </template>
  45. <script>
  46. export default {
  47. components: {},
  48. props: ["curQue"],
  49. data() {
  50. return {
  51. chsFhList: [",", "。", "“", ":", "》", "《", "?", "!", ";"],
  52. noFont: ['~','!','@','#','$','%','^','&','*','(',')'], // 对应不要拼音字体
  53. };
  54. },
  55. computed: {},
  56. watch: {},
  57. //方法集合
  58. methods: {
  59. // 处理数据
  60. handleData(){
  61. let _this = this
  62. let curQue = JSON.parse(JSON.stringify(this.curQue));
  63. curQue.option.forEach((dItem, dIndex) => {
  64. let paraArr = []
  65. dItem.detail.wordsList.forEach((sItem, sIndex) => {
  66. this.mergeWordSymbol(dItem.detail.wordsList, sItem, sIndex);
  67. let obj = {
  68. pinyin: sItem.pinyin,
  69. chs: sItem.chs,
  70. isShow: sItem.isShow,
  71. };
  72. paraArr.push(obj);
  73. })
  74. this.$set(_this.curQue.option[dIndex].detail,'resArr',paraArr)
  75. })
  76. },
  77. //词和标点合一起
  78. mergeWordSymbol(sItem, wItem, curIndex) {
  79. let leg = sItem.length;
  80. if (curIndex < leg - 1) {
  81. if (this.chsFhList.indexOf(wItem.chs) > -1) {
  82. wItem.isShow = false;
  83. } else {
  84. wItem.isShow = true;
  85. }
  86. }
  87. },
  88. },
  89. //生命周期 - 创建完成(可以访问当前this实例)
  90. created() {
  91. this.handleData()
  92. },
  93. //生命周期 - 挂载完成(可以访问DOM元素)
  94. mounted() {},
  95. beforeCreate() {}, //生命周期 - 创建之前
  96. beforeMount() {}, //生命周期 - 挂载之前
  97. beforeUpdate() {}, //生命周期 - 更新之前
  98. updated() {}, //生命周期 - 更新之后
  99. beforeDestroy() {}, //生命周期 - 销毁之前
  100. destroyed() {}, //生命周期 - 销毁完成
  101. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  102. };
  103. </script>
  104. <style lang='scss' scoped>
  105. //@import url(); 引入公共css类
  106. .Textproblem{
  107. width: 100%;
  108. padding: 8px 24px;
  109. background: #F7F7F7;
  110. border: 1px solid rgba(0, 0, 0, 0.1);
  111. border-radius: 8px;
  112. h2{
  113. margin: 16px 0 0;
  114. font-weight: 500;
  115. font-size: 16px;
  116. line-height: 24px;
  117. color: #000000;
  118. }
  119. ul{
  120. padding-top: 16px;
  121. li{
  122. display: flex;
  123. margin-bottom: 16px;
  124. b{
  125. color: rgba(0, 0, 0, 0.85);
  126. font-size: 16px;
  127. line-height: 24px;
  128. font-family: 'FZJCGFKTK';
  129. margin-right: 4px;
  130. font-weight: normal;
  131. }
  132. .content-right{
  133. flex: 1;
  134. .content-con{
  135. font-size: 16px;
  136. line-height: 24px;
  137. color: #000000;
  138. font-family: 'FZJCGFKTK';
  139. margin: 0;
  140. &.content-con-small{
  141. font-size: 16px;
  142. }
  143. }
  144. .con-box{
  145. display: flex;
  146. flex-flow: wrap;
  147. .con-item{
  148. text-align: center;
  149. padding: 0 1px;
  150. &.con-item-0{
  151. text-align: left;
  152. padding-left: 0;
  153. }
  154. }
  155. span{
  156. display: block;
  157. }
  158. .pinyin{
  159. font-family: 'GB-PINYINOK-B';
  160. font-size: 12px;
  161. line-height: 20px;
  162. color: #000000;
  163. height: 20px;
  164. &.noFont{
  165. font-family: initial;
  166. }
  167. }
  168. .synthesis-box{
  169. display: flex;
  170. }
  171. }
  172. .english{
  173. color: rgba(0, 0, 0, 0.85);
  174. font-size: 14px;
  175. line-height: 150%;
  176. font-family: 'robot';
  177. display: block;
  178. word-break: break-word;
  179. }
  180. }
  181. }
  182. }
  183. }
  184. </style>