wangfukang 3 weeks ago
parent
commit
e4eb2e184c
  1. 27
      package1/buyFood/buyFood.vue
  2. 184
      package1/group/groupBuySingle.vue

27
package1/buyFood/buyFood.vue

@ -179,7 +179,7 @@
</view>
<view class="goods-content-bottom">
<view style="width: 45%;flex:1;">
X2
X1
</view>
<view class="pintuan-left-price">
<view
@ -667,14 +667,17 @@
signType: res.signType,
paySign: res.paySign,
success: function(res2) {
that.$refs.payPopup.close();
uni.showToast({
title: '支付成功',
icon: 'success'
});
setTimeout(() => {
uni.showToast({ title: '支付成功', icon: 'success' });
that.tui.request("/api/wechat/pay/paySuccess", "POST", {
outTradeNo: that.currentOrderId
}, false, false).then((res3) => {
if(res3.code == 200){
that.handlePaymentSuccess();
}, 1500);
}else{
that.tui.toast("订单创建失败,请联系客服处理");
}
})
},
fail: function(err) {
that.tui.toast("支付失败或取消");
@ -717,19 +720,15 @@
this.$refs.pintuanPopup.open('center');
} else if (isJoining) {
uni.redirectTo({
url: '/package1/order/pendGroup?groupId=' + this.groupItem.groupId
url: '/package1/order/orderDetail?id=' + this.currentOrderId
});
}
}
},
onPintuanPopupChange(e) {
if (!e.show && this.isPaymentSuccessGroupInitiate) {
// pendGroup
let groupId = this.createdOrderInfo?.groupId || this.createdOrderInfo?.groupDeliveryOrderId || this.createdOrderInfo?.id || this.currentOrderId;
uni.redirectTo({
url: `/package1/order/pendGroup?groupId=${groupId}`
url: '/package1/order/orderDetail?id=' + this.currentOrderId
});
}
},
getMustFinishTime() {
if (!this.formData.deliveryTime || this.formData.deliveryTime === '自动送达' || this.formData.deliveryTime ===

184
package1/group/groupBuySingle.vue

@ -56,11 +56,12 @@
公告{{shopItem.remark}}
</view>
</view>
<view class="pintuan" style="padding: 0;margin-top:20rpx;display: flex;" v-if="orderListWait.length > 1" @tap="openOrderWait()">
<view class="pintuan" style="padding: 0;margin-top:20rpx;display: flex;" v-if="orderListWait.length > 1" @tap="openOrderWait('')">
<swiper class="zaixian-swiper" vertical circular :autoplay="orderListWait.length > 1"
:interval="onlineWorkerInterval" :duration="onlineWorkerDuration">
<swiper-item v-for="(item,index) in orderListWait" :key="index">
<view>
<view class="pintuan-left">
<view class="pintuan-left-img">
<img :src="item.productPicture" alt="">
@ -74,8 +75,6 @@
</view>
</view>
</view>
</swiper-item>
<view class="pintuan-right">
<view class="pintuan-right-img">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png"
@ -86,6 +85,8 @@
<text style="color: red;">{{item.targetMembers - item.currentMembers}}</text>拼成
</view>
</view>
</view>
</swiper-item>
</swiper>
</view>
<!-- 分类栏移到goods-list外层position:sticky才能生效 -->
@ -117,14 +118,14 @@
<view class="goods-deal1">
月售 <text> 100+</text>
</view>
<view class="goods-tag" @tap="openOrderWait()">
<view class="goods-tag" @tap.stop="openOrderWait(item)" v-if="item.orderListWait != undefined && item.orderListWait.length > 0">
<view class="pintuan-right-img">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png"
alt="" />
<view class="weipincheng">+</view>
</view>
<view class="pintuan-right-cha">
<text style="color: red;">12</text>拼成
<text style="color: red;">{{item.minGroupCount}}</text>拼成
</view>
</view>
</view>
@ -268,10 +269,6 @@
<view style="font-size: 28rpx;line-height: 54rpx;margin-right: 20rpx;">
{{currentItem.attributeListPrice | sliceMsg}}
</view>
<view class="pintuan-left-price"
v-if="currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0">
拼团<text style="color: red;">{{currentItem.productGroupBuyPrices | slicePrice}}</text>
</view>
</view>
</view>
</view>
@ -337,20 +334,20 @@
<view v-if="isPintuan" class="pintuan1">
<template v-if="!groupId">
<view class="pintuan2" style="border-bottom-left-radius: 50px;border-top-left-radius: 50px;"
@tap="submitPintuan(true)">
@tap.stop="submitPintuan(true)">
面对面团
</view>
<view class="pintuan2"
style="background: rgba(0, 35, 28, 1);border-bottom-right-radius: 50px;border-top-right-radius: 50px;color: rgba(166, 255, 234, 1);"
@tap="submitPintuan(false)">
发起拼团{{selectedGroupRule && selectedGroupRule.groupPrice ? parseFloat(selectedGroupRule.groupPrice).toFixed(2) : '0.00'}}
@tap.stop="submitPintuan(false)">
发起拼团{{selectedGroupRule && selectedGroupRule.groupPrice ? parseFloat(selectedGroupRule.groupPriceAndMore).toFixed(2) : '0.00'}}
</view>
</template>
<template v-else>
<view class="pintuan2"
style="width: 100%; border-radius: 50px; "
@tap="submitPintuan(false)">
参与拼团{{selectedGroupRule && selectedGroupRule.groupPrice ? parseFloat(selectedGroupRule.groupPrice).toFixed(2) : '0.00'}}
@tap.stop="submitPintuan(false)">
参与拼团{{selectedGroupRule && selectedGroupRule.groupPriceAndMore ? parseFloat(selectedGroupRule.groupPriceAndMore).toFixed(2) : '0.00'}}
</view>
</template>
</view>
@ -369,6 +366,9 @@
<view class="goods-top">
快来加入一起成团吧
</view>
<view class="goods-top">
可以选取任意拼团商品下单
</view>
<scroll-view scroll-y style="max-height: 50vh;">
<template>
<!-- 占位假数据展示 -->
@ -389,7 +389,7 @@
</view>
</view>
</view>
<view class="list-btn" @tap="submitPintuan">
<view class="list-btn" @tap.stop="chooseOrderWait(item)">
去拼单
</view>
</view>
@ -417,7 +417,10 @@
若拼团失败将会为您自动退款
</view>
<view v-if="groupId != '' && isFaceToFaceGroup" style="height: 40rpx;text-align: center;color: red;">
包含打包费 {{currentItem.lunchBox}} 配送费(均摊) {{tuanzhangOrder.deliveryFee}}
配送费(均摊) {{tuanzhangOrder.deliveryFee}}
</view>
<view v-if="groupdeliveryType == 1" style="height: 40rpx;text-align: center;color: red;">
包含打包费 {{currentItem.lunchBox}}
</view>
</view>
<view class="box1" style="display: flex;padding: 40rpx;">
@ -491,6 +494,7 @@
selectedGroupRule: {},
pageNum: 1,
total: 1,
chooseWaitType:false,
// sticky top
navBarHeight: 0,
orderListWait:[],
@ -507,6 +511,7 @@
categoryId: ''
},
menuButtonInfo: {},
groupdeliveryType:'',
isPintuan: true,
groupId: '',
isFaceToFaceGroup: false,
@ -628,7 +633,6 @@
}
this.getCategory(this.shopItem.id);
this.getProduct('');
this.getOrderWait();
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect();
@ -663,6 +667,8 @@
}
}
//
that.getOrderWait();
that.total = res.result.pages; // pages =
that.pageNum = that.searchForm.pageNum;
@ -733,7 +739,65 @@
duration: 200
});
},
openOrderWait(){
openOrderWait(item){
this.chooseWaitType = false
if(item != ''){
this.chooseWaitType = true
this.orderListWait = item.orderListWait
this.currentItem = item;
// Parse specifications
this.parsedSpecs = [];
if (item.attributeList && item.attributeList !== '{}') {
try {
let attrs = typeof item.attributeList === 'string' ? JSON.parse(item.attributeList) : item
.attributeList;
for (let key in attrs) {
if (attrs[key] && attrs[key].title && attrs[key].title.length > 0) {
this.parsedSpecs.push({
name: key,
options: attrs[key].title,
selected: attrs[key].title[0] // Default select first
});
}
}
} catch (e) {
console.error("Failed to parse specifications", e);
}
}
this.isPintuan = true;
if (this.groupId) {
// Determine best price match given targetMembers
let prices = item.productGroupBuyPrices || [];
let validPrices = prices.filter(p => p.groupCount <= this.targetMembers);
if (validPrices.length > 0) {
this.selectedGroupRule = validPrices.reduce((max, obj) => (obj.groupCount > max.groupCount ? obj : max));
this.selectedGroupRule.groupPriceAndMore = this.selectedGroupRule.groupPrice
} else if (prices.length > 0) {
this.selectedGroupRule = prices.reduce((prev, curr) => (prev.groupCount < curr.groupCount ? prev : curr));
this.selectedGroupRule.groupPriceAndMore = this.selectedGroupRule.groupPrice
} else {
this.selectedGroupRule = {};
}
} else {
// Normal init
if (item.productGroupBuyPrices && item.productGroupBuyPrices.length > 0) {
this.selectedGroupRule = item.productGroupBuyPrices[0];
this.selectedGroupRule.groupPriceAndMore = this.selectedGroupRule.groupPrice
} else {
this.selectedGroupRule = {};
}
}
let moreBuyPrice = 0
for(let i = 0;i<this.moreBuyList.length;i++){
if(this.moreBuyList[i].quantity > 0){
moreBuyPrice += Number((Number(this.moreBuyList[i].quantity) * Number(this.sliceMsg2(this.moreBuyList[i].attributeListPrice))).toFixed(2))
}
}
this.selectedGroupRule.groupPriceAndMore = Number(this.selectedGroupRule.groupPrice) + moreBuyPrice
}
this.$refs.pintuanGroupPopup.open('bottom')
},
getOrderWait(){
@ -747,6 +811,21 @@
that.loadStatus = 'nomore';
if (res.code == 200) {
that.orderListWait = res.result;
for(let i = 0;i<that.productItem.length;i++){
that.productItem[i].orderListWait = []
if(that.orderListWait !=null){
that.productItem[i].minGroupCount = that.orderListWait[0].targetMembers - that.orderListWait[0].currentMembers
for(let y = 0;y<that.orderListWait.length;y++){
if(that.productItem[i].id == that.orderListWait[y].productId){
if(that.productItem[i].minGroupCount > (that.orderListWait[y].targetMembers - that.orderListWait[y].currentMembers)){
that.productItem[i].minGroupCount = that.orderListWait[y].targetMembers - that.orderListWait[y].currentMembers
}
that.productItem[i].orderListWait.push(that.orderListWait[y])
}
}
}
}
that.$forceUpdate();
} else {
that.tui.toast(res.message);
@ -755,6 +834,14 @@
uni.hideLoading();
}).catch((res) => {});
},
chooseOrderWait(item){
this.$refs.pintuanGroupPopup.close();
this.groupId = item.id;
this.targetMembers = parseInt(item.targetMembers);
if(this.chooseWaitType){
this.$refs.pintuanPopup.open('bottom');
}
},
openPopup(type, index, item) {
if (type == 'car') {
this.$refs.carPopup.open('bottom')
@ -789,8 +876,10 @@
let validPrices = prices.filter(p => p.groupCount <= this.targetMembers);
if (validPrices.length > 0) {
this.selectedGroupRule = validPrices.reduce((max, obj) => (obj.groupCount > max.groupCount ? obj : max));
this.selectedGroupRule.groupPriceAndMore = this.selectedGroupRule.groupPrice
} else if (prices.length > 0) {
this.selectedGroupRule = prices.reduce((prev, curr) => (prev.groupCount < curr.groupCount ? prev : curr));
this.selectedGroupRule.groupPriceAndMore = this.selectedGroupRule.groupPrice
} else {
this.selectedGroupRule = {};
}
@ -806,11 +895,20 @@
// Normal init
if (item.productGroupBuyPrices && item.productGroupBuyPrices.length > 0) {
this.selectedGroupRule = item.productGroupBuyPrices[0];
this.selectedGroupRule.groupPriceAndMore = this.selectedGroupRule.groupPrice
} else {
this.selectedGroupRule = {};
}
}
let moreBuyPrice = 0
for(let i = 0;i<this.moreBuyList.length;i++){
if(this.moreBuyList[i].quantity > 0){
moreBuyPrice += Number((Number(this.moreBuyList[i].quantity) * Number(this.sliceMsg2(this.moreBuyList[i].attributeListPrice))).toFixed(2))
}
}
this.selectedGroupRule.groupPriceAndMore = Number(this.selectedGroupRule.groupPrice) + moreBuyPrice
this.$refs.pintuanPopup.open('bottom');
} else {
this.isPintuan = false;
@ -834,6 +932,7 @@
},
selectGroupRule(rule) {
this.selectedGroupRule = rule;
this.selectedGroupRule.groupPriceAndMore = this.selectedGroupRule.groupPrice
},
submitAddToCart() {
let specChoices = {};
@ -892,6 +991,16 @@
price: parseFloat(this.selectedGroupRule && this.selectedGroupRule.groupPrice ? this.selectedGroupRule.groupPrice : 0),
quantity: 1
}];
if(this.currentItem.moreBuyData){
for(let a = 0;a<this.currentItem.moreBuyData.length;a++){
items.push({
productId: this.currentItem.moreBuyData[a].id,
specs: '',
price: parseFloat(this.sliceMsg2(this.currentItem.moreBuyData[a].attributeListPrice)).toFixed(2),
quantity: this.currentItem.moreBuyData[a].quantity
});
}
}
let packageFee = parseFloat(this.currentItem.lunchBox || 0);
@ -899,7 +1008,7 @@
userId: uni.getStorageSync('id') || 'test-user123',
shopId: this.shopItem.id,
deliveryType: this.tuanzhangOrder.deliveryType,
packageFee: this.tuanzhangOrder.deliveryType == 1 ? this.packageFee : 0,
packageFee: this.tuanzhangOrder.deliveryType == 1 ? packageFee : 0,
remark: '',
items: items,
receiverName: '',
@ -916,6 +1025,7 @@
uni.hideLoading();
if (res.success && res.result) {
this.currentOrderId = res.result.id;
this.groupdeliveryType = res.result.deliveryType;
this.backendTotalAmount = res.result.totalAmount;
this.$refs.payPopup.open('bottom');
if (this.$refs.pintuanPopup) this.$refs.pintuanPopup.close();
@ -1054,17 +1164,33 @@
this.moreBuyData.splice(index1,1)
}
},
sliceMsg2(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name = newObj[as].specPrice
}
}
return name;
},
changeValue(value) {
let moreBuyPrice = 0
for(let i = 0;i<this.moreBuyList.length;i++){
if(this.moreBuyList[i].id == this.checkMoreBuyIndex){
this.moreBuyList[i].quantity = value
}
if(this.moreBuyList[i].quantity > 0){
moreBuyPrice += Number((Number(this.moreBuyList[i].quantity) * Number(this.sliceMsg2(this.moreBuyList[i].attributeListPrice))).toFixed(2))
}
}
this.selectedGroupRule.groupPriceAndMore = Number(this.selectedGroupRule.groupPrice) + moreBuyPrice
for(let i = 0;i<this.moreBuyData.length;i++){
if(this.moreBuyData[i].id == this.checkMoreBuyIndex){
this.moreBuyData[i].quantity = value
}
}
this.$forceUpdate()
},
wxPayment() {
let that = this;
@ -1087,9 +1213,19 @@
signType: res.signType,
paySign: res.paySign,
success: function(res2) {
that.$refs.payPopup.close();
uni.showToast({ title: '支付成功', icon: 'success' });
setTimeout(() => { that.$refs.joinSuccessPopup.open('bottom'); }, 1500);
that.tui.request("/api/wechat/pay/paySuccess", "POST", {
outTradeNo: that.currentOrderId
}, false, false).then((res3) => {
if(res3.code == 200){
uni.redirectTo({
url: '/package1/order/orderDetail?id=' + that.currentOrderId + '&groupId=' + that.groupId
});
}else{
that.tui.toast("订单创建失败,请联系客服处理");
}
})
},
fail: function(err) {
that.tui.toast("支付失败或取消");
@ -1648,11 +1784,11 @@
}
.zaixian-swiper{
flex: 1;
height: 76rpx;
height: 126rpx;
}
.zaixian-item{
height: 76rpx;
line-height: 76rpx;
height: 126rpx;
line-height: 126rpx;
font-size: 24rpx;
overflow: hidden;
text-overflow: ellipsis;

Loading…
Cancel
Save