From a4043cbfd0b199b7818af1aff47aaf3187461e77 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Thu, 18 Dec 2025 09:42:46 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
groupBuying/detail/index.vue | 10 +-
groupBuying/goodsDetail/goodsDetail.vue | 159 +++++++++++++-----------
groupBuying/index/index.vue | 7 +-
3 files changed, 101 insertions(+), 75 deletions(-)
diff --git a/groupBuying/detail/index.vue b/groupBuying/detail/index.vue
index 393f30f..83351d7 100644
--- a/groupBuying/detail/index.vue
+++ b/groupBuying/detail/index.vue
@@ -1,7 +1,7 @@
-
@@ -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({})
diff --git a/groupBuying/goodsDetail/goodsDetail.vue b/groupBuying/goodsDetail/goodsDetail.vue
index 70a13b6..687f3ee 100644
--- a/groupBuying/goodsDetail/goodsDetail.vue
+++ b/groupBuying/goodsDetail/goodsDetail.vue
@@ -32,10 +32,11 @@
{{item.shopAddress}}
-
-
-
- 立即拼团
+
+
+
+
+ 立即拼团
@@ -47,16 +48,18 @@
剩余:
{{getRemainingHMS(item)}}
-
+
快速拼成
-
+
-
+
+
-
-
+
+
+
-
+
可核销门店:
@@ -67,7 +70,7 @@
站前北街7号附近
-
+
@@ -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)
@@ -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;
}
}
}
diff --git a/groupBuying/index/index.vue b/groupBuying/index/index.vue
index 2959010..960bcd4 100644
--- a/groupBuying/index/index.vue
+++ b/groupBuying/index/index.vue
@@ -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)