uni-indexed-list-item.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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" @click.stop="toGoodsList(item.brandId)">
  8. <view class="uni-indexed-list__item-container">
  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' : '#aaa'" size="24" />
  12. </view>
  13. <view class="diy_item flex_row_start_start">
  14. <image class="img" :src="item.image" @error='setDefaultImg(item,index)' mode="item.image"></image>
  15. <!-- <view class="img" :style="{backgroundImage: 'url('+item.image+')'}" ></view> -->
  16. <view class="detail flex_column_start_start">
  17. <text class="name">{{item.name}}</text>
  18. <text class="desc">{{item.brandDesc}}</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import uniIcons from '../uni-icons/uni-icons.vue'
  29. export default {
  30. name: 'UniIndexedList',
  31. components: {
  32. uniIcons
  33. },
  34. props: {
  35. loaded: {
  36. type: Boolean,
  37. default: false
  38. },
  39. idx: {
  40. type: Number,
  41. default: 0
  42. },
  43. list: {
  44. type: Object,
  45. default () {
  46. return {}
  47. }
  48. },
  49. showSelect: {
  50. type: Boolean,
  51. default: false
  52. }
  53. },
  54. data() {
  55. return{
  56. imgUrl: getApp().globalData.imgUrl,
  57. defaultImg:getApp().globalData.imgUrl+ "default/brand.png"
  58. }
  59. },
  60. methods: {
  61. setDefaultImg(item,index){
  62. item.image = this.defaultImg
  63. },
  64. onClick(item) {
  65. },
  66. toGoodsList(brandId){
  67. uni.navigateTo({
  68. url:'/pages/product/list?brandId='+brandId
  69. })
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .uni-indexed-list__list {
  76. background-color: $uni-bg-color;
  77. /* #ifndef APP-NVUE */
  78. display: flex;
  79. /* #endif */
  80. flex-direction: column;
  81. }
  82. .uni-indexed-list__item {
  83. font-size: $uni-font-size-lg;
  84. /* #ifndef APP-NVUE */
  85. display: flex;
  86. /* #endif */
  87. flex: 1;
  88. flex-direction: row;
  89. justify-content: space-between;
  90. align-items: center;
  91. }
  92. .uni-indexed-list__item-container {
  93. padding-left: 30rpx;
  94. flex: 1;
  95. position: relative;
  96. /* #ifndef APP-NVUE */
  97. display: flex;
  98. box-sizing: border-box;
  99. /* #endif */
  100. flex-direction: row;
  101. justify-content: space-between;
  102. align-items: center;
  103. }
  104. .uni-indexed-list__item-border {
  105. flex: 1;
  106. position: relative;
  107. /* #ifndef APP-NVUE */
  108. display: flex;
  109. box-sizing: border-box;
  110. /* #endif */
  111. flex-direction: row;
  112. justify-content: space-between;
  113. align-items: center;
  114. padding-left: 0;
  115. border-bottom-style: solid;
  116. border-bottom-width: 1rpx;
  117. border-bottom-color: rgba(0, 0, 0, .05);
  118. }
  119. .uni-indexed-list__item-border--last {
  120. border-bottom-width: 0px;
  121. }
  122. .uni-indexed-list__item-content {
  123. flex: 1;
  124. font-size: 14px;
  125. }
  126. .uni-indexed-list {
  127. /* #ifndef APP-NVUE */
  128. display: flex;
  129. /* #endif */
  130. flex-direction: row;
  131. }
  132. .uni-indexed-list__title-wrapper {
  133. /* #ifndef APP-NVUE */
  134. display: flex;
  135. width: 100%;
  136. /* #endif */
  137. background-color: #f5f5f5;
  138. height: 36rpx;
  139. line-height: 36rpx;
  140. padding-left: 27rpx;
  141. }
  142. .uni-indexed-list__title {
  143. color: $main-font-color;
  144. font-size: 22rpx;
  145. }
  146. .diy_item {
  147. padding: 20rpx 70rpx 20rpx 0;
  148. .img {
  149. background-size: contain;
  150. background-position: center center;
  151. background-repeat: no-repeat;
  152. width: 80rpx;
  153. height: 80rpx;
  154. overflow: hidden;
  155. background-color: #F3F3F3;
  156. border-radius: 14rpx;
  157. flex-shrink: 0;
  158. }
  159. .detail {
  160. margin-left: 20rpx;
  161. padding-top: 5rpx;
  162. .name {
  163. color: #2D2D2D;
  164. font-size: 30rpx;
  165. line-height: 40rpx;
  166. }
  167. .desc {
  168. color: $main-third-color;
  169. font-size: 22rpx;
  170. line-height: 30rpx;
  171. width: 540rpx;
  172. white-space: nowrap;
  173. text-overflow: ellipsis;
  174. overflow: hidden;
  175. }
  176. }
  177. }
  178. </style>