OptionModel.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!-- -->
  2. <template>
  3. <div
  4. :class="['dialogue-option', index % 2 == 0 ? 'pink-bg' : 'blue-bg']"
  5. v-if="curOption"
  6. >
  7. <div
  8. :class="['left-icon', index % 2 == 0 ? 'pink-left' : 'blue-left']"
  9. ></div>
  10. <div
  11. class="dialogue-option-con"
  12. v-for="(item, index) in resArr"
  13. :key="'curOption' + index"
  14. >
  15. <span
  16. class="sentence"
  17. v-for="(wItem, wIndex) in item"
  18. :key="'curOption_word' + wIndex"
  19. >
  20. <span class="NNPE-pinyin padding">{{ wItem.pinyin }}</span>
  21. <span class="NNPE-chs padding">{{ wItem.chs }}</span>
  22. </span>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. export default {
  28. components: {},
  29. props: ["curOption", "index"],
  30. data() {
  31. return {
  32. bgList: [
  33. {
  34. bg: require("../../../../assets/NPC/op-pink-bg.png"),
  35. bgLeft: require("../../../../assets/NPC/op-pink-left.png"),
  36. },
  37. {
  38. bg: require("../../../../assets/NPC/op-blue-bg.png"),
  39. bgLeft: require("../../../../assets/NPC/op-blue-left.png"),
  40. },
  41. ],
  42. resArr: [],
  43. };
  44. },
  45. computed: {},
  46. watch: {},
  47. //方法集合
  48. methods: {
  49. handleData() {
  50. let resArr = [];
  51. this.curOption.detail.forEach((dItem) => {
  52. dItem.wordsList.forEach((sItem) => {
  53. let sentArr = [];
  54. sItem.forEach((wItem) => {
  55. let obj = {
  56. chs: wItem.chs,
  57. pinyin: wItem.pinyin,
  58. };
  59. sentArr.push(obj);
  60. });
  61. resArr.push(sentArr);
  62. });
  63. });
  64. this.resArr = resArr;
  65. console.log(this.resArr);
  66. },
  67. },
  68. //生命周期 - 创建完成(可以访问当前this实例)
  69. created() {},
  70. //生命周期 - 挂载完成(可以访问DOM元素)
  71. mounted() {
  72. console.log("curOption");
  73. console.log(this.curOption);
  74. if (this.curOption) {
  75. this.handleData();
  76. }
  77. },
  78. beforeCreate() {}, //生命周期 - 创建之前
  79. beforeMount() {}, //生命周期 - 挂载之前
  80. beforeUpdate() {}, //生命周期 - 更新之前
  81. updated() {}, //生命周期 - 更新之后
  82. beforeDestroy() {}, //生命周期 - 销毁之前
  83. destroyed() {}, //生命周期 - 销毁完成
  84. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  85. };
  86. </script>
  87. <style lang='scss' scoped>
  88. //@import url(); 引入公共css类
  89. .dialogue-option {
  90. position: relative;
  91. width: 256px;
  92. height: 256px;
  93. display: flex;
  94. flex-direction: column;
  95. justify-content: center;
  96. align-items: center;
  97. margin-top: 16px;
  98. &.pink-bg {
  99. background: url("../../../../assets/NPC/op-pink-bg.png") no-repeat left top;
  100. background-size: 100% 100%;
  101. }
  102. &.blue-bg {
  103. background: url("../../../../assets/NPC/op-blue-bg.png") no-repeat left top;
  104. background-size: 100% 100%;
  105. }
  106. .left-icon {
  107. position: absolute;
  108. left: -16px;
  109. top: -16px;
  110. z-index: 9999;
  111. &.pink-left {
  112. width: 44px;
  113. height: 54px;
  114. background: url("../../../../assets/NPC/op-pink-left.png") no-repeat left
  115. top;
  116. background-size: 100% 100%;
  117. }
  118. &.blue-left {
  119. width: 82px;
  120. height: 68px;
  121. background: url("../../../../assets/NPC/op-blue-left.png") no-repeat left
  122. top;
  123. background-size: 100% 100%;
  124. }
  125. }
  126. .dialogue-option-con {
  127. clear: both;
  128. overflow: hidden;
  129. margin-bottom: 8px;
  130. .sentence {
  131. float: left;
  132. text-align: center;
  133. > span {
  134. display: block;
  135. &.NNPE-pinyin {
  136. font-family: "GB-PINYINOK-B";
  137. font-weight: normal;
  138. font-size: 14px;
  139. line-height: 22px;
  140. color: #000000;
  141. height: 21px;
  142. &.textLeft {
  143. text-align: left;
  144. }
  145. }
  146. &.NNPE-chs {
  147. font-family: "FZJCGFKTK";
  148. font-size: 24px;
  149. line-height: 32px;
  150. color: #000000;
  151. &.active {
  152. background: rgba(60, 200, 99, 0.2);
  153. }
  154. &.wordActive {
  155. color: #de4444;
  156. }
  157. }
  158. &.padding {
  159. padding: 0 3px;
  160. }
  161. }
  162. }
  163. }
  164. }
  165. </style>