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 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>
<view>
@ -388,6 +412,18 @@
deliveryTimeOp,
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) {
if (option.shopItem) {
this.shopItem = JSON.parse(decodeURIComponent(option.shopItem));
@ -408,7 +444,15 @@
computed: {
goodsAmountCalc() {
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 {
return this.cartItems.reduce((acc, curr) => acc + (curr.quantity * parseFloat(curr.price)), 0);
}
@ -714,16 +758,39 @@
}
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() {
let isJoiningFaceToFace = this.isGroupBuy && this.groupItem && this.groupItem.groupId && this.groupItem
.isFaceToFace;
let items = [];
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({
productId: this.groupItem.item.id,
productName: this.groupItem.item.productName,
productPicture: this.groupItem.item.productPicture,
specs: JSON.stringify(this.groupItem.specs || {}),
price: parseFloat(this.groupItem.groupRule.groupPrice),
isMain:0,
quantity: 1
});
} else {

302
package1/group/groupBuySingle.vue

@ -56,30 +56,37 @@
公告{{shopItem.remark}}
</view>
</view>
<view class="pintuan" style="padding: 0;margin-top:20rpx;display: flex;">
<view class="pintuan-left">
<view class="pintuan-left-img">
<img src="/static/images/img/shangpintu.png" alt="">
</view>
<view class="pintuan-left-box">
<view class="pintuan-left-name">
无骨双拼|招牌炸鸡套餐
<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 class="pintuan-left">
<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 class="pintuan-left-price">
拼团<text style="color: red;">59.90</text>
</swiper-item>
<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 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>
</swiper>
</view>
<!-- 分类栏移到goods-list外层position:sticky才能生效 -->
<view class="menu-list" id="menuList"
@ -110,7 +117,7 @@
<view class="goods-deal1">
月售 <text> 100+</text>
</view>
<view class="goods-tag">
<view class="goods-tag" @tap="openOrderWait()">
<view class="pintuan-right-img">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/94f91382e76c4f289d53fbf858e8732b.png"
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);">
直接购买¥{{item.attributeListPrice | sliceMsg}}
</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) }}
</view>
</view>
@ -284,9 +291,30 @@
</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
v-if="groupId == '' && isPintuan && currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0">
<view class="spec11">
<view class="spec11" style="margin-top: -15px;">
成团选择
</view>
<view class="goods-team">
@ -302,34 +330,6 @@
</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>
<view style="width: 100%;height: 160rpx;"></view>
</scroll-view>
@ -363,86 +363,17 @@
<!-- 拼团和选规格弹窗 -->
<uni-popup ref="pintuanGroupPopup" background-color="#fff">
<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>
</view>
<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>
<scroll-view scroll-y style="max-height: 50vh;">
<template
v-if="isPintuan && currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0">
<template>
<!-- 占位假数据展示 -->
<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-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="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"
@ -451,10 +382,10 @@
</view>
<view class="list-right-cha">
<view class="cha11">
人拼
{{item.targetMembers}}人拼
</view>
<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>
@ -551,13 +482,18 @@
productItem: [],
tuanzhangOrder:{},
cartItems: [],
moreBuyData:[],
vModelValue:0,
currentItem: {},
checkMoreBuyIndex:'',
parsedSpecs: [],
moreBuyList:[],
selectedGroupRule: {},
pageNum: 1,
total: 1,
// sticky top
navBarHeight: 0,
orderListWait:[],
//
menuListOffsetTop: 0,
lastScrollTop: 0,
@ -567,7 +503,7 @@
shopId: '',
delFlag: 1,
pageNum: 1,
pageSize: '10',
pageSize: '100',
categoryId: ''
},
menuButtonInfo: {},
@ -577,6 +513,8 @@
targetMembers: 2,
backendTotalAmount: 0,
currentOrderId: '',
onlineWorkerInterval:2500,
onlineWorkerDuration:500,
menuList: [{
categoryName: '猜你喜欢',
id: '',
@ -690,6 +628,7 @@
}
this.getCategory(this.shopItem.id);
this.getProduct('');
this.getOrderWait();
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect();
@ -715,12 +654,16 @@
that.tui.request("/app/product/getShareList", "POST", this.searchForm, false, false).then((res) => {
that.loadStatus = 'nomore';
if (res.code == 200) {
if (that.searchForm.pageNum == 1) {
that.productItem = res.result.records;
} else {
that.productItem = [...that.productItem, ...res.result.records];
that.productItem = res.result.records;
for(let i = 0;i<that.productItem.length;i++){
if(that.productItem[i].isMoreBuy == 1){
//
that.productItem[i].isChecked = false
that.moreBuyList.push(that.productItem[i])
}
}
console.log(res.result.records)
that.total = res.result.pages; // pages =
that.pageNum = that.searchForm.pageNum;
//
@ -790,6 +733,28 @@
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) {
if (type == 'car') {
this.$refs.carPopup.open('bottom')
@ -896,6 +861,13 @@
}
// 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 = {
item: this.currentItem,
groupRule: this.selectedGroupRule,
@ -905,6 +877,7 @@
isFaceToFace: this.groupId ? this.isFaceToFaceGroup : (isFaceToFace || false)
};
// Directly navigate to checkout
console.log("111",this.currentItem)
uni.navigateTo({
url: '/package1/buyFood/buyFood?item=' + encodeURIComponent(JSON.stringify(goData)) +
'&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' +
@ -926,7 +899,7 @@
userId: uni.getStorageSync('id') || 'test-user123',
shopId: this.shopItem.id,
deliveryType: this.tuanzhangOrder.deliveryType,
packageFee: packageFee,
packageFee: this.tuanzhangOrder.deliveryType == 1 ? this.packageFee : 0,
remark: '',
items: items,
receiverName: '',
@ -937,7 +910,7 @@
shopAddress: this.shopItem.shopAddress || '',
groupId: this.groupId
};
payload.regionId = JSON.parse(uni.getStorageSync('area')).id
uni.showLoading({ title: '创建订单中...' });
this.tui.request("/mall/order/create", "POST", payload, false, false).then(res => {
uni.hideLoading();
@ -1051,6 +1024,48 @@
let bestRule = validPrices.reduce((max, obj) => (obj.groupCount > max.groupCount ? obj : max));
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() {
let that = this;
if (!this.currentOrderId || !this.backendTotalAmount) return;
@ -1610,7 +1625,7 @@
.team1 {
width: 77px;
height: 83px;
height: 63px;
background: #eee;
border-radius: 10px;
font-size: 13px;
@ -1622,7 +1637,7 @@
.team-check {
width: 77px;
height: 83px;
height: 63px;
background: rgba(166, 255, 234, 1);
border-radius: 10px;
font-size: 13px;
@ -1631,8 +1646,21 @@
float: left;
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 {
height: 13px;
margin-top: 10px;
}

Loading…
Cancel
Save