text.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="flex-grow-1">
  3. <block v-if="type==4 ||type==7 || type==8">
  4. <view @click="bindCate(type,text.link.id||'')" :style="style" v-if="name==''"
  5. class="box-pack-between flex-y-center border-b">
  6. <text>{{ text.t }}</text>
  7. <text class="iconfont icon-jiantou"></text>
  8. </view>
  9. <view :style="style" class="text-overflow" v-else>{{ name }}</view>
  10. </block>
  11. <block v-else>
  12. <view :style="style" v-if="name==''">{{ text.t }}</view>
  13. <view :style="style" class="text-overflow" v-else>{{ name }}</view>
  14. </block>
  15. <!-- {{type}} -->
  16. <!-- <span :style="style" v-if="name==''">{{ text.t }}</span>
  17. <span :style="style" v-else>{{ name }}</span>-->
  18. </view>
  19. </template>
  20. <script>
  21. import store from '../../store/index.js'
  22. export default {
  23. name: 'moduleText',
  24. props: {
  25. 'text': {
  26. type: Object
  27. },
  28. 'name': {
  29. default: ''
  30. },
  31. 'type': {
  32. default: 1
  33. },
  34. },
  35. computed: {
  36. style() {
  37. if (this.text.d) {
  38. let style = `font-size:${this.text.f}px;color:${this.text.c};`;
  39. if (this.text.b) {
  40. style += 'font-weight:bold;';
  41. }
  42. if (this.text.i) {
  43. style += 'font-style:italic;';
  44. }
  45. if (this.text.u) {
  46. style += 'text-decoration:underline;';
  47. }
  48. return style;
  49. }
  50. }
  51. },
  52. methods: {
  53. bindCate(type, id) {
  54. console.log(id, type, "id")
  55. if (type == 4) {
  56. store.commit('SET_CATE_ID', id || '')
  57. uni.switchTab({
  58. url: "../../pages/index/index"
  59. })
  60. }
  61. if (type == 7) {
  62. uni.navigateTo({
  63. url: "../../pintuan/list"
  64. })
  65. }
  66. if (type == 8) {
  67. uni.navigateTo({
  68. url: "../../subscribe/shopsSubscrbe"
  69. })
  70. }
  71. }
  72. },
  73. };
  74. </script>
  75. <style>
  76. .icon-jiantou {
  77. font-size: 24rpx;
  78. }
  79. /* view{
  80. font-size: 24rpx;
  81. } */
  82. .text-overflow {
  83. overflow: hidden;
  84. text-overflow: ellipsis;
  85. white-space: nowrap;
  86. }
  87. </style>