u-des-row.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="u-des-row" :class="{'border': border, 'click': isCilck}" @click="$emit('click')">
  3. <slot name="left" />
  4. <view class="label">
  5. {{label}}
  6. </view>
  7. <view class="value">
  8. <slot name="value" :isOpen="isOpen">
  9. {{value}}
  10. </slot>
  11. </view>
  12. <!-- -->
  13. <view class="right-icon" v-if="forward">
  14. <uni-icons type="forward" size="12" color="#9FA5BA" />
  15. </view>
  16. <view class="right-icon" v-else-if="eye" @click="isOpen=!isOpen">
  17. <image v-if="isOpen" src="/static/open_icon.png" style="width: 28rpx;height: 20rpx;" mode=""></image>
  18. <image v-else src="/static/no_open.png" style="width: 28rpx;height: 11rpx;" mode=""></image>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. name: "u-des-row",
  25. props: {
  26. label: {
  27. type: [String, Number],
  28. default: ''
  29. },
  30. value: {
  31. type: [String, Number],
  32. default: ''
  33. },
  34. border: {
  35. type: Boolean,
  36. default: false
  37. },
  38. forward: { // 向右箭头
  39. type: Boolean,
  40. default: false
  41. },
  42. eye: { // 眼睛 可视?
  43. type: Boolean,
  44. default: false
  45. },
  46. },
  47. data() {
  48. return {
  49. isOpen: false
  50. }
  51. },
  52. computed: {
  53. isCilck() {
  54. return Boolean(this.$listeners['click'])
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .u-des-row {
  61. display: flex;
  62. justify-content: space-between;
  63. align-items: center;
  64. height: 100rpx;
  65. &.border {
  66. border-bottom: 1px solid #F5F7FA;
  67. }
  68. &.click {
  69. cursor: pointer;
  70. &:hover {
  71. background: #F5F7FA;
  72. }
  73. }
  74. .label {
  75. font-size: 28rpx;
  76. margin-right: 16rpx;
  77. color: #333333;
  78. font-weight: bold;
  79. }
  80. .value {
  81. flex: 1;
  82. text-align: right;
  83. font-size: 28rpx;
  84. font-weight: 400;
  85. color: #333333;
  86. //超过一行省略号 one-line
  87. overflow: hidden;
  88. text-overflow: ellipsis;
  89. white-space: nowrap;
  90. }
  91. .right-icon {
  92. height: 36rpx;
  93. width: 36rpx;
  94. display: flex;
  95. align-items: center;
  96. justify-content: flex-end;
  97. cursor: pointer;
  98. }
  99. }
  100. </style>