移动系统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
<!-- 门店列表 -->
<template>
    <view>
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <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>
        <label v-for="store in storeList" :key="store.id" @tap="selStore(store.id)">
            <view class="store-item coreshop-flex coreshop-justify-between">
                <view class="coreshop-flex coreshop-align-center">
                    <view class="img-box"><image class="store-img" :src="store.logoImage" mode="aspectFill" lazy-load></image></view>
                    <view class="item-left coreshop-flex coreshop-flex-direction coreshop-align-start">
                        <text class="store-title">{{ store.storeName }}</text>
                        <text class="store-content">{{ store.address }}</text>
                    </view>
                </view>
 
                <radio style="transform: scale(0.7);" class="orange" :checked="storeId == store.id" :class="{ checked: storeId == store.id }"></radio>
            </view>
        </label>
 
        <view class="coreshop-bg-white coreshop-card-hight-box" />
 
        <!--底部-->
        <view class="coreshop-foot-hight-view" />
        <view class="coreshop-bottomBox">
            <button class="coreshop-btn coreshop-btn-square coreshop-btn-w" @click="saveAllStore" v-if="isShopManager">查看所有数据</button>
            <button class="coreshop-btn coreshop-btn-square coreshop-btn-b" @click="saveStore">选择门店数据</button>
        </view>
 
    </view>
</template>
 
<script>
    export default {
        components: {},
        data() {
            return {
                storeList: [],
                storeId: 0,
                isShopManager: false
            };
        },
        computed: {},
        onLoad() {
            this.getStoreAddress();
            //判断是否是店员
            this.$u.api.isStoreUser().then(res => {
                this.isShopManager = res.data.isShopManager
            })
        },
        methods: {
            // 选择门店
            selStore(id) {
                this.storeId = id;
            },
            // 确认门店
            saveStore() {
                if (this.storeId == 0) {
                    this.$u.toast("请选择门店")
                    return false;
                }
                this.$u.route('/pages/member/merchant/index/index', {
                    storeId: this.storeId,
                    isShopManager: this.isShopManager,
                });
            },
            // 确认门店
            saveAllStore() {
                this.$u.route('/pages/member/merchant/index/index', {
                    storeId: this.storeId,
                    isShopManager: this.isShopManager,
                });
            },
            //获取门店列表
            getStoreAddress() {
                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.getStoreListForUser(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;
                        //console.log('当前位置的经度2:' + res);
                    },
                    fail: function () {
                        _this.latitude = 0;
                        _this.longitude = 0;
                        _this.$u.toast("获取您的经纬度坐标失败")
                    },
                    complete: function (res) {
                        let data = {
                            'key': _this.key,
                            'longitude': _this.longitude,
                            'latitude': _this.latitude,
                            'page': _this.page,
                            'limit': _this.limit,
                        }
                        _this.$u.api.getStoreListForUser(data).then(e => {
                            if (e.status) {
                                console.log(e);
                                _this.storeList = [..._this.storeList, ...e.data]
                            } else {
                                _this.$u.toast("门店数据获取失败。");
                            }
                        });
                    }
                });
                // #endif
            },
        }
    };
</script>
 
 
<style lang="scss" scoped>
    @import "storeList.scss";
</style>