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

地址添加

parent 8aa495e2
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
<view class="area"> <view class="area">
<view class="area_l"> <view class="area_l">
<view class="area_lt">当前定位</view> <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>
<view class="area_r"> <view class="area_r">
<wd-icon name="location" size="22px" @tap="changeLocation" /> <wd-icon name="location" size="22px" @tap="changeLocation" />
...@@ -59,7 +61,9 @@ ...@@ -59,7 +61,9 @@
<script setup> <script setup>
import Header from '@/pages/order/components/Header/index.vue'; import Header from '@/pages/order/components/Header/index.vue';
import { addAddress, updateAddress, deleteAddress } from '@/api/address'; import { addAddress, updateAddress, deleteAddress } from '@/api/address';
import api from '@/services';
const newAddressFlag = ref(false); const newAddressFlag = ref(false);
const reForm = ref(); const reForm = ref();
...@@ -92,46 +96,54 @@ const hdSubmit = async () => { ...@@ -92,46 +96,54 @@ const hdSubmit = async () => {
await addAddress({ await addAddress({
...forMData.value, ...forMData.value,
commonAddr: forMData.value.commonAddr ? 1 : 0, commonAddr: forMData.value.commonAddr ? 1 : 0,
province: forMData.value.province,
city: forMData.value.city,
area: forMData.value.area,
}); });
}; };
function handleSubmit() { function handleSubmit() {
console.log('model的值', reForm.value);
reForm.value reForm.value
.validate() .validate()
.then(({ valid }) => { .then(({ valid }) => {
if (valid) { if (valid) {
hdSubmit(); hdSubmit();
// xma.showToast({ xma.showToast({
// title: '提交成功', title: '提交成功',
// duration: 2000, duration: 2000,
// success: function () { });
// console.log('数据更新后跳转地址列表页');
// },
// });
} }
}) })
.catch((error) => { .catch((error) => {
console.log(error, 'error'); console.log(error, 'error');
}); });
} }
// 重新定位收货地址 // 重新定位收货地址
async function changeLocation() { async function changeLocation() {
uni.chooseLocation({ uni.chooseLocation({
success: function (res) { success: function (res) {
forMData.value.city = res.address; // forMData.value.city = res.address;
forMData.value.addr = res.address; forMData.value.addr = res.address;
forMData.value.lng = res.longitude; forMData.value.lng = res.longitude;
forMData.value.lat = res.latitude; forMData.value.lat = res.latitude;
console.log('位置信息:' + JSON.stringify(res)); console.log('位置信息:' + JSON.stringify(res));
console.log('位置名称:' + res.name); uni.request({
console.log('详细地址:' + res.address); url: '/ws/geocoder/v1/',
console.log('纬度:' + res.latitude); data: {
console.log('经度:' + res.longitude); 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> </script>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
class="pubList" class="pubList"
v-for="item in list" v-for="item in list"
:key="item.shopId" :key="item.shopId"
@click="item.shopStatus != [1, 2, 3] ? shopGto(item) : ''" @click="item.shopStatus != [1, 2, 3] ? shopGto(item.shopId) : ''"
> >
<!-- 列表头部 --> <!-- 列表头部 -->
<view class="titlecon"> <view class="titlecon">
......
...@@ -45,6 +45,11 @@ export default defineConfig({ ...@@ -45,6 +45,11 @@ export default defineConfig({
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''), 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