地址

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