index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <page-loading :loading="loading">
  3. <view class="product-page">
  4. <view class="logo logo-black" />
  5. <u-search
  6. v-model="keywords"
  7. placeholder="搜索产品"
  8. :show-action="false"
  9. shape="square"
  10. bg-color="#fff"
  11. border-color="#ccc"
  12. height="84rpx"
  13. @search="handleSearch"
  14. />
  15. <view
  16. class="product-list dir-left-wrap"
  17. >
  18. <view
  19. v-for="(item,index) in lists"
  20. :key="index"
  21. class="product-item main-left"
  22. @click="$u.route({url: `/pages/product/detail?id=${item.id}`})"
  23. >
  24. <view class="detail dir-top-wrap">
  25. <text>热销品类排名</text>
  26. <view class="name"> {{ item.name }}</view>
  27. </view>
  28. <view class="cover-img">
  29. <image :src="item.cover_img" mode="aspectFill" />
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </page-loading>
  35. </template>
  36. <script>
  37. import PageLoading from '../../components/PageLoading'
  38. export default {
  39. name: 'Product',
  40. components: { PageLoading },
  41. data() {
  42. return {
  43. loading: false,
  44. keywords: '',
  45. limit: 3,
  46. lists: []
  47. }
  48. },
  49. computed: {},
  50. methods: {
  51. handleSearch() {
  52. this.$u.route({ url: `/pages/product/list?keywords=${this.keywords}` })
  53. },
  54. getLists() {
  55. this.$api.product.search({
  56. limit: this.limit,
  57. page: this.page
  58. }).then(res => {
  59. this.loading = false
  60. this.lists = res.data
  61. })
  62. }
  63. },
  64. onLoad() {
  65. this.loading = true
  66. this.getLists()
  67. },
  68. onShow() {
  69. this.getLists()
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .product-page {
  75. padding: 0 30rpx;
  76. overflow: hidden;
  77. height: 100vh;
  78. .logo{
  79. margin: 30rpx auto;
  80. }
  81. .product-list{
  82. margin-top: 40rpx;
  83. .product-item{
  84. width: 690rpx;
  85. margin-bottom: 10rpx;
  86. &:last-child{
  87. margin-bottom: 0;
  88. }
  89. .detail{
  90. padding: 50rpx 0 20rpx 50rpx;
  91. font-size: 24rpx;
  92. color: #333333;
  93. background: #F2F2F2;
  94. flex: 1;
  95. text{
  96. color: #b4936d;
  97. }
  98. .name{
  99. margin-top: 16rpx;
  100. font-size: 42rpx;
  101. }
  102. }
  103. .cover-img{
  104. width: 355rpx;
  105. height: 250rpx;
  106. image{
  107. width: 100%;
  108. height: 100%;
  109. }
  110. }
  111. }
  112. }
  113. }
  114. </style>