liaoxujun@qq.com
2024-03-05 f0ca9fb79a91544c037c55a291be00e8c469bf34
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<template>
    <view>
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <u-navbar :title="storeName" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>
        <view ref="myStore">
            <view class="mst-top">
                <u-swiper :list="storeBanner"></u-swiper>
            </view>
            <view class="mst-bot">
                <view class='coreshop-grid'>
                    <view class='coreshop-item'>
                        <image class='coreshop-item-img' :src='storeLogo'></image>
                    </view>
                    <view class='coreshop-item'>
                        <view class="coreshop-font-xl">{{totalGoods}}</view>
                        <text class='coreshop-item-text'>全部宝贝</text>
                    </view>
                    <!-- #ifdef MP-TOUTIAO -->
                    <view class='coreshop-item' @click="$u.throttle(createPoster, 500)">
                        <u-icon name="star" size="18" labelSize="14" label="分享店铺" labelPos="bottom" space="10"></u-icon>
                    </view>
                    <!-- #endif -->
                    <!-- #ifndef MP-TOUTIAO -->
                    <view class='coreshop-item' @click="openPopup()">
                        <u-icon name="star" size="18" labelSize="14" label="收藏本店" labelPos="bottom" space="10"></u-icon>
                    </view>
                    <!-- #endif -->
                    <!-- #ifndef MP-WEIXIN -->
                    <view class='coreshop-item' @click="$u.throttle(createPoster, 500)">
                        <u-icon name="grid" size="18" labelSize="14" label="二维码" labelPos="bottom" space="10"></u-icon>
                    </view>
                    <!-- #endif -->
                    <!-- #ifdef MP-WEIXIN -->
                    <view class='coreshop-item' @click="$u.throttle(createPoster, 500)">
                        <u-icon name="grid" size="18" labelSize="14" label="二维码" labelPos="bottom" space="10"></u-icon>
                    </view>
                    <!-- #endif -->
                </view>
            </view>
            <view class="coreshop-padding-15 coreshop-margin-bottom-15 coreshop-bg-white coreshop-solid-bottom" @tap="goSearch()">
                <u-search placeholder="请输入关键字搜索" :show-action="true" action-text="搜索" :animation="false"></u-search>
            </view>
            <!-- 收藏弹出窗 -->
            <u-popup mode="top" v-model="lvvpopref">
                <view class="collect-pop">
                    <!-- #ifdef MP-WEIXIN -->
                    <image src="/static/images/distribution/wxxcx.png" mode="widthFix"></image>
                    <!-- #endif -->
                </view>
            </u-popup>
        </view>
        <!-- 商品列表 -->
        <view>
            <view class="coreshop-goods-group" v-if="goodsData.length>0">
                <u-grid col="2" :border="false" align="left">
                    <u-grid-item bg-color="transparent" :custom-style="{padding: '0px'}" v-for="(item, index) in goodsData" :key="index" @click="goGoodsDetail(item.id)">
                        <view class="good_box">
                            <u--image :src="item.image"  mode="widthFix" width="100%" radius="10"></u--image>
                            <view class="good_title u-line-2">
                                {{item.name}}
                            </view>
                            <view class="good-price">
                                {{item.price}}元 <span class="coreshop-font-xs  coreshop-text-through coreshop-margin-left-15 coreshop-text-gray">{{item.mktprice}}元</span>
                            </view>
                            <view class="good-tag-recommend" v-if="item.isRecommend">
                                推荐
                            </view>
                            <view class="good-tag-hot" v-if="item.isHot">
                                热门
                            </view>
                        </view>
                    </u-grid-item>
                </u-grid>
            </view>
            <!-- 无数据时默认显示 -->
            <view class="coreshop-emptybox" v-else>
                <u-empty :icon="$globalConstVars.apiFilesUrl+'/static/images/empty/order.png'" icon-size="150" text="暂无商品列表" mode="list"></u-empty>
            </view>
        </view>
        <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="20" margin-bottom="20" />
    </view>
 
</template>
<script>
    
 
    export default {
        
        data() {
            return {
                goodsData: [],
                status: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                },
                orderItems: [{
                    name: '全部宝贝',
                    nums: '115'
                },
                {
                    name: '收藏本店',
                    icon: '/static/images/ic-me-collect.png',
                },
                {
                    name: '二维码',
                    icon: '/static/images/qr_code.png',
                }
                ],
                storeCode: '',
                storeName: '', //店铺名称
                storeLogo: '',
                store_banner: '',
                storeDesc: '', //店铺介绍
                storeBanner: [],
                totalGoods: 0,
                page: 1, //默认页码
                searchKey: '请输入关键字搜索',
                shareUrl: this.$globalConstVars.shareUrl,
                lvvpopref: false
            }
        },
        onShow: function () {
            if (this.$store.state.config.agentStore == '2') {
                //跳转到首页
                this.$u.route({
                    type: 'switchTab',
                    url: '/pages/index/default/default'
                });
            }
        },
        //加载执行
        onLoad: function (options) {
            let store = options.store;
            this.storeCode = store;
            this.getAgent(store);
            this.getGoods();
        },
        methods: {
            // 显示modal弹出框
            openPopup() {
                this.lvvpopref = true;
            },
            // 关闭modal弹出框
            closePopup() {
                this.lvvpopref = false;
            },
            //去搜索
            goSearch() {
                let pages = getCurrentPages();
                let prevPage = pages[pages.length - 2];
                // #ifdef MP-WEIXIN || APP-PLUS || APP-PLUS-NVUE || MP-TOUTIAO
                if (prevPage && prevPage.route) {
                    let search_flag = prevPage.route;
                    if (search_flag == 'pages/search/search') {
                        uni.navigateBack({
                            delta: 1
                        });
                    } else {
                        this.$u.route('/pages/search/search');
                    }
                } else {
                    this.$u.route('/pages/search/search');
                }
                // #endif
                // #ifdef MP-ALIPAY
                if (prevPage && prevPage.__proto__.route) {
                    let search_flag = prevPage.__proto__.route;
                    if (search_flag == 'pages/search/search') {
                        uni.navigateBack({
                            delta: 1
                        });
                    } else {
                        this.$u.route('/pages/search/search');
                    }
                } else {
                    this.$u.route('/pages/search/search');
                }
                // #endif
            },
 
            //取得商品数据
            getGoods: function () {
                let data = {
                    page: this.page,
                    limit: 10
                }
                this.status = 'loading'
                this.$u.api.getAgentGoodsPageList(data).then(res => {
                    if (res.status) {
                        this.totalGoods = res.data.totalCount;
                        if (this.page >= res.data.totalPages) {
                            // 没有数据了
                            this.status = 'nomore'
                        } else {
                            // 未加载完毕
                            this.status = 'loadmore'
                            this.page++
                        }
                        this.goodsData = [...this.goodsData, ...res.data.list]
                    } else {
                        this.$u.toast(res.msg)
                    }
                });
            },
            //获取经销商信息
            getAgent: function (store) {
                let _this = this;
                _this.$u.api.getAgentStoreInfo({
                    id: store
                }).then(res => {
                    if (res.status) {
                        _this.storeName = res.data.storeName ? res.data.storeName : "我的店铺";
                        _this.storeDesc = res.data.storeDesc;
                        _this.storeLogo = res.data.storeLogo ? res.data.storeLogo : '/static/images/common/empty.png';
 
                        if (res.data.storeBanner) {
                            _this.storeBanner = res.data.storeBanner.split(',');
                        } else {
                            _this.storeBanner.push('/static/images/common/empty-banner.png');
                        }
 
                        //_this.totalGoods = res.data.totalGoods;
                        uni.setNavigationBarTitle({
                            title: _this.storeName
                        });
                    } else {
                        //报错了
                        _this.$u.toast(res.msg);
                    }
                });
            },
            // 生成邀请海报
            createPoster() {
                let data = {
                    client: this.$globalConstVars.shareClient.wxMiNiProgram,
                    url: this.$globalConstVars.shareUrl,
                    type: this.$globalConstVars.shareModel.poster,
                    page: this.$globalConstVars.shareType.agent,
                    params: {
                        store: this.storeCode
                    },
                    
                }
                let userToken = this.$db.get('userToken')
                if (userToken && userToken != '') {
                    data.token = userToken
                }
                this.$u.api.share(data).then(res => {
                    if (res.status) {
                        data.params.posterUrl = res.data;
                        data.params.shareType = this.$globalConstVars.shareType.agent;
                        this.$u.route('/pages/share/shareNewPoster/shareNewPoster' + uni.$u.queryParams(data.params))
                    } else {
                        this.$u.toast(res.msg)
                    }
                })
            },
            //获取分享URL
            getShareUrl() {
                let data = {
                    client: this.$globalConstVars.shareClient.wxMiNiProgram,
                    url: this.$globalConstVars.shareUrl,
                    type: this.$globalConstVars.shareModel.url,
                    page: this.$globalConstVars.shareType.agent,
                    params: {
                        store: this.storeCode
                    }
                };
                let userToken = this.$db.get('userToken');
                if (userToken && userToken != '') {
                    data.token = userToken
                }
                this.$u.api.share(data).then(res => {
                    this.shareUrl = res.data
                });
            }
        },
        watch: {
            storeCode: {
                handler() {
                    this.getShareUrl();
                },
                deep: true
            }
        },
        //上拉加载
        onReachBottom() {
            if (this.status === 'loadmore') {
                this.getGoods();
            }
        },
        //分享
        onShareAppMessage(res) {
            return {
                title: this.storeName ? this.storeName : this.$store.state.config.shareTitle,
                imageUrl: this.storeLogo ? this.storeLogo : this.$store.state.config.shareImage,
                path: this.shareUrl
            }
        },
        onShareTimeline(res) {
            return {
                title: this.storeName ? this.storeName : this.$store.state.config.shareTitle,
                imageUrl: this.storeLogo ? this.storeLogo : this.$store.state.config.shareImage,
                path: this.shareUrl
            }
        },
    }
</script>
<style lang="scss" scoped>
    @import "myStore.scss";
</style>