wangfukang 1 month ago
parent
commit
111ae98115
  1. 209
      package1/buyFood/buyFood.vue
  2. 25
      package1/runErrand/runErrand.vue

209
package1/buyFood/buyFood.vue

@ -392,16 +392,6 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<uni-popup ref="deliveryClosedPopup" type="center" background-color="transparent" @change="onDeliveryClosedPopupChange">
<view class="delivery-closed-popup" @tap.stop>
<view class="delivery-closed-icon">
<uni-icons type="info-filled" size="28" color="#0b9b73"></uni-icons>
</view>
<view class="delivery-closed-title">当前区域暂未开启配送</view>
<view class="delivery-closed-desc">本店目前只能选择到店消费,关闭提示后会为你自动切换到到店标签。</view>
<view class="delivery-closed-btn" @tap="closeDeliveryClosedPopup">知道了</view>
</view>
</uni-popup>
<!-- 警告弹出层 --> <!-- 警告弹出层 -->
<uni-popup ref="warnPopup" background-color="#fff"> <uni-popup ref="warnPopup" background-color="#fff">
<view class="warnImg"> <view class="warnImg">
@ -572,6 +562,9 @@
<view class="free-order-subtitle">未支付免单资格会传递给下一个小伙伴</view> <view class="free-order-subtitle">未支付免单资格会传递给下一个小伙伴</view>
</view> </view>
</view> </view>
<view class="page-toast" v-if="pageToastText">
<view class="page-toast-inner">{{pageToastText}}</view>
</view>
<common-loading /> <common-loading />
</view> </view>
</template> </template>
@ -581,6 +574,7 @@
import addressList from '@/package1/address/addressList.vue' import addressList from '@/package1/address/addressList.vue'
import { requireLoginToCurrentPage } from '@/utils/authRedirect.js' import { requireLoginToCurrentPage } from '@/utils/authRedirect.js'
import { buildGroupHomeSharePath } from '@/utils/sharePath.js' import { buildGroupHomeSharePath } from '@/utils/sharePath.js'
const NOW_MAKE_GUIDE_CACHE_KEY = 'buyFoodNowMakeGuideShown'
export default { export default {
data() { data() {
return { return {
@ -595,6 +589,9 @@
peisongyuan: '' peisongyuan: ''
}, },
nowMake:true, nowMake:true,
nowMakeGuideShownInPage: false,
pageToastText: '',
pageToastTimer: null,
content: [], content: [],
remark:'', remark:'',
remarkInputValue: '', remarkInputValue: '',
@ -631,7 +628,6 @@
deliveryEnabled: 1, deliveryEnabled: 1,
deliverySwitchChecked: false, deliverySwitchChecked: false,
deliverySwitchLoading: false, deliverySwitchLoading: false,
deliveryClosedPopupVisible: false,
areaKind: 1 areaKind: 1
} }
}, },
@ -677,6 +673,9 @@
this.nowMake = false; this.nowMake = false;
this.isPack = 0; this.isPack = 0;
} }
if (this.isStoreConsumeOnly) {
this.switchToStoreMode();
}
if (this.supportShopDelivery) { if (this.supportShopDelivery) {
this.selected = 'shopDelivery'; this.selected = 'shopDelivery';
} }
@ -705,6 +704,12 @@
isStoreGroupOrder() { isStoreGroupOrder() {
return this.orderScene === 'storeGroup' || (this.groupItem && this.groupItem.orderScene === 'storeGroup') || this.shopItem.merchantType == 2; return this.orderScene === 'storeGroup' || (this.groupItem && this.groupItem.orderScene === 'storeGroup') || this.shopItem.merchantType == 2;
}, },
isStoreConsumeOnly() {
return this.shopItem && this.shopItem.storeConsumeOnly == 1;
},
shouldShowNowMakeGuide() {
return Number(this.shopItem.merchantType) === 1 && this.isPaotui == false && !this.isStoreGroupOrder && this.nowMake;
},
highFloorFeeCalc() { highFloorFeeCalc() {
if (this.selected === 'shopDelivery') return 0; if (this.selected === 'shopDelivery') return 0;
if (this.selected === 'zhiding' && this.assignedWorker) { if (this.selected === 'zhiding' && this.assignedWorker) {
@ -836,6 +841,9 @@
this.syncAreaKind(); this.syncAreaKind();
this.isNavigatingToWorkerList = false; this.isNavigatingToWorkerList = false;
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
if (this.isStoreConsumeOnly) {
this.switchToStoreMode();
}
const keepAddressBookOpen = uni.getStorageSync('keepAddressBookOpen') === '1'; const keepAddressBookOpen = uni.getStorageSync('keepAddressBookOpen') === '1';
const needsAddressListRefresh = uni.getStorageSync('addressListNeedsRefresh') === '1'; const needsAddressListRefresh = uni.getStorageSync('addressListNeedsRefresh') === '1';
if (keepAddressBookOpen) { if (keepAddressBookOpen) {
@ -899,11 +907,27 @@
onUnload() { onUnload() {
uni.$off('updateDeliveryWorker'); uni.$off('updateDeliveryWorker');
uni.removeStorageSync('pendingAssignWorker'); uni.removeStorageSync('pendingAssignWorker');
if (this.pageToastTimer) {
clearTimeout(this.pageToastTimer);
this.pageToastTimer = null;
}
}, },
methods: { methods: {
nowMakeMethod(){ nowMakeMethod(){
this.nowMake = !this.nowMake this.nowMake = !this.nowMake
}, },
maybeShowNowMakeGuide() {
if (this.nowMakeGuideShownInPage || !this.shouldShowNowMakeGuide) return;
if (uni.getStorageSync(NOW_MAKE_GUIDE_CACHE_KEY) === '1') return;
this.nowMakeGuideShownInPage = true;
uni.setStorageSync(NOW_MAKE_GUIDE_CACHE_KEY, '1');
uni.showModal({
title: '温馨提示',
content: '如不需要商家立即出餐,可取消勾选“立即出餐”。',
showCancel: false,
confirmText: '知道了'
});
},
checkPack(type) { checkPack(type) {
if (this.isPack === type) return; if (this.isPack === type) return;
this.isPack = type; this.isPack = type;
@ -1060,10 +1084,41 @@
isDeliveryClosed() { isDeliveryClosed() {
return this.shouldCheckDeliverySwitch() && Number(this.deliveryEnabled) === 0; return this.shouldCheckDeliverySwitch() && Number(this.deliveryEnabled) === 0;
}, },
isDeliveryUnavailable() {
return this.shouldCheckDeliverySwitch() && (this.isStoreConsumeOnly || this.isDeliveryClosed());
},
showPageToast(text, duration = 1500) {
if (!text) return;
this.pageToastText = text;
if (this.pageToastTimer) {
clearTimeout(this.pageToastTimer);
}
this.pageToastTimer = setTimeout(() => {
this.pageToastText = '';
this.pageToastTimer = null;
}, duration);
},
showDeliveryUnavailableTip() {
if (this.isDeliveryClosed()) {
this.showPageToast('当前区域关闭了外卖配送', 1500);
return true;
}
if (this.isStoreConsumeOnly) {
this.showPageToast('当前商家暂不支持外卖配送', 1500);
return true;
}
return false;
},
fetchDeliverySwitch() { fetchDeliverySwitch() {
if (!this.shouldCheckDeliverySwitch()) return Promise.resolve(true); if (!this.shouldCheckDeliverySwitch()) return Promise.resolve(true);
const regionId = this.getCurrentRegionId(); const regionId = this.getCurrentRegionId();
if (!regionId) return Promise.resolve(true); if (!regionId) {
if (this.isStoreConsumeOnly) {
this.switchToStoreMode();
return Promise.resolve(false);
}
return Promise.resolve(true);
}
this.deliverySwitchLoading = true; this.deliverySwitchLoading = true;
return this.tui.request('/app/shopArea/deliverySwitch/get', 'GET', { return this.tui.request('/app/shopArea/deliverySwitch/get', 'GET', {
regionId: regionId regionId: regionId
@ -1072,36 +1127,53 @@
if (res.code == 200 || res.success) { if (res.code == 200 || res.success) {
this.deliveryEnabled = res.result == null ? 1 : Number(res.result); this.deliveryEnabled = res.result == null ? 1 : Number(res.result);
this.deliverySwitchChecked = true; this.deliverySwitchChecked = true;
if (this.isDeliveryClosed() && this.isPaotui && !this.deliveryClosedPopupVisible) { if (this.isDeliveryUnavailable() && this.isPaotui) {
this.openDeliveryClosedPopup(); this.switchToStoreMode();
return false; return false;
} }
} }
return !this.isDeliveryClosed(); return !this.isDeliveryUnavailable();
}).catch(() => { }).catch(() => {
this.deliverySwitchLoading = false; this.deliverySwitchLoading = false;
if (this.isStoreConsumeOnly) {
this.switchToStoreMode();
return false;
}
return true; return true;
}); });
}, },
async ensureDeliveryAvailable() { async ensureDeliveryAvailable() {
if (!this.shouldCheckDeliverySwitch() || !this.isPaotui) return true; if (!this.shouldCheckDeliverySwitch() || !this.isPaotui) return true;
if (this.isDeliveryUnavailable()) {
this.switchToStoreMode();
return false;
}
if (!this.deliverySwitchChecked) { if (!this.deliverySwitchChecked) {
const available = await this.fetchDeliverySwitch(); const available = await this.fetchDeliverySwitch();
if (!available) return false; if (!available) return false;
} }
if (this.isDeliveryClosed()) { if (this.isDeliveryUnavailable()) {
this.openDeliveryClosedPopup(); this.switchToStoreMode();
return false; return false;
} }
return true; return true;
}, },
selectOrderMode(isDelivery) { async selectOrderMode(isDelivery) {
if (!isDelivery) { if (!isDelivery) {
this.switchToStoreMode(); this.switchToStoreMode();
return; return;
} }
if (this.isDeliveryClosed()) { if (!this.deliverySwitchChecked && this.shouldCheckDeliverySwitch()) {
this.openDeliveryClosedPopup(); const available = await this.fetchDeliverySwitch();
if (!available) {
this.showDeliveryUnavailableTip();
this.switchToStoreMode();
return;
}
}
if (this.isDeliveryUnavailable()) {
this.showDeliveryUnavailableTip();
this.switchToStoreMode();
return; return;
} }
this.isPaotui = true; this.isPaotui = true;
@ -1109,27 +1181,10 @@
}, },
switchToStoreMode() { switchToStoreMode() {
this.isPaotui = false; this.isPaotui = false;
this.fetchCoupons();
},
openDeliveryClosedPopup() {
this.deliveryClosedPopupVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.deliveryClosedPopup) { this.maybeShowNowMakeGuide();
this.$refs.deliveryClosedPopup.open('center');
}
}); });
}, this.fetchCoupons(true);
closeDeliveryClosedPopup() {
this.switchToStoreMode();
if (this.$refs.deliveryClosedPopup) {
this.$refs.deliveryClosedPopup.close();
}
},
onDeliveryClosedPopupChange(e) {
this.deliveryClosedPopupVisible = e.show;
if (!e.show && this.isDeliveryClosed()) {
this.switchToStoreMode();
}
}, },
onPayPopupChange(e) { onPayPopupChange(e) {
this.payPopupVisible = e.show; this.payPopupVisible = e.show;
@ -1390,7 +1445,7 @@
this.fetchCoupons(); this.fetchCoupons();
this.$refs.couponPopup.open('bottom'); this.$refs.couponPopup.open('bottom');
}, },
fetchCoupons() { fetchCoupons(hideLoading) {
let userId = uni.getStorageSync('id'); let userId = uni.getStorageSync('id');
if (!userId) return; if (!userId) return;
let amount = this.preDiscountTotal; let amount = this.preDiscountTotal;
@ -1400,7 +1455,7 @@
applyScene: this.isStoreGroupOrder ? 4 : 1, applyScene: this.isStoreGroupOrder ? 4 : 1,
amount: amount, amount: amount,
merchantId: this.shopItem.id || this.shopItem.shopId || '0' merchantId: this.shopItem.id || this.shopItem.shopId || '0'
}, false, true).then((res) => { }, false, true, hideLoading).then((res) => {
if (res.code == 200 && res.result) { if (res.code == 200 && res.result) {
this.availableCoupons = res.result; this.availableCoupons = res.result;
if (this.selectedCoupon) { if (this.selectedCoupon) {
@ -1846,6 +1901,31 @@
overflow: hidden; overflow: hidden;
} }
.page-toast {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 100000;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
}
.page-toast-inner {
max-width: 520rpx;
padding: 24rpx 36rpx;
border-radius: 16rpx;
background: rgba(0, 0, 0, 0.72);
color: #fff;
font-size: 28rpx;
font-weight: 700;
line-height: 40rpx;
text-align: center;
}
.checkout-fixed-header { .checkout-fixed-header {
position: fixed; position: fixed;
top: 0; top: 0;
@ -2620,53 +2700,6 @@
box-shadow: 0 12rpx 26rpx rgba(11, 155, 115, 0.2); box-shadow: 0 12rpx 26rpx rgba(11, 155, 115, 0.2);
} }
.delivery-closed-popup {
width: 620rpx;
padding: 48rpx 38rpx 36rpx;
background: linear-gradient(180deg, #ffffff 0%, #f2fff9 100%);
border-radius: 34rpx;
box-sizing: border-box;
text-align: center;
box-shadow: 0 24rpx 70rpx rgba(0, 35, 28, 0.18);
}
.delivery-closed-icon {
width: 92rpx;
height: 92rpx;
margin: 0 auto 24rpx;
border-radius: 50%;
background: rgba(11, 155, 115, 0.12);
display: flex;
align-items: center;
justify-content: center;
}
.delivery-closed-title {
color: $primary;
font-size: 34rpx;
font-weight: 700;
line-height: 1.4;
}
.delivery-closed-desc {
margin-top: 18rpx;
color: $muted;
font-size: 26rpx;
line-height: 42rpx;
}
.delivery-closed-btn {
margin-top: 38rpx;
height: 80rpx;
line-height: 80rpx;
border-radius: 999rpx;
color: #fff;
font-size: 28rpx;
font-weight: 700;
background: linear-gradient(135deg, #0b9b73, #20d6a4);
box-shadow: 0 12rpx 26rpx rgba(11, 155, 115, 0.2);
}
.coupon-row { .coupon-row {
border-top: 1rpx solid #f0f3f2; border-top: 1rpx solid #f0f3f2;
font-size: 28rpx; font-size: 28rpx;

25
package1/runErrand/runErrand.vue

@ -443,7 +443,8 @@
availableCoupons: [], availableCoupons: [],
selectedCoupon: null, selectedCoupon: null,
navigatingFromPayPopup: false, navigatingFromPayPopup: false,
baseDeliveryFee: 0 baseDeliveryFee: 0,
areaKind: 1
} }
}, },
components: { components: {
@ -481,14 +482,19 @@
}, },
minimumCommissionText() { minimumCommissionText() {
return this.formatAmountText(this.getMinimumCommissionAmount()); return this.formatAmountText(this.getMinimumCommissionAmount());
},
isSocialArea() {
return Number(this.areaKind) === 2;
} }
}, },
watch: {}, watch: {},
onLoad() { onLoad() {
this.syncAreaKind()
this.enableShareMenu() this.enableShareMenu()
//this.getShopArea() //this.getShopArea()
}, },
onShow() { onShow() {
this.syncAreaKind()
this.enableShareMenu() this.enableShareMenu()
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
const keepAddressBookOpen = uni.getStorageSync('keepAddressBookOpen') === '1'; const keepAddressBookOpen = uni.getStorageSync('keepAddressBookOpen') === '1';
@ -560,6 +566,19 @@
imageUrl: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/f7227759d693497a8beab87ff437a875.png' imageUrl: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/f7227759d693497a8beab87ff437a875.png'
} }
}, },
syncAreaKind(areaObj) {
let area = areaObj;
if (!area) {
try {
const cached = uni.getStorageSync('area');
area = cached ? (typeof cached === 'string' ? JSON.parse(cached) : cached) : null;
} catch (e) {
area = null;
}
}
const kind = area ? Number(area.areaKind) : 1;
this.areaKind = kind === 2 ? 2 : 1;
},
backHome() { backHome() {
uni.switchTab({ uni.switchTab({
url: '/pages/index/index', url: '/pages/index/index',
@ -1127,7 +1146,7 @@
shopAddressStr = (this.formData.pickupAddress.areaName || '') + (this.formData.pickupAddress.floor ? this.formData.pickupAddress.floor + '层' : '') + (this.formData.pickupAddress.roomNum || ''); shopAddressStr = (this.formData.pickupAddress.areaName || '') + (this.formData.pickupAddress.floor ? this.formData.pickupAddress.floor + '层' : '') + (this.formData.pickupAddress.roomNum || '');
shopName = this.formData.pickupAddress.receiverName || '个人寄件'; shopName = this.formData.pickupAddress.receiverName || '个人寄件';
shopPhone = this.formData.pickupAddress.receiverPhone || ''; shopPhone = this.formData.pickupAddress.receiverPhone || '';
getAreaId = this.formData.pickupAddress.areaId; getAreaId = this.isSocialArea ? this.formData.pickupAddress.id : this.formData.pickupAddress.areaId;
} }
let codes = this.addFormData.codeList.map(c => c.code).filter(c => c).join(','); let codes = this.addFormData.codeList.map(c => c.code).filter(c => c).join(',');
@ -1135,7 +1154,7 @@
let payload = { let payload = {
getAreaId: getAreaId, getAreaId: getAreaId,
putAreaId: this.formData.address.areaId, putAreaId: this.isSocialArea ? this.formData.address.id : this.formData.address.areaId,
deliveryType: deliveryType, deliveryType: deliveryType,
receiverName: this.formData.address.receiverName, receiverName: this.formData.address.receiverName,
receiverPhone: this.formData.address.receiverPhone, receiverPhone: this.formData.address.receiverPhone,

Loading…
Cancel
Save