移动系统liao
2025-02-17 557c2711a3e103ebc3d0492344eca9730d5e92b2
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
<template>
    <view>
        <u-navbar title="门店列表" 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 class="content">
            <view class="coreshop-padding-15 coreshop-bg-white coreshop-solid-bottom">
                <u-search placeholder="请输入门店名" v-model="key" :show-action="true" action-text="搜索" :animation="false" @clear="clear" @search="storeSearch" @custom="storeSearch"></u-search>
            </view>
            <view v-if="storeList.length>0">
                <view class="coreshop-list menu-avatar" v-for="(item, key) in storeList" :key="key" @click="selectStore(item.id, item.storeName, item.mobile, item.address)">
                    <view class="coreshop-list-item  coreshop-padding-top-10  coreshop-padding-bottom-10">
                        <view class="coreshop-avatar lg radius" :style="[{backgroundImage:'url('+ item.logoImage +')'}]" />
                        <view class="content">
                            <view class="coreshop-text-grey">{{item.storeName|| ''}}</view>
                            <view class="coreshop-text-gray coreshop-font-sm">
                                <view class="u-line-1">
                                    电话:{{item.mobile|| ''}}
                                </view>
                            </view>
                            <view class="coreshop-text-gray coreshop-font-sm">
                                <view class="u-line-2">
                                    地址:{{item.address|| ''}}
                                </view>
                            </view>
                        </view>
                        <view class="action">
                            <view class="coreshop-text-grey coreshop-font-xs coreshop-margin-bottom-10">{{item.distanceStr|| ''}}</view>
                            <u-button type="success" size="mini">选择</u-button>
                        </view>
                    </view>
                </view>
            </view>
            <!-- 无数据时默认显示 -->
            <view class="coreshop-emptybox" v-else>
                <u-empty :icon="$globalConstVars.apiFilesUrl+'/static/images/empty/history.png'" icon-size="150" text="暂无门店列表" mode="list"></u-empty>
            </view>
        </view>
 
        <!-- 登录提示 -->
        <coreshop-login-modal></coreshop-login-modal>
    </view>
 
</template>
 
<script>
    export default {
        data() {
            return {
                storeList: [],
                key: '',
                longitude: '',
                latitude: '',
                page: 1,
                limit: 30,
            }
        },
        onLoad() {
            this.getStoreList();
        },
        methods: {
            //门店搜索
            storeSearch() {
                console.log('storeSearch');
                this.page = 1;
                this.limit = 30;
                this.storeList = [];
                this.getStoreList();
            },
            clear() {
                console.log('clear');
                this.page = 1;
                this.limit = 30;
                this.storeList = [];
                this.getStoreList();
            },
            //获取门店列表
            getStoreList() {
                let _this = this;
                // #ifdef MP-WEIXIN
                wx.getFuzzyLocation({
                    type: 'wgs84',
                    success(res) {
                        _this.latitude = res.latitude
                        _this.longitude = res.longitude
                        console.log('当前位置的经度1:' + res);
                    },
                    fail: function () {
                        _this.$u.toast("获取您的经纬度坐标失败")
                    },
                    complete: function (res) {
                        if (!_this.longitude || !_this.latitude) {
                            _this.longitude = '0';
                            _this.latitude = '0';
                        }
                        let data = {
                            'key': _this.key,
                            'longitude': _this.longitude,
                            'latitude': _this.latitude,
                            'page': _this.page,
                            'limit': _this.limit,
                        }
                        _this.$u.api.storeList(data).then(e => {
                            if (e.status) {
                                console.log(e);
                                _this.storeList = [..._this.storeList, ...e.data]
                            } else {
                                _this.$u.toast("门店数据获取失败。");
                            }
                        });
                    }
                })
                // #endif
                // #ifndef MP-WEIXIN
                uni.getLocation({
                    type: 'wgs84',
                    success: function (res) {
                        _this.longitude = res.longitude;
                        _this.latitude = res.latitude;
                    },
                    fail: function () {
                        _this.$u.toast("获取您的经纬度坐标失败")
                    },
                    complete: function (res) {
                        if (!_this.longitude || !_this.latitude) {
                            _this.longitude = '0';
                            _this.latitude = '0';
                        }
                        let data = {
                            'key': _this.key,
                            'longitude': _this.longitude,
                            'latitude': _this.latitude,
                            'page': _this.page,
                            'limit': _this.limit,
                        }
                        _this.$u.api.storeList(data).then(e => {
                            if (e.status) {
                                console.log(e);
                                _this.storeList = [..._this.storeList, ...e.data]
                            } else {
                                _this.$u.toast("门店数据获取失败。");
                            }
                        });
                    }
                });
                // #endif
            },
            //门店选择
            selectStore(id, name, mobile, address) {
                let pages = getCurrentPages()
                let pre = pages[pages.length - 2]
                let store = {};
                store['id'] = id;
                store['name'] = name;
                store['mobile'] = mobile;
                store['address'] = address;
 
                // #ifdef MP-ALIPAY || MP-TOUTIAO
                this.$db.set('userStore', store, true);
                // #endif
 
                // #ifdef MP-WEIXIN
                pre.$vm.store = store
                // #endif
 
                // #ifdef APP-PLUS || APP-PLUS-NVUE
                pre.$vm.store = store
                // #endif
 
                uni.navigateBack({
                    delta: 1
                });
            }
        }
    }
</script>
 
<style lang="scss">
    @import "storeList.scss";
</style>