【砍价详情】

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) {
return request.get("app-api/promotion/bargain-activity/page", {

View File

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