123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <template>
- <div class="goods-list-container">
- <vab-query-form>
- <vab-query-form-right-panel :span="24">
- <el-form
- ref="form"
- :model="queryForm"
- :inline="true"
- @submit.native.prevent
- >
- <el-form-item>
- <el-input v-model="queryForm.title" placeholder="商品名称" />
- </el-form-item>
- <el-form-item>
- <el-button
- icon="el-icon-search"
- type="primary"
- native-type="submit"
- @click="handleQuery"
- >
- 查询
- </el-button>
- </el-form-item>
- </el-form>
- </vab-query-form-right-panel>
- </vab-query-form>
- <el-row :gutter="20">
- <el-col
- v-for="(item, index) in list"
- :key="index"
- :xs="24"
- :sm="8"
- :md="8"
- :lg="8"
- :xl="6"
- >
- <el-card :body-style="{ padding: '0px' }" shadow="hover">
- <div class="goods-list-card-body">
- <div class="goods-list-tag-group">
- <el-tag v-if="item.isRecommend" hit type="success">推荐</el-tag>
- <el-tag v-if="item.status === 0" hit type="danger">缺货</el-tag>
- </div>
- <div class="goods-list-image-group">
- <img :src="item.image" class="goods-list-image" />
- </div>
- <div class="goods-list-title">{{ item.title }}</div>
- <div class="goods-list-description">{{ item.description }}</div>
- <div class="goods-list-price">
- <span>¥ {{ item.price }} 元</span>
- </div>
- </div>
- </el-card>
- </el-col>
- </el-row>
- <el-pagination
- background
- :current-page="queryForm.pageNo"
- :layout="layout"
- :page-size="queryForm.pageSize"
- :total="total"
- @current-change="handleCurrentChange"
- @size-change="handleSizeChange"
- ></el-pagination>
- </div>
- </template>
- <script>
- import { getList } from "@/api/goodsList";
- export default {
- name: "Goods",
- components: {},
- data() {
- return {
- queryForm: {
- pageNo: 1,
- pageSize: 20,
- title: "",
- },
- list: null,
- listLoading: true,
- layout: "total, sizes, prev, pager, next, jumper",
- total: 0,
- elementLoadingText: "正在加载...",
- };
- },
- created() {
- this.fetchData();
- },
- methods: {
- handleSizeChange(val) {
- this.queryForm.pageSize = val;
- this.fetchData();
- },
- handleCurrentChange(val) {
- this.queryForm.pageNo = val;
- this.fetchData();
- },
- handleQuery() {
- this.queryForm.pageNo = 1;
- this.fetchData();
- },
- async fetchData() {
- this.listLoading = true;
- const { data, totalCount } = await getList(this.queryForm);
- this.list = data;
- this.total = totalCount;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .goods-list-container {
- .goods-list-card-body {
- position: relative;
- text-align: center;
- cursor: pointer;
- .goods-list-tag-group {
- position: absolute;
- top: 10px;
- right: 5px;
- z-index: 9;
- }
- .goods-list-image-group {
- height: 400px;
- overflow: hidden;
- .goods-list-image {
- width: 100%;
- height: 400px;
- transition: all ease-in-out 0.3s;
- &:hover {
- transform: scale(1.1);
- }
- }
- }
- .goods-list-title {
- margin: 8px 0;
- font-size: 16px;
- font-weight: bold;
- }
- .goods-list-description {
- font-size: 14px;
- color: #808695;
- }
- .goods-list-price {
- margin: 8px 0;
- font-size: 14px;
- color: $base-color-orange;
- s {
- color: #c5c8ce;
- }
- }
- }
- }
- </style>
|