doum
2025-08-21 b830b6a25e8aa0d2ee285d4efd5c12504a3f36a7
前端
已修改3个文件
109 ■■■■■ 文件已修改
small-program/App.vue 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
small-program/pages/index/index.vue 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
small-program/store/index.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
small-program/App.vue
@@ -1,11 +1,13 @@
<script>
    import { mapState } from 'vuex'
    var QQMapWX = require('@/utils/qqmap-wx-jssdk.js')
    export default {
        computed: {
            ...mapState(['userInfo','openid'])
        },
        onLaunch: function() {  
            var that = this;
            that.getLocaltionBiz()
            if (!this.openid || this.openid =='') {
                uni.login({
                    provider: 'weixin',
@@ -16,17 +18,6 @@
                            that.$store.commit('setToken', res.data.token)
                            that.$store.commit('setOpenid', res.data.openid)
                            that.$store.commit('setUserInfo', res.data.member)
                            uni.getLocation({
                                type: 'wgs84',
                                success: (addr) => {
                                    that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
                                    that.$isResolve()
                                },
                                fail: (err) => {
                                    console.error('获取位置失败', err);
                                    that.$isResolve()
                                }
                            });
                            
                        }
                    }
@@ -36,31 +27,9 @@
                let res = this.$u.api.getMemberInfo({}).then(res =>{ 
                    if (res && res.code === 200) { 
                        that.$store.commit('setUserInfo', res.data)
                        uni.getLocation({
                            type: 'wgs84',
                            success: (addr) => {
                                that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
                                that.$isResolve()
                            },
                            fail: (err) => {
                                console.error('获取位置失败', err);
                                that.$isResolve()
                            }
                        });
                    } else {
                        that.$store.commit('setToken','')
                        that.$store.commit('setUserInfo',{})
                        uni.getLocation({
                            type: 'wgs84',
                            success: (addr) => {
                                that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
                                that.$isResolve()
                            },
                            fail: (err) => {
                                console.error('获取位置失败', err);
                                that.$isResolve()
                            }
                        });
                    }
                })
            }
@@ -70,6 +39,51 @@
        },
        onHide: function() {
            console.log('App Hide')
        },
        methods:{
            getLocaltionBiz(){
                var that =this
                uni.getLocation({
                    type: 'wgs84',
                    success: (addr) => {
                        const locParam = { latitude: addr.latitude, longitude: addr.longitude ,address:'获取地址失败'};
                        var address =null
                        const qqmapsdk = new QQMapWX({
                             key: '4PXBZ-JLBC7-LCLXG-P2SZX-C4HYE-LDBLQ' //腾讯地图申请的key(后续需要公司提供,个人开发者额度有限)
                         });
                          // 腾讯地图逆地理编码
                        qqmapsdk.reverseGeocoder({
                            locParam,
                            success: function(res) {
                                console.log(res, '==================获取地址');
                                let info = res.result;
                                locParam.province = info.address_component.province;
                                locParam.city = info.address_component.city;
                                locParam.area = info.address_component.district;
                                locParam.street = info.address_component.street;
                                var ta = info.address  || '地址获取失败' ;
                                if(info.formatted_addresses  && info.formatted_addresses.recommend){
                                    ta =info.formatted_addresses.recommend
                                }
                                locParam.address =ta
                                that.$store.commit('setPosition',locParam)
                                that.$isResolve()
                            },
                            fail: (err) => {
                                console.error('获取位置失败===========', err);
                                that.$store.commit('setPosition',locParam)
                                that.$isResolve()
                            }
                        });
                        // that.$store.commit('setPosition',locParam)
                        that.$isResolve()
                    },
                    fail: (err) => {
                        console.error('获取位置失败', err);
                        that.$isResolve()
                    }
                });
            }
        }
    }
</script>
small-program/pages/index/index.vue
@@ -83,10 +83,10 @@
        <!-- 发单方 -->
        <view class="index-c" v-if="typeViewId === 0">
            <view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
            <view class="index-c-title" :style="{ height: navHeight + 'px' }" @click="selectAddress">
            <view class="index-c-title" :style="{ height: navHeight + 'px' }" @click="selectAddress(-1)">
                <text class="index-c-title-logo">近快</text>
                <image class="dingwei" src="/static/icon/home_ic_location@2x.png" mode="widthFix"></image>
                <text>西湖国际广场</text>
                <text>{{location.address || address || '获取地址失败'}}</text>
                <image class="qu" src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
            </view>
            
@@ -322,10 +322,6 @@
                     <view></view>
                     <text>{{item}}</text> 
                 </view> 
                 <view class="phone-item" v-for="(item,index) in serverPhone"    :key="item" @click="contactPhoneDo(item)">
                     <view></view>
                     <text>{{item}}</text>
                 </view>
                <!-- <view class="phone-botton"  @click="contactPhone()" >关闭</view> -->
            </view>
        </u-popup>
@@ -339,7 +335,7 @@
    export default {
        components: { sunuiMverify },
        computed: {
            ...mapState(['navHeight', 'statusbarHeight','userInfo','token','openid', 'latitude', 'longitude']),
            ...mapState(['navHeight', 'statusbarHeight','userInfo','token','openid', 'latitude', 'longitude','address']),
            totalPrice() {
                return this.form.estimatedAccount / 100
            }
@@ -352,6 +348,11 @@
                isLogin: false,
                typeId: 0,
                qqmapsdk: null,
                location:{
                    latitude:null,
                    longitude:null,
                    address:null,
                },
                type: [
                    { name: '用工', id: 0 },
                    { name: '运货', id: 1 },
@@ -715,6 +716,11 @@
                            this.form.wayInfoDTOList[0].lat = res.latitude
                            this.form.wayInfoDTOList[0].lgt = res.longitude
                            this.form.wayInfoDTOList[0].location = res.address
                        }else if (type == -1) {
                            console.log(res)
                            this.location.latitude = res.latitude
                            this.location.longitude = res.longitude
                            this.location.address =res.name ||  res.address
                        }
                    }
                });
@@ -1124,6 +1130,10 @@
                    font-size: 32rpx;
                    color: #ffffff;
                    margin-right: 12rpx;
                    max-width: 280rpx;
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                }
                .qu {
                    width: 22rpx;
small-program/store/index.js
@@ -19,7 +19,8 @@
        openid: token || '',
        
        latitude: '',
        longitude: ''
        longitude: '',
        address:'定位中'
    },
    mutations: {
        // 设置导航栏高度
@@ -49,6 +50,8 @@
            console.log(obj)
            state.latitude = obj.latitude
            state.longitude = obj.longitude
            state.address = obj.address
            console.log("=====================",obj)
        },
        // 清除缓存数据
        empty(state) {