RoleChs.vue 3.0 KB

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