xuxueyang
2024-10-20 f4fd489475500b0d41dde019963307d217321d50
update 定位
已修改3个文件
25 ■■■■ 文件已修改
App.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/user/address/address.vue 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
store/index.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
App.vue
@@ -7,7 +7,14 @@
    export default {
        onLaunch: async function(options) {
            //清除一些缓存
            this.$storage.removeItem('cache_home_show_coupon')
            this.$storage.removeItem('cache_home_show_coupon')
            var defaultaddress = this.$storage.getItem("defaultaddress")
            if(defaultaddress){
                // this.$store.dispatch('getCurrentInfo');
                this.$store.commit('setAddressDesc', (defaultaddress || ''))
            }
            // #ifdef PUB_PARTNER
            // this.$storage.removeItem('cache_partner_info')
            // #endif
pages/user/address/address.vue
@@ -19,7 +19,7 @@
                </view>
                <view class="flex" @click="changeCurrentAddress">
                    <view>
                        <image style="width: 30rpx;height: 30rpx;" class="m-t-2"
                        <image style="width: 30rpx;height: 30rpx;margin-top: 6rpx;margin-right: 10rpx;" class="m-t-2"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a2/a248385d4fe748ca81ee058ea5bf8c47icon-address.jpg">
                        </image>
                    </view>
@@ -262,7 +262,7 @@
                    //表单选择了地址
                    wx.chooseLocation({
                        success: location => {
                            console.log('success loc', location)
                            console.log('success loc', location,source)
                            // address: "江苏省苏州市吴中区太湖东路288号"
                            // errMsg: "chooseLocation:ok"
                            // latitude: 31.26249
@@ -270,13 +270,14 @@
                            // name: "苏州市吴中区人民政府"
                            if (source === 'form') {
                                // (location.address || '') +
                                that.submitForm.address = (location.name || '')
                                that.submitForm.address = (location.name || location.address || '')
                                that.submitForm.latitude = location.latitude || 0
                                that.submitForm.longitude = location.longitude || 0
                            } else if (source === 'input') {
                                // (location.address || '') +
                                // that.search_flow =   (location.name || '')
                                that.$store.commit('setAddressDesc', (location.name || ''))
                                that.$store.commit('setAddressDesc', (location.name || location.address || ''))
                                that.$forceUpdate()
                            }
                            // if (!that.submitForm.province && location.provinceName) {
@@ -386,11 +387,11 @@
                    },
                    fail: (err) => {
                        this.error = err;
                        that.error = err;
                        console.error('定位失败:', err);
                    },
                    complete() {
                        this.$message.hideLoading()
                        that.$message.hideLoading()
                    }
                });
            },
store/index.js
@@ -71,7 +71,10 @@
            state.defaultaddress = defaultaddress
        },
        setAddressDesc(state, addressDesc) {
            console.log('setAddressDesc',addressDesc)
            state.addressDesc = addressDesc
            storage.setItem("defaultaddress",addressDesc || "")
        },
        setTestTrue(state) {
            state.testvuex = true