diff --git a/api/promotion/bargain.js b/api/promotion/bargain.js index cdfa6cd4..aadf1ffe 100644 --- a/api/promotion/bargain.js +++ b/api/promotion/bargain.js @@ -33,3 +33,13 @@ export function getBargainRecordSummary() { noAuth: true // TODO 芋艿:后续要做调整 }); } + +// 获得砍价活动详情 +export function getBargainRecordDetail(id, activityId) { + return request.get("app-api/promotion/bargain-record/get-detail", { + id, + activityId + }, { + noAuth: true // TODO 芋艿:后续要做调整 + }); +} diff --git a/pages/activity/goods_bargain_details/index.vue b/pages/activity/goods_bargain_details/index.vue index 27e2aa51..b091646d 100644 --- a/pages/activity/goods_bargain_details/index.vue +++ b/pages/activity/goods_bargain_details/index.vue @@ -39,36 +39,35 @@ - + + :class="new Date().getTime() >= bargainUserInfo.expireTime ? 'font_hui': ''"> 已砍¥{{bargainUserInfo.alreadyPrice}} + :class="new Date().getTime() >= bargainUserInfo.expireTime ? 'font_hui': ''">¥{{ fen2yuan(bargainUserInfo.price - bargainUserInfo.payPrice) }} 还剩¥{{bargainUserInfo.surplusPrice}} + :class="new Date().getTime() >= bargainUserInfo.expireTime ? 'font_hui': ''">¥{{ fen2yuan(bargainUserInfo.remainPrice) }} + :class="new Date().getTime() >= bargainUserInfo.expireTime ? 'bg_qian': ''"> + :class="new Date().getTime() >= bargainUserInfo.expireTime ? 'bg-color-hui': ''" + :style="'width:'+ (100 * (bargainUserInfo.price - bargainUserInfo.payPrice) / (bargainUserInfo.price - bargainUserInfo.bargainPrice)) +'%;'" /> - 一 已有{{bargainInfo.sales}}位好友砍价成功 一 + 一 已有{{ bargainInfo.successCount }}位好友砍价成功 一 + v-if="startBargainUid === uid && action === 1"> 立即参与砍价 商品暂无库存 - + 邀请好友帮砍价 邀请好友帮砍价 @@ -78,7 +77,7 @@ - + 帮好友砍一刀 @@ -104,20 +103,20 @@ 我也要参与 - + + + - - 恭喜您砍价成功,快去支付吧~ + 恭喜您砍价成功,快去支付吧~ 继续选购 - 立即支付 - 去支付 + 立即支付 + 去支付 - + + 恭喜您砍价成功,去看看别的商品吧~ @@ -126,23 +125,16 @@ 继续选购 - - 活动已结束 - - - 商品已售罄 - - - 再去逛逛 + + + + 再去逛逛 + - - - 您购买的商品数量已达上限 - - + @@ -183,7 +175,6 @@ 暂无助力记录 - @@ -300,6 +291,7 @@ import { silenceBindingSpread } from "@/utils"; import * as BargainApi from '@/api/promotion/bargain.js'; import * as Util from '@/utils/util.js'; + import {getBargainRecordDetail} from "../../../api/promotion/bargain"; const app = getApp(); export default { components: { @@ -313,7 +305,7 @@ data() { return { // ========== 拼团活动 ========== - id: 0, // 砍价商品 id + id: 0, // 砍价活动 id bargainInfo: {}, // 砍价活动 buyPrice: '', // 最后砍价购买价格 bgColor: { @@ -323,19 +315,24 @@ 'timeTxtwidth': '16rpx', 'isDay': true }, + tagStyle: { + img: 'width:100%;' + }, // ========== 拼团记录 ========== storeBargainId: 0, // 砍价活动 id + bargainUserInfo: {}, //开启砍价用户信息 + action: 0, // 拼团记录的参与动作 + + bargainStatus: 0, //当前用户砍价状态: + // 1-可以参与砍价 TODO ,2-参与次数已满 TODO ,3-砍价中 TODO,4-已完成 TODO,5-可以帮砍 TODO,6-已帮砍 TODO,7-帮砍次数已满 TODO,8-已生成订单未支付 TODO,9-已支付 TODO // TODO 芋艿:未整理 active: false, - bargainStatus: 0, //当前用户砍价状态:1-可以参与砍价,2-参与次数已满,3-砍价中,4-已完成,5-可以帮砍,6-已帮砍,7-帮砍次数已满,8-已生成订单未支付,9-已支付 startBargainUid: 0, // 开启砍价用户 uid - bargainUserInfo: {}, //开启砍价用户信息 page: 1, limit: 5, - limitStatus: false, bargainUserHelpList: [], bargainUserHelpInfo: [], bargainUserBargainPrice: 0, //砍了多少钱 @@ -348,9 +345,7 @@ navH: '', datatime: 0, offest: '', - tagStyle: { - img: 'width:100%;' - }, + H5ShareBox: false, //公众号分享图片 systemH: 0, pages: '', @@ -447,10 +442,10 @@ uni.setNavigationBarTitle({ title: bargainInfo.name.substring(0, 13) + '...' }) - // 有库存,且未结束的情况下,获取当前砍价记录 - if (this.isLogin && bargainInfo.stock > 0 && new Date().getTime() < bargainInfo.endTime) { - // this.gobargainUserInfo(); - } + + // 获得拼团记录 + this.gobargainUserInfo(); + //#ifdef H5 this.getImageBase64(bargainInfo.picUrl); //#endif @@ -464,15 +459,60 @@ // }); }) }, + /** + * 去商品页 + */ + goProduct() { + uni.navigateTo({ + url: `/pages/goods_details/index?id=${this.bargainInfo.spuId}` + }) + }, + // 去支付 TODO 芋艿:待定 + goConfirm() { + uni.navigateTo({ + url: `/pages/activity/bargain/index` + }) + }, + + // ========== 拼团活动 ========== + + /** + * 获得拼团记录 + */ + gobargainUserInfo: function() { + BargainApi.getBargainRecordDetail(this.bargainId, this.bargainUserId).then(res => { + const bargainUserInfo = res.data; + this.bargainUserInfo = bargainUserInfo; + this.action = bargainUserInfo.action; + this.storeBargainId = bargainUserInfo.id || this.storeBargainId; + this.buyPrice = this.bargainUserInfo.payPrice || this.buyPrice; + if (bargainUserInfo.payPrice >= 0 && bargainUserInfo.bargainPrice >= 0) { + bargainUserInfo.remainPrice = bargainUserInfo.payPrice - bargainUserInfo.bargainPrice; // 剩余可砍的金额 + } + this.bargainStatus = bargainUserInfo.bargainStatus; + + // TODO 芋艿:后续下面从单独的接口拿数据 + // this.bargainUserHelpList = bargainUserInfo.userHelpList || []; + //#ifdef H5 + if (bargainUserInfo.storeBargainUserId) { + this.make(); + } + this.setOpenShare(); + //#endif + }).catch(err => { + // 状态异常返回上级页面 + return this.$util.Tips({ + title: err.toString() + }, { + tab: 3, + url: 1 + }); + }); + }, // TODO 芋艿:未整理 - //去支付 - goConfirm() { - uni.navigateTo({ - url: `/pages/activity/bargain/index` - }) - }, + //#ifdef H5 setOpenShare() { let that = this; @@ -511,12 +551,6 @@ openTap() { this.$set(this, 'couponsHidden', !this.couponsHidden); }, - // 去商品页 - goProduct() { - uni.navigateTo({ - url: `/pages/goods_details/index?id=${this.bargainInfo.spuId}` - }) - }, // 自己砍价; userBargain: function() { if (this.uid === this.startBargainUid) { @@ -560,33 +594,7 @@ that.imgTop = res.data.code; }) }, - //获取砍价用户信息 - gobargainUserInfo: function() { - getBargainUser({ - bargainId: this.id, - bargainUserId: this.storeBargainId || 0 - }).then(res => { - let bargainUserInfo = res.data; - this.bargainUserInfo = bargainUserInfo; - this.bargainStatus = bargainUserInfo.bargainStatus; - this.storeBargainId = bargainUserInfo.storeBargainUserId; - this.buyPrice = this.$util.$h.Sub(parseFloat(this.bargainPrice), parseFloat(bargainUserInfo - .alreadyPrice)) - this.bargainUserHelpList = bargainUserInfo.userHelpList || []; - //#ifdef H5 - if (bargainUserInfo.storeBargainUserId) this.make(); - this.setOpenShare(); - //#endif - }).catch(err => { - //状态异常返回上级页面 - return this.$util.Tips({ - title: err.toString() - }, { - tab: 3, - url: 1 - }); - }); - }, + goPay: function() { //立即支付 if (this.isLogin === false) { toLogin();