RoleChs.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. 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. data() {
  51. return {};
  52. },
  53. computed: {
  54. wordColor() {
  55. let color = 'rgba(0,0,0,0.85)';
  56. if (this.color) {
  57. color = this.color;
  58. }
  59. return color;
  60. },
  61. },
  62. watch: {},
  63. // 生命周期 - 创建完成(可以访问当前this实例)
  64. created() {},
  65. // 生命周期 - 挂载完成(可以访问DOM元素)
  66. mounted() {},
  67. beforeCreate() {}, // 生命周期 - 创建之前
  68. beforeMount() {}, // 生命周期 - 挂载之前
  69. beforeUpdate() {}, // 生命周期 - 更新之前
  70. updated() {}, // 生命周期 - 更新之后
  71. beforeDestroy() {}, // 生命周期 - 销毁之前
  72. destroyed() {}, // 生命周期 - 销毁完成
  73. activated() {},
  74. // 方法集合
  75. methods: {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  76. };
  77. </script>
  78. <style lang="scss" scoped>
  79. //@import url(); 引入公共css类
  80. .role-rItem {
  81. display: flex;
  82. align-items: center;
  83. justify-content: flex-start;
  84. .adult-book-input {
  85. &-roleText {
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. width: 36px;
  90. height: 36px;
  91. font-size: 12px;
  92. line-height: 20px;
  93. color: #fff;
  94. text-align: center;
  95. background: #a7a7a7;
  96. border-radius: 100%;
  97. }
  98. &-roleImg {
  99. width: 36px;
  100. height: 36px;
  101. overflow: hidden;
  102. border-radius: 50%;
  103. }
  104. }
  105. .pinyin {
  106. margin-right: 4px;
  107. margin-left: 8px;
  108. font-family: 'League';
  109. font-size: 14px;
  110. line-height: 22px;
  111. color: rgba(0, 0, 0, 85%);
  112. }
  113. .chs {
  114. font-family: '楷体';
  115. font-size: 16px;
  116. line-height: 24px;
  117. color: rgba(0, 0, 0, 85%);
  118. }
  119. }
  120. </style>