Browse Source

'修改时间段选择等逻辑'

master
Lj 1 week ago
parent
commit
a7826455e2
4 changed files with 161 additions and 36 deletions
  1. +40
    -2
      pages/baoyou-city/baoyou-city.vue
  2. +2
    -2
      pages/subcomponent/detail.vue
  3. +57
    -31
      pages/subcomponent/pickup.vue
  4. +62
    -1
      pages/subcomponent/promo-qrcode.vue

+ 40
- 2
pages/baoyou-city/baoyou-city.vue View File

@ -12,7 +12,18 @@
</view> </view>
<!-- 蓝色banner卡片 --> <!-- 蓝色banner卡片 -->
<view class="byc-banner"> <view class="byc-banner">
<image class="byc-banner-img" :src="myCityImage" mode="widthFix" />
<image
class="byc-banner-img"
:src="myCityImage"
mode="widthFix"
@error="onImageError"
@load="onImageLoad"
/>
<!-- 备用背景 -->
<view v-if="!myCityImage || imageLoadError" class="byc-banner-fallback">
<view class="byc-banner-title">包邮服务城市</view>
<view class="byc-banner-desc">已开通包邮服务的城市列表</view>
</view>
</view> </view>
<!-- 主内容卡片 --> <!-- 主内容卡片 -->
<view class="byc-main-card"> <view class="byc-main-card">
@ -46,7 +57,8 @@
navBarHeight: 88, // navBarHeight: 88, //
menuButtonInfo: null, menuButtonInfo: null,
cityList: [], cityList: [],
bannerTop: 0 // banner
bannerTop: 0, // banner
imageLoadError: false //
} }
}, },
onLoad() { onLoad() {
@ -78,12 +90,24 @@
}, },
myCityImage() { myCityImage() {
const item = getApp().globalData.configData.find(i => i.keyName === 'city_banner') const item = getApp().globalData.configData.find(i => i.keyName === 'city_banner')
console.log(item);
return item ? item.keyContent : '' return item ? item.keyContent : ''
}, },
}, },
methods: { methods: {
goBack() { goBack() {
uni.navigateBack() uni.navigateBack()
},
//
onImageError(e) {
console.error('包邮城市背景图加载失败:', e);
this.imageLoadError = true;
//
},
//
onImageLoad(e) {
console.log('包邮城市背景图加载成功');
this.imageLoadError = false;
} }
} }
} }
@ -157,6 +181,20 @@
display: block; display: block;
object-fit: cover; object-fit: cover;
} }
.byc-banner-fallback {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(135deg, #2486f6 0%, #4a9eff 100%);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 40rpx;
box-sizing: border-box;
}
.byc-main-card { .byc-main-card {
background: #fff; background: #fff;
border-radius: 36rpx; border-radius: 36rpx;


+ 2
- 2
pages/subcomponent/detail.vue View File

@ -146,7 +146,7 @@
<text class="order-value">2025-03-20 11:00~12:00</text> <text class="order-value">2025-03-20 11:00~12:00</text>
</view> </view>
<view class="order-row"> <view class="order-row">
<text class="order-label">取件地址</text>
<text class="order-label">取件地址</text>false
<text class="order-value">{{ address }}</text> <text class="order-value">{{ address }}</text>
</view> </view>
</view> </view>
@ -155,7 +155,7 @@
<!-- 底部按钮仅在线预约时显示 --> <!-- 底部按钮仅在线预约时显示 -->
<view class="bottom-btns" v-if="(status === 0||(status === 1 && state==0)) && state !== 3 && state !== 4"> <view class="bottom-btns" v-if="(status === 0||(status === 1 && state==0)) && state !== 3 && state !== 4">
<button class="btn cancel-btn" @tap="showCancelModal = true">取消订单</button> <button class="btn cancel-btn" @tap="showCancelModal = true">取消订单</button>
<button class="btn contact-btn" @tap="contactCourier" v-if="status === 1">联系快递员</button>
<button class="btn contact-btn" @tap="contactCourier" v-if="status === 1&& phone?true:false">联系快递员</button>
</view> </view>
<!-- 取消订单弹窗 --> <!-- 取消订单弹窗 -->


+ 57
- 31
pages/subcomponent/pickup.vue View File

@ -130,18 +130,18 @@
</view> </view>
</view> </view>
<view class="picker-section"> <view class="picker-section">
<view class="section-title">选择时间</view>
<view class="time-btns">
<view
v-for="(slot, idx) in timeSlots"
:key="idx"
:class="['time-btn', {active: selectedTimeSlot === idx}]"
@tap="selectTimeSlot(idx)"
>
{{ slot }}
</view>
</view>
</view>
<view class="section-title">选择时间</view>
<view class="time-btns">
<view
v-for="(slot, idx) in timeSlots"
:key="idx"
:class="['time-btn', {active: selectedTimeSlot === idx, disabled: !availableTimeSlots[idx]}]"
@tap="availableTimeSlots[idx] ? selectTimeSlot(idx) : null"
>
{{ slot }}
</view>
</view>
</view>
<view class="confirm-btn" @tap="confirmTime">确认</view> <view class="confirm-btn" @tap="confirmTime">确认</view>
</view> </view>
</view> </view>
@ -167,8 +167,8 @@ export default {
showTimePicker: false, showTimePicker: false,
currentDateTab: 0, currentDateTab: 0,
dateTabs: [], // dateTabs: [], //
timeSlots: ['11:00~13:00', '13:00~15:00', '15:00~17:00'],
selectedTimeSlot: 0,
timeSlots: ['09:00~11:00', '11:00~13:00', '13:00~15:00', '15:00~17:00', '17:00~19:00'],
selectedTimeSlot: -1,
steps: [], // steps: [], //
showAllItems: false, showAllItems: false,
addressId: '' addressId: ''
@ -237,6 +237,18 @@ export default {
uni.$off('clearRecycleData') uni.$off('clearRecycleData')
}, },
computed: { computed: {
availableTimeSlots() {
const tab = this.dateTabs[this.currentDateTab];
if (!tab) return this.timeSlots.map(() => true);
const dateObj = tab.date;
const now = new Date();
return this.timeSlots.map(slot => {
const startTime = slot.split('~')[0];
const [h, m] = startTime.split(':');
const slotDate = new Date(dateObj.getFullYear(), dateObj.getMonth(), dateObj.getDate(), h, m);
return slotDate > now;
});
},
totalCount() { totalCount() {
return this.selectedItems.reduce((sum, item) => sum + item.quantity, 0) return this.selectedItems.reduce((sum, item) => sum + item.quantity, 0)
}, },
@ -299,23 +311,29 @@ export default {
this.currentDateTab = index this.currentDateTab = index
}, },
selectTimeSlot(index) { selectTimeSlot(index) {
this.selectedTimeSlot = index
},
confirmTime() {
const tab = this.dateTabs[this.currentDateTab]
const dateObj = tab.date
const timeStr = this.timeSlots[this.selectedTimeSlot] // '11:00~13:00'
const startTime = timeStr.split('~')[0] // '11:00'
const yyyy = dateObj.getFullYear()
const mm = (dateObj.getMonth() + 1).toString().padStart(2, '0')
const dd = dateObj.getDate().toString().padStart(2, '0')
this.selectedTime = `${yyyy}-${mm}-${dd} ${startTime}:00`
this.closeTimePicker()
},
resetPicker() {
this.currentDateTab = 0
this.selectedTimeSlot = 0
},
if (this.availableTimeSlots[index]) {
this.selectedTimeSlot = index;
}
},
confirmTime() {
if (this.selectedTimeSlot === -1) {
uni.showToast({ title: '请选择可用时间段', icon: 'none' });
return;
}
const tab = this.dateTabs[this.currentDateTab];
const dateObj = tab.date;
const timeStr = this.timeSlots[this.selectedTimeSlot];
const startTime = timeStr.split('~')[0];
const yyyy = dateObj.getFullYear();
const mm = (dateObj.getMonth() + 1).toString().padStart(2, '0');
const dd = dateObj.getDate().toString().padStart(2, '0');
this.selectedTime = `${yyyy}-${mm}-${dd} ${startTime}:00`;
this.closeTimePicker();
},
resetPicker() {
this.currentDateTab = 0;
this.selectedTimeSlot = -1;
},
toggleAgreement() { toggleAgreement() {
this.agreed = !this.agreed this.agreed = !this.agreed
}, },
@ -832,4 +850,12 @@ export default {
padding: 36rpx 0 24rpx 30rpx; padding: 36rpx 0 24rpx 30rpx;
letter-spacing: 1rpx; letter-spacing: 1rpx;
} }
.time-btn.disabled {
color: #ccc;
background: #f0f0f0;
border-color: #eee;
pointer-events: none;
}
</style> </style>

+ 62
- 1
pages/subcomponent/promo-qrcode.vue View File

@ -21,7 +21,20 @@
</view> --> </view> -->
<!-- 二维码区 --> <!-- 二维码区 -->
<view class="qrcode-modal-section"> <view class="qrcode-modal-section">
<image class="qrcode-img" :src="qrcodeUrl" mode="widthFix" />
<image
class="qrcode-img"
:src="qrcodeUrl"
mode="widthFix"
@error="onQrcodeError"
@load="onQrcodeLoad"
/>
<!-- 备用二维码显示 -->
<view v-if="qrcodeLoadError" class="qrcode-fallback">
<view class="qrcode-placeholder">
<text class="placeholder-text">二维码加载失败</text>
<text class="placeholder-desc">请检查网络连接后重试</text>
</view>
</view>
<!-- <view class="invite-code">邀请码{{inviteCode}}</view> --> <!-- <view class="invite-code">邀请码{{inviteCode}}</view> -->
</view> </view>
<!-- 底部按钮 --> <!-- 底部按钮 -->
@ -47,6 +60,7 @@ export default {
userInfo: {}, userInfo: {},
qrcodeUrl: '/static/qrcode.png', qrcodeUrl: '/static/qrcode.png',
inviteCode: '888888', inviteCode: '888888',
qrcodeLoadError: false, //
} }
}, },
onLoad() { onLoad() {
@ -182,6 +196,19 @@ export default {
}) })
} }
}) })
},
//
onQrcodeError(e) {
console.error('二维码图片加载失败:', e);
this.qrcodeLoadError = true;
//
},
//
onQrcodeLoad(e) {
console.log('二维码图片加载成功');
this.qrcodeLoadError = false;
} }
} }
} }
@ -279,6 +306,40 @@ export default {
border-radius: 24rpx; border-radius: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08); box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
} }
.qrcode-fallback {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #fff;
border-radius: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
display: flex;
justify-content: center;
align-items: center;
}
.qrcode-placeholder {
display: flex;
flex-direction: column;
align-items: center;
padding: 40rpx;
.placeholder-text {
font-size: 32rpx;
color: #666;
margin-bottom: 16rpx;
font-weight: bold;
}
.placeholder-desc {
font-size: 28rpx;
color: #999;
text-align: center;
}
}
.invite-code { .invite-code {
margin-top: 32rpx; margin-top: 32rpx;


Loading…
Cancel
Save