【砍价详情】

1. 接入拼团活动的详情接口
pull/1/MERGE
YunaiV 2023-06-20 21:18:32 +08:00
parent 725a37eae5
commit 220b21b6b6
3 changed files with 132 additions and 119 deletions

View File

@ -9,6 +9,15 @@ export function getBargainActivityList(count) {
}); });
} }
// 获得砍价活动详情
export function getBargainActivityDetail(id) {
return request.get("app-api/promotion/bargain-activity/get-detail", {
id
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}
// 获得砍价活动分页 // 获得砍价活动分页
export function getBargainActivityPage(count) { export function getBargainActivityPage(count) {
return request.get("app-api/promotion/bargain-activity/page", { return request.get("app-api/promotion/bargain-activity/page", {

View File

@ -12,26 +12,24 @@
<view class='wrapper'> <view class='wrapper'>
<view class='pictxt acea-row row-between' @tap="goProduct"> <view class='pictxt acea-row row-between' @tap="goProduct">
<view class='pictrue'> <view class='pictrue'>
<image :src='bargainInfo.image'></image> <image :src='bargainInfo.picUrl' />
</view> </view>
<view class='text acea-row row-column-around'> <view class='text acea-row row-column-around'>
<view class='line1'>{{bargainInfo.title}}</view> <view class='line1'>{{ bargainInfo.name }}</view>
<view class="surplus">最低价{{bargainInfo.minPrice}}</view> <view class="surplus">最低价{{ fen2yuan(bargainInfo.bargainPrice) }}</view>
<view class="surplus">剩余{{bargainInfo.quota}}{{bargainInfo.unitName}}</view> <view class="surplus">剩余{{ bargainInfo.stock }} {{bargainInfo.unitName}}</view>
<view class='money font-color-red'> <view class='money font-color-red'>
当前: 当前: <text class='num'>{{ fen2yuan(buyPrice) }}</text>
<text class='num'>{{buyPrice}}</text>
</view> </view>
<view class="acea-row" <view class="acea-row" v-if="bargainInfo.endTime > new Date().getTime() && bargainInfo.stock > 0">
v-if="new Date().getTime()- bargainInfo.stopTime < 0 && bargainInfo.quota>0">
<countDown :tipText="' '" :bgColor="bgColor" :dayText="':'" :hourText="':'" <countDown :tipText="' '" :bgColor="bgColor" :dayText="':'" :hourText="':'"
:minuteText="':'" :secondText="' '" :datatime="datatime" :isDay="true"></countDown> :minuteText="':'" :secondText="' '" :datatime="bargainInfo.endTime / 1000" :isDay="true" />
<text style="font-size: 22rpx;margin-left: 4rpx;line-height: 36rpx;">后结束</text> <text style="font-size: 22rpx;margin-left: 4rpx;line-height: 36rpx;">后结束</text>
</view> </view>
<view v-if="new Date().getTime()- bargainInfo.stopTime >=0"> <view v-else-if="bargainInfo.endTime <= new Date().getTime()">
<view style="font-size: 22rpx;" @tap='currentBargainUser'>已结束</view> <view style="font-size: 22rpx;" @tap='currentBargainUser'>已结束</view>
</view> </view>
<view v-if="bargainInfo.quota==0"> <view v-else-if="bargainInfo.stock <= 0">
<view style="font-size: 22rpx;" @tap='currentBargainUser'>已售罄</view> <view style="font-size: 22rpx;" @tap='currentBargainUser'>已售罄</view>
</view> </view>
</view> </view>
@ -39,6 +37,8 @@
</view> </view>
</view> </view>
<view class="content"> <view class="content">
<!-- 自己砍价1-可以参与砍价5-砍价中 -->
<!-- 别人砍价5-可以帮砍 -->
<block <block
v-if="(startBargainUid == uid && (bargainStatus==1 || bargainStatus==3)) || (startBargainUid != uid && bargainStatus==5)"> v-if="(startBargainUid == uid && (bargainStatus==1 || bargainStatus==3)) || (startBargainUid != uid && bargainStatus==5)">
<view class='money acea-row row-center' <view class='money acea-row row-center'
@ -63,14 +63,12 @@
<!-- 自己砍价 --> <!-- 自己砍价 -->
<view <view
v-if="startBargainUid == uid && parseFloat(bargainUserInfo.surplusPrice) > 0 && bargainStatus==1"> v-if="startBargainUid === uid && parseFloat(bargainUserInfo.surplusPrice) > 0 && bargainStatus==1">
<view class='bargainBnt' @tap='userBargain' v-if="quota>0"> <view class='bargainBnt' @tap='userBargain' v-if="bargainInfo.stock > 0"></view>
立即参与砍价 <view class='bargainBnt grey' v-else></view>
</view>
<view class='bargainBnt grey' v-if="quota<=0"></view>
</view> </view>
<view <view
v-if="startBargainUid == uid && parseFloat(bargainUserInfo.surplusPrice) > 0 && bargainStatus==3"> v-if="startBargainUid === uid && parseFloat(bargainUserInfo.surplusPrice) > 0 && bargainStatus==3">
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<view class='bargainBnt' v-if="$wechat.isWeixin()" @click="H5ShareBox = true"></view> <view class='bargainBnt' v-if="$wechat.isWeixin()" @click="H5ShareBox = true"></view>
<view class='bargainBnt' v-else @tap='getBargainUserBargainPricePoster'>邀请好友帮砍价</view> <view class='bargainBnt' v-else @tap='getBargainUserBargainPricePoster'>邀请好友帮砍价</view>
@ -80,18 +78,19 @@
<!-- #endif --> <!-- #endif -->
</view> </view>
<!-- 别人砍价 -->
<view <view
v-if="startBargainUid != uid && bargainStatus==5 && parseFloat(bargainUserInfo.surplusPrice) > 0"> v-if="startBargainUid !== uid && bargainStatus==5 && parseFloat(bargainUserInfo.surplusPrice) > 0">
<view class='bargainBnt' @tap='setBargainHelp'>帮好友砍一刀</view> <view class='bargainBnt' @tap='setBargainHelp'>帮好友砍一刀</view>
</view> </view>
<view v-if="startBargainUid != uid && bargainStatus==4 && parseFloat(bargainUserInfo.surplusPrice) == 0" > <view v-if="startBargainUid !== uid && bargainStatus==4 && parseFloat(bargainUserInfo.surplusPrice) == 0" >
<view class='bargainSuccess'> <view class='bargainSuccess'>
<image src="../static/cheng.png"></image> <image src="../static/cheng.png"></image>
好友已砍成功 好友已砍成功
</view> </view>
<view class='bargainBnt' @tap='currentBargainUser'>我也要参与</view> <view class='bargainBnt' @tap='currentBargainUser'>我也要参与</view>
</view> </view>
<view v-if="startBargainUid != uid && bargainStatus === 7"> <view v-if="startBargainUid !== uid && bargainStatus === 7">
<view class='bargainSuccess'> <view class='bargainSuccess'>
<image src="../static/cheng.png"></image> <image src="../static/cheng.png"></image>
您已帮其他好友砍过此商品 您已帮其他好友砍过此商品
@ -130,10 +129,10 @@
<view v-if="new Date().getTime()- bargainInfo.stopTime >=0"> <view v-if="new Date().getTime()- bargainInfo.stopTime >=0">
<view class='huiBtn' @tap='currentBargainUser'>活动已结束</view> <view class='huiBtn' @tap='currentBargainUser'>活动已结束</view>
</view> </view>
<view v-else-if="bargainInfo.quota==0"> <view v-else-if="bargainInfo.stock == 0">
<view class='huiBtn' @tap='currentBargainUser'>商品已售罄</view> <view class='huiBtn' @tap='currentBargainUser'>商品已售罄</view>
</view> </view>
<navigator v-if="new Date().getTime()- bargainInfo.stopTime >=0 || bargainInfo.quota==0" <navigator v-if="new Date().getTime()- bargainInfo.stopTime >=0 || bargainInfo.stock === 0"
url="/pages/activity/goods_bargain/index" hover-class="none"> url="/pages/activity/goods_bargain/index" hover-class="none">
<view class="go">再去逛逛<text class="iconfont icon-jiantou"></text></view> <view class="go">再去逛逛<text class="iconfont icon-jiantou"></text></view>
</navigator> </navigator>
@ -202,11 +201,9 @@
</view> </view>
<view class='goodsDetails borRadius14'> <view class='goodsDetails borRadius14'>
<view class='conter borRadius14'> <view class='conter borRadius14'>
<jyf-parser v-if="bargainInfo.content" :html="bargainInfo.content" ref="article" <jyf-parser v-if="bargainInfo.description" :html="bargainInfo.description" ref="article" :tag-style="tagStyle" />
:tag-style="tagStyle" />
<view v-else class="contentNo"> <view v-else class="contentNo">
<text class="iconfont icon-xiaolian mr8"></text> <text class="iconfont icon-xiaolian mr8" /> 暂无商品详情
暂无商品详情
</view> </view>
</view> </view>
</view> </view>
@ -258,8 +255,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class='mask' catchtouchmove="true" v-show='active==true || posters==true || canvasStatus' <view class='mask' catchtouchmove="true" v-show='active || posters || canvasStatus' @tap='close' />
@tap='close'></view>
</view> </view>
<!-- 发送给朋友图片 --> <!-- 发送给朋友图片 -->
@ -302,6 +298,8 @@
import home from '@/components/home'; import home from '@/components/home';
import parser from "@/components/jyf-parser/jyf-parser"; import parser from "@/components/jyf-parser/jyf-parser";
import { silenceBindingSpread } from "@/utils"; import { silenceBindingSpread } from "@/utils";
import * as BargainApi from '@/api/promotion/bargain.js';
import * as Util from '@/utils/util.js';
const app = getApp(); const app = getApp();
export default { export default {
components: { components: {
@ -314,41 +312,40 @@
*/ */
data() { data() {
return { return {
bgColor: { // ========== ==========
'bgColor': '#333333', id: 0, // id
'Color': '#fff', bargainInfo: {}, //
'width': '44rpx', buyPrice: '', //
'timeTxtwidth': '16rpx', bgColor: {
'isDay': true 'bgColor': '#333333',
}, 'Color': '#fff',
countDownDay: '00', 'width': '44rpx',
countDownHour: '00', 'timeTxtwidth': '16rpx',
countDownMinute: '00', 'isDay': true
countDownSecond: '00', },
// ========== ==========
storeBargainId: 0, // id
// TODO
active: false, active: false,
id: 0, //id
bargainStatus: 0, //1-,2-3-,4-5-6-,7-,8-9- bargainStatus: 0, //1-,2-3-,4-5-6-,7-,8-9-
startBargainUid: 0, //uid startBargainUid: 0, // uid
bargainUserInfo: {}, // bargainUserInfo: {}, //
//bargainUserId: 0, //
storeBargainId: 0, // id
bargainInfo: {}, //
page: 1, page: 1,
limit: 5, limit: 5,
limitStatus: false, limitStatus: false,
bargainUserHelpList: [], bargainUserHelpList: [],
bargainUserHelpInfo: [], bargainUserHelpInfo: [],
bargainUserBargainPrice: 0, // bargainUserBargainPrice: 0, //
bargainCount: [], //
retunTop: true, retunTop: true,
bargainPartake: 0, bargainPartake: 0,
isHelp: false, isHelp: false,
interval: null, interval: null,
productStock: 0, // productStock: 0, //
quota: 0, //
userBargainStatusHelp: true, userBargainStatusHelp: true,
navH: '', navH: '',
bargainPrice: 0,
datatime: 0, datatime: 0,
offest: '', offest: '',
tagStyle: { tagStyle: {
@ -361,7 +358,6 @@
loading: false, loading: false,
loadend: false, loadend: false,
posters: false, posters: false,
buyPrice: '', //
qrcodeSize: 600, qrcodeSize: 600,
posterbackgd: '/static/images/canbj.png', posterbackgd: '/static/images/canbj.png',
PromotionCode: '', // PromotionCode: '', //
@ -375,62 +371,102 @@
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function(options) {
var that = this;
that.$store.commit("PRODUCT_TYPE", 'normal');
// #ifdef MP // #ifdef MP
uni.getSystemInfo({ uni.getSystemInfo({
success: function(res) { success: res => {
that.systemH = res.statusBarHeight this.systemH = res.statusBarHeight
that.navH = that.systemH + 10 this.navH = this.systemH + 10
} }
}) })
// #endif // #endif
var pages = getCurrentPages(); const pages = getCurrentPages();
if (pages.length <= 1) { if (pages.length <= 1) {
that.retunTop = false this.retunTop = false
} }
// uni.setNavigationBarTitle({
title: '砍价详情'
})
// scene id startBargainUid
//
// #ifdef MP // #ifdef MP
if (options.scene) { if (options.scene) {
var value = util.getUrlParams(decodeURIComponent(options.scene)); const value = util.getUrlParams(decodeURIComponent(options.scene));
if (typeof value === 'object') { if (typeof value === 'object') {
value.id ? options.id = value.id : options.id = '' value.id ? options.id = value.id : options.id = ''
if (value.startBargainUid) options.startBargainUid = value.startBargainUid; if (value.startBargainUid) {
//广uid options.startBargainUid = value.startBargainUid;
if (value.pid) app.globalData.spid = value.pid; }
// 广uid
if (value.pid) {
app.globalData.spid = value.pid;
}
} else { } else {
app.globalData.spid = value; app.globalData.spid = value;
} }
} }
//广uid // 广uid
if (options.spid) app.globalData.spid = options.spid; if (options.spid) {
app.globalData.spid = options.spid;
}
// #endif // #endif
if (options.hasOwnProperty('id')) {
options.id ? that.id = options.id : that.id = '' // idstartBargainUid
if (options.hasOwnProperty('id')) {
options.id ? this.id = options.id : this.id = ''
} }
options.startBargainUid === 'undefined' ? that.startBargainUid = 0 : that.startBargainUid = Number(options if (options.startBargainUid === 'undefined') {
.startBargainUid); this.startBargainUid = 0
} else {
this.startBargainUid = Number(options.startBargainUid);
}
if (this.isLogin) { if (this.isLogin) {
if (that.startBargainUid === 0) { if (this.startBargainUid === 0) {
that.startBargainUid = Number(that.$store.state.app.uid) this.startBargainUid = Number(this.$store.state.app.uid)
} }
this.storeBargainId = options.storeBargainId ? Number(options.storeBargainId) : 0; this.storeBargainId = options.storeBargainId ? Number(options.storeBargainId) : 0;
this.page = 1;
} else {
this.$Cache.set('login_back_url',
'/pages/activity/goods_bargain_details/index?id=' + options.id +
'&startBargainUid=' + this
.uid + '&spid=' + this.uid + '&storeBargainId=' + this.storeBargainId
);
toLogin();
} }
this.isLogin && silenceBindingSpread(); // TODO
uni.setNavigationBarTitle({ if (this.isLogin) {
title: '砍价详情' silenceBindingSpread();
}) }
}, },
methods: { methods: {
// ========== ==========
/**
* 获取砍价产品详情
*/
getBargainDetails: function() {
BargainApi.getBargainActivityDetail(this.id).then(res => {
const bargainInfo = res.data;
this.bargainInfo = bargainInfo;
this.buyPrice = this.bargainInfo.price;
this.pages = '/pages/activity/goods_bargain_details/index?id=' + this.id +
'&startBargainUid=' + this.uid + '&scene=' + this.uid + '&storeBargainId=' + this.storeBargainId;
uni.setNavigationBarTitle({
title: bargainInfo.name.substring(0, 13) + '...'
})
//
if (this.isLogin && bargainInfo.stock > 0 && new Date().getTime() < bargainInfo.endTime) {
// this.gobargainUserInfo();
}
//#ifdef H5
this.getImageBase64(bargainInfo.picUrl);
//#endif
}).catch(function (err) {
console.log(err, '=====');
// this.$util.Tips({
// title: err
// }, {
// tab: 2,
// url: '/pages/activity/goods_bargain/index'
// });
})
},
// TODO
// //
goConfirm() { goConfirm() {
uni.navigateTo({ uni.navigateTo({
@ -461,9 +497,7 @@
"onMenuShareTimeline" "onMenuShareTimeline"
], ],
configTimeline configTimeline
) ).catch(res => {
.then(res => {})
.catch(res => {
if (res.is_ready) { if (res.is_ready) {
res.wx.updateAppMessageShareData(configTimeline); res.wx.updateAppMessageShareData(configTimeline);
res.wx.updateTimelineShareData(configTimeline); res.wx.updateTimelineShareData(configTimeline);
@ -480,7 +514,7 @@
// //
goProduct() { goProduct() {
uni.navigateTo({ uni.navigateTo({
url: `/pages/goods_details/index?id=${this.bargainInfo.productId}` url: `/pages/goods_details/index?id=${this.bargainInfo.spuId}`
}) })
}, },
// //
@ -567,39 +601,6 @@
}]); }]);
} }
}, },
//
getBargainDetails: function() {
var that = this;
getBargainDetail(that.id).then(function(res) {
let bargainInfo = res.data;
that.bargainInfo = bargainInfo;
that.bargainPrice = bargainInfo.price;
that.quota = bargainInfo.quota;
that.datatime = bargainInfo.stopTime / 1000;
that.pages = '/pages/activity/goods_bargain_details/index?id=' + that.id +
'&startBargainUid=' + that
.uid + '&scene=' + that.uid + '&storeBargainId=' + that.storeBargainId;
uni.setNavigationBarTitle({
title: bargainInfo.title.substring(0, 13) + '...'
})
that.bargainUserHelpList = []
if (that.isLogin && that.quota > 0 && new Date().getTime() - bargainInfo.stopTime < 0) {
that.gobargainUserInfo();
} else {
that.buyPrice = that.bargainPrice;
}
//#ifdef H5
that.getImageBase64(bargainInfo.image);
//#endif
}).catch(function(err) {
that.$util.Tips({
title: err
}, {
tab: 2,
url: '/pages/activity/goods_bargain/index'
});
})
},
currentBargainUser: function() { // currentBargainUser: function() { //
this.page = 1; this.page = 1;
uni.navigateTo({ uni.navigateTo({
@ -696,7 +697,11 @@
this.$set(this, 'active', false); this.$set(this, 'active', false);
this.$set(this, 'posters', false); this.$set(this, 'posters', false);
this.$set(this, 'canvasStatus', false); this.$set(this, 'canvasStatus', false);
} },
fen2yuan(price) {
return Util.fen2yuan(price)
}
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示

View File

@ -75,7 +75,6 @@
import * as BannerApi from '@/api/promotion/banner.js'; import * as BannerApi from '@/api/promotion/banner.js';
import * as Util from '@/utils/util.js'; import * as Util from '@/utils/util.js';
import home from '@/components/home/index.vue' import home from '@/components/home/index.vue'
import {getCombinationRecordSummary} from "../../../api/promotion/combination";
let app = getApp(); let app = getApp();
export default { export default {
components: { components: {