wangfukang 3 weeks ago
parent
commit
ddfa237e68
  1. 69
      package1/buyFood/buyFood.vue
  2. 302
      package1/group/groupBuySingle.vue

69
package1/buyFood/buyFood.vue

@ -191,6 +191,30 @@
</view> </view>
</view> </view>
</view> </view>
<view v-if="groupItem.item.moreBuyData" style="display: flex;padding: 20rpx;background: #f5f5f5;border-radius: 20rpx; margin-bottom:20rpx;"
v-for="(cartItem, index) in groupItem.item.moreBuyData" :key="index">
<view class="goods-img">
<img :src="cartItem.productPicture" alt="">
</view>
<view class="goods-content">
<view class="goods-name">
{{cartItem.productName}}
</view>
<view class="goods-content-center" v-if="cartItem.specs">
<view class="goods-deal1">
{{getSpecDisplayString(cartItem.specs)}}
</view>
</view>
<view class="goods-content-bottom">
<view style="width: 45%;flex:1;">
X{{cartItem.quantity}}
</view>
<view class="pintuan-left-price">
{{cartItem.attributeListPrice | sliceMsg}}
</view>
</view>
</view>
</view>
</block> </block>
<view> <view>
@ -388,6 +412,18 @@
deliveryTimeOp, deliveryTimeOp,
addressList addressList
}, },
filters: {
sliceMsg(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name = newObj[as].specPrice
}
}
return name;
}
},
onLoad(option) { onLoad(option) {
if (option.shopItem) { if (option.shopItem) {
this.shopItem = JSON.parse(decodeURIComponent(option.shopItem)); this.shopItem = JSON.parse(decodeURIComponent(option.shopItem));
@ -408,7 +444,15 @@
computed: { computed: {
goodsAmountCalc() { goodsAmountCalc() {
if (this.isGroupBuy && this.groupItem) { if (this.isGroupBuy && this.groupItem) {
return parseFloat(this.groupItem.groupRule.groupPrice); if(this.groupItem.item.moreBuyData){
let allPrice = parseFloat(this.groupItem.groupRule.groupPrice)
for(let a = 0;a<this.groupItem.item.moreBuyData.length;a++){
allPrice += parseFloat(Number(this.sliceMsg1(this.groupItem.item.moreBuyData[a].attributeListPrice)) * this.groupItem.item.moreBuyData[a].quantity);
}
return parseFloat(allPrice);
}else{
return parseFloat(this.groupItem.groupRule.groupPrice);
}
} else { } else {
return this.cartItems.reduce((acc, curr) => acc + (curr.quantity * parseFloat(curr.price)), 0); return this.cartItems.reduce((acc, curr) => acc + (curr.quantity * parseFloat(curr.price)), 0);
} }
@ -714,16 +758,39 @@
} }
return null; return null;
}, },
sliceMsg1(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name = newObj[as].specPrice
}
}
return name;
},
submitOrderToBackend() { submitOrderToBackend() {
let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem
.isFaceToFace; .isFaceToFace;
let items = []; let items = [];
if (this.isGroupBuy && this.groupItem) { if (this.isGroupBuy && this.groupItem) {
if(this.groupItem.item.moreBuyData){
for(let a = 0;a<this.groupItem.item.moreBuyData.length;a++){
items.push({
productId: this.groupItem.item.moreBuyData[a].id,
specs: '',
price: parseFloat(this.sliceMsg1(this.groupItem.item.moreBuyData[a].attributeListPrice)),
quantity: this.groupItem.item.moreBuyData[a].quantity
});
}
}
items.push({ items.push({
productId: this.groupItem.item.id, productId: this.groupItem.item.id,
productName: this.groupItem.item.productName,
productPicture: this.groupItem.item.productPicture,
specs: JSON.stringify(this.groupItem.specs || {}), specs: JSON.stringify(this.groupItem.specs || {}),
price: parseFloat(this.groupItem.groupRule.groupPrice), price: parseFloat(this.groupItem.groupRule.groupPrice),
isMain:0,
quantity: 1 quantity: 1
}); });
} else { } else {

302
package1/group/groupBuySingle.vue

@ -56,30 +56,37 @@
公告{{shopItem.remark}} 公告{{shopItem.remark}}
</view> </view>
</view> </view>
<view class="pintuan" style="padding: 0;margin-top:20rpx;display: flex;"> <view class="pintuan" style="padding: 0;margin-top:20rpx;display: flex;" v-if="orderListWait.length > 1" @tap="openOrderWait()">
<view class="pintuan-left">
<view class="pintuan-left-img"> <swiper class="zaixian-swiper" vertical circular :autoplay="orderListWait.length > 1"
<img src="/static/images/img/shangpintu.png" alt=""> :interval="onlineWorkerInterval" :duration="onlineWorkerDuration">
</view> <swiper-item v-for="(item,index) in orderListWait" :key="index">
<view class="pintuan-left-box"> <view class="pintuan-left">
<view class="pintuan-left-name"> <view class="pintuan-left-img">
无骨双拼|招牌炸鸡套餐 <img :src="item.productPicture" alt="">
</view>
<view class="pintuan-left-box">
<view class="pintuan-left-name">
{{item.productName}}
</view>
<view class="pintuan-left-price">
拼团<text style="color: red;">{{item.groupPrice}}</text>
</view>
</view>
</view> </view>
<view class="pintuan-left-price"> </swiper-item>
拼团<text style="color: red;">59.90</text>
<view class="pintuan-right">
<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;">{{item.targetMembers - item.currentMembers}}</text>拼成
</view> </view>
</view> </view>
</view> </swiper>
<view class="pintuan-right">
<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;">1</text>拼成
</view>
</view>
</view> </view>
<!-- 分类栏移到goods-list外层position:sticky才能生效 --> <!-- 分类栏移到goods-list外层position:sticky才能生效 -->
<view class="menu-list" id="menuList" <view class="menu-list" id="menuList"
@ -110,7 +117,7 @@
<view class="goods-deal1"> <view class="goods-deal1">
月售 <text> 100+</text> 月售 <text> 100+</text>
</view> </view>
<view class="goods-tag"> <view class="goods-tag" @tap="openOrderWait()">
<view class="pintuan-right-img"> <view class="pintuan-right-img">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png" <img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png"
alt="" /> alt="" />
@ -134,7 +141,7 @@
style="background: rgba(166, 255, 234, 0.3);margin-right: 6%;border: 1px solid rgba(166, 255, 234, 0.5);"> style="background: rgba(166, 255, 234, 0.3);margin-right: 6%;border: 1px solid rgba(166, 255, 234, 0.5);">
直接购买¥{{item.attributeListPrice | sliceMsg}} 直接购买¥{{item.attributeListPrice | sliceMsg}}
</view> </view>
<view class="goods-btn" :style="{'float':groupId != ''?'right':''}" @tap="openPopup('xiadan','pintuan',item)"> <view v-if="item.productGroupBuyPrices != null && item.isMoreBuy != 1" class="goods-btn" :style="{'float':groupId != ''?'right':''}" @tap="openPopup('xiadan','pintuan',item)">
拼团购买¥{{ getGroupPrice(item) }} 拼团购买¥{{ getGroupPrice(item) }}
</view> </view>
</view> </view>
@ -283,10 +290,31 @@
</view> </view>
</view> </view>
</view> </view>
<view class="spec11" v-if="moreBuyList.length > 0 && isPintuan" style="display: flex;">
搭配小食
<view style="flex: 1;text-align: right;">
<uni-number-box v-model="vModelValue" :min="0" @change="changeValue" />
</view>
</view>
<view class="goods-team" v-if="moreBuyList.length > 0 && isPintuan">
<view :class="spec.isChecked ? 'team-check' : 'team1'"
v-for="(spec, sIndex) in moreBuyList" :key="sIndex"
@tap="selectMoreBuy(spec,sIndex)">
<view class="team11">
{{spec.attributeListPrice | sliceMsg}} {{spec.quantity ? spec.quantity : ''}}
</view>
<view class="team11">
{{spec.productName}}
</view>
</view>
</view>
<template <template
v-if="groupId == '' && isPintuan && currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0"> v-if="groupId == '' && isPintuan && currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0">
<view class="spec11"> <view class="spec11" style="margin-top: -15px;">
成团选择 成团选择
</view> </view>
<view class="goods-team"> <view class="goods-team">
@ -302,34 +330,6 @@
</view> </view>
</view> </view>
</view> </view>
<view class="spec11" @tap="$refs.pintuanGroupPopup.open('bottom')">
他们都在拼
<uni-icons type="right" size="12"></uni-icons>
</view>
<!-- 占位假数据展示 -->
<view class="">
<view class="goods-center">
<view class="list-right">
<view class="list-right-img">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png"
alt="" />
<view class="list-weipincheng">+</view>
</view>
<view class="list-right-cha">
<view class="cha11">
二人拼
</view>
<view style="line-height: 20px;padding-left: 5px;">
<text style="color: red;">1</text>拼成
</view>
</view>
</view>
<view class="list-btn" @tap="submitPintuan">
去拼单
</view>
</view>
</view>
</template> </template>
<view style="width: 100%;height: 160rpx;"></view> <view style="width: 100%;height: 160rpx;"></view>
</scroll-view> </scroll-view>
@ -363,86 +363,17 @@
<!-- 拼团和选规格弹窗 --> <!-- 拼团和选规格弹窗 -->
<uni-popup ref="pintuanGroupPopup" background-color="#fff"> <uni-popup ref="pintuanGroupPopup" background-color="#fff">
<view class="car-content"> <view class="car-content">
<view class="car-close" @tap="$refs.pintuanPopup.close()"> <view class="car-close" @tap="$refs.pintuanGroupPopup.close()">
<uni-icons type="close" size="30" color="#fff"></uni-icons> <uni-icons type="close" size="30" color="#fff"></uni-icons>
</view> </view>
<view class="goods-top"> <view class="goods-top">
<view class="goods-img"> 快来加入一起成团吧
<img :src="currentItem.productPicture" alt="" style="border-radius: 10px;">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/6c4ab92a43c842d8bb22035bce1f65cc.png"
alt=""
style="width:30rpx;height:30rpx;position: absolute;top: 0;left: 0;background-size: 100%;" />
</view>
<view class="goods-content">
<view class="goods-name">
{{currentItem.productName}}
</view>
<view class="goods-content-center">
<view class="goods-deal1">
月售 <text> 100+</text>
</view>
</view>
<view class="goods-content-bottom">
<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> </view>
<scroll-view scroll-y style="max-height: 50vh;"> <scroll-view scroll-y style="max-height: 50vh;">
<template <template>
v-if="isPintuan && currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0">
<!-- 占位假数据展示 --> <!-- 占位假数据展示 -->
<view class=""> <view class="">
<view class="goods-center"> <view class="goods-center" v-for="(item, index) in orderListWait" :key="index">
<view class="list-right">
<view class="list-right-img">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png"
alt="" />
<view class="list-weipincheng">+</view>
</view>
<view class="list-right-cha">
<view class="cha11">
二人拼
</view>
<view style="line-height: 20px;padding-left: 5px;">
<text style="color: red;">1</text>拼成
</view>
</view>
</view>
<view class="list-btn" @tap="submitPintuan">
去拼单
</view>
</view>
</view>
<view class="">
<view class="goods-center">
<view class="list-right">
<view class="list-right-img">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png"
alt="" />
<view class="list-weipincheng">+</view>
</view>
<view class="list-right-cha">
<view class="cha11">
二人拼
</view>
<view style="line-height: 20px;padding-left: 5px;">
<text style="color: red;">1</text>拼成
</view>
</view>
</view>
<view class="list-btn" @tap="submitPintuan">
去拼单
</view>
</view>
</view>
<view class="">
<view class="goods-center">
<view class="list-right"> <view class="list-right">
<view class="list-right-img"> <view class="list-right-img">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png" <img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png"
@ -451,10 +382,10 @@
</view> </view>
<view class="list-right-cha"> <view class="list-right-cha">
<view class="cha11"> <view class="cha11">
人拼 {{item.targetMembers}}人拼
</view> </view>
<view style="line-height: 20px;padding-left: 5px;"> <view style="line-height: 20px;padding-left: 5px;">
<text style="color: red;">1</text>拼成 <text style="color: red;">{{item.targetMembers - item.currentMembers}}</text>拼成
</view> </view>
</view> </view>
</view> </view>
@ -551,13 +482,18 @@
productItem: [], productItem: [],
tuanzhangOrder:{}, tuanzhangOrder:{},
cartItems: [], cartItems: [],
moreBuyData:[],
vModelValue:0,
currentItem: {}, currentItem: {},
checkMoreBuyIndex:'',
parsedSpecs: [], parsedSpecs: [],
moreBuyList:[],
selectedGroupRule: {}, selectedGroupRule: {},
pageNum: 1, pageNum: 1,
total: 1, total: 1,
// sticky top // sticky top
navBarHeight: 0, navBarHeight: 0,
orderListWait:[],
// //
menuListOffsetTop: 0, menuListOffsetTop: 0,
lastScrollTop: 0, lastScrollTop: 0,
@ -567,7 +503,7 @@
shopId: '', shopId: '',
delFlag: 1, delFlag: 1,
pageNum: 1, pageNum: 1,
pageSize: '10', pageSize: '100',
categoryId: '' categoryId: ''
}, },
menuButtonInfo: {}, menuButtonInfo: {},
@ -577,6 +513,8 @@
targetMembers: 2, targetMembers: 2,
backendTotalAmount: 0, backendTotalAmount: 0,
currentOrderId: '', currentOrderId: '',
onlineWorkerInterval:2500,
onlineWorkerDuration:500,
menuList: [{ menuList: [{
categoryName: '猜你喜欢', categoryName: '猜你喜欢',
id: '', id: '',
@ -690,6 +628,7 @@
} }
this.getCategory(this.shopItem.id); this.getCategory(this.shopItem.id);
this.getProduct(''); this.getProduct('');
this.getOrderWait();
}, },
onShow() { onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect(); this.menuButtonInfo = uni.getMenuButtonBoundingClientRect();
@ -715,12 +654,16 @@
that.tui.request("/app/product/getShareList", "POST", this.searchForm, false, false).then((res) => { that.tui.request("/app/product/getShareList", "POST", this.searchForm, false, false).then((res) => {
that.loadStatus = 'nomore'; that.loadStatus = 'nomore';
if (res.code == 200) { if (res.code == 200) {
if (that.searchForm.pageNum == 1) { that.productItem = res.result.records;
that.productItem = res.result.records; for(let i = 0;i<that.productItem.length;i++){
} else { if(that.productItem[i].isMoreBuy == 1){
that.productItem = [...that.productItem, ...res.result.records]; //
that.productItem[i].isChecked = false
that.moreBuyList.push(that.productItem[i])
}
} }
console.log(res.result.records)
that.total = res.result.pages; // pages = that.total = res.result.pages; // pages =
that.pageNum = that.searchForm.pageNum; that.pageNum = that.searchForm.pageNum;
// //
@ -790,6 +733,28 @@
duration: 200 duration: 200
}); });
}, },
openOrderWait(){
this.$refs.pintuanGroupPopup.open('bottom')
},
getOrderWait(){
let that = this
this.tui.request("/mall/order/getMallOrderGroupByShopId", "POST", {
shopId:this.shopItem.id,
status:0,
isFace:0,
}, false, false).then((res) => {
that.loadStatus = 'nomore';
if (res.code == 200) {
that.orderListWait = res.result;
that.$forceUpdate();
} else {
that.tui.toast(res.message);
return;
}
uni.hideLoading();
}).catch((res) => {});
},
openPopup(type, index, item) { openPopup(type, index, item) {
if (type == 'car') { if (type == 'car') {
this.$refs.carPopup.open('bottom') this.$refs.carPopup.open('bottom')
@ -896,6 +861,13 @@
} }
// Pack data for checkout // Pack data for checkout
this.currentItem.moreBuyData = []
for(let i = 0;i<this.moreBuyData.length;i++){
if(this.moreBuyData[i].quantity != undefined && this.moreBuyData[i].quantity > 0){
this.currentItem.moreBuyData.push(this.moreBuyData[i])
}
}
let goData = { let goData = {
item: this.currentItem, item: this.currentItem,
groupRule: this.selectedGroupRule, groupRule: this.selectedGroupRule,
@ -905,6 +877,7 @@
isFaceToFace: this.groupId ? this.isFaceToFaceGroup : (isFaceToFace || false) isFaceToFace: this.groupId ? this.isFaceToFaceGroup : (isFaceToFace || false)
}; };
// Directly navigate to checkout // Directly navigate to checkout
console.log("111",this.currentItem)
uni.navigateTo({ uni.navigateTo({
url: '/package1/buyFood/buyFood?item=' + encodeURIComponent(JSON.stringify(goData)) + url: '/package1/buyFood/buyFood?item=' + encodeURIComponent(JSON.stringify(goData)) +
'&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' + '&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' +
@ -926,7 +899,7 @@
userId: uni.getStorageSync('id') || 'test-user123', userId: uni.getStorageSync('id') || 'test-user123',
shopId: this.shopItem.id, shopId: this.shopItem.id,
deliveryType: this.tuanzhangOrder.deliveryType, deliveryType: this.tuanzhangOrder.deliveryType,
packageFee: packageFee, packageFee: this.tuanzhangOrder.deliveryType == 1 ? this.packageFee : 0,
remark: '', remark: '',
items: items, items: items,
receiverName: '', receiverName: '',
@ -937,7 +910,7 @@
shopAddress: this.shopItem.shopAddress || '', shopAddress: this.shopItem.shopAddress || '',
groupId: this.groupId groupId: this.groupId
}; };
payload.regionId = JSON.parse(uni.getStorageSync('area')).id
uni.showLoading({ title: '创建订单中...' }); uni.showLoading({ title: '创建订单中...' });
this.tui.request("/mall/order/create", "POST", payload, false, false).then(res => { this.tui.request("/mall/order/create", "POST", payload, false, false).then(res => {
uni.hideLoading(); uni.hideLoading();
@ -1051,6 +1024,48 @@
let bestRule = validPrices.reduce((max, obj) => (obj.groupCount > max.groupCount ? obj : max)); let bestRule = validPrices.reduce((max, obj) => (obj.groupCount > max.groupCount ? obj : max));
return parseFloat(bestRule.groupPrice).toFixed(2); return parseFloat(bestRule.groupPrice).toFixed(2);
}, },
selectMoreBuy(item,index){
this.checkMoreBuyIndex = item.id
this.moreBuyList[index].isChecked = !this.moreBuyList[index].isChecked;
let isHas = false
let index1 = ''
for(let i = 0;i<this.moreBuyList.length;i++){
if(this.moreBuyList[i].id != item.id && this.moreBuyList[index].isChecked){
this.moreBuyList[i].isChecked = false
}
}
for(let i = 0;i<this.moreBuyData.length;i++){
if(this.moreBuyData[i].id == this.moreBuyList[index].id){
isHas = true
index1 = i
this.vModelValue = this.moreBuyData[i].quantity ? this.moreBuyData[i].quantity : 0
this.moreBuyList[index].quantity = this.moreBuyData[i].quantity ? this.moreBuyData[i].quantity : 0
}
}
if(!isHas){
this.vModelValue = 0
}
if(this.moreBuyList[index].isChecked && !isHas){
item.quantity = 0
this.moreBuyData.push(item)
}
if(!this.moreBuyList[index].isChecked && isHas){
this.moreBuyData.splice(index1,1)
}
},
changeValue(value) {
for(let i = 0;i<this.moreBuyList.length;i++){
if(this.moreBuyList[i].id == this.checkMoreBuyIndex){
this.moreBuyList[i].quantity = value
}
}
for(let i = 0;i<this.moreBuyData.length;i++){
if(this.moreBuyData[i].id == this.checkMoreBuyIndex){
this.moreBuyData[i].quantity = value
}
}
},
wxPayment() { wxPayment() {
let that = this; let that = this;
if (!this.currentOrderId || !this.backendTotalAmount) return; if (!this.currentOrderId || !this.backendTotalAmount) return;
@ -1610,7 +1625,7 @@
.team1 { .team1 {
width: 77px; width: 77px;
height: 83px; height: 63px;
background: #eee; background: #eee;
border-radius: 10px; border-radius: 10px;
font-size: 13px; font-size: 13px;
@ -1622,7 +1637,7 @@
.team-check { .team-check {
width: 77px; width: 77px;
height: 83px; height: 63px;
background: rgba(166, 255, 234, 1); background: rgba(166, 255, 234, 1);
border-radius: 10px; border-radius: 10px;
font-size: 13px; font-size: 13px;
@ -1631,8 +1646,21 @@
float: left; float: left;
margin-right: 20px; margin-right: 20px;
} }
.zaixian-swiper{
flex: 1;
height: 76rpx;
}
.zaixian-item{
height: 76rpx;
line-height: 76rpx;
font-size: 24rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.team11 { .team11 {
height: 13px;
margin-top: 10px; margin-top: 10px;
} }

Loading…
Cancel
Save