|
|
@ -130,12 +130,12 @@ |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="goods-bottom"> |
|
|
<view class="goods-bottom"> |
|
|
<view class="goods-btn" @tap="openPopup('xiadan','dandu',item)" |
|
|
<view class="goods-btn" v-if="!groupId" @tap="openPopup('xiadan','dandu',item)" |
|
|
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" @tap="openPopup('xiadan','pintuan',item)"> |
|
|
<view class="goods-btn" :style="groupId ? 'width:100%;' : ''" @tap="openPopup('xiadan','pintuan',item)"> |
|
|
拼团购买¥{{item.productGroupBuyPrices | slicePrice}} |
|
|
拼团购买¥{{ getGroupPrice(item) }} |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
@ -468,6 +468,71 @@ |
|
|
</scroll-view> |
|
|
</scroll-view> |
|
|
</view> |
|
|
</view> |
|
|
</uni-popup> |
|
|
</uni-popup> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 支付弹出层 --> |
|
|
|
|
|
<uni-popup ref="payPopup" background-color="#fff"> |
|
|
|
|
|
<view class="pay-popup" style="height: 480px;background: #fff;border-radius: 20px 20px 0 0;padding-top: 20px;"> |
|
|
|
|
|
<view class="content"> |
|
|
|
|
|
<view class="box1"> |
|
|
|
|
|
<view style="height: 70rpx;line-height: 70rpx;text-align: center;"> |
|
|
|
|
|
支付剩余时间 59:09 |
|
|
|
|
|
</view> |
|
|
|
|
|
<view |
|
|
|
|
|
style="height: 90rpx;line-height: 90rpx;text-align: center;font-weight: 700;font-size: 30rpx;"> |
|
|
|
|
|
¥<text |
|
|
|
|
|
style="font-size: 60rpx;">{{backendTotalAmount ? backendTotalAmount.toFixed(2) : '0.00'}}</text> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view style="height: 40rpx;text-align: center;color: red;"> |
|
|
|
|
|
若拼团失败,将会为您自动退款 |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="box1" style="display: flex;padding: 40rpx;"> |
|
|
|
|
|
<view style="flex: 1;"> |
|
|
|
|
|
<view style="height: 42rpx;line-height: 42rpx;display: flex;"> |
|
|
|
|
|
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4c8e0cc311db4d38ab43e019673c4b8c.png" |
|
|
|
|
|
alt="" style="width: 42rpx;height: 42rpx;margin-right: 20rpx;" /> |
|
|
|
|
|
<text style="font-size: 30rpx;font-weight: 700;">微信支付</text> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view style="text-align: right;margin-left: 60rpx;color: #777;width: 146rpx;"> |
|
|
|
|
|
使用微信支付 |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view style="width: 36rpx;padding-top: 20rpx;"> |
|
|
|
|
|
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/02bff7edc4e04caaa1868955ff684f1f.png" |
|
|
|
|
|
alt="" style="width: 36rpx;height: 36rpx;" /> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="btn" style="background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));width: 90%;height: 50px;border-radius: 50px;text-align: center;font-size: 14px;font-weight: 700;line-height: 50px;margin: 20px auto;" @tap="wxPayment"> |
|
|
|
|
|
确认付款 |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</uni-popup> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 参团成功提示弹出层 --> |
|
|
|
|
|
<uni-popup ref="joinSuccessPopup" background-color="#fff" @change="onJoinSuccessPopupChange"> |
|
|
|
|
|
<view class="pintuan-popup" style="position: relative;height: 600px;width: 100%;border-top-left-radius: 10px;border-top-right-radius: 10px;padding: 10px;"> |
|
|
|
|
|
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/ecd00dab1c9c44198d765bc08bc1bd71.png" alt="" |
|
|
|
|
|
style="position: absolute;top: 0;right: 0;width: 240rpx;height: 180rpx;" @tap="$refs.joinSuccessPopup.close()"> |
|
|
|
|
|
<view style="position: absolute;bottom: 0;width: 100%;height: 760rpx;"> |
|
|
|
|
|
<view class="kaituan1"> |
|
|
|
|
|
<view class="kaituan1-title" style="margin-top: 100rpx;text-align: center;font-size: 40rpx;font-weight: bold;"> |
|
|
|
|
|
参团成功! |
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="kaituan1-title1" style="text-align: center;margin-top: 20rpx;color: #777;"> |
|
|
|
|
|
您已成功参与拼团 |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="kaituan2" style="display: flex;justify-content: center;margin-top: 60rpx;"> |
|
|
|
|
|
<view class="kaituan22"> |
|
|
|
|
|
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/801c569079da4540990c1cc634186fdd.png" |
|
|
|
|
|
alt="" |
|
|
|
|
|
style="width: 90rpx;height: 90rpx;border-radius: 90rpx;margin: 0 auto;display: block;" /> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</uni-popup> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
@ -505,6 +570,9 @@ |
|
|
isPintuan: true, |
|
|
isPintuan: true, |
|
|
groupId: '', |
|
|
groupId: '', |
|
|
isFaceToFaceGroup: false, |
|
|
isFaceToFaceGroup: false, |
|
|
|
|
|
targetMembers: 2, |
|
|
|
|
|
backendTotalAmount: 0, |
|
|
|
|
|
currentOrderId: '', |
|
|
menuList: [{ |
|
|
menuList: [{ |
|
|
categoryName: '猜你喜欢', |
|
|
categoryName: '猜你喜欢', |
|
|
id: '', |
|
|
id: '', |
|
|
@ -587,10 +655,23 @@ |
|
|
if (option.isFaceToFace) { |
|
|
if (option.isFaceToFace) { |
|
|
this.isFaceToFaceGroup = option.isFaceToFace === '1' || option.isFaceToFace === 'true'; |
|
|
this.isFaceToFaceGroup = option.isFaceToFace === '1' || option.isFaceToFace === 'true'; |
|
|
} |
|
|
} |
|
|
|
|
|
if (option.targetMembers) { |
|
|
|
|
|
this.targetMembers = parseInt(option.targetMembers); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.targetMembers = 2; // Default fallback |
|
|
|
|
|
} |
|
|
if (this.type == 'shop') { |
|
|
if (this.type == 'shop') { |
|
|
this.shopItem = JSON.parse(option.item); |
|
|
try { |
|
|
|
|
|
this.shopItem = JSON.parse(decodeURIComponent(option.item)); |
|
|
|
|
|
} catch(e) { |
|
|
|
|
|
this.shopItem = JSON.parse(option.item); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
this.productItem = JSON.parse(option.item); |
|
|
try { |
|
|
|
|
|
this.productItem = JSON.parse(decodeURIComponent(option.item)); |
|
|
|
|
|
} catch(e) { |
|
|
|
|
|
this.productItem = JSON.parse(option.item); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
this.getCategory(this.shopItem.id); |
|
|
this.getCategory(this.shopItem.id); |
|
|
this.getProduct(''); |
|
|
this.getProduct(''); |
|
|
@ -721,12 +802,35 @@ |
|
|
|
|
|
|
|
|
if (index == 'pintuan') { |
|
|
if (index == 'pintuan') { |
|
|
this.isPintuan = true; |
|
|
this.isPintuan = true; |
|
|
// Set default group rule |
|
|
|
|
|
if (item.productGroupBuyPrices && item.productGroupBuyPrices.length > 0) { |
|
|
if (this.groupId) { |
|
|
this.selectedGroupRule = item.productGroupBuyPrices[0]; |
|
|
// 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)); |
|
|
|
|
|
} else if (prices.length > 0) { |
|
|
|
|
|
this.selectedGroupRule = prices.reduce((prev, curr) => (prev.groupCount < curr.groupCount ? prev : curr)); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.selectedGroupRule = {}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.isFaceToFaceGroup) { |
|
|
|
|
|
if (this.parsedSpecs.length === 0) { |
|
|
|
|
|
// No specs needed, jump straight to direct pay |
|
|
|
|
|
this.submitFTFJoinPay({}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
this.selectedGroupRule = {}; |
|
|
// Normal init |
|
|
|
|
|
if (item.productGroupBuyPrices && item.productGroupBuyPrices.length > 0) { |
|
|
|
|
|
this.selectedGroupRule = item.productGroupBuyPrices[0]; |
|
|
|
|
|
} else { |
|
|
|
|
|
this.selectedGroupRule = {}; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.$refs.pintuanPopup.open('bottom'); |
|
|
this.$refs.pintuanPopup.open('bottom'); |
|
|
} else { |
|
|
} else { |
|
|
this.isPintuan = false; |
|
|
this.isPintuan = false; |
|
|
@ -769,6 +873,13 @@ |
|
|
specChoices[spec.name] = spec.selected; |
|
|
specChoices[spec.name] = spec.selected; |
|
|
} |
|
|
} |
|
|
let packageFee = parseFloat(this.currentItem.lunchBox || 0); |
|
|
let packageFee = parseFloat(this.currentItem.lunchBox || 0); |
|
|
|
|
|
|
|
|
|
|
|
if (this.groupId && this.isFaceToFaceGroup) { |
|
|
|
|
|
// Direct face-to-face pay path |
|
|
|
|
|
this.submitFTFJoinPay(specChoices); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Pack data for checkout |
|
|
// Pack data for checkout |
|
|
let goData = { |
|
|
let goData = { |
|
|
item: this.currentItem, |
|
|
item: this.currentItem, |
|
|
@ -786,6 +897,47 @@ |
|
|
}); |
|
|
}); |
|
|
this.$refs.pintuanPopup.close(); |
|
|
this.$refs.pintuanPopup.close(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
submitFTFJoinPay(specChoices) { |
|
|
|
|
|
let items = [{ |
|
|
|
|
|
productId: this.currentItem.id, |
|
|
|
|
|
specs: JSON.stringify(specChoices || {}), |
|
|
|
|
|
price: parseFloat(this.selectedGroupRule && this.selectedGroupRule.groupPrice ? this.selectedGroupRule.groupPrice : 0), |
|
|
|
|
|
quantity: 1 |
|
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
let packageFee = parseFloat(this.currentItem.lunchBox || 0); |
|
|
|
|
|
|
|
|
|
|
|
let payload = { |
|
|
|
|
|
userId: uni.getStorageSync('id') || 'test-user123', |
|
|
|
|
|
shopId: this.shopItem.id, |
|
|
|
|
|
deliveryType: 1, |
|
|
|
|
|
packageFee: packageFee, |
|
|
|
|
|
remark: '', |
|
|
|
|
|
items: items, |
|
|
|
|
|
receiverName: '', |
|
|
|
|
|
receiverPhone: '', |
|
|
|
|
|
receiverAddress: '', |
|
|
|
|
|
shopName: this.shopItem.shopName, |
|
|
|
|
|
shopPhone: this.shopItem.shopPhone || '', |
|
|
|
|
|
shopAddress: this.shopItem.shopAddress || '', |
|
|
|
|
|
groupId: this.groupId |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
uni.showLoading({ title: '创建订单中...' }); |
|
|
|
|
|
this.tui.request("/mall/order/create", "POST", payload, false, false).then(res => { |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
if (res.success && res.result) { |
|
|
|
|
|
this.currentOrderId = res.result.id; |
|
|
|
|
|
this.backendTotalAmount = res.result.totalAmount; |
|
|
|
|
|
this.$refs.payPopup.open('bottom'); |
|
|
|
|
|
if (this.$refs.pintuanPopup) this.$refs.pintuanPopup.close(); |
|
|
|
|
|
} else { |
|
|
|
|
|
uni.showToast({ title: res.message || '下单失败', icon: 'none' }); |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
addToCart(item, specs) { |
|
|
addToCart(item, specs) { |
|
|
let specStr = specs ? JSON.stringify(specs) : ''; |
|
|
let specStr = specs ? JSON.stringify(specs) : ''; |
|
|
let cartId = item.id + '_' + specStr; |
|
|
let cartId = item.id + '_' + specStr; |
|
|
@ -869,6 +1021,73 @@ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
getGroupPrice(item) { |
|
|
|
|
|
if (!this.groupId) { |
|
|
|
|
|
return this.$options.filters.slicePrice(item.productGroupBuyPrices); |
|
|
|
|
|
} |
|
|
|
|
|
let target = this.targetMembers; |
|
|
|
|
|
let prices = item.productGroupBuyPrices || []; |
|
|
|
|
|
if (prices.length === 0) return '0.00'; |
|
|
|
|
|
let validPrices = prices.filter(p => p.groupCount <= target); |
|
|
|
|
|
if (validPrices.length === 0) { |
|
|
|
|
|
let minRule = prices.reduce((prev, curr) => (prev.groupCount < curr.groupCount ? prev : curr)); |
|
|
|
|
|
return parseFloat(minRule.groupPrice).toFixed(2); |
|
|
|
|
|
} |
|
|
|
|
|
let bestRule = validPrices.reduce((max, obj) => (obj.groupCount > max.groupCount ? obj : max)); |
|
|
|
|
|
return parseFloat(bestRule.groupPrice).toFixed(2); |
|
|
|
|
|
}, |
|
|
|
|
|
wxPayment() { |
|
|
|
|
|
let that = this; |
|
|
|
|
|
if (!this.currentOrderId || !this.backendTotalAmount) return; |
|
|
|
|
|
|
|
|
|
|
|
let amountInCents = Math.round(this.backendTotalAmount * 100); |
|
|
|
|
|
|
|
|
|
|
|
this.tui.request("/api/wechat/pay/unified-order", "POST", { |
|
|
|
|
|
openid: uni.getStorageSync('miniProgramOpenid') || 'test-openid', |
|
|
|
|
|
amount: amountInCents, |
|
|
|
|
|
description: '拼团参与订单', |
|
|
|
|
|
outTradeNo: this.currentOrderId |
|
|
|
|
|
}, false, false).then((res) => { |
|
|
|
|
|
if (res.code == 200) { |
|
|
|
|
|
uni.requestPayment({ |
|
|
|
|
|
provider: 'wxpay', |
|
|
|
|
|
timeStamp: res.timeStamp, |
|
|
|
|
|
nonceStr: res.nonceStr, |
|
|
|
|
|
package: res.package, |
|
|
|
|
|
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); |
|
|
|
|
|
}, |
|
|
|
|
|
fail: function(err) { |
|
|
|
|
|
that.tui.toast("支付失败或取消"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 模拟支付成功 |
|
|
|
|
|
if (res.code == 404 || res.code == 500 || res.code == 400 || !res.code) { |
|
|
|
|
|
that.tui.request( |
|
|
|
|
|
`/hiver/order/payMallOrderSuccess?orderId=${that.currentOrderId}&workerId=`, |
|
|
|
|
|
"POST", {}, false, false).then(res2 => { |
|
|
|
|
|
that.$refs.payPopup.close(); |
|
|
|
|
|
uni.showToast({ title: '支付成功(模拟)', icon: 'none' }); |
|
|
|
|
|
setTimeout(() => { that.$refs.joinSuccessPopup.open('bottom'); }, 1500); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
that.tui.toast(res.message); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
onJoinSuccessPopupChange(e) { |
|
|
|
|
|
if (!e.show) { |
|
|
|
|
|
uni.redirectTo({ |
|
|
|
|
|
url: '/package1/order/pendGroup?groupId=' + this.groupId |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
back() { |
|
|
back() { |
|
|
uni.navigateBack() |
|
|
uni.navigateBack() |
|
|
} |
|
|
} |
|
|
|