2024-08-07 14:09:15 +00:00
|
|
|
|
<!-- 下单界面,收货地址 or 自提门店的选择组件 -->
|
2024-08-05 10:00:11 +00:00
|
|
|
|
<template>
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<view class="allAddress" :style="state.isPickUp ? '' : 'padding-top:10rpx;'">
|
2024-08-05 10:00:11 +00:00
|
|
|
|
<view class="nav flex flex-wrap">
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<view
|
|
|
|
|
class="item font-color"
|
|
|
|
|
:class="state.deliveryType === 1 ? 'on' : 'on2'"
|
|
|
|
|
@tap="switchDeliveryType(1)"
|
|
|
|
|
v-if="state.isPickUp"
|
|
|
|
|
/>
|
|
|
|
|
<view
|
|
|
|
|
class="item font-color"
|
|
|
|
|
:class="state.deliveryType === 2 ? 'on' : 'on2'"
|
|
|
|
|
@tap="switchDeliveryType(2)"
|
|
|
|
|
v-if="state.isPickUp"
|
|
|
|
|
/>
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
2024-08-07 14:09:15 +00:00
|
|
|
|
<!-- 情况一:收货地址的选择 -->
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<view
|
|
|
|
|
class="address flex flex-wrap flex-center ss-row-between"
|
|
|
|
|
@tap="onSelectAddress"
|
|
|
|
|
v-if="state.deliveryType === 1"
|
|
|
|
|
:style="state.isPickUp ? '' : 'border-top-left-radius: 14rpx;border-top-right-radius: 14rpx;'"
|
|
|
|
|
>
|
|
|
|
|
<view class="addressCon" v-if="state.addressInfo.name">
|
|
|
|
|
<view class="name"
|
|
|
|
|
>{{ state.addressInfo.name }}
|
|
|
|
|
<text class="phone">{{ state.addressInfo.mobile }}</text>
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
|
|
|
|
<view class="flex flex-wrap">
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<text class="default font-color" v-if="state.addressInfo.defaultStatus">[默认]</text>
|
|
|
|
|
<text class="line2"
|
|
|
|
|
>{{ state.addressInfo.areaName }} {{ state.addressInfo.detailAddress }}</text
|
|
|
|
|
>
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<view class="addressCon" v-else>
|
|
|
|
|
<view class="setaddress">设置收货地址</view>
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<view class="iconfont">
|
2024-08-05 10:00:11 +00:00
|
|
|
|
<view class="ss-rest-button">
|
|
|
|
|
<text class="_icon-forward" />
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2024-08-07 14:09:15 +00:00
|
|
|
|
<!-- 情况二:门店的选择 -->
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<view class="address flex flex-wrap flex-center ss-row-between" v-else @tap="onSelectAddress">
|
|
|
|
|
<view class="addressCon" v-if="state.pickUpInfo.name">
|
|
|
|
|
<view class="name"
|
|
|
|
|
>{{ state.pickUpInfo.name }}
|
|
|
|
|
<text class="phone">{{ state.pickUpInfo.phone }}</text>
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<view class="line1">
|
|
|
|
|
{{ state.pickUpInfo.areaName }}{{ ', ' + state.pickUpInfo.detailAddress }}
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
2024-09-13 11:21:22 +00:00
|
|
|
|
</view>
|
|
|
|
|
<view class="addressCon" v-else>
|
|
|
|
|
<view class="setaddress">选择自提门店</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="iconfont">
|
|
|
|
|
<view class="ss-rest-button">
|
|
|
|
|
<text class="_icon-forward" />
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
2024-09-13 11:21:22 +00:00
|
|
|
|
</view>
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
2024-09-13 11:21:22 +00:00
|
|
|
|
<view class="line">
|
2024-08-07 14:09:15 +00:00
|
|
|
|
<image :src="sheep.$url.static('/static/images/line.png', 'local')" />
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2024-08-06 08:09:53 +00:00
|
|
|
|
import { computed } from 'vue';
|
2024-08-05 10:00:11 +00:00
|
|
|
|
import sheep from '@/sheep';
|
2024-08-07 15:51:29 +00:00
|
|
|
|
import { isEmpty } from 'lodash-es';
|
2024-08-05 10:00:11 +00:00
|
|
|
|
|
2024-08-06 08:09:53 +00:00
|
|
|
|
const props = defineProps({
|
|
|
|
|
modelValue: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default() {},
|
2024-09-13 11:21:22 +00:00
|
|
|
|
},
|
2024-08-05 10:00:11 +00:00
|
|
|
|
});
|
2024-08-06 08:09:53 +00:00
|
|
|
|
const emits = defineEmits(['update:modelValue']);
|
|
|
|
|
|
|
|
|
|
// computed 解决父子组件双向数据同步
|
|
|
|
|
const state = computed({
|
2024-09-13 11:21:22 +00:00
|
|
|
|
get() {
|
2024-08-06 08:09:53 +00:00
|
|
|
|
return new Proxy(props.modelValue, {
|
|
|
|
|
set(obj, name, val) {
|
|
|
|
|
emits('update:modelValue', {
|
|
|
|
|
...obj,
|
|
|
|
|
[name]: val,
|
|
|
|
|
});
|
|
|
|
|
return true;
|
2024-09-13 11:21:22 +00:00
|
|
|
|
},
|
|
|
|
|
});
|
2024-08-06 08:09:53 +00:00
|
|
|
|
},
|
2024-09-13 11:21:22 +00:00
|
|
|
|
set(val) {
|
2024-08-06 08:09:53 +00:00
|
|
|
|
emits('update:modelValue', val);
|
2024-09-13 11:21:22 +00:00
|
|
|
|
},
|
|
|
|
|
});
|
2024-08-05 10:00:11 +00:00
|
|
|
|
|
|
|
|
|
// 选择地址
|
|
|
|
|
function onSelectAddress() {
|
2024-09-13 11:21:22 +00:00
|
|
|
|
let emitName = 'SELECT_ADDRESS';
|
2024-08-09 02:10:01 +00:00
|
|
|
|
let addressPage = '/pages/user/address/list?type=select';
|
2024-09-13 11:21:22 +00:00
|
|
|
|
if (state.value.deliveryType === 2) {
|
|
|
|
|
emitName = 'SELECT_PICK_UP_INFO';
|
|
|
|
|
addressPage = '/pages/user/goods_details_store/index';
|
2024-08-05 10:00:11 +00:00
|
|
|
|
}
|
|
|
|
|
uni.$once(emitName, (e) => {
|
|
|
|
|
changeConsignee(e.addressInfo);
|
|
|
|
|
});
|
|
|
|
|
sheep.$router.go(addressPage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更改收货人地址&计算订单信息
|
|
|
|
|
async function changeConsignee(addressInfo = {}) {
|
|
|
|
|
if (!isEmpty(addressInfo)) {
|
2024-09-13 11:21:22 +00:00
|
|
|
|
if (state.value.deliveryType === 1) {
|
2024-08-06 08:09:53 +00:00
|
|
|
|
state.value.addressInfo = addressInfo;
|
2024-08-05 10:00:11 +00:00
|
|
|
|
}
|
2024-09-13 11:21:22 +00:00
|
|
|
|
if (state.value.deliveryType === 2) {
|
2024-08-06 08:09:53 +00:00
|
|
|
|
state.value.pickUpInfo = addressInfo;
|
2024-08-05 10:00:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 收货方式切换
|
2024-09-13 11:21:22 +00:00
|
|
|
|
const switchDeliveryType = (type) => {
|
2024-08-06 08:09:53 +00:00
|
|
|
|
state.value.deliveryType = type;
|
2024-09-13 11:21:22 +00:00
|
|
|
|
};
|
2024-08-05 10:00:11 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2024-09-13 11:21:22 +00:00
|
|
|
|
.allAddress .font-color {
|
|
|
|
|
color: #e93323 !important;
|
2024-08-05 10:00:11 +00:00
|
|
|
|
}
|
2024-09-13 11:21:22 +00:00
|
|
|
|
.line2 {
|
2024-08-05 10:00:11 +00:00
|
|
|
|
width: 504rpx;
|
|
|
|
|
}
|
|
|
|
|
.textR {
|
|
|
|
|
text-align: right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.line {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 3rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.line image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address {
|
|
|
|
|
padding: 28rpx;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address .addressCon {
|
|
|
|
|
width: 596rpx;
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
color: #666;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address .addressCon .name {
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
color: #282828;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
margin-bottom: 10rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address .addressCon .name .phone {
|
|
|
|
|
margin-left: 50rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address .addressCon .default {
|
|
|
|
|
margin-right: 12rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address .addressCon .setaddress {
|
|
|
|
|
color: #333;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address .iconfont {
|
|
|
|
|
font-size: 35rpx;
|
|
|
|
|
color: #707070;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress {
|
|
|
|
|
width: 100%;
|
|
|
|
|
background: linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
|
|
|
|
|
// background-image: linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
|
|
|
|
|
// background-image: -webkit-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
|
|
|
|
|
// background-image: -moz-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
|
|
|
|
|
//padding: 100rpx 30rpx 0 30rpx;
|
|
|
|
|
padding-top: 100rpx;
|
|
|
|
|
padding-bottom: 10rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .nav {
|
|
|
|
|
width: 690rpx;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .nav .item {
|
|
|
|
|
width: 334rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .nav .item.on {
|
|
|
|
|
position: relative;
|
|
|
|
|
width: 230rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .nav .item.on::before {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 0;
|
2024-09-13 11:21:22 +00:00
|
|
|
|
content: '快递配送';
|
2024-08-05 10:00:11 +00:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
display: block;
|
|
|
|
|
height: 0;
|
|
|
|
|
width: 336rpx;
|
|
|
|
|
border-width: 0 20rpx 80rpx 0;
|
|
|
|
|
border-style: none solid solid;
|
|
|
|
|
border-color: transparent transparent #fff;
|
|
|
|
|
z-index: 2;
|
|
|
|
|
border-radius: 14rpx 36rpx 0 0;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 80rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .nav .item:nth-of-type(2).on::before {
|
2024-09-13 11:21:22 +00:00
|
|
|
|
content: '到店自提';
|
2024-08-05 10:00:11 +00:00
|
|
|
|
border-width: 0 0 80rpx 20rpx;
|
|
|
|
|
border-radius: 36rpx 14rpx 0 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .nav .item.on2 {
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .nav .item.on2::before {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 0;
|
2024-09-13 11:21:22 +00:00
|
|
|
|
content: '到店自提';
|
2024-08-05 10:00:11 +00:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
display: block;
|
|
|
|
|
height: 0;
|
|
|
|
|
width: 401rpx;
|
|
|
|
|
border-width: 0 0 60rpx 60rpx;
|
|
|
|
|
border-style: none solid solid;
|
|
|
|
|
border-color: transparent transparent #f7c1bd;
|
|
|
|
|
border-radius: 36rpx 14rpx 0 0;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 60rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .nav .item:nth-of-type(1).on2::before {
|
2024-09-13 11:21:22 +00:00
|
|
|
|
content: '快递配送';
|
2024-08-05 10:00:11 +00:00
|
|
|
|
border-width: 0 60rpx 60rpx 0;
|
|
|
|
|
border-radius: 14rpx 36rpx 0 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .address {
|
|
|
|
|
width: 690rpx;
|
|
|
|
|
max-height: 180rpx;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.allAddress .line {
|
|
|
|
|
width: 100%;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
}
|
|
|
|
|
</style>
|