index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view>
  3. <view v-if="showTitle" style="padding: 6px 0 6px 0; color: #333; font-size: 16px; display: flex; align-items: center">
  4. <view style="width: 4px; height: 20px; background: linear-gradient(to bottom, #f89c33, #f86834); margin-right: 4px" />
  5. {{ title }}
  6. </view>
  7. <view class="list">
  8. <view v-for="(item, index) in lists" :key="index" class="list-item" @click="_handleClick(item.url)">
  9. <view class="content">
  10. <image v-if="iconShow" class="icon" :src="item.image" :alt="item.image" />
  11. <view class="title">{{ item.text }}</view>
  12. </view>
  13. <view>{{ '>' }}</view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script setup>
  19. defineProps({
  20. lists: {
  21. type: Array,
  22. default: () => [],
  23. },
  24. iconShow: {
  25. type: Boolean,
  26. default: true,
  27. },
  28. showTitle: {
  29. type: Boolean,
  30. default: true,
  31. },
  32. title: {
  33. type: String,
  34. default: '',
  35. },
  36. });
  37. const _handleClick = (url) => {
  38. if (url) {
  39. uni.navigateTo({
  40. url,
  41. fail: (err) => {
  42. uni.switchTab({
  43. url,
  44. });
  45. },
  46. });
  47. }
  48. };
  49. </script>
  50. <style lang="less" scoped>
  51. .list {
  52. width: 100%;
  53. box-sizing: border-box;
  54. border-radius: 8px;
  55. .list-item {
  56. display: flex;
  57. justify-content: space-between;
  58. align-items: center;
  59. padding: 16px;
  60. background: #fff;
  61. cursor: pointer;
  62. border-bottom: 1px solid #f2f2f2;
  63. &:first-child {
  64. border-radius: 8px 8px 0 0;
  65. }
  66. &:last-child {
  67. border-radius: 0 0 8px 8px;
  68. }
  69. .content {
  70. display: flex;
  71. align-items: center;
  72. .icon {
  73. width: 48rpx;
  74. height: 48rpx;
  75. margin-right: 12px;
  76. border-radius: 8px;
  77. }
  78. .title {
  79. font-size: 16px;
  80. color: #333;
  81. }
  82. }
  83. .arrow {
  84. color: #999;
  85. }
  86. }
  87. }
  88. </style>