From 36289d526cb6030260db9741fce7dbdfa75ab843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E8=B6=8A?= <552369664@qq.com> Date: Tue, 3 Sep 2024 15:36:18 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E3=80=90=E7=BB=BC=E5=90=88=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E3=80=91=E6=94=B9=E9=80=A0=E6=8B=BC=E5=9B=A2=E8=A3=85?= =?UTF-8?q?=E4=BF=AE=EF=BC=88=E4=BB=8D=E9=9C=80=E4=BC=98=E5=8C=96=EF=BC=89?= =?UTF-8?q?=EF=BC=9B=E5=A4=84=E7=90=86=E6=97=A0=E6=B3=95=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=88=B0=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 7 +- pages/user/goods_details_store/index.vue | 6 +- sheep/api/promotion/combination.js | 11 + .../components/s-goods-card/s-goods-card.vue | 15 +- .../s-goods-column/s-goods-column.vue | 63 ++- .../s-groupon-block/s-groupon-block.vue | 449 ++++++++++++------ .../components/s-live-block/s-live-block.vue | 4 +- sheep/helper/index.js | 2 +- sheep/platform/share.js | 3 +- 9 files changed, 366 insertions(+), 194 deletions(-) diff --git a/manifest.json b/manifest.json index 4732b6d3..ac575dbe 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "appid": "__UNI__460BC4C", "description": "基于 uni-app + Vue3 技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。", "versionName": "2.1.0", - "versionCode": 183, + "versionCode": "183", "transformPx": false, "app-plus": { "usingComponents": true, @@ -188,7 +188,8 @@ "setting": { "urlCheck": false, "minified": true, - "postcss": true + "postcss": false, + "es6": false }, "optimization": { "subPackages": true @@ -236,4 +237,4 @@ "_spaceID": "192b4892-5452-4e1d-9f09-eee1ece40639", "locale": "zh-Hans", "fallbackLocale": "zh-Hans" -} +} \ No newline at end of file diff --git a/pages/user/goods_details_store/index.vue b/pages/user/goods_details_store/index.vue index 07b68508..92ef2d0b 100644 --- a/pages/user/goods_details_store/index.vue +++ b/pages/user/goods_details_store/index.vue @@ -75,7 +75,6 @@ const jsWxSdk = sheep.$platform.useProvider('wechat').jsWxSdk; if (jsWxSdk.isWechat()) { jsWxSdk.getLocation((res) => { - console.log(res); state.user_latitude = res.latitude; state.user_longitude = res.longitude; uni.setStorageSync(LATITUDE, res.latitude); @@ -92,7 +91,8 @@ state.user_longitude = res.longitude; uni.setStorageSync(LATITUDE, res.latitude); uni.setStorageSync(LONGITUDE, res.longitude); - } catch { + } catch (e) { + console.error(e); } getList(); }, @@ -172,7 +172,7 @@ state.user_latitude = uni.getStorageSync(LATITUDE); state.user_longitude = uni.getStorageSync(LONGITUDE); } catch (e) { - // error + console.error(e) } }); diff --git a/sheep/api/promotion/combination.js b/sheep/api/promotion/combination.js index 44f61e9d..49931102 100644 --- a/sheep/api/promotion/combination.js +++ b/sheep/api/promotion/combination.js @@ -31,6 +31,17 @@ const CombinationApi = { }); }, + // 获得拼团活动明细列表 + getCombinationActivityDetailList: (combinationActivityIds) => { + return request({ + url: '/promotion/combination-activity/get-detail-list', + method: 'GET', + params: { + combinationActivityIds + }, + }); + }, + // 获得最近 n 条拼团记录(团长发起的) getHeadCombinationRecordList: (activityId, status, count) => { return request({ diff --git a/sheep/components/s-goods-card/s-goods-card.vue b/sheep/components/s-goods-card/s-goods-card.vue index 59f2bf10..21df6ad1 100644 --- a/sheep/components/s-goods-card/s-goods-card.vue +++ b/sheep/components/s-goods-card/s-goods-card.vue @@ -147,7 +147,7 @@ TWO_COL: 'twoCol', // 单列小图 ONE_COL_SMALL_IMG: 'oneColSmallImg', - } + }; const state = reactive({ goodsList: [], @@ -157,16 +157,16 @@ const props = defineProps({ data: { type: Object, - default() {}, + default: () => ({}) }, styles: { type: Object, - default() {}, + default: () => ({}) }, }); - const { layoutType, btnBuy, spuIds } = props.data ?? {}; - const { marginLeft, marginRight } = props.styles ?? {}; + const { layoutType, btnBuy, spuIds } = props.data || {}; + const { marginLeft, marginRight } = props.styles || {}; // 购买按钮样式 const buyStyle = computed(() => { @@ -215,6 +215,7 @@ // 计数 count++; } + //endregion /** @@ -232,7 +233,7 @@ // 加载商品列表 state.goodsList = await getGoodsListByIds(spuIds.join(',')); // 只有双列布局时需要 - if (layoutType === LayoutTypeEnum.TWO_COL){ + if (layoutType === LayoutTypeEnum.TWO_COL) { // 分列 calculateGoodsColumn(); } @@ -247,11 +248,13 @@ .goods-list-box { width: 50%; box-sizing: border-box; + .left-list { &:nth-last-child(1) { margin-bottom: 0 !important; } } + .right-list { &:nth-last-child(1) { margin-bottom: 0 !important; diff --git a/sheep/components/s-goods-column/s-goods-column.vue b/sheep/components/s-goods-column/s-goods-column.vue index 228c64e1..7e81a16e 100644 --- a/sheep/components/s-goods-column/s-goods-column.vue +++ b/sheep/components/s-goods-column/s-goods-column.vue @@ -155,7 +155,7 @@ - 秒杀 + 秒杀 拼团 @@ -285,9 +285,9 @@ - 去购买 + + 去购买 + @@ -297,35 +297,34 @@ * 商品卡片 * * @property {Array} size = [xs | sm | md | lg | sl ] - 列表数据 - * @property {String} tag - md及以上才有 - * @property {String} img - 图片 - * @property {String} background - 背景色 - * @property {String} topRadius - 上圆角 - * @property {String} bottomRadius - 下圆角 - * @property {String} title - 标题 - * @property {String} titleColor - 标题颜色 + * @property {String} tag - md及以上才有 + * @property {String} img - 图片 + * @property {String} background - 背景色 + * @property {String} topRadius - 上圆角 + * @property {String} bottomRadius - 下圆角 + * @property {String} title - 标题 + * @property {String} titleColor - 标题颜色 * @property {Number} titleWidth = 0 - 标题宽度,默认0,单位rpx - * @property {String} subTitle - 副标题 - * @property {String} subTitleColor - 副标题颜色 - * @property {String} subTitleBackground - 副标题背景 - * @property {String | Number} price - 价格 - * @property {String} priceColor - 价格颜色 - * @property {String | Number} originPrice - 原价/划线价 - * @property {String} originPriceColor - 原价颜色 - * @property {String | Number} sales - 销售数量 - * @property {String} salesColor - 销售数量颜色 + * @property {String} subTitle - 副标题 + * @property {String} subTitleColor - 副标题颜色 + * @property {String} subTitleBackground - 副标题背景 + * @property {String | Number} price - 价格 + * @property {String} priceColor - 价格颜色 + * @property {String | Number} originPrice - 原价/划线价 + * @property {String} originPriceColor - 原价颜色 + * @property {String | Number} sales - 销售数量 + * @property {String} salesColor - 销售数量颜色 * * @slots activity - 活动插槽 * @slots cart - 购物车插槽,默认包含文字,背景色,文字颜色 || 图片 || 行为 * - * @event {Function()} click - 点击卡片 + * @event {Function()} click - 点击卡片 * */ import { computed, reactive, getCurrentInstance, onMounted, nextTick } from 'vue'; import sheep from '@/sheep'; import { fen2yuan, formatSales } from '@/sheep/hooks/useGoods'; import { formatStock } from '@/sheep/hooks/useGoods'; - import goodsCollectVue from '@/pages/user/goods-collect.vue'; import { isArray } from 'lodash-es'; // 数据 @@ -354,11 +353,11 @@ }, tagStyle: { type: Object, - default: {}, + default: () => ({}), }, data: { type: Object, - default: {}, + default: () => ({}), }, size: { type: String, @@ -451,6 +450,7 @@ // 获取卡片实时高度 const { proxy } = getCurrentInstance(); const elId = `sheep_${Math.ceil(Math.random() * 10e5).toString(36)}`; + function getGoodsPriceCardWH() { if (props.size === 'md') { const view = uni.createSelectorQuery().in(proxy); @@ -469,6 +469,7 @@ }); } } + onMounted(() => { nextTick(() => { getGoodsPriceCardWH(); @@ -482,11 +483,13 @@ left: 0; top: 0; z-index: 2; + .tag-icon { width: 72rpx; height: 44rpx; } } + .seckill-tag { position: absolute; left: 0; @@ -501,6 +504,7 @@ color: #ffffff; line-height: 32rpx; } + .groupon-tag { position: absolute; left: 0; @@ -515,14 +519,17 @@ color: #ffffff; line-height: 32rpx; } + .goods-img { width: 100%; height: 100%; background-color: #f5f5f5; } + .price-unit { margin-right: -4px; } + .sales-text { display: table; font-size: 24rpx; @@ -586,10 +593,12 @@ width: 100%; height: 208rpx; } + .sm-goods-content { padding: 20rpx 16rpx; box-sizing: border-box; } + .sm-goods-title { font-size: 26rpx; color: #333; @@ -619,6 +628,7 @@ color: #333; width: 100%; } + .md-goods-subtitle { font-size: 24rpx; font-weight: 400; @@ -669,6 +679,7 @@ // line-height: 36rpx; // width: 410rpx; } + .lg-goods-subtitle { font-size: 24rpx; font-weight: 400; @@ -695,6 +706,7 @@ font-size: 24rpx; color: #ffffff; } + .tag-box { width: 100%; } @@ -708,10 +720,12 @@ z-index: 1; width: 100%; background-color: $white; + .sl-goods-content { padding: 20rpx 20rpx; box-sizing: border-box; } + .sl-img-box { width: 100%; height: 360rpx; @@ -722,6 +736,7 @@ color: #333; font-weight: 500; } + .sl-goods-subtitle { font-size: 24rpx; font-weight: 400; diff --git a/sheep/components/s-groupon-block/s-groupon-block.vue b/sheep/components/s-groupon-block/s-groupon-block.vue index d7e6fcf5..be3e6508 100644 --- a/sheep/components/s-groupon-block/s-groupon-block.vue +++ b/sheep/components/s-groupon-block/s-groupon-block.vue @@ -1,171 +1,312 @@ - + \ No newline at end of file diff --git a/sheep/components/s-live-block/s-live-block.vue b/sheep/components/s-live-block/s-live-block.vue index 9d1ad032..6e0b6c95 100644 --- a/sheep/components/s-live-block/s-live-block.vue +++ b/sheep/components/s-live-block/s-live-block.vue @@ -70,8 +70,8 @@ default() {}, }, }); - const { mode, goodsFields, mpliveIds } = props.data ?? {}; - const { marginLeft, marginRight } = props.styles ?? {}; + const { mode, goodsFields, mpliveIds } = props.data || {}; + const { marginLeft, marginRight } = props.styles || {}; async function getLiveListByIds(ids) { const { data } = await sheep.$api.app.mplive.getRoomList(ids); diff --git a/sheep/helper/index.js b/sheep/helper/index.js index 38e6afeb..59272f5d 100644 --- a/sheep/helper/index.js +++ b/sheep/helper/index.js @@ -621,7 +621,7 @@ function setProperty(obj, key, value) { function page() { const pages = getCurrentPages(); // 某些特殊情况下(比如页面进行redirectTo时的一些时机),pages可能为空数组 - return `/${pages[pages.length - 1]?.route ?? ''}`; + return `/${pages[pages.length - 1]?.route || ''}`; } /** diff --git a/sheep/platform/share.js b/sheep/platform/share.js index 9ab2a3a6..53fe1968 100644 --- a/sheep/platform/share.js +++ b/sheep/platform/share.js @@ -186,7 +186,8 @@ const bindBrokerageUser = async (val= undefined) => { } await BrokerageApi.bindBrokerageUser({ bindUserId: shareId }); uni.removeStorageSync('shareId'); - } catch { + } catch (e) { + console.error(e); } }; From 85441704cb5d7d81d1ead342375a88d094876f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E8=B6=8A?= <552369664@qq.com> Date: Wed, 4 Sep 2024 23:01:16 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91=E6=8E=A5=E5=8F=A3=E5=9C=B0=E5=9D=80=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sheep/api/promotion/combination.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sheep/api/promotion/combination.js b/sheep/api/promotion/combination.js index 49931102..bf1d6c6a 100644 --- a/sheep/api/promotion/combination.js +++ b/sheep/api/promotion/combination.js @@ -32,12 +32,12 @@ const CombinationApi = { }, // 获得拼团活动明细列表 - getCombinationActivityDetailList: (combinationActivityIds) => { + getCombinationActivityDetailList: (ids) => { return request({ - url: '/promotion/combination-activity/get-detail-list', + url: '/promotion/combination-activity/detail-list', method: 'GET', params: { - combinationActivityIds + ids, }, }); }, @@ -58,9 +58,9 @@ const CombinationApi = { // 获得我的拼团记录分页 getCombinationRecordPage: (params) => { return request({ - url: "/promotion/combination-record/page", + url: '/promotion/combination-record/page', method: 'GET', - params + params, }); }, From b6dd2ae1ebbd18d400275a98ae2bc2fa91e1ea87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E8=B6=8A?= <552369664@qq.com> Date: Thu, 5 Sep 2024 11:32:30 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91=E6=8B=BC=E5=9B=A2=E6=B4=BB=E5=8A=A8=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sheep/api/promotion/combination.js | 6 ++-- .../s-groupon-block/s-groupon-block.vue | 33 ++++++++++++++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/sheep/api/promotion/combination.js b/sheep/api/promotion/combination.js index bf1d6c6a..62791f07 100644 --- a/sheep/api/promotion/combination.js +++ b/sheep/api/promotion/combination.js @@ -37,7 +37,7 @@ const CombinationApi = { url: '/promotion/combination-activity/detail-list', method: 'GET', params: { - ids, + ids }, }); }, @@ -58,9 +58,9 @@ const CombinationApi = { // 获得我的拼团记录分页 getCombinationRecordPage: (params) => { return request({ - url: '/promotion/combination-record/page', + url: "/promotion/combination-record/page", method: 'GET', - params, + params }); }, diff --git a/sheep/components/s-groupon-block/s-groupon-block.vue b/sheep/components/s-groupon-block/s-groupon-block.vue index be3e6508..14f3204f 100644 --- a/sheep/components/s-groupon-block/s-groupon-block.vue +++ b/sheep/components/s-groupon-block/s-groupon-block.vue @@ -144,6 +144,7 @@ import sheep from '@/sheep'; import CombinationApi from '@/sheep/api/promotion/combination'; import SpuApi from '@/sheep/api/product/spu'; + import spu from '@/sheep/api/product/spu'; // 布局类型 const LayoutTypeEnum = { @@ -241,21 +242,35 @@ * @param ids 商品编号列表 * @return {Promise} 商品列表 */ - async function getSpuDetail(spuId) { - const { data: spu } = await SpuApi.getSpuDetail(spuId) + async function getSpuDetail(ids) { + const { data: spu } = await SpuApi.getSpuDetail(ids); return spu; } // 初始化 onMounted(async () => { - // 加载商品列表 + // 加载活动列表 const activityList = await getCombinationActivityDetailList(activityIds.join(',')); - // 创建 SPU 请求的 Promise 数组 - const spuPromises = activityList.map(activity => getSpuDetail(activity.spuId)); - // 等待所有 SPU 请求完成 - // 处理 spuList - state.spuList = await Promise.all(spuPromises); + // 循环获取活动商品SPU详情并添加到spuList + for (const activity of activityList) { + state.spuList.push(await getSpuDetail(activity.spuId)); + } + + + // 循环活动列表 + activityList.forEach(activity => { + // 获取活动商品的最低价格 + activity.products.forEach(product => { + const combinationPrice = product.combinationPrice || Infinity; + + // 找到对应的 spu 并更新价格 + const spu = state.spuList.find(spu => activity.spuId === spu.id); + if (spu) { + spu.price = Math.min(combinationPrice, spu.price || Infinity); + } + }); + }); // 只有双列布局时需要 if (layoutType === LayoutTypeEnum.TWO_COL) { @@ -273,11 +288,13 @@ .goods-list-box { width: 50%; box-sizing: border-box; + .left-list { &:nth-last-child(1) { margin-bottom: 0 !important; } } + .right-list { &:nth-last-child(1) { margin-bottom: 0 !important; From 75e7e58b8dbb7611009bed3d646f654e82f0f2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E8=B6=8A?= <552369664@qq.com> Date: Thu, 5 Sep 2024 12:40:53 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/user/goods_details_store/index.vue | 19 +++++++---- sheep/api/promotion/combination.js | 6 ++-- .../components/s-goods-card/s-goods-card.vue | 14 +++++--- .../s-groupon-block/s-groupon-block.vue | 33 +++++++++---------- sheep/platform/share.js | 2 +- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/pages/user/goods_details_store/index.vue b/pages/user/goods_details_store/index.vue index 92ef2d0b..3df0435d 100644 --- a/pages/user/goods_details_store/index.vue +++ b/pages/user/goods_details_store/index.vue @@ -1,7 +1,12 @@