update:新增砍价成功图片跳转店铺,新增砍价有效期倒计时时间戳
This commit is contained in:
parent
27d2d0b231
commit
a0c6678a9e
@ -47,8 +47,15 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="part-bottom-sty">
|
||||
<view :class="Info.can_buy_now==2?'time_fon_sty_reason1':'time_fon_sty_reason2'" >{{Info.cannot_buy_now_reason}}</view>
|
||||
<view class="time_sty">
|
||||
<view
|
||||
:class="
|
||||
Info.can_buy_now == 2
|
||||
? 'time_fon_sty_reason1'
|
||||
: 'time_fon_sty_reason2'
|
||||
"
|
||||
>{{ Info.cannot_buy_now_reason }}</view
|
||||
>
|
||||
<view class="time_sty">
|
||||
<view class="time_fon_sty">
|
||||
{{ __("活动时间仅剩") }}
|
||||
</view>
|
||||
@ -127,11 +134,17 @@
|
||||
Info.order_id == ''
|
||||
"
|
||||
>
|
||||
<!-- <view class="" @click="goshop">还差xx</view> -->
|
||||
<view class="immediately_btn" v-if="Info.can_buy_now==1" @click="goshop"></view>
|
||||
<!-- <view class="" @click="goshop">还差xx</view> -->
|
||||
<view
|
||||
:class="Info.can_buy_now === 2 ? 'help_cut_btn2' : 'help_cut_btn'"
|
||||
style=""
|
||||
class="immediately_btn"
|
||||
v-if="Info.can_buy_now == 1"
|
||||
@click="goshop"
|
||||
></view>
|
||||
<view
|
||||
:class="
|
||||
Info.can_buy_now === 2 ? 'help_cut_btn2' : 'help_cut_btn'
|
||||
"
|
||||
style=""
|
||||
v-if="Info.activity_state == 1"
|
||||
@click="shareBox"
|
||||
></view>
|
||||
@ -273,7 +286,7 @@
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- <view style="display:flex; flex-direction: column; justify-content:center;align-items: center;">
|
||||
<!-- <view style="display:flex; flex-direction: column; justify-content:center;align-items: center;">
|
||||
<view>活动规则</view>
|
||||
<textarea name="" id="" cols="30" rows="10">
|
||||
砍价时间:顾客发起活动后需要在规定时间内完成砍价,超过时间则砍价失败。一般建议时间为24小时。
|
||||
@ -291,19 +304,22 @@
|
||||
</view>
|
||||
<view :class="['msk']" @tap="back" v-if="showImg">
|
||||
<view class="msk_box">
|
||||
<image
|
||||
src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/xcxfile/appicon/cutprice-1/cut-price-animation.png"
|
||||
style="width: 100%"
|
||||
mode="widthFix"
|
||||
@tap="back"
|
||||
></image>
|
||||
<navigator
|
||||
:url="'/pagesub/index/store?store_id=' + Info.store_id"
|
||||
@tap.stop="goToStore"
|
||||
>
|
||||
<image
|
||||
src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/xcxfile/appicon/cutprice-1/cut-price-animation.png"
|
||||
style="width: 100%"
|
||||
mode="widthFix"
|
||||
></image>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-tap-btn">
|
||||
<navigator
|
||||
url="/pages/index/index"
|
||||
open-type="switchTab"
|
||||
:url="'/pagesub/index/store?store_id=' + Info.store_id"
|
||||
class="u-go-home"
|
||||
>
|
||||
<view class="iconfont icon-shouyeshouye"></view>
|
||||
@ -322,6 +338,7 @@
|
||||
:shareDataDefault="shareData"
|
||||
ref="shareBoxApp"
|
||||
></share-box-app>
|
||||
<loginPopup :show="showLoginPopup" @close="closeLoginPopup"></loginPopup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -341,7 +358,7 @@ import { mapState, mapMutations } from "vuex";
|
||||
|
||||
import shareBoxMp from "../../components/share-box-mp.vue";
|
||||
import shareBoxApp from "../../components/share-box-app.vue";
|
||||
|
||||
import loginPopup from "@/components/loginPopup.vue";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -390,11 +407,15 @@ export default {
|
||||
href: "https://www.suteshop.com",
|
||||
image: "",
|
||||
},
|
||||
showLoginPopup: false,
|
||||
expiredAt: 0, // 初始化时间戳为0
|
||||
countdownTimer: null, // 定时器实例,用于清除
|
||||
};
|
||||
},
|
||||
components: {
|
||||
shareBoxMp,
|
||||
shareBoxApp,
|
||||
loginPopup,
|
||||
},
|
||||
computed: mapState([
|
||||
"Config",
|
||||
@ -459,6 +480,10 @@ export default {
|
||||
if (this.$refs.shareBoxApp.showBoxView) {
|
||||
this.$refs.shareBoxApp.cancel();
|
||||
}
|
||||
// 新增:清除倒计时定时器
|
||||
if (that.countdownTimer) {
|
||||
clearInterval(that.countdownTimer);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations([
|
||||
@ -488,6 +513,10 @@ export default {
|
||||
data: params,
|
||||
success: function (data, status, msg, code) {
|
||||
if (200 == status) {
|
||||
// 新增:保存接口返回的过期时间戳(注意判断是否存在)
|
||||
if (data.expired_at) {
|
||||
that.setData({ expiredAt: data.expired_at }); // 存储时间戳
|
||||
}
|
||||
data.CutPricePercent =
|
||||
(data.activity_rule.item_unit_price - data.ac_sale_price) /
|
||||
(data.activity_rule.item_unit_price -
|
||||
@ -497,7 +526,8 @@ export default {
|
||||
ac_id: data.ac_id,
|
||||
width: 100 * parseFloat(data.CutPricePercent).toFixed(2),
|
||||
});
|
||||
that.getTime();
|
||||
// that.getTime();
|
||||
that.startCountdown();
|
||||
data.ac_sale_price - data.ac_mix_limit_price <= 0
|
||||
? that.setData({
|
||||
isCut: false,
|
||||
@ -520,6 +550,56 @@ export default {
|
||||
},
|
||||
});
|
||||
},
|
||||
closeLoginPopup() {
|
||||
this.showLoginPopup = false;
|
||||
},
|
||||
// 新增:基于expired_at时间戳的倒计时逻辑
|
||||
startCountdown() {
|
||||
var that = this;
|
||||
// 清除已有定时器(避免重复)
|
||||
if (that.countdownTimer) {
|
||||
clearInterval(that.countdownTimer);
|
||||
}
|
||||
|
||||
// 定义倒计时更新函数
|
||||
function updateCountdown() {
|
||||
const now = new Date().getTime(); // 当前时间戳(毫秒)
|
||||
const expiredAt = that.expiredAt; // 接口返回的过期时间戳(毫秒)
|
||||
const remainingTime = expiredAt - now; // 剩余时间(毫秒)
|
||||
|
||||
// 情况1:已过期(剩余时间<=0)
|
||||
if (remainingTime <= 0) {
|
||||
that.setData({
|
||||
Time: { hour: "00", min: "00", sec: "00" },
|
||||
end: 3, // 标记活动结束
|
||||
});
|
||||
clearInterval(that.countdownTimer); // 清除定时器
|
||||
return;
|
||||
}
|
||||
|
||||
// 情况2:未过期,计算剩余时、分、秒
|
||||
const hours = Math.floor(remainingTime / 3600000); // 小时:3600*1000
|
||||
const minutes = Math.floor((remainingTime % 3600000) / 60000); // 分钟:60*1000
|
||||
const seconds = Math.floor((remainingTime % 60000) / 1000); // 秒
|
||||
|
||||
// 补零(确保显示两位数)
|
||||
const formatHour = hours.toString().padStart(2, "0");
|
||||
const formatMin = minutes.toString().padStart(2, "0");
|
||||
const formatSec = seconds.toString().padStart(2, "0");
|
||||
|
||||
// 更新页面数据
|
||||
that.setData({
|
||||
Time: { hour: formatHour, min: formatMin, sec: formatSec },
|
||||
end: 2, // 标记活动进行中
|
||||
});
|
||||
}
|
||||
|
||||
// 立即执行一次(避免初始延迟)
|
||||
updateCountdown();
|
||||
|
||||
// 每隔1秒更新一次
|
||||
that.countdownTimer = setInterval(updateCountdown, 1000);
|
||||
},
|
||||
getTime: function () {
|
||||
var e = this,
|
||||
t = new Date().getTime(),
|
||||
@ -668,8 +748,20 @@ export default {
|
||||
},
|
||||
|
||||
bargin: function () {
|
||||
// 未登录时显示登录弹窗
|
||||
if (!this.hasLogin) {
|
||||
this.showLoginPopup = true;
|
||||
return;
|
||||
}
|
||||
this.CutPrice();
|
||||
},
|
||||
// 图片点击跳转店铺
|
||||
goToStore() {
|
||||
var that = this;
|
||||
that.setData({ showImg: false });
|
||||
that.GetVendorCutPriceEventDetail();
|
||||
that.GetOtherCutPriceActivityList();
|
||||
},
|
||||
back: function () {
|
||||
this.setData({
|
||||
showImg: false,
|
||||
@ -690,6 +782,11 @@ export default {
|
||||
}
|
||||
},
|
||||
goshop: function () {
|
||||
// 未登录时显示登录弹窗
|
||||
if (!this.hasLogin) {
|
||||
this.showLoginPopup = true;
|
||||
return;
|
||||
}
|
||||
var e = this,
|
||||
params = {
|
||||
amount: 1,
|
||||
@ -765,6 +862,11 @@ export default {
|
||||
});
|
||||
},
|
||||
shareBox: function () {
|
||||
// 未登录时显示登录弹窗
|
||||
if (!this.hasLogin) {
|
||||
this.showLoginPopup = true;
|
||||
return;
|
||||
}
|
||||
let that = this;
|
||||
// 如允许点击超链接跳转,则应该打开一个新页面,并传入href,由新页面内嵌webview组件负责显示该链接内容
|
||||
var $href = $.sprintf(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user