拼团修改
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="min-page bg-f7 color-333 u-font-28 relative">
|
||||
<view class="top" :style="topStyle">
|
||||
<up-navbar bg-color="transparent" :fixed="false" :placeholder="false" title="订单详情" left-icon-color="#fff"
|
||||
<up-navbar bg-color="transparent" :fixed="false" :placeholder="false" title="订单详情" left-icon-color="#fff" @leftClick="uni.navigateBack()"
|
||||
title-color="#fff"></up-navbar>
|
||||
<view class="u-flex info u-col-center">
|
||||
</view>
|
||||
@@ -184,8 +184,16 @@
|
||||
})
|
||||
|
||||
function init(opt) {
|
||||
// 获取小程序进入场景和参数
|
||||
const launchOptions = uni.getLaunchOptionsSync();
|
||||
console.log(launchOptions);
|
||||
// 获取链接上的参数
|
||||
const launchOptionsQuery = launchOptions.query;
|
||||
console.log('launchOptionsQuery', launchOptionsQuery);
|
||||
Object.assign(query, launchOptionsQuery)
|
||||
console.log(opt)
|
||||
Object.assign(query, opt)
|
||||
console.log(query)
|
||||
getDetail()
|
||||
}
|
||||
const item = reactive({})
|
||||
|
||||
@@ -32,10 +32,11 @@
|
||||
<view class="">{{item.shopAddress}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bg-f7" style="height: 32rpx"></view>
|
||||
<view class="groups">
|
||||
<view class="color-000 u-m-b-28 u-font-32 font-700">立即拼团</view>
|
||||
|
||||
<template v-if="item.gbOrderList.length">
|
||||
<view class="bg-f7" style="height: 32rpx"></view>
|
||||
<view class="groups">
|
||||
<view class="color-000 u-m-b-28 u-font-32 font-700">立即拼团</view>
|
||||
<view class="item u-flex" v-for="(item,index) in item.gbOrderList" :key="index">
|
||||
<up-avatar size="76rpx" :src="item.avatar"></up-avatar>
|
||||
<view class="u-flex u-flex-1 u-p-l-22 u-col-center u-row-between">
|
||||
@@ -47,16 +48,18 @@
|
||||
<text class="color-666">剩余:</text>
|
||||
<text class="main-color">{{getRemainingHMS(item)}}</text>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="btn" @click="fastBuy(item)">快速拼成</view>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
<view class="bg-f7" style="height: 32rpx"></view>
|
||||
|
||||
|
||||
<view class="desc">
|
||||
<view class="u-flex">
|
||||
<view class="color-666 no-wrap" style="min-width: 180rpx;">可核销门店:</view>
|
||||
@@ -67,7 +70,7 @@
|
||||
<view class="">站前北街7号附近</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="bg-f7" style="height: 24rpx"></view>
|
||||
|
||||
<view class="goods-detail" v-if="item.goodsCategory!='优惠券'">
|
||||
@@ -196,24 +199,24 @@
|
||||
|
||||
const popupData = reactive({
|
||||
show: false,
|
||||
item:null
|
||||
item: null
|
||||
});
|
||||
|
||||
function exchangeClick() {
|
||||
popupData.show = true
|
||||
|
||||
}
|
||||
|
||||
function fastBuy(item){
|
||||
popupData.item=item;
|
||||
|
||||
function fastBuy(item) {
|
||||
popupData.item = item;
|
||||
popupData.show = true
|
||||
}
|
||||
watch(()=>popupData.show,(newval)=>{
|
||||
if(!newval){
|
||||
popupData.item=null
|
||||
watch(() => popupData.show, (newval) => {
|
||||
if (!newval) {
|
||||
popupData.item = null
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function confirmExchange() {
|
||||
// modalData.show = false;
|
||||
exchange()
|
||||
@@ -230,7 +233,7 @@
|
||||
shopId: item.shopId,
|
||||
number: 1,
|
||||
price: item.extraPrice,
|
||||
groupOrderNo:popupData.item?popupData.item.groupOrderNo:'',
|
||||
groupOrderNo: popupData.item ? popupData.item.groupOrderNo : '',
|
||||
openId
|
||||
}).then(orderRes => {
|
||||
popupData.show = false;
|
||||
@@ -238,7 +241,8 @@
|
||||
console.log(res)
|
||||
if (res) {
|
||||
uni.redirectTo({
|
||||
url: '/groupBuying/success/index?detailId='+orderRes.goodsRecord.id
|
||||
url: '/groupBuying/success/index?detailId=' + orderRes.goodsRecord
|
||||
.id
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
@@ -327,84 +331,93 @@
|
||||
const query = reactive({
|
||||
shopId: '',
|
||||
wareId: '',
|
||||
groupOrderNo:''
|
||||
})
|
||||
|
||||
|
||||
const coverImgs = ref([])
|
||||
|
||||
function init(opt) {
|
||||
// 获取小程序进入场景和参数
|
||||
const launchOptions = uni.getLaunchOptionsSync();
|
||||
console.log(launchOptions);
|
||||
// 获取链接上的参数
|
||||
const launchOptionsQuery = launchOptions.query;
|
||||
console.log('launchOptionsQuery', launchOptionsQuery);
|
||||
Object.assign(query, launchOptionsQuery)
|
||||
console.log(opt)
|
||||
Object.assign(query, opt)
|
||||
console.log(query)
|
||||
getDetail()
|
||||
}
|
||||
|
||||
function getDetail() {
|
||||
Api.wareDetail(query).then(res => {
|
||||
res.wareCommentImgs = res.wareCommentImgs.split(',').filter(v=>v)
|
||||
res.wareCommentImgs = res.wareCommentImgs.split(',').filter(v => v)
|
||||
Object.assign(item, res)
|
||||
console.log(item)
|
||||
coverImgs.value = res.wareImgs.split(',')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 计算剩余时间差(毫秒)
|
||||
* @param {Object} item - 包含groupEndTime的订单/拼团对象
|
||||
* @returns {number} 剩余时间(毫秒)
|
||||
*/
|
||||
function returnRemainingTime(item) {
|
||||
if (!item?.groupEndTime) return 0; // 容错:无结束时间则返回0
|
||||
return dayjs(item.groupEndTime).valueOf() - dayjs().valueOf();
|
||||
if (!item?.groupEndTime) return 0; // 容错:无结束时间则返回0
|
||||
return dayjs(item.groupEndTime).valueOf() - dayjs().valueOf();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将毫秒差格式化为 HH:MM:SS(最多72小时)
|
||||
* @param {number} ms - 时间差(毫秒)
|
||||
* @returns {string} 格式化后的时分秒(如 09:09:09、72:00:00、00:00:00)
|
||||
*/
|
||||
function formatTimeToHMS(ms) {
|
||||
// 边界1:已过期/无剩余时间 → 显示00:00:00
|
||||
if (ms <= 0) return '00:00:00';
|
||||
|
||||
// 边界2:超过72小时 → 按72小时算(72*60*60*1000 = 259200000毫秒)
|
||||
const maxMs = 72 * 60 * 60 * 1000;
|
||||
const validMs = Math.min(ms, maxMs);
|
||||
|
||||
// 转换为总秒数(取整,避免小数)
|
||||
const totalSeconds = Math.floor(validMs / 1000);
|
||||
|
||||
// 拆解小时、分钟、秒
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const remainingSeconds = totalSeconds % 3600;
|
||||
const minutes = Math.floor(remainingSeconds / 60);
|
||||
const seconds = remainingSeconds % 60;
|
||||
|
||||
// 补零(确保两位数,如 9 → 09)
|
||||
const pad = (num) => String(num).padStart(2, '0');
|
||||
return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
|
||||
// 边界1:已过期/无剩余时间 → 显示00:00:00
|
||||
if (ms <= 0) return '00:00:00';
|
||||
|
||||
// 边界2:超过72小时 → 按72小时算(72*60*60*1000 = 259200000毫秒)
|
||||
const maxMs = 72 * 60 * 60 * 1000;
|
||||
const validMs = Math.min(ms, maxMs);
|
||||
|
||||
// 转换为总秒数(取整,避免小数)
|
||||
const totalSeconds = Math.floor(validMs / 1000);
|
||||
|
||||
// 拆解小时、分钟、秒
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const remainingSeconds = totalSeconds % 3600;
|
||||
const minutes = Math.floor(remainingSeconds / 60);
|
||||
const seconds = remainingSeconds % 60;
|
||||
|
||||
// 补零(确保两位数,如 9 → 09)
|
||||
const pad = (num) => String(num).padStart(2, '0');
|
||||
return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
|
||||
}
|
||||
|
||||
|
||||
let timer=null
|
||||
let nowTime=ref(Date.now())
|
||||
timer=setInterval(()=>{
|
||||
nowTime.value=Date.now()
|
||||
},1000)
|
||||
|
||||
|
||||
|
||||
let timer = null
|
||||
let nowTime = ref(Date.now())
|
||||
timer = setInterval(() => {
|
||||
nowTime.value = Date.now()
|
||||
}, 1000)
|
||||
|
||||
// 组合使用:获取格式化后的剩余时间
|
||||
function getRemainingHMS(item) {
|
||||
nowTime.value
|
||||
const ms = returnRemainingTime(item);
|
||||
return formatTimeToHMS(ms);
|
||||
const ms = returnRemainingTime(item);
|
||||
return formatTimeToHMS(ms);
|
||||
}
|
||||
|
||||
|
||||
function returnNeedPerpole(data){
|
||||
return data.groupPeopleNum-data.currentPeopleNum
|
||||
|
||||
|
||||
function returnNeedPerpole(data) {
|
||||
return data.groupPeopleNum - data.currentPeopleNum
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
onLoad(init)
|
||||
</script>
|
||||
|
||||
@@ -621,25 +634,29 @@
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.groups{
|
||||
|
||||
.groups {
|
||||
padding: 28rpx 22rpx;
|
||||
background-color: #fff;
|
||||
.item{
|
||||
|
||||
.item {
|
||||
padding: 28rpx 0;
|
||||
border-bottom: 2rpx solid #EDEDED;
|
||||
&:last-child{
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.main-color{
|
||||
color: #ed5a2e;
|
||||
|
||||
.main-color {
|
||||
color: #ed5a2e;
|
||||
}
|
||||
.btn{
|
||||
|
||||
.btn {
|
||||
padding: 8rpx 26rpx;
|
||||
border-radius: 36rpx;
|
||||
background: #E8AD7B;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,12 +352,13 @@
|
||||
|
||||
onShareAppMessage(() => {
|
||||
console.log('onShareAppMessage')
|
||||
|
||||
console.log(shareItem)
|
||||
const query=`groupOrderNo=${shareItem.groupOrderNo}&shopId=${shareItem.shopId}`
|
||||
return wxShare({
|
||||
title: shareItem.wareJson.wareName,
|
||||
imageUrl: shareItem.goodsImg,
|
||||
path:'/groupBuying/goodsDetail/goodsDetail',
|
||||
query: `wareId=${shareItem.wareId}&shopId=${shareItem.shopId}`,
|
||||
path:'/groupBuying/detail/index' +'?'+query,
|
||||
query,
|
||||
})
|
||||
})
|
||||
onLoad(getData)
|
||||
|
||||
Reference in New Issue
Block a user