地址

parent c362463f
...@@ -9,7 +9,13 @@ ...@@ -9,7 +9,13 @@
<view class="full_list" v-else> <view class="full_list" v-else>
<wd-swipe-action> <wd-swipe-action>
<view class="additem" v-for="(item, index) in addressList" :key="index"> <view
@click.stop="selectAddress(item)"
:class="activeAdd === item ? 'acitve-additem' : 'additem'"
class="additem"
v-for="(item, index) in addressList"
:key="index"
>
<view class="additem_l"> <view class="additem_l">
<view class="address">{{ item.addr }}</view> <view class="address">{{ item.addr }}</view>
<view class="info"> <view class="info">
...@@ -22,7 +28,7 @@ ...@@ -22,7 +28,7 @@
<view class="txt">默认</view> <view class="txt">默认</view>
</view> </view>
<view v-else class="box" @click="deleteAdd(item.addrId)"> <view v-else class="box" @click.stop="deleteAdd(item.addrId)">
<wd-icon name="circle1" size="12px"></wd-icon> <wd-icon name="circle1" size="12px"></wd-icon>
<view class="txt">删除</view> <view class="txt">删除</view>
</view> </view>
...@@ -47,12 +53,16 @@ import { getAddressList, deleteAddress } from '@/api/address'; ...@@ -47,12 +53,16 @@ import { getAddressList, deleteAddress } from '@/api/address';
const isAdressEmpty = ref(false); const isAdressEmpty = ref(false);
const addressList = ref([]); const addressList = ref([]);
const activeAdd = ref(null);
const getAddressListData = async () => { const getAddressListData = async () => {
const { data: res } = await getAddressList(); const { data: res } = await getAddressList();
console.log(res); console.log(res);
if (res) { if (res) {
addressList.value = res; addressList.value = res;
activeAdd.value = res.filter((item) => {
return item.commonAddr === 1;
})[0];
res.length === 0 ? (isAdressEmpty.value = true) : (isAdressEmpty.value = false); res.length === 0 ? (isAdressEmpty.value = true) : (isAdressEmpty.value = false);
} }
}; };
...@@ -61,6 +71,13 @@ getAddressListData(); ...@@ -61,6 +71,13 @@ getAddressListData();
const addNewAddress = () => { const addNewAddress = () => {
xma.navigateTo({ url: '/pages/address/addressEdit?new=true' }); xma.navigateTo({ url: '/pages/address/addressEdit?new=true' });
}; };
const selectAddress = (item) => {
activeAdd.value = item;
xma.setStorageSync('address', item);
xma.navigateBack({
delta: 1,
});
};
const editAddress = (col) => { const editAddress = (col) => {
xma.navigateTo({ xma.navigateTo({
url: `/pages/address/addressEdit?content=${JSON.stringify(col)}`, url: `/pages/address/addressEdit?content=${JSON.stringify(col)}`,
...@@ -100,6 +117,7 @@ page { ...@@ -100,6 +117,7 @@ page {
margin-top: 20rpx; margin-top: 20rpx;
padding-bottom: 180rpx; padding-bottom: 180rpx;
.acitve-additem,
.additem { .additem {
width: 710rpx; width: 710rpx;
padding: 20rpx; padding: 20rpx;
...@@ -166,7 +184,9 @@ page { ...@@ -166,7 +184,9 @@ page {
} }
} }
} }
.acitve-additem {
border: 2rpx solid #fa5151;
}
.addBtn { .addBtn {
width: 630rpx; width: 630rpx;
height: 72rpx; height: 72rpx;
......
...@@ -161,7 +161,6 @@ const imgUrl = import.meta.env.VITE_APP_IMG_URL; ...@@ -161,7 +161,6 @@ const imgUrl = import.meta.env.VITE_APP_IMG_URL;
const textInputs = ref(''); const textInputs = ref('');
const basketIds = ref([]); const basketIds = ref([]);
const activeCouponId = ref(''); const activeCouponId = ref('');
const changeAddress = ref(false);
const addressParams = ref({}); const addressParams = ref({});
const showpopup = ref(false); const showpopup = ref(false);
const outTradeNos = ref(null); const outTradeNos = ref(null);
...@@ -177,12 +176,15 @@ onLoad((options) => { ...@@ -177,12 +176,15 @@ onLoad((options) => {
skuIds.value = skuId; skuIds.value = skuId;
types.value = type; types.value = type;
if (type === 'qg') { if (type === 'qg') {
console.log('1111111111111111111');
groupBuyConfirmFn(prodId, skuId).then((res) => { groupBuyConfirmFn(prodId, skuId).then((res) => {
useraddrDefaultUserAddrFn().then(() => { useraddrDefaultUserAddrFn().then(() => {
groupBuyUpdateFnQg(); groupBuyUpdateFnQg();
}); });
}); });
} else { } else {
console.log('22222222222222222222222');
basketIds.value = ids.split(','); basketIds.value = ids.split(',');
sgyrddBasketConfirmFn(basketIds.value).then(() => { sgyrddBasketConfirmFn(basketIds.value).then(() => {
useraddrDefaultUserAddrFn().then(() => { useraddrDefaultUserAddrFn().then(() => {
...@@ -193,6 +195,7 @@ onLoad((options) => { ...@@ -193,6 +195,7 @@ onLoad((options) => {
}); });
function groupBuyUpdateFnQg(couponUserId = '') { function groupBuyUpdateFnQg(couponUserId = '') {
const { receiverName, receiverMobile, receiverAddress } = addressParams.value; const { receiverName, receiverMobile, receiverAddress } = addressParams.value;
groupBuyUpdate({ groupBuyUpdate({
key: orderInfo.value.key, key: orderInfo.value.key,
couponUserId, couponUserId,
...@@ -206,21 +209,37 @@ function groupBuyUpdateFnQg(couponUserId = '') { ...@@ -206,21 +209,37 @@ function groupBuyUpdateFnQg(couponUserId = '') {
}); });
} }
onShow(() => { onShow(() => {
if (changeAddress.value) { const storgeAddress = xma.getStorageSync('address') || null;
if (storgeAddress) {
addressInfo.value = storgeAddress;
addressParams.value.receiverName = storgeAddress.receiver;
addressParams.value.receiverMobile = storgeAddress.mobile;
addressParams.value.receiverAddress = storgeAddress.addr;
if (types.value === 'qg') { if (types.value === 'qg') {
groupBuyConfirmFn(prodIds.value, skuIds.value).then((res) => { groupBuyConfirmFn(prodIds.value, skuIds.value).then((res) => {
useraddrDefaultUserAddrFn().then(() => { groupBuyUpdateFnQg();
groupBuyUpdateFnQg();
});
}); });
} else { } else {
sgyrddBasketConfirmFn(basketIds.value).then(() => { sgyrddBasketConfirmFn(basketIds.value).then(() => {
useraddrDefaultUserAddrFn().then(() => { groupBuyUpdateFn();
groupBuyUpdateFn();
});
}); });
} }
} }
// else {
// if (types.value === 'qg') {
// groupBuyConfirmFn(prodIds.value, skuIds.value).then((res) => {
// useraddrDefaultUserAddrFn().then(() => {
// groupBuyUpdateFnQg();
// });
// });
// } else {
// sgyrddBasketConfirmFn(basketIds.value).then(() => {
// useraddrDefaultUserAddrFn().then(() => {
// groupBuyUpdateFn();
// });
// });
// }
// }
if (outTradeNos.value) { if (outTradeNos.value) {
// 查询订单状态决定是否支付 // 查询订单状态决定是否支付
...@@ -306,7 +325,6 @@ function selectShopCoupon(item) { ...@@ -306,7 +325,6 @@ function selectShopCoupon(item) {
} }
} }
const jumpToAddressList = () => { const jumpToAddressList = () => {
changeAddress.value = true;
wx.navigateTo({ wx.navigateTo({
url: '/pages/address/addressList', url: '/pages/address/addressList',
}); });
...@@ -380,6 +398,7 @@ const payNow = async (data) => { ...@@ -380,6 +398,7 @@ const payNow = async (data) => {
} else { } else {
groupBuyConfirmFn(prodIds.value, skuIds.value); groupBuyConfirmFn(prodIds.value, skuIds.value);
} }
xma.removeStorageSync('address');
}); });
} else { } else {
znsgyOrderCreate(params.value).then((res) => { znsgyOrderCreate(params.value).then((res) => {
...@@ -388,6 +407,7 @@ const payNow = async (data) => { ...@@ -388,6 +407,7 @@ const payNow = async (data) => {
} else { } else {
sgyrddBasketConfirmFn(basketIds.value); sgyrddBasketConfirmFn(basketIds.value);
} }
xma.removeStorageSync('address');
}); });
} }
}; };
......
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