Browse Source

修改团购和秒杀倒计时为0的问题

master
Gao xiaosong 4 years ago
parent
commit
1e8dbdad17
  1. 54
      components/CountDown.vue
  2. 286
      pages/activity/DargainDetails/index.vue
  3. 10
      pages/activity/GoodsSeckill/index.vue
  4. 2
      pages/activity/SeckillDetails/index.vue

54
components/CountDown.vue

@ -12,29 +12,29 @@
</view>
</template>
<script>
export default {
name: "CountDown",
export default {
name: 'CountDown',
props: {
//
tipText: {
type: String,
default: "倒计时"
default: '倒计时'
},
dayText: {
type: String,
default: "天"
default: '天'
},
hourText: {
type: String,
default: "时"
default: '时'
},
minuteText: {
type: String,
default: "分"
default: '分'
},
secondText: {
type: String,
default: "秒"
default: '秒'
},
datatime: {
type: Number,
@ -45,25 +45,25 @@
default: true
}
},
data: function () {
data: function() {
return {
day: "00",
hour: "00",
minute: "00",
second: "00"
day: '00',
hour: '00',
minute: '00',
second: '00'
};
},
created: function () {
created: function() {
this.show_time();
},
mounted: function () {},
mounted: function() {},
methods: {
show_time: function () {
show_time: function() {
let that = this;
function runTime() {
//
let intDiff = that.datatime - Date.parse(new Date()) / 1000; //
let intDiff = that.datatime - new Date() / 1000; //
let day = 0,
hour = 0,
minute = 0,
@ -77,28 +77,24 @@
}
hour = Math.floor(intDiff / (60 * 60)) - day * 24;
minute = Math.floor(intDiff / 60) - day * 24 * 60 - hour * 60;
second =
Math.floor(intDiff) -
day * 24 * 60 * 60 -
hour * 60 * 60 -
minute * 60;
if (hour <= 9) hour = "0" + hour;
if (minute <= 9) minute = "0" + minute;
if (second <= 9) second = "0" + second;
second = Math.floor(intDiff) - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60;
if (hour <= 9) hour = '0' + hour;
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
that.day = day;
that.hour = hour;
that.minute = minute;
that.second = second;
} else {
that.day = "00";
that.hour = "00";
that.minute = "00";
that.second = "00";
that.day = '00';
that.hour = '00';
that.minute = '00';
that.second = '00';
}
}
runTime();
setInterval(runTime, 1000);
}
}
};
};
</script>

286
pages/activity/DargainDetails/index.vue

@ -9,9 +9,7 @@
<!-- 帮助砍价帮砍成功-->
<view class="pictxt acea-row row-center-wrapper ">
<div class="bargain-header">
<view class="pictrue">
<image :src="bargainUserInfo.avatar" />
</view>
<view class="pictrue"><image :src="bargainUserInfo.avatar" /></view>
<view class="text">
{{ bargainUserInfo.nickname }}
<text>邀请您帮忙砍价</text>
@ -21,8 +19,15 @@
</view>
<view class="wrapper bargain-box time on">
<div class="pictxt ">
<count-down :isDay="true" :tipText="'倒计时 '" :dayText="' 天 '" :hourText="' 时 '" :minuteText="' 分 '"
:secondText="' 秒'" :datatime="goodsDetail.stopTime/1000"></count-down>
<count-down
:isDay="true"
:tipText="'倒计时 '"
:dayText="' 天 '"
:hourText="' 时 '"
:minuteText="' 分 '"
:secondText="' 秒'"
:datatime="goodsDetail.stopTime"
></count-down>
</div>
</view>
<view class="wrapper bargain-box bargain-product">
@ -66,7 +71,8 @@
userBargainStatus 砍价状态为
-->
<view class="bargainSuccess" v-if="pay">
<span class="iconfont icon-xiaolian"></span>恭喜您砍价成功快去支付吧~
<span class="iconfont icon-xiaolian"></span>
恭喜您砍价成功快去支付吧~
</view>
<!-- 参与砍价按钮 同一人-->
@ -85,26 +91,23 @@
<view class="bargainBnt" @click="goPay" v-if="pay">立即支付</view>
<view class="bargainBnt on" @click="goList">抢更多商品</view>
<view class="tip">已有<span class="font-color-red" v-text="bargainHelpCount.count"></span>位好友成功帮您砍价</view>
<view class="tip">
已有
<span class="font-color-red" v-text="bargainHelpCount.count"></span>
位好友成功帮您砍价
</view>
<view class="lock"></view>
</view>
<view class="bargainGang bargain-box">
<view class="title font-color-red acea-row row-center-wrapper">
<view class="pictrue">
<image src="@/static/images/left.png" />
</view>
<view class="pictrue"><image src="@/static/images/left.png" /></view>
<view class="titleCon">砍价帮</view>
<view class="pictrue on">
<image src="@/static/images/left.png" />
</view>
<view class="pictrue on"><image src="@/static/images/left.png" /></view>
</view>
<view class="list">
<view class="item acea-row row-between-wrapper" v-for="(item, bargainHelpListIndex) in bargainHelpList"
:key="bargainHelpListIndex">
<view class="item acea-row row-between-wrapper" v-for="(item, bargainHelpListIndex) in bargainHelpList" :key="bargainHelpListIndex">
<view class="pictxt acea-row row-between-wrapper">
<view class="pictrue">
<image :src="item.avatar" />
</view>
<view class="pictrue"><image :src="item.avatar" /></view>
<view class="text">
<view class="name line1" v-text="item.nickname"></view>
<view class="line1" v-text="item.add_time"></view>
@ -116,42 +119,35 @@
</view>
</view>
</view>
<view class="load font-color-red" v-if="!helpListStatus " @click="getBargainHelpList">点击加载更多
</view>
<view class="load font-color-red" v-if="!helpListStatus" @click="getBargainHelpList">点击加载更多</view>
<view class="lock"></view>
</view>
<view class="goodsDetails bargain-box">
<view class="title font-color-red acea-row row-center-wrapper">
<view class="pictrue">
<image src="@/static/images/left.png" />
</view>
<view class="pictrue"><image src="@/static/images/left.png" /></view>
<view class="titleCon">商品详情</view>
<view class="pictrue on">
<image src="@/static/images/left.png" />
</view>
<view class="pictrue on"><image src="@/static/images/left.png" /></view>
</view>
<view class="conter" v-html="goodsDetail.description"></view>
<view class="lock"></view>
</view>
<view class="goodsDetails bargain-box">
<view class="title font-color-red acea-row row-center-wrapper">
<view class="pictrue">
<image src="@/static/images/left.png" />
</view>
<view class="pictrue"><image src="@/static/images/left.png" /></view>
<view class="titleCon">活动规则</view>
<view class="pictrue on">
<image src="@/static/images/left.png" />
</view>
<view class="pictrue on"><image src="@/static/images/left.png" /></view>
</view>
<view class="conter" v-html="goodsDetail.rule"></view>
</view>
<view class="bargainTip" :class="active === true ? 'on' : ''">
<view class="cutOff" v-if="bargainUid === userInfo.uid">
您已砍掉
<text class="font-color-red" v-text="bargainHelpPrice"></text>听说分享次数越多砍价成功的机会越大哦
<text class="font-color-red" v-text="bargainHelpPrice"></text>
听说分享次数越多砍价成功的机会越大哦
</view>
<view class="cutOff on" v-else>
<view class="help font-color-red" v-text="'成功帮砍' + bargainHelpPrice + '元'"></view>您也可以砍价低价拿哦快去挑选心仪的商品吧~
<view class="help font-color-red" v-text="'成功帮砍' + bargainHelpPrice + '元'"></view>
您也可以砍价低价拿哦快去挑选心仪的商品吧~
</view>
<view class="tipBnt" @click="goPoster" v-if="bargainUid === userInfo.uid">邀请好友帮砍价</view>
<view class="tipBnt" @click="getBargainStart" v-else>我也要参与</view>
@ -160,8 +156,8 @@
</view>
</template>
<script>
import CountDown from "@/components/CountDown";
import {
import CountDown from '@/components/CountDown';
import {
getBargainDetail,
getBargainShare,
getBargainStart,
@ -170,33 +166,25 @@
getBargainHelpList,
getBargainHelpCount,
getBargainStartUser
} from "@/api/activity";
import {
postCartAdd
} from "@/api/store";
import {
mapGetters
} from "vuex";
import {} from "@/libs/wechat";
import {
isWeixin,
parseQuery,
handleQrCode
} from "@/utils/index";
} from '@/api/activity';
import { postCartAdd } from '@/api/store';
import { mapGetters } from 'vuex';
import {} from '@/libs/wechat';
import { isWeixin, parseQuery, handleQrCode } from '@/utils/index';
const NAME = "DargainDetails";
const NAME = 'DargainDetails';
export default {
name: "DargainDetails",
export default {
name: 'DargainDetails',
components: {
CountDown
},
props: {},
data: function () {
data: function() {
return {
bargainId: 0, //
bargainSumCount: 0, //
activeMsg: "",
activeMsg: '',
active: false,
bargainHelpPrice: 0, //
bargainHelpList: [],
@ -215,16 +203,16 @@
inviteFriends: false, //
helpFriendsBargain: false, //
bargainSuccess: false, //
mainBargainSuccess: false, //
mainBargainSuccess: false //
};
},
computed: mapGetters(["userInfo", "isLogin"]),
mounted: function () {
computed: mapGetters(['userInfo', 'isLogin']),
mounted: function() {
this.mountedStart();
},
methods: {
//
mountedStart: function () {
mountedStart: function() {
var that = this;
let url = handleQrCode();
// bargainId id
@ -236,13 +224,13 @@
} else {
//
that.bargainId = that.$yroute.query.id;
that.bargainUid = that.$yroute.query.partake
that.bargainUid = that.$yroute.query.partake;
}
if (this.bargainUid == 0 || !this.bargainUid) {
// urluiduid
that.bargainUid = that.userInfo.uid;
}
console.log(this)
console.log(this);
//
that.getBargainDetail();
@ -265,27 +253,27 @@
this.getBargainHelpCount();
},
//
openAlone: function () {
openAlone: function() {
this.$yrouter.push({
path: "/pages/shop/GoodsCon/index",
path: '/pages/shop/GoodsCon/index',
query: {
id: this.goodsDetail.productId
}
});
},
//
goPay: function () {
goPay: function() {
var data = {};
var that = this;
data.productId = that.goodsDetail.productId;
data.cartNum = that.goodsDetail.num;
data.uniqueId = "";
data.uniqueId = '';
data.bargainId = that.bargainId;
data.new = 1;
postCartAdd(data)
.then(res => {
that.$yrouter.push({
path: "/pages/order/OrderSubmission/index",
path: '/pages/order/OrderSubmission/index',
query: {
id: res.data.cartId
}
@ -294,17 +282,17 @@
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
icon: 'none',
duration: 2000
});
});
},
//
goPoster: function () {
goPoster: function() {
var that = this;
that.getBargainShare(that.bargainId);
this.$yrouter.push({
path: "/pages/activity/Poster/index",
path: '/pages/activity/Poster/index',
query: {
id: that.bargainId,
type: 2
@ -312,55 +300,49 @@
});
},
//
goList: function () {
goList: function() {
this.$yrouter.push({
path: "/pages/activity/GoodsBargain/index"
path: '/pages/activity/GoodsBargain/index'
});
},
//
//bargainId 0
//bargainId
getBargainShare: function (bargainId) {
getBargainShare: function(bargainId) {
var that = this;
getBargainShare({
bargainId: bargainId
}).then(res => {
that.bargainShare = res.data
that.bargainShare = res.data;
});
},
//
getBargainDetail: function () {
getBargainDetail: function() {
var that = this;
uni.showLoading({
title: "加载中",
title: '加载中',
mask: true
});
getBargainDetail(that.bargainId)
.then(res => {
uni.hideLoading()
uni.hideLoading();
that.goodsDetail = res.data.bargain;
that.goodsDetail.description = that.goodsDetail.description.replace(
/\<img/gi,
'<img style="max-width:100%;height:auto;"'
);
that.goodsDetail.rule = that.goodsDetail.rule.replace(
/\<img/gi,
'<img style="max-width:100%;height:auto;"'
);
that.goodsDetail.stopTime = that.goodsDetail.stopTime / 1000
that.goodsDetail.description = that.goodsDetail.description.replace(/\<img/gi, '<img style="max-width:100%;height:auto;"');
that.goodsDetail.rule = that.goodsDetail.rule.replace(/\<img/gi, '<img style="max-width:100%;height:auto;"');
that.goodsDetail.stopTime = that.goodsDetail.stopTime / 1000;
that.getBargainHelpCount();
})
.catch(res => {
uni.hideLoading()
uni.hideLoading();
uni.showToast({
title: res.msg,
icon: "none",
icon: 'none',
duration: 2000
});
});
},
// -
getBargainStart: function () {
getBargainStart: function() {
var that = this;
getBargainStart({
bargainId: that.bargainId
@ -373,21 +355,18 @@
.catch(res => {
uni.showToast({
title: res.msg,
icon: "none",
icon: 'none',
duration: 2000
});
});
},
//
getBargainHelp: function () {
getBargainHelp: function() {
var that = this;
if (
this.bargainHelpCount.price === 0 &&
that.bargainUid !== that.userInfo.uid
) {
if (this.bargainHelpCount.price === 0 && that.bargainUid !== that.userInfo.uid) {
return uni.showToast({
title: "好友已经砍价成功",
icon: "success",
title: '好友已经砍价成功',
icon: 'success',
duration: 2000
});
}
@ -398,10 +377,10 @@
getBargainHelp(data)
.then(res => {
that.activeMsg = res.data.status;
if (res.data.status === "SUCCESSFUL" && that.bargainUid !== that.userInfo.uid) {
if (res.data.status === 'SUCCESSFUL' && that.bargainUid !== that.userInfo.uid) {
uni.showToast({
title: "您已经砍过了",
icon: "none",
title: '您已经砍过了',
icon: 'none',
duration: 2000
});
return;
@ -414,13 +393,13 @@
.catch(res => {
uni.showToast({
title: res.msg,
icon: "none",
icon: 'none',
duration: 2000
});
});
},
//
getBargainHelpPrice: function () {
getBargainHelpPrice: function() {
var that = this;
getBargainHelpPrice({
bargainId: that.bargainId,
@ -431,9 +410,9 @@
that.getBargainHelpCount();
that.getBargainHelpList();
switch (that.activeMsg) {
case "SUCCESSFUL":
case 'SUCCESSFUL':
break;
case "SUCCESS":
case 'SUCCESS':
that.active = true;
break;
}
@ -441,13 +420,13 @@
.catch(res => {
uni.showToast({
title: res.msg,
icon: "none",
icon: 'none',
duration: 2000
});
});
},
//
getBargainHelpList: function () {
getBargainHelpList: function() {
var that = this;
if (that.helpListStatus === true) return;
getBargainHelpList({
@ -465,37 +444,37 @@
})
.catch(err => {
if (!err.msg) {
return
return;
}
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
icon: 'none',
duration: 2000
});
});
},
//
getBargainHelpCount: function () {
getBargainHelpCount: function() {
getBargainHelpCount({
bargainId: this.bargainId,
bargainUserUid: this.bargainUid
})
.then(res => {
// ** 使 = -
let remainingPrice = (this.goodsDetail.price - res.data.alreadyPrice).toFixed(2)
let remainingPrice = (this.goodsDetail.price - res.data.alreadyPrice).toFixed(2);
this.bargainHelpCount = {
...res.data,
remainingPrice
}
this.handleButtonStatus()
};
this.handleButtonStatus();
})
.catch(err => {
if (!err.msg) {
return
return;
}
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
icon: 'none',
duration: 2000
});
});
@ -504,24 +483,17 @@
handleButtonStatus() {
//
// 1. ==> &&
if (
this.bargainUid === this.userInfo.uid &&
this.bargainHelpCount.status == 0
) {
this.participate = true
if (this.bargainUid === this.userInfo.uid && this.bargainHelpCount.status == 0) {
this.participate = true;
} else {
this.participate = false
this.participate = false;
}
// 2. ==> && && >0
if (
this.bargainUid === this.userInfo.uid &&
this.bargainHelpCount.status == 1 &&
this.bargainHelpCount.price > 0
) {
this.inviteFriends = true
if (this.bargainUid === this.userInfo.uid && this.bargainHelpCount.status == 1 && this.bargainHelpCount.price > 0) {
this.inviteFriends = true;
} else {
this.inviteFriends = false
this.inviteFriends = false;
}
// 3. ==> && && >0 &&
@ -531,40 +503,33 @@
// this.bargainHelpCount.userBargainStatus &&
this.bargainHelpCount.price > 0
) {
this.helpFriendsBargain = true
this.helpFriendsBargain = true;
} else {
this.helpFriendsBargain = false
this.helpFriendsBargain = false;
}
// 4. ==> && && <=0
if (
this.bargainUid === this.userInfo.uid &&
this.bargainHelpCount.status == 1 &&
this.bargainHelpCount.price <= 0
) {
this.pay = true
if (this.bargainUid === this.userInfo.uid && this.bargainHelpCount.status == 1 && this.bargainHelpCount.price <= 0) {
this.pay = true;
} else {
this.pay = false
this.pay = false;
}
// 5. ==> &&
if (
this.bargainUid != this.userInfo.uid
) {
this.bargain = true
if (this.bargainUid != this.userInfo.uid) {
this.bargain = true;
} else {
this.bargain = false
this.bargain = false;
}
//
// 1. ==> &&
// 2. ==> &&
// 3. ==> && true
},
//
//
getBargainStartUser: function () {
getBargainStartUser: function() {
var that = this;
getBargainStartUser({
bargainId: that.bargainId,
@ -577,53 +542,51 @@
.catch(res => {
uni.showToast({
title: res.msg,
icon: "none",
icon: 'none',
duration: 2000
});
});
},
//
close: function () {
close: function() {
this.active = false;
},
//
onShareAppMessage: function () {
onShareAppMessage: function() {
return {
title: this.storeInfo.title,
imageUrl: this.storeInfo.image,
path: "pages/activity/DargainDetails/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync(
"uid"),
path: 'pages/activity/DargainDetails/index?id=' + this.storeInfo.id + '&spread=' + uni.getStorageSync('uid'),
success(res) {
uni.showToast({
title: '分享成功'
})
});
},
fail(res) {
uni.showToast({
title: '分享失败',
icon: 'none'
})
});
}
};
}
},
},
onShareAppMessage() {
return {
path: `/pages/activity/DargainDetails/index/?id=${this.$yroute.query.id}&partake=${this.userInfo.uid}`
};
}
};
};
</script>
<style lang="less">
.bargain {
.bargain {
&.on {
.bargain-box {
background: #fff;
width: auto;
margin: 0 20rpx;
border: 0;
}
.header {
@ -642,14 +605,13 @@
}
}
}
}
}
page {
page {
background-color: #f5f5f5 !important;
}
}
.bargainBnt_hui {
.bargainBnt_hui {
font-size: 0.3 * 100rpx;
font-weight: bold;
color: #fff;
@ -660,9 +622,9 @@
text-align: center;
line-height: 0.8 * 100rpx;
margin-top: 0.32 * 100rpx;
}
}
.bargain_view {
.bargain_view {
left: 0;
right: 0;
height: 0.48 * 100rpx;
@ -675,9 +637,9 @@
color: #fff;
text-align: center;
line-height: 0.48 * 100rpx;
}
}
.iconfonts {
.iconfonts {
font-size: 0.22 * 100rpx;
}
}
</style>

10
pages/activity/GoodsSeckill/index.vue

@ -45,12 +45,12 @@
<view class="piece font-color-red" v-text="'仅剩' + itemSeckill.stock + '件'"></view>
</view>
</view>
<view class="grab bg-color-red" v-if="item.status === 1 && itemSeckill.stock > 0"
@click="goDetail(itemSeckill.id,item.status)">马上抢</view>
<view class="grab bg-color-red" v-if="item.status === 1 && itemSeckill.stock > 0" @click="goDetail(itemSeckill.id,item.status)">马上抢</view>
<view class="grab" v-if="item.status === 1 && itemSeckill.stock <= 0">已售磬</view>
<view class="grab bg-color-red" @click="goDetail(itemSeckill.id,item.status)" v-if="item.status === 2">即将开始
</view>
<view class="grab bg-color-red" @click="goDetail(itemSeckill.id,item.status)" v-if="item.status === 0">已结束</view>
<view class="grab bg-color-red" v-if="item.status === 2">即将开始</view>
<view class="grab bg-color-red" v-if="item.status === 0">已结束</view>
<!-- <view class="grab bg-color-red" @click="goDetail(itemSeckill.id,item.status)" v-if="item.status === 2">即将开始</view> -->
<!-- <view class="grab bg-color-red" @click="goDetail(itemSeckill.id,item.status)" v-if="item.status === 0">已结束</view> -->
</view>
</view>
<view class="noCommodity" style="background-color: #f5f5f5;" v-if="seckillList.length === 0 && page > 1">

2
pages/activity/SeckillDetails/index.vue

@ -20,7 +20,7 @@
:hourText="' : '"
:minuteText="' : '"
:secondText="' '"
:datatime="datatime / 1000"
:datatime="datatime"
></count-down>
</view>
<view class="iconfont icon-jiantou"></view>

Loading…
Cancel
Save