index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="goods-list-container">
  3. <vab-query-form>
  4. <vab-query-form-right-panel :span="24">
  5. <el-form
  6. ref="form"
  7. :model="queryForm"
  8. :inline="true"
  9. @submit.native.prevent
  10. >
  11. <el-form-item>
  12. <el-input v-model="queryForm.title" placeholder="商品名称" />
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button
  16. icon="el-icon-search"
  17. type="primary"
  18. native-type="submit"
  19. @click="handleQuery"
  20. >
  21. 查询
  22. </el-button>
  23. </el-form-item>
  24. </el-form>
  25. </vab-query-form-right-panel>
  26. </vab-query-form>
  27. <el-row :gutter="20">
  28. <el-col
  29. v-for="(item, index) in list"
  30. :key="index"
  31. :xs="24"
  32. :sm="8"
  33. :md="8"
  34. :lg="8"
  35. :xl="6"
  36. >
  37. <el-card :body-style="{ padding: '0px' }" shadow="hover">
  38. <div class="goods-list-card-body">
  39. <div class="goods-list-tag-group">
  40. <el-tag v-if="item.isRecommend" hit type="success">推荐</el-tag>
  41. <el-tag v-if="item.status === 0" hit type="danger">缺货</el-tag>
  42. </div>
  43. <div class="goods-list-image-group">
  44. <img :src="item.image" class="goods-list-image" />
  45. </div>
  46. <div class="goods-list-title">{{ item.title }}</div>
  47. <div class="goods-list-description">{{ item.description }}</div>
  48. <div class="goods-list-price">
  49. <span>¥ {{ item.price }}</span>
  50. </div>
  51. </div>
  52. </el-card>
  53. </el-col>
  54. </el-row>
  55. <el-pagination
  56. background
  57. :current-page="queryForm.pageNo"
  58. :layout="layout"
  59. :page-size="queryForm.pageSize"
  60. :total="total"
  61. @current-change="handleCurrentChange"
  62. @size-change="handleSizeChange"
  63. ></el-pagination>
  64. </div>
  65. </template>
  66. <script>
  67. import { getList } from "@/api/goodsList";
  68. export default {
  69. name: "Goods",
  70. components: {},
  71. data() {
  72. return {
  73. queryForm: {
  74. pageNo: 1,
  75. pageSize: 20,
  76. title: "",
  77. },
  78. list: null,
  79. listLoading: true,
  80. layout: "total, sizes, prev, pager, next, jumper",
  81. total: 0,
  82. elementLoadingText: "正在加载...",
  83. };
  84. },
  85. created() {
  86. this.fetchData();
  87. },
  88. methods: {
  89. handleSizeChange(val) {
  90. this.queryForm.pageSize = val;
  91. this.fetchData();
  92. },
  93. handleCurrentChange(val) {
  94. this.queryForm.pageNo = val;
  95. this.fetchData();
  96. },
  97. handleQuery() {
  98. this.queryForm.pageNo = 1;
  99. this.fetchData();
  100. },
  101. async fetchData() {
  102. this.listLoading = true;
  103. const { data, totalCount } = await getList(this.queryForm);
  104. this.list = data;
  105. this.total = totalCount;
  106. },
  107. },
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. .goods-list-container {
  112. .goods-list-card-body {
  113. position: relative;
  114. text-align: center;
  115. cursor: pointer;
  116. .goods-list-tag-group {
  117. position: absolute;
  118. top: 10px;
  119. right: 5px;
  120. z-index: 9;
  121. }
  122. .goods-list-image-group {
  123. height: 400px;
  124. overflow: hidden;
  125. .goods-list-image {
  126. width: 100%;
  127. height: 400px;
  128. transition: all ease-in-out 0.3s;
  129. &:hover {
  130. transform: scale(1.1);
  131. }
  132. }
  133. }
  134. .goods-list-title {
  135. margin: 8px 0;
  136. font-size: 16px;
  137. font-weight: bold;
  138. }
  139. .goods-list-description {
  140. font-size: 14px;
  141. color: #808695;
  142. }
  143. .goods-list-price {
  144. margin: 8px 0;
  145. font-size: 14px;
  146. color: $base-color-orange;
  147. s {
  148. color: #c5c8ce;
  149. }
  150. }
  151. }
  152. }
  153. </style>