MrShi
11 小时以前 742e2a6eb5d0c6c348ae779a8bc8eaa79c958b4f
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<template>
    <view class="box">
        <view class="search">
            <u-search placeholder="请输入商品名称搜索" height="36" searchIconColor="#999999" borderColor="#EEEEEE"
                bgColor="#F9F9FB" :showAction="false" v-model="goodsName" @search="search" />
        </view>
        <view class="history">
            <view class="history-title">历史搜索</view>
            <view class="history-list">
                <view class="history-list-item">支重轮</view>
            </view>
        </view>
        <template v-if="isSearch">
            <view class="list">
                <image class="list-notfund" v-if="goodsList.length === 0" src="/static/images/default_search@2x.png" mode="widthFix"></image>
                <view class="commodity-item" v-for="(item, i) in goodsList" :key="i" v-else>
                    <view class="commodity-item-image">
                        <image :src="item.imgurl" mode="widthFix"></image>
                    </view>
                    <view class="commodity-item-box">
                        <view class="commodity-item-box-title">
                            {{item.name}}
                        </view>
                        <view class="commodity-item-box-price">
                            <view class="commodity-item-box-price-a">
                                <text>{{item.minPrice[0]}}</text>
                                <text>.{{item.minPrice[1]}}</text>
                            </view>
                            <view class="commodity-item-box-price-b">
                                ¥{{item.price}}
                            </view>
                        </view>
                        <view class="commodity-item-shou">
                            <text>已售{{item.saleNum + item.realSaleNum}}</text>
                            <view class="commodity-item-shou-add">+</view>
                        </view>
                    </view>
                </view>
            </view>
        </template>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                goodsName: '',
                goodsList: [],
                page: 1,
                next: true,
                isSearch: false
            };
        },
        onReachBottom() {
            this.getGoodsList()
        },
        methods: {
            search() {
                if (!this.isSearch) {
                    this.isSearch = true
                }
                this.next = true
                this.page = 1
                this.goodsList = []
                this.getGoodsList()
            },
            getGoodsList() {
                if (!this.next) return;
                this.$u.api.goodsPage({
                    capacity: 10,
                    page: this.page,
                    model: {
                        type: 0,
                        sortInfo: 3,
                        goodsName: this.goodsName
                    }
                }).then(res => {
                    if (res.code === 200) {
                        res.data.records.forEach(item => {
                            item.minPrice = item.minPrice.toFixed(2).split('.')
                        })
                        this.goodsList.push(...res.data.records)
                        this.page++
                        if (this.goodsList.length === res.data.total) {
                            this.next = false
                        }
                    }
                })
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    .box {
        width: 100%;
        .search {
            width: 100%;
            padding: 30rpx;
            box-sizing: border-box;
            background-color: #ffffff;
            position: sticky;
            top: 0;
            left: 0;
            z-index: 999;
            margin-bottom: 14rpx;
        }
        .history {
            width: 100%;
            padding: 0 30rpx;
            box-sizing: border-box;
            .history-title {
                font-weight: 500;
                font-size: 30rpx;
                color: #111111;
            }
            .history-list {
                width: 100%;
                margin-top: 26rpx;
                display: flex;
                align-items: center;
                flex-wrap: wrap;
                .history-list-item {
                    padding: 0 28rpx;
                    height: 66rpx;
                    line-height: 66rpx;
                    background: #F7F7F7;
                    border-radius: 34rpx;
                    font-weight: 400;
                    font-size: 26rpx;
                    color: #111111;
                    margin-right: 24rpx;
                    margin-bottom: 24rpx;
                    &:last-child {
                        margin: 0 !important;
                    }
                }
            }
        }
        .list {
            width: 100%;
            padding: 20rpx 30rpx;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            
            .list-notfund {
                width: 320rpx;
                height: 320rpx;
                margin: 0 auto;
                margin-top: 240rpx;
            }
            
            .commodity-item {
                width: 332rpx;
                background-color: #ffffff;
                margin-bottom: 20rpx;
                .commodity-item-image {
                    width: 100%;
                    height: 336rpx;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    image {
                        width: 100%;
                    }
                }
                .commodity-item-box {
                    width: 100%;
                    padding: 20rpx;
                    box-sizing: border-box;
                    .commodity-item-box-title {
                        font-weight: 600;
                        font-size: 30rpx;
                        color: #222222;
                    }
                    .commodity-item-box-price {
                        width: 100%;
                        display: flex;
                        align-items: baseline;
                        margin-top: 8rpx;
                        .commodity-item-box-price-a {
                            display: flex;
                            align-items: baseline;
                            margin-right: 8rpx;
                            text {
                                &:nth-child(1) {
                                    font-weight: bold;
                                    font-size: 32rpx;
                                    color: #E4001D;
                                    &::before {
                                        content: '¥';
                                        font-weight: 400;
                                        font-size: 24rpx;
                                        color: #E4001D;
                                    }
                                }
                                &:nth-child(2) {
                                    font-weight: 400;
                                    font-size: 24rpx;
                                    color: #E4001D;
                                }
                            }
                        }
                        .commodity-item-box-price-b {
                            font-weight: 400;
                            font-size: 22rpx;
                            color: #999999;
                        }
                    }
                    .commodity-item-shou {
                        width: 100%;
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
                        text {
                            font-weight: 400;
                            font-size: 24rpx;
                            color: #999999;
                        }
                        .commodity-item-shou-add {
                            width: 44rpx;
                            height: 44rpx;
                            background: #004096;
                            border-radius: 50%;
                            line-height: 44rpx;
                            text-align: center;
                            font-size: 30rpx;
                            color: #fff;
                        }
                    }
                }
            }
        }
    }
</style>