RoleChs.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div v-if="curRole" class="role-rItems">
  3. <img
  4. v-if="type === 'upload'"
  5. :src="curRole.img_list[0] && curRole.img_list[0].file_url"
  6. class="adult-book-input-roleImg"
  7. />
  8. <img
  9. v-else-if="type === 'simple' && curRole.simpleHead !== ''"
  10. class="adult-book-input-roleImg"
  11. :src="require('@/assets/simple' + curRole.simpleHead + '.png')"
  12. />
  13. <span
  14. v-else
  15. class="adult-book-input-roleTexts"
  16. :class="[
  17. curRole.fullName
  18. ? curRole.fullName.length === 4
  19. ? 'adult-book-input-roleTextPadding'
  20. : curRole.name && curRole.name.length === 4
  21. ? 'adult-book-input-roleTextPadding'
  22. : ''
  23. : '',
  24. ]"
  25. :style="{ background: curRole.color }"
  26. >{{ convertText(curRole.fullName || curRole.name) }}</span
  27. >
  28. <!-- <template>
  29. <span class="pinyin" :style="{ color: wordColor }">{{ curRole.fullName }}</span>
  30. <span class="chs" :style="{ color: wordColor }">{{ curRole.fullPinyin }}</span>
  31. </template> -->
  32. </div>
  33. </template>
  34. <script>
  35. export default {
  36. components: {},
  37. filters: {
  38. handlePinyin(wordsList) {
  39. let str = '';
  40. wordsList.forEach((item, index) => {
  41. if (index < wordsList.length - 1) {
  42. str += `${item.pinyin} `;
  43. } else {
  44. str += item.pinyin;
  45. }
  46. });
  47. return str;
  48. },
  49. handleChs(wordsList) {
  50. let str = '';
  51. wordsList.forEach((item, index) => {
  52. if (index < wordsList.length - 1) {
  53. str += `${item.chs} `;
  54. } else {
  55. str += item.chs;
  56. }
  57. });
  58. return str;
  59. },
  60. },
  61. props: ['curRole', 'color', 'type'],
  62. inject: ['convertText'],
  63. data() {
  64. return {};
  65. },
  66. computed: {
  67. wordColor() {
  68. let color = 'rgba(0,0,0,0.85)';
  69. if (this.color) {
  70. color = this.color;
  71. }
  72. return color;
  73. },
  74. },
  75. watch: {},
  76. // 生命周期 - 创建完成(可以访问当前this实例)
  77. created() {},
  78. // 生命周期 - 挂载完成(可以访问DOM元素)
  79. mounted() {},
  80. beforeCreate() {}, // 生命周期 - 创建之前
  81. beforeMount() {}, // 生命周期 - 挂载之前
  82. beforeUpdate() {}, // 生命周期 - 更新之前
  83. updated() {}, // 生命周期 - 更新之后
  84. beforeDestroy() {}, // 生命周期 - 销毁之前
  85. destroyed() {}, // 生命周期 - 销毁完成
  86. activated() {},
  87. // 方法集合
  88. methods: {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. //@import url(); 引入公共css类
  93. .role-rItems {
  94. display: flex;
  95. align-items: center;
  96. justify-content: flex-start;
  97. .adult-book-input {
  98. &-roleTexts {
  99. display: flex;
  100. align-items: center;
  101. justify-content: center;
  102. width: 44px;
  103. height: 44px;
  104. padding: 1px;
  105. font-size: 12px;
  106. line-height: 15px;
  107. color: #fff;
  108. text-align: center;
  109. background: #a7a7a7;
  110. border-radius: 100%;
  111. }
  112. &-roleTextPadding {
  113. padding: 2px 5px;
  114. }
  115. &-roleImg {
  116. width: 44px;
  117. height: 44px;
  118. overflow: hidden;
  119. border-radius: 50%;
  120. }
  121. }
  122. .pinyin {
  123. margin-right: 4px;
  124. margin-left: 8px;
  125. font-family: 'League';
  126. font-size: 14px;
  127. line-height: 22px;
  128. color: rgba(0, 0, 0, 85%);
  129. }
  130. .chs {
  131. font-family: '楷体';
  132. font-size: 16px;
  133. line-height: 24px;
  134. color: rgba(0, 0, 0, 85%);
  135. }
  136. }
  137. </style>