Browse Source

拼团列表

master
tianyi 3 months ago
parent
commit
faf316c9ab
  1. 491
      package1/group/groupBuySingle.vue

491
package1/group/groupBuySingle.vue

@ -2,7 +2,8 @@
<!-- 拼团单一商家 --> <!-- 拼团单一商家 -->
<view class="page1"> <view class="page1">
<!-- 固定顶部导航栏悬浮在背景图之上 --> <!-- 固定顶部导航栏悬浮在背景图之上 -->
<view class="nav-bar" :style="{'padding-top': menuButtonInfo.top +'px','background':lastScrollTop>200?'#fff':''}"> <view class="nav-bar"
:style="{'padding-top': menuButtonInfo.top +'px','background':lastScrollTop>200?'#fff':''}">
<view class="back-btn" @tap="back"> <view class="back-btn" @tap="back">
<uni-icons type="left" size="28"></uni-icons> <uni-icons type="left" size="28"></uni-icons>
</view> </view>
@ -81,14 +82,19 @@
</view> </view>
</view> </view>
<!-- 分类栏移到goods-list外层position:sticky才能生效 --> <!-- 分类栏移到goods-list外层position:sticky才能生效 -->
<view class="menu-list" id="menuList" :style="{'top': navBarHeight + 'px','background':lastScrollTop>200?'#fff':''}"> <view class="menu-list" id="menuList"
<view class="menu1" @tap="checkTab(index)" v-for="(item,index) in menuList" :key="index" :style="{'font-size':item.checked?'40rpx':'30rpx','color':item.checked?'rgba(0, 35, 28, 1)':'#777'}"> :style="{'top': navBarHeight + 'px','background':lastScrollTop>200?'#fff':''}">
<view class="menu1" @tap="checkTab(index)" v-for="(item,index) in menuList" :key="index"
:style="{'font-size':item.checked?'40rpx':'30rpx','color':item.checked?'rgba(0, 35, 28, 1)':'#777'}">
<view style="width: 90px;">{{item.categoryName}}</view> <view style="width: 90px;">{{item.categoryName}}</view>
<img v-if="item.checked" class="checked-img" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4bb5fc7725cb4a7a84d1d3a15f05b39c.png" alt="" /> <img v-if="item.checked" class="checked-img"
src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4bb5fc7725cb4a7a84d1d3a15f05b39c.png"
alt="" />
</view> </view>
</view> </view>
<view class="goods-list"> <view class="goods-list">
<view class="goods-member" v-for="(item,index) in productItem" :key="index" @tap="goDetail('product',item)"> <view class="goods-member" v-for="(item,index) in productItem" :key="index"
@tap="goDetail('product',item)">
<view class="goods-top"> <view class="goods-top">
<view class="goods-img"> <view class="goods-img">
<img :src="item.productPicture" alt="" style="border-radius: 10px;"> <img :src="item.productPicture" alt="" style="border-radius: 10px;">
@ -139,13 +145,15 @@
<view style="width: 100%;height: 160rpx;"></view> <view style="width: 100%;height: 160rpx;"></view>
<view class="bottom"> <view class="bottom">
<view class="bottom-left"> <view class="bottom-left">
<view style="position: relative;width: 60rpx;height: 80rpx;margin-top: 20rpx;" @tap="openPopup('car','','')"> <view style="position: relative;width: 60rpx;height: 80rpx;margin-top: 20rpx;"
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/60db52398a65459e9541881c926986a4.png" alt="" /> @tap="openPopup('car','','')">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/60db52398a65459e9541881c926986a4.png"
alt="" />
<view class="bottom-dot" v-if="cartTotalCount > 0">{{cartTotalCount}}</view> <view class="bottom-dot" v-if="cartTotalCount > 0">{{cartTotalCount}}</view>
</view> </view>
<view class="bottom-price">{{cartTotalPrice}}</view> <view class="bottom-price">{{cartTotalPrice}}</view>
</view> </view>
<view class="bottom-right" @tap="submitCartCheckout"> <view class="bottom-right" @tap="submitCartCheckout">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/d93d893296ed46ea99cfd0e8e2835eaa.png" alt="" /> <img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/d93d893296ed46ea99cfd0e8e2835eaa.png" alt="" />
</view> </view>
</view> </view>
@ -162,9 +170,11 @@
</view> </view>
<scroll-view scroll-y style="max-height: 400rpx;"> <scroll-view scroll-y style="max-height: 400rpx;">
<view class="goods-top" style="padding: 10px 0;" v-for="(cartItem, index) in cartItems" :key="index"> <view class="goods-top" style="padding: 10px 0;" v-for="(cartItem, index) in cartItems"
:key="index">
<view class="goods-img" style="width: 120rpx;height: 120rpx;"> <view class="goods-img" style="width: 120rpx;height: 120rpx;">
<img :src="cartItem.item.productPicture" alt="" style="border-radius: 10px;width:100%;height:100%;"> <img :src="cartItem.item.productPicture" alt=""
style="border-radius: 10px;width:100%;height:100%;">
</view> </view>
<view class="goods-content" style="padding-left: 20rpx;"> <view class="goods-content" style="padding-left: 20rpx;">
<view class="goods-name"> <view class="goods-name">
@ -172,15 +182,18 @@
</view> </view>
<view class="goods-content-center"> <view class="goods-content-center">
<view class="goods-deal1" v-if="cartItem.specs"> <view class="goods-deal1" v-if="cartItem.specs">
<text style="color: #999; font-size: 20rpx;">已选规格: {{getSpecDisplayString(cartItem.specs)}}</text> <text style="color: #999; font-size: 20rpx;">已选规格:
{{getSpecDisplayString(cartItem.specs)}}</text>
</view> </view>
</view> </view>
<view class="goods-content-bottom" style="margin-top: 10rpx;"> <view class="goods-content-bottom" style="margin-top: 10rpx;">
<view style="font-size: 28rpx;line-height: 54rpx;margin-right: 20rpx;flex: 1;color: red;"> <view
style="font-size: 28rpx;line-height: 54rpx;margin-right: 20rpx;flex: 1;color: red;">
{{cartItem.price}} {{cartItem.price}}
</view> </view>
<view class="goods-num"> <view class="goods-num">
<view class="num-plus" style="background: #999;color: #fff;" @tap="adjustCart(cartItem.cartId, -1)"> <view class="num-plus" style="background: #999;color: #fff;"
@tap="adjustCart(cartItem.cartId, -1)">
- -
</view> </view>
<view class="num"> <view class="num">
@ -199,25 +212,29 @@
<view class="bottom" style="padding-bottom: 10px;"> <view class="bottom" style="padding-bottom: 10px;">
<view class="bottom-left"> <view class="bottom-left">
<view style="width: 60rpx;height: 80rpx;margin-top: 10rpx;" @tap="$refs.carPopup.close()"> <view style="width: 60rpx;height: 80rpx;margin-top: 10rpx;" @tap="$refs.carPopup.close()">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/60db52398a65459e9541881c926986a4.png" alt="" /> <img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/60db52398a65459e9541881c926986a4.png"
alt="" />
</view> </view>
<view class="bottom-price" style="line-height: 24px;"> <view class="bottom-price" style="line-height: 24px;">
<view>{{cartTotalPrice}}</view> <view>{{cartTotalPrice}}</view>
</view> </view>
</view> </view>
<view class="bottom-right" @tap="submitCartCheckout"> <view class="bottom-right" @tap="submitCartCheckout">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/d93d893296ed46ea99cfd0e8e2835eaa.png" alt="" /> <img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/d93d893296ed46ea99cfd0e8e2835eaa.png"
alt="" />
</view> </view>
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<!-- 警告弹出层 --> <!-- 警告弹出层 -->
<uni-popup ref="warnPopup" background-color="#fff"> <uni-popup ref="warnPopup" background-color="#fff">
<view class="warnImg"> <view class="warnImg">
<img @tap="$refs.warnPopup.close()" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4996043b3987401794b974d359429b8e.png" alt="购物车是空的" style="width:300px;height:370px;" /> <img @tap="$refs.warnPopup.close()"
</view> src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4996043b3987401794b974d359429b8e.png"
</uni-popup> alt="购物车是空的" style="width:300px;height:370px;" />
</view>
</uni-popup>
<!-- 拼团和选规格弹窗 --> <!-- 拼团和选规格弹窗 -->
<uni-popup ref="pintuanPopup" background-color="#fff"> <uni-popup ref="pintuanPopup" background-color="#fff">
<view class="car-content"> <view class="car-content">
@ -244,8 +261,9 @@
<view style="font-size: 28rpx;line-height: 54rpx;margin-right: 20rpx;"> <view style="font-size: 28rpx;line-height: 54rpx;margin-right: 20rpx;">
{{currentItem.attributeListPrice | sliceMsg}} {{currentItem.attributeListPrice | sliceMsg}}
</view> </view>
<view class="pintuan-left-price" v-if="currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0"> <view class="pintuan-left-price"
拼团<text style="color: red;">{{currentItem.productGroupBuyPrices | slicePrice}}</text> v-if="currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0">
拼团<text style="color: red;">{{currentItem.productGroupBuyPrices | slicePrice}}</text>
</view> </view>
</view> </view>
</view> </view>
@ -256,25 +274,26 @@
<view class="spec11"> <view class="spec11">
{{spec.name}} {{spec.name}}
</view> </view>
<view class="spec22" > <view class="spec22">
<view :class="spec.selected === option ? 'spec-check' : 'spec222'" <view :class="spec.selected === option ? 'spec-check' : 'spec222'"
v-for="(option, oIndex) in spec.options" v-for="(option, oIndex) in spec.options" :key="oIndex"
:key="oIndex" @tap="selectSpec(sIndex, option)">
@tap="selectSpec(sIndex, option)">
{{option}} {{option}}
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<template v-if="isPintuan && currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0"> <template
v-if="isPintuan && currentItem.productGroupBuyPrices && currentItem.productGroupBuyPrices.length > 0">
<view class="spec11"> <view class="spec11">
成团选择 成团选择
</view> </view>
<view class="goods-team"> <view class="goods-team">
<view :class="selectedGroupRule && selectedGroupRule.groupCount === rule.groupCount ? 'team-check' : 'team1'" <view
v-for="(rule, rIndex) in currentItem.productGroupBuyPrices" :key="rIndex" :class="selectedGroupRule && selectedGroupRule.groupCount === rule.groupCount ? 'team-check' : 'team1'"
@tap="selectGroupRule(rule)"> v-for="(rule, rIndex) in currentItem.productGroupBuyPrices" :key="rIndex"
@tap="selectGroupRule(rule)">
<view class="team11"> <view class="team11">
{{parseFloat(rule.groupPrice).toFixed(2)}} {{parseFloat(rule.groupPrice).toFixed(2)}}
</view> </view>
@ -284,8 +303,9 @@
</view> </view>
</view> </view>
<view class="spec11"> <view class="spec11" @tap="$refs.pintuanGroupPopup.open('bottom')">
他们都在拼 他们都在拼
<uni-icons type="right" size="12"></uni-icons>
</view> </view>
<!-- 占位假数据展示 --> <!-- 占位假数据展示 -->
<view class=""> <view class="">
@ -298,15 +318,12 @@
</view> </view>
<view class="list-right-cha"> <view class="list-right-cha">
<view class="cha11"> <view class="cha11">
不限 二人
</view> </view>
<view class=""> <view style="line-height: 20px;padding-left: 5px;">
<text style="color: red;">1</text>拼成 <text style="color: red;">1</text>拼成
</view> </view>
</view> </view>
<view class="list-right-price">
去凑单
</view>
</view> </view>
<view class="list-btn" @tap="submitPintuan"> <view class="list-btn" @tap="submitPintuan">
去拼单 去拼单
@ -319,15 +336,20 @@
<view class="bottom" style="padding-bottom: 20px;height: 80px;z-index: 10;"> <view class="bottom" style="padding-bottom: 20px;height: 80px;z-index: 10;">
<view v-if="isPintuan" class="pintuan1"> <view v-if="isPintuan" class="pintuan1">
<template v-if="!groupId"> <template v-if="!groupId">
<view class="pintuan2" style="border-bottom-left-radius: 50px;border-top-left-radius: 50px;" @tap="submitPintuan(true)"> <view class="pintuan2" style="border-bottom-left-radius: 50px;border-top-left-radius: 50px;"
@tap="submitPintuan(true)">
面对面团 面对面团
</view> </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)"> <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'}} 发起拼团{{selectedGroupRule && selectedGroupRule.groupPrice ? parseFloat(selectedGroupRule.groupPrice).toFixed(2) : '0.00'}}
</view> </view>
</template> </template>
<template v-else> <template v-else>
<view class="pintuan2" style="width: 100%; border-radius: 50px; background: rgba(0, 35, 28, 1); color: rgba(166, 255, 234, 1);" @tap="submitPintuan(false)"> <view class="pintuan2"
style="width: 100%; border-radius: 50px; background: rgba(0, 35, 28, 1); color: rgba(166, 255, 234, 1);"
@tap="submitPintuan(false)">
参与拼团{{selectedGroupRule && selectedGroupRule.groupPrice ? parseFloat(selectedGroupRule.groupPrice).toFixed(2) : '0.00'}} 参与拼团{{selectedGroupRule && selectedGroupRule.groupPrice ? parseFloat(selectedGroupRule.groupPrice).toFixed(2) : '0.00'}}
</view> </view>
</template> </template>
@ -338,6 +360,114 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<!-- 拼团和选规格弹窗 -->
<uni-popup ref="pintuanGroupPopup" background-color="#fff">
<view class="car-content">
<view class="car-close" @tap="$refs.pintuanPopup.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">
<!-- 占位假数据展示 -->
<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="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>
</view>
</uni-popup>
</view> </view>
</template> </template>
@ -346,17 +476,17 @@
data() { data() {
return { return {
loadStatus: 'more', loadStatus: 'more',
type:'', type: '',
shopId:'', shopId: '',
shopItem:{}, shopItem: {},
productId:'', productId: '',
productItem:[], productItem: [],
cartItems: [], cartItems: [],
currentItem: {}, currentItem: {},
parsedSpecs: [], parsedSpecs: [],
selectedGroupRule: {}, selectedGroupRule: {},
pageNum:1, pageNum: 1,
total:1, total: 1,
// sticky top // sticky top
navBarHeight: 0, navBarHeight: 0,
// //
@ -364,21 +494,21 @@
lastScrollTop: 0, lastScrollTop: 0,
// onPageScroll // onPageScroll
isSwitching: false, isSwitching: false,
searchForm:{ searchForm: {
shopId:'', shopId: '',
delFlag: 1, delFlag: 1,
pageNum: 1, pageNum: 1,
pageSize: '10', pageSize: '10',
categoryId:'' categoryId: ''
}, },
menuButtonInfo: {}, menuButtonInfo: {},
isPintuan:true, isPintuan: true,
groupId: '', groupId: '',
isFaceToFaceGroup: false, isFaceToFaceGroup: false,
menuList:[{ menuList: [{
categoryName:'猜你喜欢', categoryName: '猜你喜欢',
id:'', id: '',
checked:true checked: true
}] }]
} }
}, },
@ -407,15 +537,15 @@
sliceMsg1(val) { sliceMsg1(val) {
var name = '正在有' var name = '正在有'
let aa = Math.floor(Math.random() * (15 - 5 + 1)) + 1; let aa = Math.floor(Math.random() * (15 - 5 + 1)) + 1;
name+=aa+'人下单' name += aa + '人下单'
return name; return name;
}, },
slicePrice(val){ slicePrice(val) {
let begin = '' let begin = ''
if(val != null){ if (val != null) {
begin = val[0].groupPrice begin = val[0].groupPrice
for(let i = 0;i < val.length;i++){ for (let i = 0; i < val.length; i++) {
if(val[i].groupPrice < begin){ if (val[i].groupPrice < begin) {
begin = val[i].groupPrice begin = val[i].groupPrice
} }
} }
@ -488,41 +618,41 @@
this.searchForm.categoryId = categoryId; this.searchForm.categoryId = categoryId;
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) { if (that.searchForm.pageNum == 1) {
that.productItem = res.result.records; that.productItem = res.result.records;
} else { } else {
that.productItem = [...that.productItem, ...res.result.records]; that.productItem = [...that.productItem, ...res.result.records];
}
console.log(res.result.records)
that.total = res.result.pages; // pages =
that.pageNum = that.searchForm.pageNum;
//
// isSwitching_switchCategory isSwitching=true
if (res.result.records.length === 0) {
const currIdx = that.menuList.findIndex(m => m.checked);
if (currIdx !== -1 && currIdx < that.menuList.length - 1) {
//
that.isSwitching = false;
that._switchCategory(currIdx + 1);
} }
console.log(res.result.records)
that.total = res.result.pages; // pages =
that.pageNum = that.searchForm.pageNum;
//
// isSwitching_switchCategory isSwitching=true
if (res.result.records.length === 0) {
const currIdx = that.menuList.findIndex(m => m.checked);
if (currIdx !== -1 && currIdx < that.menuList.length - 1) {
//
that.isSwitching = false;
that._switchCategory(currIdx + 1);
}
}
that.$forceUpdate();
} else {
that.tui.toast(res.message);
return;
} }
that.$forceUpdate(); uni.hideLoading();
} else { }).catch((res) => {});
that.tui.toast(res.message);
return;
}
uni.hideLoading();
}).catch((res) => {});
}, },
getCategory(id){ getCategory(id) {
let that = this let that = this
that.tui.request("/app/productCategory/list", "GET", { that.tui.request("/app/productCategory/list", "GET", {
shopId:id shopId: id
}, false, true).then((res) => { }, false, true).then((res) => {
if (res.code == 200) { if (res.code == 200) {
if(res.result.length >0){ if (res.result.length > 0) {
for(let i = 0;i<res.result.length;i++){ for (let i = 0; i < res.result.length; i++) {
res.result[i].checked = false res.result[i].checked = false
that.menuList.push(res.result[i]) that.menuList.push(res.result[i])
} }
@ -541,7 +671,9 @@
this.isSwitching = true; this.isSwitching = true;
this.checkTab(index); this.checkTab(index);
// 400ms200ms200ms // 400ms200ms200ms
setTimeout(() => { this.isSwitching = false; }, 400); setTimeout(() => {
this.isSwitching = false;
}, 400);
}, },
checkTab(index) { checkTab(index) {
for (let i = 0; i < this.menuList.length; i++) { for (let i = 0; i < this.menuList.length; i++) {
@ -556,20 +688,24 @@
// nav-bar // nav-bar
// menuListOffsetTop - navBarHeight 使sticky // menuListOffsetTop - navBarHeight 使sticky
const target = this.menuListOffsetTop - this.navBarHeight; const target = this.menuListOffsetTop - this.navBarHeight;
uni.pageScrollTo({ scrollTop: target > 0 ? target : 0, duration: 200 }); uni.pageScrollTo({
scrollTop: target > 0 ? target : 0,
duration: 200
});
}, },
openPopup(type,index,item){ openPopup(type, index, item) {
if(type == 'car'){ if (type == 'car') {
this.$refs.carPopup.open('bottom') this.$refs.carPopup.open('bottom')
}else if(type == 'xiadan'){ } else if (type == 'xiadan') {
this.currentItem = item; this.currentItem = item;
// Parse specifications // Parse specifications
this.parsedSpecs = []; this.parsedSpecs = [];
if(item.attributeList && item.attributeList !== '{}') { if (item.attributeList && item.attributeList !== '{}') {
try { try {
let attrs = typeof item.attributeList === 'string' ? JSON.parse(item.attributeList) : item.attributeList; let attrs = typeof item.attributeList === 'string' ? JSON.parse(item.attributeList) : item
for(let key in attrs) { .attributeList;
if(attrs[key] && attrs[key].title && attrs[key].title.length > 0) { for (let key in attrs) {
if (attrs[key] && attrs[key].title && attrs[key].title.length > 0) {
this.parsedSpecs.push({ this.parsedSpecs.push({
name: key, name: key,
options: attrs[key].title, options: attrs[key].title,
@ -577,15 +713,15 @@
}); });
} }
} }
} catch(e) { } catch (e) {
console.error("Failed to parse specifications", e); console.error("Failed to parse specifications", e);
} }
} }
if(index == 'pintuan'){ if (index == 'pintuan') {
this.isPintuan = true; this.isPintuan = true;
// Set default group rule // Set default group rule
if(item.productGroupBuyPrices && item.productGroupBuyPrices.length > 0) { if (item.productGroupBuyPrices && item.productGroupBuyPrices.length > 0) {
this.selectedGroupRule = item.productGroupBuyPrices[0]; this.selectedGroupRule = item.productGroupBuyPrices[0];
} else { } else {
this.selectedGroupRule = {}; this.selectedGroupRule = {};
@ -594,9 +730,12 @@
} else { } else {
this.isPintuan = false; this.isPintuan = false;
// If solo buy and NO specs, add immediately to cart // If solo buy and NO specs, add immediately to cart
if(this.parsedSpecs.length === 0) { if (this.parsedSpecs.length === 0) {
this.addToCart(item, null); this.addToCart(item, null);
uni.showToast({ title: '已加入购物车', icon: 'none' }); uni.showToast({
title: '已加入购物车',
icon: 'none'
});
} else { } else {
// Open popup to select specs // Open popup to select specs
this.$refs.pintuanPopup.open('bottom'); this.$refs.pintuanPopup.open('bottom');
@ -617,7 +756,10 @@
specChoices[spec.name] = spec.selected; specChoices[spec.name] = spec.selected;
} }
this.addToCart(this.currentItem, specChoices); this.addToCart(this.currentItem, specChoices);
uni.showToast({ title: '已加入购物车', icon: 'none' }); uni.showToast({
title: '已加入购物车',
icon: 'none'
});
this.$refs.pintuanPopup.close(); this.$refs.pintuanPopup.close();
}, },
submitPintuan(isFaceToFace) { submitPintuan(isFaceToFace) {
@ -637,7 +779,9 @@
}; };
// Directly navigate to checkout // Directly navigate to checkout
uni.navigateTo({ uni.navigateTo({
url: '/package1/buyFood/buyFood?item=' + encodeURIComponent(JSON.stringify(goData)) + '&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' + packageFee url: '/package1/buyFood/buyFood?item=' + encodeURIComponent(JSON.stringify(goData)) +
'&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' +
packageFee
}); });
this.$refs.pintuanPopup.close(); this.$refs.pintuanPopup.close();
}, },
@ -645,19 +789,23 @@
let specStr = specs ? JSON.stringify(specs) : ''; let specStr = specs ? JSON.stringify(specs) : '';
let cartId = item.id + '_' + specStr; let cartId = item.id + '_' + specStr;
let existingItem = this.cartItems.find(c => c.cartId === cartId); let existingItem = this.cartItems.find(c => c.cartId === cartId);
if(existingItem) { if (existingItem) {
existingItem.quantity++; existingItem.quantity++;
} else { } else {
let priceToUse = 0; let priceToUse = 0;
if(item.attributeListPrice) { if (item.attributeListPrice) {
try { try {
let pObj = typeof item.attributeListPrice === 'string' ? JSON.parse(item.attributeListPrice) : item.attributeListPrice; let pObj = typeof item.attributeListPrice === 'string' ? JSON.parse(item.attributeListPrice) :
if(Array.isArray(pObj) && pObj.length > 0) { item.attributeListPrice;
if (Array.isArray(pObj) && pObj.length > 0) {
priceToUse = parseFloat(pObj[0].specPrice); priceToUse = parseFloat(pObj[0].specPrice);
} else { } else {
for(let k in pObj) { priceToUse = parseFloat(pObj[k].specPrice); break; } for (let k in pObj) {
priceToUse = parseFloat(pObj[k].specPrice);
break;
}
} }
} catch(e){} } catch (e) {}
} }
this.cartItems.push({ this.cartItems.push({
cartId: cartId, cartId: cartId,
@ -670,9 +818,9 @@
}, },
adjustCart(cartId, delta) { adjustCart(cartId, delta) {
let index = this.cartItems.findIndex(c => c.cartId === cartId); let index = this.cartItems.findIndex(c => c.cartId === cartId);
if(index !== -1) { if (index !== -1) {
let newQty = this.cartItems[index].quantity + delta; let newQty = this.cartItems[index].quantity + delta;
if(newQty <= 0) { if (newQty <= 0) {
this.cartItems.splice(index, 1); this.cartItems.splice(index, 1);
} else { } else {
this.cartItems[index].quantity = newQty; this.cartItems[index].quantity = newQty;
@ -680,13 +828,15 @@
} }
}, },
getSpecDisplayString(specs) { getSpecDisplayString(specs) {
if(!specs) return ''; if (!specs) return '';
let arr = []; let arr = [];
for(let k in specs) { arr.push(specs[k]); } for (let k in specs) {
arr.push(specs[k]);
}
return arr.join(','); return arr.join(',');
}, },
submitCartCheckout() { submitCartCheckout() {
if(this.cartItems.length === 0) { if (this.cartItems.length === 0) {
this.$refs.warnPopup.open() this.$refs.warnPopup.open()
return; return;
} }
@ -698,7 +848,9 @@
// //
uni.navigateTo({ uni.navigateTo({
url: '/package1/buyFood/buyFood?cart=' + encodeURIComponent(JSON.stringify(this.cartItems)) + '&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' + totalPackageFee url: '/package1/buyFood/buyFood?cart=' + encodeURIComponent(JSON.stringify(this.cartItems)) +
'&shopItem=' + encodeURIComponent(JSON.stringify(this.shopItem)) + '&packageFee=' +
totalPackageFee
}); });
}, },
goDetail(type) { goDetail(type) {
@ -706,11 +858,11 @@
uni.navigateTo({ uni.navigateTo({
url: '/package1/goods/goodsDetail' url: '/package1/goods/goodsDetail'
}) })
}else if(type == 'shopDetail'){ } else if (type == 'shopDetail') {
uni.navigateTo({ uni.navigateTo({
url: '/package1/group/groupBuyDetail?item=' + JSON.stringify(this.shopItem) url: '/package1/group/groupBuyDetail?item=' + JSON.stringify(this.shopItem)
}) })
}else if(type == 'shopEvaluate'){ } else if (type == 'shopEvaluate') {
uni.navigateTo({ uni.navigateTo({
url: '/package1/group/shopEvaluate?item=' + JSON.stringify(this.shopItem) url: '/package1/group/shopEvaluate?item=' + JSON.stringify(this.shopItem)
}) })
@ -764,7 +916,7 @@
.title-search { .title-search {
display: flex; display: flex;
flex: 1; flex: 1;
background: rgba(255,255,255,0.9); background: rgba(255, 255, 255, 0.9);
height: 54rpx; height: 54rpx;
margin-left: 20rpx; margin-left: 20rpx;
border-radius: 54rpx; border-radius: 54rpx;
@ -946,9 +1098,12 @@
z-index: 97; z-index: 97;
} }
.pintuan-right-cha {} .pintuan-right-cha {
line-height: 20px;
padding-left: 5px;
}
.goods-member{ .goods-member {
padding: 10px 0; padding: 10px 0;
margin-top: 10px; margin-top: 10px;
border-radius: 10px; border-radius: 10px;
@ -1066,7 +1221,7 @@
.bottom-left { .bottom-left {
flex: 1; flex: 1;
display: flex; display: flex;
padding: 20rpx; padding: 20rpx;
img { img {
width: 60rpx; width: 60rpx;
@ -1075,12 +1230,12 @@
} }
} }
.bottom-price{ .bottom-price {
margin-left: 40rpx; margin-left: 40rpx;
font-size: 40rpx; font-size: 40rpx;
color: red; color: red;
font-weight: 700; font-weight: 700;
line-height: 110rpx; line-height: 110rpx;
} }
.bottom-right { .bottom-right {
@ -1093,20 +1248,21 @@
background-size: 100%; background-size: 100%;
} }
} }
.bottom-dot{
position: absolute; .bottom-dot {
top: 0; position: absolute;
right: -20rpx; top: 0;
background: red; right: -20rpx;
color: #fff; background: red;
width: 32rpx; color: #fff;
height: 32rpx; width: 32rpx;
border-radius: 32rpx; height: 32rpx;
text-align: center; border-radius: 32rpx;
line-height: 32rpx; text-align: center;
line-height: 32rpx;
} }
.car-content{ .car-content {
position: relative; position: relative;
height: 600px; height: 600px;
width: 100%; width: 100%;
@ -1116,7 +1272,7 @@
overflow: scroll; overflow: scroll;
} }
.car-close{ .car-close {
width: 30px; width: 30px;
height: 30px; height: 30px;
position: absolute; position: absolute;
@ -1124,14 +1280,15 @@
right: 10px; right: 10px;
} }
.car-title{ .car-title {
height: 48px; height: 48px;
line-height: 30px; line-height: 30px;
margin: 0 auto; margin: 0 auto;
font-size: 14px; font-size: 14px;
font-weight: 700; font-weight: 700;
} }
.num-plus{
.num-plus {
width: 28px; width: 28px;
height: 28px; height: 28px;
font-size: 18px; font-size: 18px;
@ -1144,20 +1301,23 @@
color: rgba(166, 255, 234, 1); color: rgba(166, 255, 234, 1);
} }
.num{
.num {
width: 40px; width: 40px;
height: 28px; height: 28px;
text-align: center; text-align: center;
line-height: 28px; line-height: 28px;
font-size: 14px; font-size: 14px;
} }
.goods-num{
.goods-num {
display: flex; display: flex;
height: 28px; height: 28px;
flex: 1; flex: 1;
margin-left: 20px; margin-left: 20px;
} }
.pintuan0{
.pintuan0 {
width: 90%; width: 90%;
height: 50px; height: 50px;
border-radius: 50px; border-radius: 50px;
@ -1168,7 +1328,8 @@
line-height: 50px; line-height: 50px;
margin: auto; margin: auto;
} }
.pintuan1{
.pintuan1 {
width: 90%; width: 90%;
height: 50px; height: 50px;
line-height: 50px; line-height: 50px;
@ -1178,18 +1339,20 @@
font-size: 13px; font-size: 13px;
font-weight: 700; font-weight: 700;
} }
.pintuan2{
.pintuan2 {
flex: 1; flex: 1;
background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1)); background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));
} }
.spec11{
.spec11 {
height: 48px; height: 48px;
line-height: 48px; line-height: 48px;
font-size: 14px; font-size: 14px;
font-weight: 700; font-weight: 700;
} }
.spec222{ .spec222 {
display: inline-block; display: inline-block;
padding: 0 10px; padding: 0 10px;
background: #eee; background: #eee;
@ -1200,7 +1363,8 @@
border-radius: 10px; border-radius: 10px;
margin-right: 10px; margin-right: 10px;
} }
.spec-check{
.spec-check {
display: inline-block; display: inline-block;
padding: 0 10px; padding: 0 10px;
background: rgba(166, 255, 234, 1); background: rgba(166, 255, 234, 1);
@ -1210,7 +1374,8 @@
border-radius: 10px; border-radius: 10px;
margin-right: 10px; margin-right: 10px;
} }
.team1{
.team1 {
width: 77px; width: 77px;
height: 83px; height: 83px;
background: #eee; background: #eee;
@ -1221,7 +1386,8 @@
float: left; float: left;
margin-right: 20px; margin-right: 20px;
} }
.team-check{
.team-check {
width: 77px; width: 77px;
height: 83px; height: 83px;
background: rgba(166, 255, 234, 1); background: rgba(166, 255, 234, 1);
@ -1232,13 +1398,16 @@
float: left; float: left;
margin-right: 20px; margin-right: 20px;
} }
.team11{
.team11 {
margin-top: 10px; margin-top: 10px;
} }
.goods-team{
.goods-team {
width: 100%; width: 100%;
min-height: 90px; min-height: 90px;
} }
.list-right { .list-right {
display: flex; display: flex;
width: 100%; width: 100%;
@ -1284,7 +1453,8 @@
.list-right-cha { .list-right-cha {
margin-left: 10px; margin-left: 10px;
} }
.list-right-price{
.list-right-price {
flex: 1; flex: 1;
text-align: right; text-align: right;
line-height: 40px; line-height: 40px;
@ -1304,7 +1474,8 @@
line-height: 30px; line-height: 30px;
margin: 20px; margin: 20px;
} }
.cha11{
.cha11 {
font-size: 11px; font-size: 11px;
background: rgba(255, 57, 57, 0.2); background: rgba(255, 57, 57, 0.2);
color: red; color: red;
@ -1313,7 +1484,8 @@
border-radius: 5px; border-radius: 5px;
margin-bottom: 5px; margin-bottom: 5px;
} }
.menu-list{
.menu-list {
height: 45px; height: 45px;
width: 100%; width: 100%;
overflow-x: scroll; overflow-x: scroll;
@ -1326,7 +1498,8 @@
align-items: center; align-items: center;
padding-bottom: 4px; padding-bottom: 4px;
} }
.checked-img{
.checked-img {
width: 90px; width: 90px;
height: 10px; height: 10px;
position: absolute; position: absolute;
@ -1334,7 +1507,7 @@
left: 0; left: 0;
} }
.menu1{ .menu1 {
width: 90px; width: 90px;
height: 35px; height: 35px;
position: relative; position: relative;

Loading…
Cancel
Save