uni-indexed-list-item.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view>
  3. <view v-if="loaded || list.itemIndex < 15" class="uni-indexed-list__title-wrapper">
  4. <text v-if="list.items && list.items.length > 0" class="uni-indexed-list__title">{{ list.key }}</text>
  5. </view>
  6. <view v-if="(loaded || list.itemIndex < 15) && list.items && list.items.length > 0" class="uni-indexed-list__list">
  7. <view v-for="(item, index) in list.items" :key="index" class="uni-indexed-list__item" hover-class="uni-indexed-list__item--hover">
  8. <view class="uni-indexed-list__item-container" @click="onClick(idx, index)">
  9. <view class="uni-indexed-list__item-border" :class="{'uni-indexed-list__item-border--last':index===list.items.length-1}">
  10. <view v-if="showSelect" style="margin-right: 20rpx;">
  11. <uni-icons :type="item.checked ? 'checkbox-filled' : 'circle'" :color="item.checked ? '#007aff' : '#C0C0C0'" size="24" />
  12. </view>
  13. <text class="uni-indexed-list__item-content">{{ item.name }}</text>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'UniIndexedList',
  23. emits:['itemClick'],
  24. props: {
  25. loaded: {
  26. type: Boolean,
  27. default: false
  28. },
  29. idx: {
  30. type: Number,
  31. default: 0
  32. },
  33. list: {
  34. type: Object,
  35. default () {
  36. return {}
  37. }
  38. },
  39. showSelect: {
  40. type: Boolean,
  41. default: false
  42. }
  43. },
  44. methods: {
  45. onClick(idx, index) {
  46. this.$emit("itemClick", {
  47. idx,
  48. index
  49. })
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" >
  55. .uni-indexed-list__list {
  56. background-color: $uni-bg-color;
  57. /* #ifndef APP-NVUE */
  58. display: flex;
  59. /* #endif */
  60. flex-direction: column;
  61. border-top-style: solid;
  62. border-top-width: 1px;
  63. border-top-color: #DEDEDE;
  64. }
  65. .uni-indexed-list__item {
  66. font-size: 14px;
  67. /* #ifndef APP-NVUE */
  68. display: flex;
  69. /* #endif */
  70. flex: 1;
  71. flex-direction: row;
  72. justify-content: space-between;
  73. align-items: center;
  74. }
  75. .uni-indexed-list__item-container {
  76. padding-left: 15px;
  77. flex: 1;
  78. position: relative;
  79. /* #ifndef APP-NVUE */
  80. display: flex;
  81. box-sizing: border-box;
  82. /* #endif */
  83. flex-direction: row;
  84. justify-content: space-between;
  85. align-items: center;
  86. /* #ifdef H5 */
  87. cursor: pointer;
  88. /* #endif */
  89. }
  90. .uni-indexed-list__item-border {
  91. flex: 1;
  92. position: relative;
  93. /* #ifndef APP-NVUE */
  94. display: flex;
  95. box-sizing: border-box;
  96. /* #endif */
  97. flex-direction: row;
  98. justify-content: space-between;
  99. align-items: center;
  100. height: 50px;
  101. padding: 25px;
  102. padding-left: 0;
  103. border-bottom-style: solid;
  104. border-bottom-width: 1px;
  105. border-bottom-color: #DEDEDE;
  106. }
  107. .uni-indexed-list__item-border--last {
  108. border-bottom-width: 0px;
  109. }
  110. .uni-indexed-list__item-content {
  111. flex: 1;
  112. font-size: 14px;
  113. color: #191919;
  114. }
  115. .uni-indexed-list {
  116. /* #ifndef APP-NVUE */
  117. display: flex;
  118. /* #endif */
  119. flex-direction: row;
  120. }
  121. .uni-indexed-list__title-wrapper {
  122. /* #ifndef APP-NVUE */
  123. display: flex;
  124. width: 100%;
  125. /* #endif */
  126. background-color: #f7f7f7;
  127. }
  128. .uni-indexed-list__title {
  129. padding: 6px 12px;
  130. line-height: 24px;
  131. font-size: 16px;
  132. font-weight: 500;
  133. }
  134. </style>