liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
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
<template>
    <view class="pop_bg"  v-if="Visible" @click="closepop">
        <view :class="Visible ? 'address-distr_open' : 'address-distr_close'">
            <view class="address-list bg-white">
                <view class="tc f36 p20 border-b-d">适用门店</view>
                <view @tap.stop="closepop" class="closeicon"><text class="icon iconfont icon-guanbi"></text></view>
                <scroll-view scroll-y="true" class="specs" style="max-height: 850rpx;">
                    <view  class="address p30 d-s-c border-b-e" v-for="(item,index) in storeList" :key="index">
                        <view class="info flex-1" @click="verify_data.verify_store_force==1 && onSelectedStore(item)">
                            <view class="user f34">
                                <text>{{item.store_name}}</text>
                            </view>
                            <view class="pt10 user f30 gray6">
                                <text>{{item.phone}}</text>
                            </view>
                            <view class="pt10 f24 gray6">
                                <text> {{item.region.province}}{{item.region.city}}{{item.region.region}}{{item.address}}</text>
                            </view>
                            <view>
                                <text class="iconfont icon-dingwei"></text>
                                <text>{{item.distance_unit}}</text>
                            </view>
                        </view>
                        <!-- 选中状态 -->
                        <view v-if="item.store_id == selectedId" class="shop-item__right">
                            <text class="iconfont icon icon-xuanze"></text>
                        </view>
                    </view>
                    
                </scroll-view>    
                <!-- 无数据提供的页面 -->
                <view v-if="!isLoading && !storeList.length">
                    <view class="yoshop-notcont tc pt30">
                        <!-- <text class="icon iconfont icon-pingjiachaping"></text> -->
                        <text class="cont">亲,暂无适用门店哦</text>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>
 
 
<script>
    export default {
        data() {
            return {
                /*数据*/
                listData: [],
                isLoading: true, // 是否正在加载中
                storeList: [], // 门店列表,
                longitude: '',
                latitude: '',
                selectedId: -1,
                Visible:false,
                url: '',
            }
        },
        props: ['isAddress','store_id', 'verify_data'],
        watch:{
            isAddress(val){
                this.Visible=val;
                if(val){
                    //#ifdef H5
                    if(this.isWeixin()){
                        this.url = window.location.href;
                    }
                    //#endif
                    // 记录已选中的id
                    this.selectedId = this.$props.store_id;
                    /*获取地址列表*/
                    this.getData(true);
                    // #ifndef H5
                    this.getLocation();
                    // #endif
                    // #ifdef H5
                    if(!this.isWeixin()){
                        this.getLocation();
                    }
                    // #endif
                }
            }
        },
        methods: {
              /**
               * 授权启用定位权限
               */
              onAuthorize() {
                let self = this;
                uni.openSetting({
                  success(res) {
                    if (res.authSetting["scope.userLocation"]) {
                      console.log('授权成功');
                      self.isAuthor = true;
                      setTimeout(() => {
                        // 获取用户坐标
                        self.getLocation((res) => {
                         
                        });
                      }, 1000);
                    }
                  }
                })
              },
            /**
             * 获取用户坐标
             */
            getLocation(callback) {
                let self = this;
                uni.getLocation({
                    type: 'wgs84',
                    success(res) {
                        self.longitude = res.longitude;
                        self.latitude = res.latitude;
                        self.getData(false);
                    },
                    fail() {
                        uni.showToast({
                            title: '获取定位失败,请点击右下角按钮打开定位权限',
                            duration: 2000,
                            icon:"none"
                        });
                        self.isAuthor=false;
                    },
                })
            },
            /**
             * 公众号获取位置
             */
            getWxLocation(signPackage, callback){
                let self = this;
                var jweixin = require('jweixin-module');
                jweixin.config(JSON.parse(signPackage));
                jweixin.ready(function(res) {
                    jweixin.getLocation({
                        type: 'wgs84', 
                        success: function (res) {
                            self.longitude = res.longitude;
                            self.latitude = res.latitude;
                            self.getData(false);
                        }
                    });
                });
                jweixin.error(function(res){
                    console.log(res);
                });
            },
 
            /*获取数据*/
            getData(isFirst) {
                let self = this;
                self.isLoading = true;
                self._get('store.store/verifyLists', {
                    storeIds: JSON.stringify(self.verify_data.verify_store_ids),
                    longitude: self.longitude,
                    latitude: self.latitude,
                    url: self.url
                }, function(res) {
                    self.isLoading = false;
                    self.storeList = res.data.list;
                    // 第一次,如果是公众号,则初始化微信sdk配置
                    if(isFirst){
                        // #ifdef H5
                        if(self.isWeixin()){
                            self.getWxLocation(res.data.signPackage);
                        }
                        // #endif
                    }
                });
            },
            closepop(){
                this.$emit('close');
            },
            /* 选择门店 */
            onSelectedStore(e) {
                let self = this;
                self.selectedId = e;
                // 设置上级页面的门店id
                self.$fire.fire('selectStoreId',e);    
                this.$emit('close');
            }
        }
    }
</script>
 
<style>
    .pop_bg{
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        background: #66666666;
        z-index: 100;
    }
    .address-list {
        padding-bottom: 90rpx;
    }
 
    .foot-btns {
        padding: 0;
    }
    .closeicon{
        position: absolute;
        right: 20rpx;
        top: 30rpx;
    }
    .foot-btns .btn-red {
        width: 100%;
        height: 90rpx;
        line-height: 90rpx;
        border-radius: 0;
    }
    .address-distr_open{
        /* position: absolute; */
        /* bottom: env(safe-area-inset-bottom); */
        /* left: 0; */
        width: 100%;
        position: fixed;
        bottom: 0;
        display: block;
    }
    .address-distr_close{
        position: absolute;
        bottom: env(safe-area-inset-bottom);
        left: 0;
        width: 100%;
        display: none;
    }
    .icon.icon-guanbi {
        color: #999;
    }
    .shop-item__right .icon-xuanze {
        color: #F6220C;
    }
</style>