Commit 4f691bbe authored by 刘玉宏's avatar 刘玉宏

地址添加

parent 8aa495e2
......@@ -25,7 +25,9 @@
<view class="area">
<view class="area_l">
<view class="area_lt">当前定位</view>
<view class="area_lb">{{ forMData.city }}</view>
<view class="area_lb">
{{ forMData.province }}-{{ forMData.city }}-{{ forMData.area }}
</view>
</view>
<view class="area_r">
<wd-icon name="location" size="22px" @tap="changeLocation" />
......@@ -59,7 +61,9 @@
<script setup>
import Header from '@/pages/order/components/Header/index.vue';
import { addAddress, updateAddress, deleteAddress } from '@/api/address';
import api from '@/services';
const newAddressFlag = ref(false);
const reForm = ref();
......@@ -92,46 +96,54 @@ const hdSubmit = async () => {
await addAddress({
...forMData.value,
commonAddr: forMData.value.commonAddr ? 1 : 0,
province: forMData.value.province,
city: forMData.value.city,
area: forMData.value.area,
});
};
function handleSubmit() {
console.log('model的值', reForm.value);
reForm.value
.validate()
.then(({ valid }) => {
if (valid) {
hdSubmit();
// xma.showToast({
// title: '提交成功',
// duration: 2000,
// success: function () {
// console.log('数据更新后跳转地址列表页');
// },
// });
xma.showToast({
title: '提交成功',
duration: 2000,
});
}
})
.catch((error) => {
console.log(error, 'error');
});
}
// 重新定位收货地址
async function changeLocation() {
uni.chooseLocation({
success: function (res) {
forMData.value.city = res.address;
// forMData.value.city = res.address;
forMData.value.addr = res.address;
forMData.value.lng = res.longitude;
forMData.value.lat = res.latitude;
console.log('位置信息:' + JSON.stringify(res));
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
uni.request({
url: '/ws/geocoder/v1/',
data: {
key: 'MN4BZ-7JXKW-2RYRD-32QGF-AHONV-PAFUN',
location: `${res.latitude},${res.longitude}`,
},
success: function (res) {
// console.log('逆地理编码:' + JSON.stringify(res));
if (res.data.status === 0) {
forMData.value.province = res.data.result.address_component.province;
forMData.value.city = res.data.result.address_component.city;
forMData.value.area = res.data.result.address_component.district;
}
},
});
},
});
const res = ('26.56806', '106.714304');
console.log('地址转换结果:' + res);
}
</script>
......
......@@ -9,7 +9,7 @@
class="pubList"
v-for="item in list"
:key="item.shopId"
@click="item.shopStatus != [1, 2, 3] ? shopGto(item) : ''"
@click="item.shopStatus != [1, 2, 3] ? shopGto(item.shopId) : ''"
>
<!-- 列表头部 -->
<view class="titlecon">
......
......@@ -45,6 +45,11 @@ export default defineConfig({
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/ws/geocoder': {
target: 'https://apis.map.qq.com',
changeOrigin: true,
bypass: (req, res, options) => res.setHeader("x-req-proxyUr1", options.target + req.url)
}
},
},
});
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment