绿满眶商城微信小程序-uniapp
xiangpei
6 天以前 70738d032bd80f5b13075f8a13045ff4de57c2c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
    <div>
        <u-navbar :title="title"></u-navbar>
        <!-- 商品 -->
        <div class="contant">
            <view  v-if="!goodsList.length" class="empty">暂无商品信息</view>
            <goodsTemplate  style="width: 100%;" :res='goodsList' :storeName='false' />
        </div>
    </div>
 
</template>
 
<script>
    import '@/components/uview-components/uview-ui'
    import {
        getGoodsList
    } from "@/api/goods.js";
    import goodsTemplate from '@/components/m-goods-list/list'
    export default {
        data() {
            return {
                title: "",
                routerVal: "",
                goodsList: [],
                params: {
                    pageNumber: 1,
                    pageSize: 10,
                    keyword: "",
                    storeCatId: "",
                    storeId: "",
                },
            };
        },
        components: {
            goodsTemplate
        },
        onLoad(options) {
            this.routerVal = options;
            this.params.storeId = options.storeId;
            this.params.storeCatId = options.id;
            this.title = options.title;
        },
        onShow() {
            this.goodsList = []
            this.params.pageNumber = 1;
            this.getGoodsData();
        },
        onReachBottom() {
            this.params.pageNumber++;
            this.getGoodsData();
        },
        methods: {
            async getGoodsData() {
                // #TODO
                let goodsList = await getGoodsList(this.params);
                if (goodsList.data.success) {
                    this.goodsList.push(...goodsList.data.result.records);
                }
            },
        },
    };
</script>
 
<style lang="scss" scoped>
    .contant {
        margin-top: 20rpx;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
 
        >.empty {
            width: 100%;
            display: flex;
            justify-content: center;
            margin-top: 40rpx;
        }
}
</style>