wangfukang 2 days ago
parent
commit
af21aecbed
  1. 100
      package1/buyFood/buyFood.vue
  2. 95
      package1/group/groupBuySingle.vue
  3. 103
      package1/runErrand/runErrand.vue

100
package1/buyFood/buyFood.vue

@ -247,6 +247,22 @@
</view>
</view>
</view>
<view
style="display: flex;height: 80rpx;line-height: 80rpx;border-top: 1px solid #eee;font-size: 28rpx;font-weight: 700; align-items:center;" @tap="openCouponPopup">
<view style="flex: 1; color: #777; font-size:32rpx;">
优惠券
</view>
<view style="color: #ff5722;" v-if="selectedCoupon">
-{{selectedCoupon.discountAmount.toFixed(2)}}
</view>
<view style="color: #0b9b73;" v-else-if="availableCoupons.length > 0">
{{availableCoupons.length}} 张可用
</view>
<view style="color: #999;" v-else>
无可用券
</view>
<uni-icons type="right" size="14" color="#999" style="margin-left:10rpx;"></uni-icons>
</view>
<view
style="display: flex;height: 80rpx;line-height: 100rpx;border-top: 1px solid #eee;font-size: 32rpx;font-weight: 700;">
<view style="flex: 1;">
@ -368,6 +384,41 @@
</view>
</view>
</uni-popup>
<uni-popup ref="couponPopup" type="bottom" background-color="#F5F8F5">
<view style="width: 100%; height: 800rpx; display: flex; flex-direction: column;">
<view style="height: 100rpx; line-height: 100rpx; text-align: center; font-size: 32rpx; font-weight: bold; border-bottom: 1px solid #eee; position: relative; background: #fff;">
选择优惠券
<uni-icons type="closeempty" size="24" @tap="$refs.couponPopup.close()" style="position: absolute; right: 30rpx; top: 0;"></uni-icons>
</view>
<scroll-view scroll-y style="flex: 1; padding: 20rpx; box-sizing: border-box;">
<view v-for="(item, index) in availableCoupons" :key="index" @tap="selectCoupon(item)"
style="background: #fff; border-radius: 12rpx; padding: 30rpx 20rpx; margin-bottom: 20rpx; display: flex; align-items: center; justify-content: space-between;">
<view style="display: flex; align-items: center; flex: 1;">
<view style="color: #ff5722; font-size: 40rpx; font-weight: bold; width: 140rpx;">
<text style="font-size: 24rpx;"></text>{{item.discountAmount}}
</view>
<view style="flex: 1; display: flex; flex-direction: column; justify-content: center; margin-left: 20rpx;">
<view style="font-size: 28rpx; font-weight: bold; color: #333; margin-bottom: 6rpx;">{{item.couponName}}</view>
<view style="font-size: 22rpx; color: #999;" v-if="item.minAmount > 0">{{item.minAmount}}可用</view>
<view style="font-size: 22rpx; color: #999;" v-else>无门槛使用</view>
</view>
</view>
<uni-icons v-if="selectedCoupon && selectedCoupon.id === item.id" type="checkmarkempty" size="20" color="#0b9b73"></uni-icons>
<view v-else style="width: 40rpx; height: 40rpx; border-radius: 50%; border: 1px solid #ddd;"></view>
</view>
<view v-if="availableCoupons.length===0" style="text-align:center; padding-top: 100rpx; color: #999;">
暂无可用优惠券
</view>
<view style="height:40rpx;"></view>
</scroll-view>
<view style="padding: 20rpx 40rpx; background: #fff;" v-if="availableCoupons.length>0">
<view @tap="selectCoupon(null)" style="width: 100%; height: 80rpx; background: linear-gradient(90deg, #e3ff96, #a6ffea); font-size: 30rpx; font-weight: 700; line-height: 80rpx; text-align: center; border-radius: 100rpx;">
不使用优惠券
</view>
</view>
</view>
</uni-popup>
<delivery-time-op @timeCallback="timeCallback" :dodge="true" ref='model' :content="content" :barHidth='600'
title="选择送达时间">
> </delivery-time-op>
@ -404,7 +455,9 @@
backendTotalAmount: 0,
currentOrderId: '',
createdOrderInfo: null,
isPaymentSuccessGroupInitiate: false
isPaymentSuccessGroupInitiate: false,
availableCoupons: [],
selectedCoupon: null
}
},
components: {
@ -508,6 +561,13 @@
return commission + this.highFloorFeeCalc;
},
totalAmountCalc() {
let total = this.preDiscountTotal;
if (this.selectedCoupon) {
total -= parseFloat(this.selectedCoupon.discountAmount);
}
return total > 0 ? total : 0;
},
preDiscountTotal() {
if(this.isPaotui==true){
return this.goodsAmountCalc + this.packageFee + this.deliveryFeeCalc;
}else{
@ -515,6 +575,13 @@
}
}
},
watch: {
preDiscountTotal(newVal, oldVal) {
if (newVal !== oldVal) {
this.fetchCoupons();
}
}
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.initAddress()
@ -627,9 +694,36 @@
url: `/package1/index/deliveryPersonList?orderType=0&shopAreaId=${shopArea}&putAreaId=${putArea}`
})
},
openCouponPopup() {
this.fetchCoupons();
this.$refs.couponPopup.open('bottom');
},
fetchCoupons() {
let userId = uni.getStorageSync('id');
if (!userId) return;
let amount = this.preDiscountTotal;
this.tui.request('/mall/coupon/available', 'GET', {
userId: userId,
regionId:JSON.parse(uni.getStorageSync('area')).id,
applyScene: 1,
amount: amount,
merchantId: this.shopItem.shopId || '0'
}, false, true).then((res) => {
if (res.code == 200 && res.result) {
this.availableCoupons = res.result;
if (this.selectedCoupon) {
let stillValid = this.availableCoupons.find(c => c.id === this.selectedCoupon.id);
if (!stillValid) this.selectedCoupon = null;
}
}
});
},
selectCoupon(item) {
this.selectedCoupon = item;
this.$refs.couponPopup.close();
},
openAddressBook() {
this.$refs.bookPopup.open('bottom')
},
checkTime(type) {
if (type === this.formData.isImmediately) {
@ -841,6 +935,8 @@
payload.getAreaId = this.shopItem.shopArea || null;
payload.putAreaId = this.formData.address ? this.formData.address.areaId : null;
}
payload.userCouponId = this.selectedCoupon ? this.selectedCoupon.id : null;
if (this.isGroupBuy && this.groupItem) {
if (this.groupItem.groupId) {

95
package1/group/groupBuySingle.vue

@ -340,6 +340,22 @@
</view>
</view>
</view>
<!-- 优惠券选择 -->
<view v-if="isPintuan" style="display: flex;height: 80rpx;line-height: 80rpx;border-top: 1px solid #eee;font-size: 28rpx;font-weight: 700; align-items:center; margin-top: 20rpx;" @tap="openCouponPopup">
<view style="flex: 1; color: #777;">
优惠券
</view>
<view style="color: #ff5722;" v-if="selectedCoupon">
-{{selectedCoupon.discountAmount.toFixed(2)}}
</view>
<view style="color: #0b9b73;" v-else-if="availableCoupons.length > 0">
{{availableCoupons.length}} 张可用
</view>
<view style="color: #999;" v-else>
无可用券
</view>
<uni-icons type="right" size="14" color="#999" style="margin-left:10rpx;"></uni-icons>
</view>
<view style="width: 100%;height: 160rpx;"></view>
</scroll-view>
<view class="bottom" style="padding-bottom: 40rpx;height: 160rpx;z-index: 10;">
@ -428,6 +444,9 @@
<text v-if="groupdeliveryType == 1"> 打包费 {{currentItem.lunchBox}} </text>
</view>
<view style="height: 40rpx;text-align: center;color: #ff5722;" v-if="selectedCoupon">
优惠券抵扣 -{{selectedCoupon.discountAmount.toFixed(2)}}
</view>
<view style="height: 40rpx;text-align: center;color: red;">
若拼团失败将会为您自动退款
</view>
@ -479,6 +498,42 @@
</view>
</view>
</uni-popup>
<!-- 优惠券选择弹出层 -->
<uni-popup ref="couponPopup" type="bottom" background-color="#F5F8F5">
<view style="width: 100%; height: 800rpx; display: flex; flex-direction: column;">
<view style="height: 100rpx; line-height: 100rpx; text-align: center; font-size: 32rpx; font-weight: bold; border-bottom: 1px solid #eee; position: relative; background: #fff;">
选择优惠券
<uni-icons type="closeempty" size="24" @tap="$refs.couponPopup.close()" style="position: absolute; right: 30rpx; top: 0;"></uni-icons>
</view>
<scroll-view scroll-y style="flex: 1; padding: 20rpx; box-sizing: border-box;">
<view v-for="(item, index) in availableCoupons" :key="index" @tap="selectCoupon(item)"
style="background: #fff; border-radius: 12rpx; padding: 30rpx 20rpx; margin-bottom: 20rpx; display: flex; align-items: center; justify-content: space-between;">
<view style="display: flex; align-items: center; flex: 1;">
<view style="color: #ff5722; font-size: 40rpx; font-weight: bold; width: 140rpx;">
<text style="font-size: 24rpx;"></text>{{item.discountAmount}}
</view>
<view style="flex: 1; display: flex; flex-direction: column; justify-content: center; margin-left: 20rpx;">
<view style="font-size: 28rpx; font-weight: bold; color: #333; margin-bottom: 6rpx;">{{item.couponName}}</view>
<view style="font-size: 22rpx; color: #999;" v-if="item.minAmount > 0">{{item.minAmount}}可用</view>
<view style="font-size: 22rpx; color: #999;" v-else>无门槛使用</view>
</view>
</view>
<uni-icons v-if="selectedCoupon && selectedCoupon.id === item.id" type="checkmarkempty" size="20" color="#0b9b73"></uni-icons>
<view v-else style="width: 40rpx; height: 40rpx; border-radius: 50%; border: 1px solid #ddd;"></view>
</view>
<view v-if="availableCoupons.length===0" style="text-align:center; padding-top: 100rpx; color: #999;">
暂无可用优惠券
</view>
<view style="height:40rpx;"></view>
</scroll-view>
<view style="padding: 20rpx 40rpx; background: #fff;" v-if="availableCoupons.length>0">
<view @tap="selectCoupon(null)" style="width: 100%; height: 80rpx; background: linear-gradient(90deg, #e3ff96, #a6ffea); font-size: 30rpx; font-weight: 700; line-height: 80rpx; text-align: center; border-radius: 100rpx;">
不使用优惠券
</view>
</view>
</view>
</uni-popup>
</view>
</template>
@ -546,7 +601,9 @@
id: '1',
checked: true
}],
shopRecommend:[]
shopRecommend:[],
availableCoupons: [],
selectedCoupon: null
}
},
components: {
@ -631,6 +688,7 @@
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect();
//this.fetchCoupons();
// sticky offsetstatusBarHeight + 40px
const info = uni.getSystemInfoSync();
this.navBarHeight = info.statusBarHeight + 40;
@ -905,7 +963,9 @@
this.$refs.pintuanGroupPopup.close();
this.groupId = item.id;
this.targetMembers = parseInt(item.targetMembers);
this.selectedCoupon = null;
if(this.chooseWaitType){
this.fetchCoupons();
this.$refs.pintuanPopup.open('bottom');
}
},
@ -936,6 +996,7 @@
if (index == 'pintuan') {
this.isPintuan = true;
this.selectedCoupon = null;
if (this.groupId) {
// Determine best price match given targetMembers
@ -976,6 +1037,7 @@
}
this.selectedGroupRule.groupPriceAndMore = Number(this.selectedGroupRule.groupPrice) + moreBuyPrice
this.fetchCoupons();
this.$refs.pintuanPopup.open('bottom');
} else {
this.isPintuan = false;
@ -1082,7 +1144,8 @@
shopName: this.shopItem.shopName,
shopPhone: this.shopItem.shopPhone || '',
shopAddress: this.shopItem.shopAddress || '',
groupId: this.groupId
groupId: this.groupId,
userCouponId: this.selectedCoupon ? this.selectedCoupon.id : null
};
payload.regionId = JSON.parse(uni.getStorageSync('area')).id
uni.showLoading({ title: '创建订单中...' });
@ -1332,6 +1395,34 @@
});
}
},
fetchCoupons() {
let userId = uni.getStorageSync('id');
if (!userId) return;
let amount = this.selectedGroupRule && this.selectedGroupRule.groupPriceAndMore ? this.selectedGroupRule.groupPriceAndMore : 0;
this.tui.request('/mall/coupon/available', 'GET', {
userId: userId,
applyScene: 1,
regionId:JSON.parse(uni.getStorageSync('area')).id,
amount: amount,
merchantId: this.shopItem.id || '0'
}, false, true).then((res) => {
if (res.code == 200 && res.result) {
this.availableCoupons = res.result;
if (this.selectedCoupon) {
let stillValid = this.availableCoupons.find(c => c.id === this.selectedCoupon.id);
if (!stillValid) this.selectedCoupon = null;
}
}
});
},
selectCoupon(item) {
this.selectedCoupon = item;
this.$refs.couponPopup.close();
},
openCouponPopup() {
this.fetchCoupons();
this.$refs.couponPopup.open('bottom');
},
back() {
uni.navigateBack()
}

103
package1/runErrand/runErrand.vue

@ -217,6 +217,21 @@
{{deliveryFeeCalc.toFixed(2)}}
</view>
</view>
<view style="display: flex;height: 80rpx;line-height: 80rpx;border-top: 1px solid #eee;font-size: 28rpx;font-weight: 700; align-items:center;" @tap="openCouponPopup">
<view style="flex: 1; color: #777; font-size:32rpx;">
优惠券
</view>
<view style="color: #ff5722;" v-if="selectedCoupon">
-{{selectedCoupon.discountAmount.toFixed(2)}}
</view>
<view style="color: #0b9b73;" v-else-if="availableCoupons.length > 0">
{{availableCoupons.length}} 张可用
</view>
<view style="color: #999;" v-else>
无可用券
</view>
<uni-icons type="right" size="14" color="#999" style="margin-left:10rpx;"></uni-icons>
</view>
<view style="display: flex;height: 80rpx;line-height: 100rpx;border-top: 1px solid #eee;font-size: 32rpx;font-weight: 700;margin-bottom: 20rpx;">
<view style="flex: 1;">合计</view>
<view>{{totalAmountCalc.toFixed(2)}}</view>
@ -300,6 +315,41 @@
<img v-if="warnPopup === 'psy'" @tap="$refs.warnPopup.close()" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/e10ad77ca478413a9c53918750ecb932.png" alt="指定配送员" style="width:100%;height:100%;" />
</view>
</uni-popup>
<uni-popup ref="couponPopup" type="bottom" background-color="#F5F8F5">
<view style="width: 100%; height: 800rpx; display: flex; flex-direction: column;">
<view style="height: 100rpx; line-height: 100rpx; text-align: center; font-size: 32rpx; font-weight: bold; border-bottom: 1px solid #eee; position: relative; background: #fff;">
选择优惠券
<uni-icons type="closeempty" size="24" @tap="$refs.couponPopup.close()" style="position: absolute; right: 30rpx; top: 0;"></uni-icons>
</view>
<scroll-view scroll-y style="flex: 1; padding: 20rpx; box-sizing: border-box;">
<view v-for="(item, index) in availableCoupons" :key="index" @tap="selectCoupon(item)"
style="background: #fff; border-radius: 12rpx; padding: 30rpx 20rpx; margin-bottom: 20rpx; display: flex; align-items: center; justify-content: space-between;">
<view style="display: flex; align-items: center; flex: 1;">
<view style="color: #ff5722; font-size: 40rpx; font-weight: bold; width: 140rpx;">
<text style="font-size: 24rpx;"></text>{{item.discountAmount}}
</view>
<view style="flex: 1; display: flex; flex-direction: column; justify-content: center; margin-left: 20rpx;">
<view style="font-size: 28rpx; font-weight: bold; color: #333; margin-bottom: 6rpx;">{{item.couponName}}</view>
<view style="font-size: 22rpx; color: #999;" v-if="item.minAmount > 0">{{item.minAmount}}可用</view>
<view style="font-size: 22rpx; color: #999;" v-else>无门槛使用</view>
</view>
</view>
<uni-icons v-if="selectedCoupon && selectedCoupon.id === item.id" type="checkmarkempty" size="20" color="#0b9b73"></uni-icons>
<view v-else style="width: 40rpx; height: 40rpx; border-radius: 50%; border: 1px solid #ddd;"></view>
</view>
<view v-if="availableCoupons.length===0" style="text-align:center; padding-top: 100rpx; color: #999;">
暂无可用优惠券
</view>
<view style="height:40rpx;"></view>
</scroll-view>
<view style="padding: 20rpx 40rpx; background: #fff;" v-if="availableCoupons.length>0">
<view @tap="selectCoupon(null)" style="width: 100%; height: 80rpx; background: linear-gradient(90deg, #e3ff96, #a6ffea); font-size: 30rpx; font-weight: 700; line-height: 80rpx; text-align: center; border-radius: 100rpx;">
不使用优惠券
</view>
</view>
</view>
</uni-popup>
</view>
</template>
@ -337,7 +387,9 @@
immediateTimeStr: '',
backendTotalAmount: 0,
currentOrderId: '',
warnPopup: ''
warnPopup: '',
availableCoupons: [],
selectedCoupon: null
}
},
components: {
@ -367,17 +419,27 @@
return commission + this.highFloorFeeCalc;
},
totalAmountCalc() {
return this.deliveryFeeCalc;
let total = this.deliveryFeeCalc;
if (this.selectedCoupon) {
total = total - parseFloat(this.selectedCoupon.discountAmount);
}
return total > 0 ? total : 0;
}
},
watch: {
deliveryFeeCalc(newVal, oldVal) {
if (newVal !== oldVal) {
this.fetchCoupons();
}
}
},
onLoad() {
//this.getShopArea()
},
onShow() {
this.getShopArea()
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.initAddress()
const now = new Date();
const startTime = new Date(now);
const endTime = new Date(now);
@ -398,6 +460,34 @@
uni.removeStorageSync('pendingAssignWorker');
},
methods: {
openCouponPopup() {
this.fetchCoupons();
this.$refs.couponPopup.open('bottom');
},
fetchCoupons() {
let userId = uni.getStorageSync('id');
if (!userId) return;
let amount = this.deliveryFeeCalc;
this.tui.request('/mall/coupon/available', 'GET', {
userId: userId,
applyScene: 2,
regionId:JSON.parse(uni.getStorageSync('area')).id,
amount: amount,
merchantId: '0'
}, false, true).then((res) => {
if (res.code == 200 && res.result) {
this.availableCoupons = res.result;
if (this.selectedCoupon) {
let stillValid = this.availableCoupons.find(c => c.id === this.selectedCoupon.id);
if (!stillValid) this.selectedCoupon = null;
}
}
});
},
selectCoupon(item) {
this.selectedCoupon = item;
this.$refs.couponPopup.close();
},
getShopArea(){
let that = this
let areaStorage = uni.getStorageSync('area');
@ -715,7 +805,8 @@
getCodes: codes,
getPictures: pics,
regionId: JSON.parse(uni.getStorageSync('area')).id,
deliveryFee: this.deliveryFeeCalc
deliveryFee: this.deliveryFeeCalc,
userCouponId: this.selectedCoupon ? this.selectedCoupon.id : null
};
let mft = this.getMustFinishTime();

Loading…
Cancel
Save