Pre Merge pull request !36 from 疯狂的世界/master-vue3

pull/36/MERGE
疯狂的世界 2024-01-11 03:56:13 +00:00 committed by Gitee
commit 8529633217
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
22 changed files with 640 additions and 801 deletions

View File

@ -4,7 +4,7 @@
<view v-if="state.data && !state.loading"> <view v-if="state.data && !state.loading">
<view <view
class="recharge-box" class="recharge-box"
v-if="state.data.goods" v-if="state.data.headRecord"
:style="[ :style="[
{ {
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx', marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
@ -14,29 +14,28 @@
> >
<s-goods-item <s-goods-item
class="goods-box" class="goods-box"
:img="state.data.goods.image" :img="state.data.headRecord.picUrl"
:title="state.data.goods.title" :title="state.data.headRecord.spuName"
:price="state.data.goods.price[0]" :price="state.data.headRecord.combinationPrice"
priceColor="#E1212B" priceColor="#E1212B"
@tap=" @tap="
sheep.$router.go('/pages/goods/groupon', { sheep.$router.go('/pages/goods/groupon', {
id: state.data.goods.id, id: state.data.headRecord.activityId
activity_id: state.data.goods.activity.id,
}) })
" "
:style="[{ top: Number(statusBarHeight + 108) + 'rpx' }]" :style="[{ top: Number(statusBarHeight + 108) + 'rpx' }]"
> >
<template #groupon> <template #groupon>
<view class="ss-flex"> <view class="ss-flex">
<view class="sales-title">{{ state.data.num }}人团</view> <view class="sales-title">{{ state.data.headRecord.userSize }}人团</view>
<view class="num-title ss-m-l-20">已拼{{ state.data.goods.sales }}</view> <view class="num-title ss-m-l-20">已拼{{ state.data.headRecord.userCount }}</view>
</view> </view>
</template> </template>
</s-goods-item> </s-goods-item>
</view> </view>
<view class="countdown-box detail-card ss-p-t-44 ss-flex-col ss-col-center"> <view class="countdown-box detail-card ss-p-t-44 ss-flex-col ss-col-center">
<view v-if="state.data.status === 'finish' || state.data.status === 'finish_fictitious'"> <view v-if="state.activity.status === 1">
<view v-if="state.data.my"> <view v-if="state.data.orderId">
<view class="countdown-title ss-flex"> <view class="countdown-title ss-flex">
<text class="cicon-check-round"></text> <text class="cicon-check-round"></text>
恭喜您~拼团成功 恭喜您~拼团成功
@ -49,24 +48,23 @@
</view> </view>
</view> </view>
</view> </view>
<view v-if="state.data.status === 'invalid'"> <view v-if="state.activity.status === 2">
<view class="countdown-title ss-flex"> <view class="countdown-title ss-flex">
<text class="cicon-info"></text> <text class="cicon-info"></text>
{{ state.data.my ? '拼团超时,已自动退款' : '该团已解散' }} {{ state.data.orderId ? '拼团超时,已自动退款' : '该团已解散' }}
</view> </view>
</view> </view>
<view v-if="state.data.status === 'ing'"> <view v-if="state.activity.status === 0">
<!-- TODO: 拼团进行中+活动结束--> <view v-if="state.data.headRecord.expireTime <= new Date().getTime()">
<view v-if="state.data.activity_status === 'ended'">
<view class="countdown-title ss-flex"> <view class="countdown-title ss-flex">
<text class="cicon-info"></text> <text class="cicon-info"></text>
拼团已结束,请关注下次活动 拼团已结束,请关注下次活动
</view> </view>
</view> </view>
<view class="countdown-title ss-flex" v-if="state.data.activity_status === 'ing'"> <view class="countdown-title ss-flex" v-else>
还差 还差
<view class="num">{{ state.data.num - state.data.current_num }}</view> <view class="num">{{ state.data.headRecord.userSize - state.data.headRecord.userCount }}</view>
拼团成功 拼团成功
<view class="ss-flex countdown-time"> <view class="ss-flex countdown-time">
<view class="countdown-h ss-flex ss-row-center">{{ endTime.h }}</view> <view class="countdown-h ss-flex ss-row-center">{{ endTime.h }}</view>
@ -83,9 +81,15 @@
</view> </view>
<view class="ss-m-t-60 ss-flex ss-flex-wrap ss-row-center"> <view class="ss-m-t-60 ss-flex ss-flex-wrap ss-row-center">
<!-- 团长 -->
<view class="header-avatar ss-m-r-24 ss-m-b-20">
<image :src="sheep.$url.cdn(state.data.headRecord.avatar)" class="avatar-img"></image>
<view class="header-tag ss-flex ss-col-center ss-row-center">团长</view>
</view>
<!-- 团员 -->
<view <view
class="header-avatar ss-m-r-24 ss-m-b-20" class="header-avatar ss-m-r-24 ss-m-b-20"
v-for="item in state.data.groupon_logs" v-for="item in state.data.memberRecords"
:key="item.id" :key="item.id"
> >
<image :src="sheep.$url.cdn(item.avatar)" class="avatar-img"></image> <image :src="sheep.$url.cdn(item.avatar)" class="avatar-img"></image>
@ -96,74 +100,53 @@
团长 团长
</view> </view>
</view> </view>
<view class="default-avatar ss-m-r-24 ss-m-b-20" v-for="item in state.number" :key="item"> <!-- 还有几个坑位 -->
<view class="default-avatar ss-m-r-24 ss-m-b-20" v-for="item in state.remainNumber" :key="item">
<image <image
:src="sheep.$url.static('/static/img/shop/avatar/unknown.png')" :src="sheep.$url.static('/static/img/shop/avatar/unknown.png')"
class="avatar-img" class="avatar-img"
></image> ></image>
</view> </view>
</view> </view>
<view
class="detail-cell-wrap ss-flex ss-col-center ss-row-between"
v-if="state.data.activity?.richtext_id > 0"
@tap="
sheep.$router.go('/pages/public/richtext', {
id: state.data.activity.richtext_id,
title: state.data.activity.richtext_title,
})
"
>
<view class="label-text">玩法</view>
<view class="ss-flex">
<view class="cell-content ss-line-1 ss-flex-1">
{{ state.data.activity?.richtext_title }}
</view>
<button class="ss-reset-button">
<text class="_icon-forward right-forwrad-icon"></text>
</button>
</view>
</view>
</view> </view>
<view <view
v-if=" v-if="state.activity.status === 1 || state.activity.status === 2"
state.data.status == 'finish' ||
state.data.status == 'finish_fictitious' ||
state.data.status == 'invalid'
"
class="ss-m-t-40 ss-flex ss-row-center" class="ss-m-t-40 ss-flex ss-row-center"
> >
<button <button
class="ss-reset-button order-btn" class="ss-reset-button order-btn"
v-if="state.data.my" v-if="state.data.orderId"
@tap="onDetail(state.data.my.order_id)" @tap="onDetail(state.data.orderId)"
> >
查看订单 查看订单
</button> </button>
<button class="ss-reset-button join-btn" v-else @tap="onCreateGroupon"> </button> <button class="ss-reset-button join-btn" v-else @tap="onCreateGroupon"> </button>
</view> </view>
<view v-if="state.data.status === 'ing'" class="ss-m-t-40 ss-flex ss-row-center"> <!-- 处于进入中时查看订单或参加或邀请好友或参加 -->
<view v-if="state.data.activity_status === 'ended'"> <view v-if="state.activity.status === 0" class="ss-m-t-40 ss-flex ss-row-center">
<view v-if="state.data.headRecord.expireTime <= new Date().getTime()">
<button <button
class="ss-reset-button join-btn" class="ss-reset-button join-btn"
v-if="state.data.my" v-if="state.data.orderId"
@tap="onDetail(state.data.my.order_id)" @tap="onDetail(state.data.orderId)"
> >
查看订单 查看订单
</button> </button>
<!-- 待确认 -->
<button <button
class="ss-reset-button disabled-btn" class="ss-reset-button disabled-btn"
v-else v-else
disabled disabled
@tap="onDetail(state.data.my.order_id)" @tap="onDetail(state.data.orderId)"
> >
去参团 去参团
</button> </button>
</view> </view>
<view v-else class="ss-flex ss-row-center"> <view v-else class="ss-flex ss-row-center">
<view v-if="state.data.my"> <view v-if="state.data.orderId">
<button <button
class="ss-reset-button join-btn" class="ss-reset-button join-btn"
:disabled="state.data.activity_status === 'ing' && endTime.ms <= 0" :disabled="endTime.ms <= 0"
@tap="onShare" @tap="onShare"
> >
邀请好友来拼团 邀请好友来拼团
@ -172,7 +155,7 @@
<view v-else> <view v-else>
<button <button
class="ss-reset-button join-btn" class="ss-reset-button join-btn"
:disabled="state.data.activity_status === 'ing' && endTime.ms <= 0" :disabled="endTime.ms <= 0"
@tap="onJoinGroupon()" @tap="onJoinGroupon()"
> >
立即参团 立即参团
@ -204,6 +187,7 @@
import { useDurationTime } from '@/sheep/hooks/useGoods'; import { useDurationTime } from '@/sheep/hooks/useGoods';
import { showShareModal } from '@/sheep/hooks/useModal'; import { showShareModal } from '@/sheep/hooks/useModal';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import CombinationApi from "@/sheep/api/promotion/combination";
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png'); const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2; const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
@ -214,15 +198,17 @@
showSelectSku: false, showSelectSku: false,
grouponNum: 0, grouponNum: 0,
number: 0, number: 0,
activity: {},
combinationHeadId: null, //
}); });
const shareInfo = computed(() => { const shareInfo = computed(() => {
if (isEmpty(state.data)) return {}; if (isEmpty(state.data)) return {};
return sheep.$platform.share.getShareInfo( return sheep.$platform.share.getShareInfo(
{ {
title: state.data.goods.title, title: state.data.headRecord.spuName,
image: sheep.$url.cdn(state.data.goods.image), image: sheep.$url.cdn(state.data.headRecord.picUrl),
desc: state.data.goods.subtitle, desc: state.data.goods?.subtitle,
params: { params: {
page: '5', page: '5',
query: state.data.id, query: state.data.id,
@ -230,10 +216,10 @@
}, },
{ {
type: 'groupon', // type: 'groupon', //
title: state.data.goods.title, // title: state.data.headRecord.spuName, //
image: sheep.$url.cdn(state.data.goods.image), // image: sheep.$url.cdn(state.data.headRecord.picUrl), //
price: state.data.goods.price[0], // price: state.data.goods?.price, //
original_price: state.data.goods.original_price, // original_price: state.data.goods?.original_price, //
}, },
); );
}); });
@ -260,25 +246,23 @@
// //
function onJoinGroupon() { function onJoinGroupon() {
state.grouponAction = 'join'; state.grouponAction = 'join';
state.grouponId = state.data.id; state.grouponId = state.data.activityId;
state.combinationHeadId = state.data.id;
state.grouponNum = state.data.num; state.grouponNum = state.data.num;
state.showSelectSku = true; state.showSelectSku = true;
} }
// //
function onBuy(e) { function onBuy(sku) {
sheep.$router.go('/pages/order/confirm', { sheep.$router.go('/pages/order/confirm', {
data: JSON.stringify({ data: JSON.stringify({
order_type: 'goods', order_type: 'goods',
buy_type: 'groupon', combinationActivityId: state.data.activity.id,
activity_id: state.data.activity.id, combinationHeadId: state.combinationHeadId,
groupon_id: state.grouponId, items: [
groupon_num: state.grouponNum,
goods_list: [
{ {
goods_id: e.goods_id, skuId: sku.id,
goods_num: e.goods_num, count: sku.count,
goods_sku_price_id: e.id,
}, },
], ],
}), }),
@ -286,16 +270,20 @@
} }
const endTime = computed(() => { const endTime = computed(() => {
return useDurationTime(state.data.expire_time); return useDurationTime(state.data.headRecord.expireTime);
}); });
// //
async function getGrouponDetail(id) { async function getGrouponDetail(id) {
const { error, data } = await sheep.$api.activity.grouponDetail(id); const { code, data } = await CombinationApi.getCombinationRecordDetail(id);
if (error === 0) { if (code === 0) {
state.data = data; state.data = data;
let number = Number(state.data.num - state.data.current_num); const remainNumber = Number(state.data.headRecord.userSize - state.data.headRecord.userCount);
state.number = number > 0 ? number : 0; state.remainNumber = remainNumber > 0 ? remainNumber : 0;
//
const { data: activity } = await CombinationApi.getCombinationActivity(data.headRecord.activityId);
state.activity = activity;
} else { } else {
state.data = null; state.data = null;
} }

View File

@ -5,23 +5,17 @@
:style="[{ marginTop: '-' + Number(statusBarHeight + 88) + 'rpx' }]" :style="[{ marginTop: '-' + Number(statusBarHeight + 88) + 'rpx' }]"
></view> ></view>
<view class="list-content"> <view class="list-content">
<!-- 参团会员统计 -->
<view class="content-header ss-flex-col ss-col-center ss-row-center"> <view class="content-header ss-flex-col ss-col-center ss-row-center">
<view class="content-header-title ss-m-b-22 ss-flex ss-row-center"> <view class="content-header-title ss-flex ss-row-center">
<view>{{ state.activityInfo.title }}</view> <view v-for="(item, index) in state.summaryData.avatars" :key="index" class="picture"
<!-- <view class="more">更多</view> --> :style='index === 6 ? "position: relative" : "position: static"'>
</view> <span class="avatar" :style='`background-image: url(${item})`'></span>
<view class="content-header-box ss-flex ss-row-center"> <span v-if="index === 6 && state.summaryData.avatars.length > 3" class="mengceng">
<view class="countdown-box ss-flex" v-if="endTime?.ms > 0 && state.activityInfo"> <i>···</i>
<view class="countdown-title ss-m-r-12">距结束</view> </span>
<view class="ss-flex countdown-time">
<view class="ss-flex countdown-h">{{ endTime.h }}</view>
<view class="ss-m-x-4">:</view>
<view class="countdown-num ss-flex ss-row-center">{{ endTime.m }}</view>
<view class="ss-m-x-4">:</view>
<view class="countdown-num ss-flex ss-row-center">{{ endTime.s }}</view>
</view>
</view> </view>
<view class="" v-if="endTime?.ms < 0 && state.activityInfo"> </view> <text class="pic_count">{{ state.summaryData.userCount || 0 }}人参与</text>
</view> </view>
</view> </view>
<scroll-view <scroll-view
@ -37,12 +31,7 @@
size="lg" size="lg"
:data="item" :data="item"
:grouponTag="true" :grouponTag="true"
@click=" @click="sheep.$router.go('/pages/goods/groupon', { id: item.id })"
sheep.$router.go('/pages/goods/groupon', {
id: item.id,
activity_id: state.activityId,
})
"
> >
<template v-slot:cart> <template v-slot:cart>
<button class="ss-reset-button cart-btn">去拼团</button> <button class="ss-reset-button cart-btn">去拼团</button>
@ -55,92 +44,67 @@
:content-text="{ :content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" }"
@tap="loadmore" @tap="loadMore"
/> />
</scroll-view> </scroll-view>
</view> </view>
</s-layout> </s-layout>
</template> </template>
<script setup> <script setup>
import { reactive, computed } from 'vue'; import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app'; import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import sheep from '@/sheep'; import sheep from '@/sheep';
import _ from 'lodash'; import CombinationApi from "@/sheep/api/promotion/combination";
import { useDurationTime } from '@/sheep/hooks/useGoods';
const { screenHeight, safeAreaInsets, screenWidth, safeArea } = sheep.$platform.device; const { safeAreaInsets, safeArea } = sheep.$platform.device;
const sys_navBar = sheep.$platform.navbar; const sysNavBar = sheep.$platform.navbar;
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2; const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const pageHeight = const pageHeight = (safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sysNavBar - 350;
(safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sys_navBar - 350;
const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-header.png'); const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-header.png');
const state = reactive({ const state = reactive({
activityId: 0,
pagination: { pagination: {
data: [], data: [],
current_page: 1, pageNo: 1,
total: 1, total: 1,
last_page: 1,
}, },
loadStatus: '', loadStatus: '',
activityInfo: {}, summaryData: {}
});
//
const endTime = computed(() => {
if (state.activityInfo.end_time) {
return useDurationTime(state.activityInfo.end_time);
}
}); });
async function getList(activityId, page = 1, list_rows = 4) { //
state.loadStatus = 'loading'; const getSummary = async () => {
const res = await sheep.$api.goods.activityList({ const { data } = await CombinationApi.getCombinationRecordSummary()
list_rows, state.summaryData = data
activity_id: activityId,
page,
});
if (res.error === 0) {
if (page >= 2) {
let couponList = _.concat(state.pagination.data, res.data.data);
state.pagination = {
...res.data,
data: couponList,
};
} else {
state.pagination = res.data;
}
if (state.pagination.current_page < state.pagination.last_page) {
state.loadStatus = 'more';
} else {
state.loadStatus = 'noMore';
}
}
} }
async function getActivity(id) {}
//
async function getList(pageNo = 1, pageSize = 10) {
state.loadStatus = 'loading';
const { data } = await CombinationApi.getCombinationActivityPage({
pageNo,
pageSize,
});
data.list.forEach(activity => {
state.pagination.data.push({...activity, price: activity.combinationPrice})
})
state.pagination.total = data.total;
state.pagination.pageNo = pageNo;
state.loadStatus = state.pagination.data.length < state.pagination.total ? 'more' : 'noMore';
}
// //
function loadmore() { function loadMore() {
if (state.loadStatus !== 'noMore') { if (state.loadStatus !== 'noMore') {
getList(state.activityId, state.pagination.current_page + 1); getList(state.pagination.pageNo + 1);
} }
} }
// //
onReachBottom(() => { onReachBottom(() => loadMore());
loadmore(); //
}); onLoad( () => {
onLoad(async (options) => { getSummary();
if (!options.id) { getList();
state.activityInfo = null;
return;
}
state.activityId = options.id;
getList(state.activityId);
const { error, data } = await sheep.$api.activity.activity(options.id);
if (error === 0) {
state.activityInfo = data;
} else {
state.activityInfo = null;
}
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -160,7 +124,7 @@
.content-header { .content-header {
width: 100%; width: 100%;
border-radius: 20rpx 20rpx 0 0; border-radius: 20rpx 20rpx 0 0;
height: 150rpx; height: 100rpx;
background: linear-gradient(180deg, #fff4f7, #ffe4d1); background: linear-gradient(180deg, #fff4f7, #ffe4d1);
.content-header-title { .content-header-title {
width: 100%; width: 100%;
@ -178,55 +142,55 @@
color: #999999; color: #999999;
line-height: 30rpx; line-height: 30rpx;
} }
}
.content-header-box { .picture {
width: 678rpx; display: inline-table;
height: 64rpx;
background: rgba($color: #fff, $alpha: 0.66);
border-radius: 32px;
.num {
font-size: 24rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #f51c11;
line-height: 30rpx;
}
.title {
font-size: 24rpx;
font-weight: 400;
font-family: OPPOSANS;
color: #333;
line-height: 30rpx;
}
.countdown-title {
font-size: 28rpx;
font-weight: 500;
color: #333333;
line-height: 28rpx;
} }
.countdown-time { .avatar {
font-size: 28rpx; width: 38rpx;
color: rgba(#ed3c30, 0.23); height: 38rpx;
.countdown-h { display: inline-table;
font-size: 24rpx; vertical-align: middle;
font-family: OPPOSANS; -webkit-user-select: none;
font-weight: 500; -moz-user-select: none;
color: #ffffff; -ms-user-select: none;
padding: 0 4rpx; user-select: none;
height: 40rpx; border-radius: 50%;
background: rgba(#ed3c30, 0.23); background-repeat: no-repeat;
border-radius: 6rpx; background-size: cover;
} background-position: 0 0;
.countdown-num { margin-right: -10rpx;
font-size: 24rpx; box-shadow: 0 0 0 1px #fe832a;
font-family: OPPOSANS; }
font-weight: 500;
color: #ffffff; .pic_count {
width: 40rpx; margin-left: 30rpx;
height: 40rpx; font-size: 22rpx;
background: rgba(#ed3c30, 0.23); font-weight: 500;
border-radius: 6rpx; width: auto;
height: auto;
background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
color: #FFFFFF;
border-radius: 19rpx;
padding: 4rpx 14rpx;
}
.mengceng {
width: 40rpx;
height: 40rpx;
line-height: 36rpx;
background: rgba(51, 51, 51, 0.6);
text-align: center;
border-radius: 50%;
opacity: 1;
position: absolute;
left: -2rpx;
color: #FFF;
top: 2rpx;
i{
font-style: normal;
font-size: 20rpx;
} }
} }
} }

View File

@ -13,34 +13,26 @@
<view v-if="state.pagination.total > 0"> <view v-if="state.pagination.total > 0">
<view <view
class="order-list-card-box bg-white ss-r-10 ss-m-t-14 ss-m-20" class="order-list-card-box bg-white ss-r-10 ss-m-t-14 ss-m-20"
v-for="order in state.pagination.data" v-for="order in state.pagination.list"
:key="order.id" :key="order.id"
> >
<view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20"> <view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
<view class="order-no">订单号{{ order.my.order.order_sn }}</view> <view class="order-no">订单号{{ order.no }}</view>
<view <view class="ss-font-26" :class="formatOrderColor(order)">
class="ss-font-26" {{ formatOrderStatus(order) }}
:class=" </view>
order.status === 'ing'
? 'warning-color'
: order.status === 'invalid'
? 'danger-color'
: 'success-color'
"
>{{ order.status_text }}</view
>
</view> </view>
<view class="border-bottom"> <view class="border-bottom" v-for="item in order.items" :key="item.id">
<s-goods-item <s-goods-item
:img="order.goods.image" :img="item.picUrl"
:title="order.goods.title" :title="item.spuName"
:price="order.goods.price[0]" :skuText="item.properties.map((property) => property.valueName).join(' ')"
priceColor="#E1212B" :price="item.price"
radius="20" :num="item.count"
> >
<template #groupon> <template #groupon>
<view class="ss-flex"> <view class="ss-flex">
<view class="sales-title"> {{ order.num }}人团 </view> <view class="sales-title"> {{ item.num }}人团 </view>
<!-- <view class="num-title ss-m-l-20"> 已拼{{ order.goods.sales }} </view> --> <!-- <view class="num-title ss-m-l-20"> 已拼{{ order.goods.sales }} </view> -->
</view> </view>
</template> </template>
@ -49,16 +41,16 @@
<view class="order-card-footer ss-flex ss-row-right ss-p-x-20"> <view class="order-card-footer ss-flex ss-row-right ss-p-x-20">
<button <button
class="detail-btn ss-reset-button" class="detail-btn ss-reset-button"
@tap="sheep.$router.go('/pages/order/detail', { id: order.my.order_id })" @tap="sheep.$router.go('/pages/order/detail', { id: order.id })"
> >
订单详情 订单详情
</button> </button>
<button <button
class="tool-btn ss-reset-button" class="tool-btn ss-reset-button"
:class="{ 'ui-BG-Main-Gradient': order.status === 'ing' }" :class="{ 'ui-BG-Main-Gradient': order.status === 0 }"
@tap="sheep.$router.go('/pages/activity/groupon/detail', { id: order.id })" @tap="sheep.$router.go('/pages/activity/groupon/detail', { id: order.id })"
> >
{{ order.status === 'ing' ? '邀请拼团' : '拼团详情' }} {{ order.status === 0 ? '邀请拼团' : '拼团详情' }}
</button> </button>
</view> </view>
</view> </view>
@ -69,7 +61,7 @@
:content-text="{ :content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" }"
@tap="loadmore" @tap="loadMore"
/> />
</s-layout> </s-layout>
</template> </template>
@ -79,15 +71,17 @@
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'; import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import sheep from '@/sheep'; import sheep from '@/sheep';
import _ from 'lodash'; import _ from 'lodash';
import OrderApi from "@/sheep/api/trade/order";
import {formatOrderColor, formatOrderStatus} from "@/sheep/hooks/useGoods";
// //
const state = reactive({ const state = reactive({
currentTab: 0, currentTab: 0,
pagination: { pagination: {
data: [], list: [],
current_page: 1,
total: 1, total: 1,
last_page: 1, pageNo: 1,
pageSize: 1,
}, },
loadStatus: '', loadStatus: '',
deleteOrderId: 0, deleteOrderId: 0,
@ -96,19 +90,18 @@
const tabMaps = [ const tabMaps = [
{ {
name: '全部', name: '全部',
value: 'all',
}, },
{ {
name: '进行中', name: '进行中',
value: 'ing', value: 0,
}, },
{ {
name: '拼团成功', name: '拼团成功',
value: 'finish', value: 1,
}, },
{ {
name: '拼团失败', name: '拼团失败',
value: 'invalid', value: 2,
}, },
]; ];
@ -116,9 +109,9 @@
function onTabsChange(e) { function onTabsChange(e) {
state.pagination = { state.pagination = {
data: [], data: [],
current_page: 1, pageNo: 1,
total: 1, total: 1,
last_page: 1, pageSize: 5,
}; };
state.currentTab = e.index; state.currentTab = e.index;
getGrouponList(); getGrouponList();
@ -149,8 +142,8 @@
async function onConfirm(orderId) { async function onConfirm(orderId) {
const { error, data } = await sheep.$api.order.confirm(orderId); const { error, data } = await sheep.$api.order.confirm(orderId);
if (error === 0) { if (error === 0) {
let index = state.pagination.data.findIndex((order) => order.id === orderId); let index = state.pagination.list.findIndex((order) => order.id === orderId);
state.pagination.data[index] = data; state.pagination.list[index] = data;
} }
} }
@ -158,33 +151,30 @@
async function onCancel(orderId) { async function onCancel(orderId) {
const { error, data } = await sheep.$api.order.cancel(orderId); const { error, data } = await sheep.$api.order.cancel(orderId);
if (error === 0) { if (error === 0) {
let index = state.pagination.data.findIndex((order) => order.id === orderId); let index = state.pagination.list.findIndex((order) => order.id === orderId);
state.pagination.data[index] = data; state.pagination.list[index] = data;
} }
} }
// //
async function getGrouponList(page = 1, list_rows = 5) { async function getGrouponList() {
state.loadStatus = 'loading'; state.loadStatus = 'loading';
let res = await sheep.$api.activity.myGroupon({ // todo:
type: tabMaps[state.currentTab].value, const { code, data } = await OrderApi.getOrderPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
status: tabMaps[state.currentTab].value,
commentStatus: tabMaps[state.currentTab].value === 30 ? false : null
}); });
if (res.error === 0) { if (code !== 0) {
if (page >= 2) { return;
let orderList = _.concat(state.pagination.data, res.data.data); }
state.pagination = { state.pagination.list = _.concat(state.pagination.list, data.list)
...res.data, state.pagination.total = data.total;
data: orderList, if (state.pagination.list.length < state.pagination.total) {
}; state.loadStatus = 'more';
} else { } else {
state.pagination = res.data; state.loadStatus = 'noMore';
}
if (state.pagination.current_page < state.pagination.last_page) {
state.loadStatus = 'more';
} else {
state.loadStatus = 'noMore';
}
} }
} }
@ -196,15 +186,16 @@
}); });
// //
function loadmore() { function loadMore() {
if (state.loadStatus !== 'noMore') { if (state.loadStatus !== 'noMore') {
getGrouponList(state.pagination.current_page + 1); state.pagination.pageNo++;
getGrouponList();
} }
} }
// //
onReachBottom(() => { onReachBottom(() => {
loadmore(); loadMore();
}); });
// //
onPullDownRefresh(() => { onPullDownRefresh(() => {

View File

@ -106,13 +106,7 @@
import { useDurationTime } from '@/sheep/hooks/useGoods'; import { useDurationTime } from '@/sheep/hooks/useGoods';
import SeckillApi from "@/sheep/api/promotion/seckill"; import SeckillApi from "@/sheep/api/promotion/seckill";
import dayjs from "dayjs"; import dayjs from "dayjs";
import {TimeStatusEnum} from "@/sheep/util/const";
//
const TimeStatusEnum = {
WAIT_START: '即将开始',
STARTED: '进行中',
END: '已结束',
}
// //
const { safeAreaInsets, safeArea } = sheep.$platform.device; const { safeAreaInsets, safeArea } = sheep.$platform.device;

View File

@ -51,8 +51,7 @@
const typePath = type === 1 ? 'seckill' : const typePath = type === 1 ? 'seckill' :
type === 2 ? 'TODO 拼团' : 'groupon'; type === 2 ? 'TODO 拼团' : 'groupon';
sheep.$router.go(`/pages/goods/${typePath}`, { sheep.$router.go(`/pages/goods/${typePath}`, {
id: activity.spuId, id: activity.id,
activity_id: activity.id,
}); });
} }
</script> </script>

View File

@ -19,7 +19,7 @@
} }
}); });
const value = computed(() => { const value = computed(() => {
if (!props.sku.id) { if (!props.sku?.id) {
return '请选择商品规格'; return '请选择商品规格';
} }
let str = ''; let str = '';

View File

@ -1,30 +1,32 @@
<!-- 拼团活动参团记录卡片 -->
<template> <template>
<view v-if="state.list.length > 0" class="groupon-list detail-card ss-p-x-20"> <view v-if="state.list.length > 0" class="groupon-list detail-card ss-p-x-20">
<view class="join-activity ss-flex ss-row-between ss-m-t-30"> <view class="join-activity ss-flex ss-row-between ss-m-t-30">
<view class="">已有{{ modelValue.sales }}人参与活动</view> <!-- todo: 接口缺少总数 -->
<view class="">已有{{ state.list.length }}人参与活动</view>
<text class="cicon-forward"></text> <text class="cicon-forward"></text>
</view> </view>
<view <view
v-for="(item, index) in state.list" v-for="(record, index) in state.list"
@tap="sheep.$router.go('/pages/activity/groupon/detail', { id: item.id })" @tap="sheep.$router.go('/pages/activity/groupon/detail', { id: record.id })"
:key="index" :key="index"
class="ss-m-t-40 ss-flex ss-row-between border-bottom ss-p-b-30" class="ss-m-t-40 ss-flex ss-row-between border-bottom ss-p-b-30"
> >
<view class="ss-flex ss-col-center"> <view class="ss-flex ss-col-center">
<image :src="sheep.$url.cdn(item.leader.avatar)" class="user-avatar"></image> <image :src="sheep.$url.cdn(record.avatar)" class="user-avatar"></image>
<view class="user-nickname ss-m-l-20 ss-line-1">{{ item.leader.nickname }}</view> <view class="user-nickname ss-m-l-20 ss-line-1">{{ record.nickname }}</view>
</view> </view>
<view class="ss-flex ss-col-center"> <view class="ss-flex ss-col-center">
<view class="ss-flex-col ss-col-bottom ss-m-r-20"> <view class="ss-flex-col ss-col-bottom ss-m-r-20">
<view class="title ss-flex ss-m-b-14"> <view class="title ss-flex ss-m-b-14">
还差 还差
<view class="num">{{ item.num - item.current_num }}</view> <view class="num">{{ record.userSize - record.userCount }}</view>
成团 成团
</view> </view>
<view class="end-time">{{ endTime(item.expire_time) }}</view> <view class="end-time">{{ endTime(record.expireTime) }}</view>
</view> </view>
<view class=""> <view class="">
<button class="ss-reset-button go-btn" @tap.stop="onJoinGroupon(item)"> 去参团 </button> <button class="ss-reset-button go-btn" @tap.stop="onJoinGroupon(record)"> 去参团 </button>
</view> </view>
</view> </view>
</view> </view>
@ -35,6 +37,7 @@
import { onMounted, reactive } from 'vue'; import { onMounted, reactive } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { useDurationTime } from '@/sheep/hooks/useGoods'; import { useDurationTime } from '@/sheep/hooks/useGoods';
import CombinationApi from "@/sheep/api/promotion/combination";
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
@ -45,13 +48,14 @@
const state = reactive({ const state = reactive({
list: [], list: [],
}); });
const emits = defineEmits(['join']);
function onJoinGroupon(groupon) { //
emits('join', groupon); const emits = defineEmits(['join']);
function onJoinGroupon(record) {
emits('join', record);
} }
// //
function endTime(time) { function endTime(time) {
const durationTime = useDurationTime(time); const durationTime = useDurationTime(time);
@ -66,12 +70,11 @@
return timeText; return timeText;
} }
//
onMounted(async () => { onMounted(async () => {
const { data } = await sheep.$api.activity.getGrouponList({ //
goods_id: props.modelValue.id, const { data } = await CombinationApi.getHeadCombinationRecordList(props.modelValue.id, 1 , 10);
activity_id: props.modelValue.activity.id, state.list = data;
});
state.list = data.data;
}); });
</script> </script>

View File

@ -4,17 +4,14 @@
<detailNavbar /> <detailNavbar />
<!-- 骨架屏 --> <!-- 骨架屏 -->
<detailSkeleton v-if="state.skeletonLoading" /> <detailSkeleton v-if="state.skeletonLoading" />
<!-- 空置页 --> <!-- 下架/售罄提醒 -->
<s-empty <s-empty
v-else-if=" v-else-if="state.goodsInfo === null || state.activity.status !== 0 || state.activity.endTime < new Date().getTime()"
state.goodsInfo === null || text="活动不存在或已结束"
!['groupon', 'groupon_ladder'].includes(state.goodsInfo.activity_type) icon="/static/soldout-empty.png"
" showAction
text="活动不存在或已结束" actionText="返回上一页"
icon="/static/soldout-empty.png" @clickAction="sheep.$router.back()"
showAction
actionText="返回上一页"
@clickAction="sheep.$router.back()"
/> />
<block v-else> <block v-else>
<view class="detail-swiper-selector"> <view class="detail-swiper-selector">
@ -35,7 +32,7 @@
<view> <view>
<view class="price-box ss-flex ss-col-bottom ss-m-b-18"> <view class="price-box ss-flex ss-col-bottom ss-m-b-18">
<view class="price-text ss-m-r-16"> <view class="price-text ss-m-r-16">
{{ goodsPrice }} {{ fen2yuan(state.activity.price || state.goodsInfo.price) }}
</view> </view>
<view class="tig ss-flex ss-col-center"> <view class="tig ss-flex ss-col-center">
<view class="tig-icon ss-flex ss-col-center ss-row-center"> <view class="tig-icon ss-flex ss-col-center ss-row-center">
@ -51,11 +48,11 @@
<view class="ss-flex ss-row-between"> <view class="ss-flex ss-row-between">
<view <view
class="origin-price ss-flex ss-col-center" class="origin-price ss-flex ss-col-center"
v-if="state.goodsInfo.original_price" v-if="state.goodsInfo.price"
> >
单买价 单买价
<view class="origin-price-text"> <view class="origin-price-text">
{{ state.goodsInfo.original_goods_price[0] || state.goodsInfo.original_price }} {{ fen2yuan(state.goodsInfo.price) }}
</view> </view>
</view> </view>
</view> </view>
@ -74,38 +71,18 @@
<view class="countdown-title" v-else> </view> <view class="countdown-title" v-else> </view>
</view> </view>
<view class="title-text ss-line-2 ss-m-b-6">{{ state.goodsInfo.title }}</view> <view class="title-text ss-line-2 ss-m-b-6">{{ state.goodsInfo.name }}</view>
<view class="subtitle-text ss-line-1">{{ state.goodsInfo.subtitle }}</view> <view class="subtitle-text ss-line-1">{{ state.goodsInfo.introduction }}</view>
</view> </view>
<!-- 功能卡片 --> <!-- 功能卡片 -->
<view class="detail-cell-card detail-card ss-flex-col"> <view class="detail-cell-card detail-card ss-flex-col">
<!-- 规格 --> <!-- 规格 -->
<detail-cell-sku <detail-cell-sku :sku="state.selectedSkuPrice" @tap="state.showSelectSku = true" />
v-model="state.selectedSkuPrice.goods_sku_text"
:skus="state.goodsInfo.skus"
@tap="state.showSelectSku = true"
/>
<!-- 玩法 -->
<detail-cell
v-if="state.goodsInfo.activity.richtext_id > 0"
label="玩法"
:value="state.goodsInfo.activity.richtext_title"
@click="
sheep.$router.go('/pages/public/richtext', {
id: state.goodsInfo.activity.richtext_id,
title: state.goodsInfo.activity.richtext_title,
})
"
/>
</view> </view>
<!-- 参团列表 --> <!-- 参团列表 -->
<groupon-card-list <groupon-card-list v-model="state.activity" @join="onJoinGroupon" />
v-if="state.goodsInfo.activity.rules.is_team_card === '1'"
v-model="state.goodsInfo"
@join="onJoinGroupon"
/>
<!-- 规格与数量弹框 --> <!-- 规格与数量弹框 -->
<s-select-groupon-sku <s-select-groupon-sku
@ -114,7 +91,6 @@
:grouponAction="state.grouponAction" :grouponAction="state.grouponAction"
:grouponNum="state.grouponNum" :grouponNum="state.grouponNum"
@buy="onBuy" @buy="onBuy"
@ladder="onLadder"
@change="onSkuChange" @change="onSkuChange"
@close="onSkuClose" @close="onSkuClose"
/> />
@ -123,65 +99,58 @@
<!-- 评价 --> <!-- 评价 -->
<detail-comment-card class="detail-comment-selector" :goodsId="state.goodsId" /> <detail-comment-card class="detail-comment-selector" :goodsId="state.goodsId" />
<!-- 详情 --> <!-- 详情 -->
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.content" /> <detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
<!-- 商品tabbar --> <!-- 商品tabbar -->
<!-- TODO: 已售罄预热 判断 设计--> <!-- TODO: 已售罄预热 判断 设计-->
<detail-tabbar v-model="state.goodsInfo"> <detail-tabbar v-model="state.goodsInfo">
<view class="buy-box ss-flex ss-col-center ss-p-r-20"> <view class="buy-box ss-flex ss-col-center ss-p-r-20">
<button <button
v-if="state.goodsInfo.activity.rules.is_alone == 1"
class="ss-reset-button origin-price-btn ss-flex-col" class="ss-reset-button origin-price-btn ss-flex-col"
@tap="sheep.$router.go('/pages/goods/index', { id: state.goodsInfo.id })" @tap="sheep.$router.go('/pages/goods/index', { id: state.goodsInfo.id })"
> >
<view class="btn-price">{{ <view class="btn-price">{{ fen2yuan(state.goodsInfo.marketPrice) }}</view>
state.goodsInfo.original_goods_price[0] || state.goodsInfo.original_price
}}</view>
<view>原价购买</view> <view>原价购买</view>
</button> </button>
<button v-else class="ss-reset-button origin-price-btn ss-flex-col">
<view class="btn-title">{{
state.grouponNum == 0 ? '阶梯团' : state.grouponNum + '人团'
}}</view>
</button>
<button <button
class="ss-reset-button btn-tox ss-flex-col" class="ss-reset-button btn-tox ss-flex-col"
@tap="onCreateGroupon" @tap="onCreateGroupon"
:class=" :class="
state.goodsInfo.activity.status === 'ing' && state.goodsInfo.stock != 0 state.activity.status === 0 && state.goodsInfo.stock !== 0
? 'check-btn-box' ? 'check-btn-box'
: 'disabled-btn-box' : 'disabled-btn-box'
" "
:disabled="state.goodsInfo.stock === 0 || state.goodsInfo.activity.status != 'ing'" :disabled="state.goodsInfo.stock === 0 || state.activity.status !== 0"
> >
<view class="btn-price">{{ goodsPrice }}</view> <view class="btn-price">{{ fen2yuan(state.activity.price || state.goodsInfo.price) }}</view>
<view v-if="state.goodsInfo.activity.status === 'ing'"> <view v-if="state.activity.startTime > new Date().getTime()"></view>
<view v-else-if="state.activity.endTime <= new Date().getTime()">已结束</view>
<view v-else>
<view v-if="state.goodsInfo.stock === 0"></view> <view v-if="state.goodsInfo.stock === 0"></view>
<view v-else></view> <view v-else></view>
</view> </view>
<view v-else>{{ state.goodsInfo.activity.status_text }}</view>
</button> </button>
</view> </view>
</detail-tabbar> </detail-tabbar>
</block> </block>
<!-- 轮播 -->
</s-layout> </s-layout>
</template> </template>
<script setup> <script setup>
import { reactive, computed, ref } from 'vue'; import { reactive, computed } from 'vue';
import { onLoad, onPageScroll } from '@dcloudio/uni-app'; import { onLoad, onPageScroll } from '@dcloudio/uni-app';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import detailNavbar from './components/detail/detail-navbar.vue'; import detailNavbar from './components/detail/detail-navbar.vue';
import detailCell from './components/detail/detail-cell.vue';
import detailCellSku from './components/detail/detail-cell-sku.vue'; import detailCellSku from './components/detail/detail-cell-sku.vue';
import detailTabbar from './components/detail/detail-tabbar.vue'; import detailTabbar from './components/detail/detail-tabbar.vue';
import detailSkeleton from './components/detail/detail-skeleton.vue'; import detailSkeleton from './components/detail/detail-skeleton.vue';
import detailCommentCard from './components/detail/detail-comment-card.vue'; import detailCommentCard from './components/detail/detail-comment-card.vue';
import detailContentCard from './components/detail/detail-content-card.vue'; import detailContentCard from './components/detail/detail-content-card.vue';
import grouponCardList from './components/groupon/groupon-card-list.vue'; import grouponCardList from './components/groupon/groupon-card-list.vue';
import { useDurationTime, formatPrice, formatGoodsSwiper } from '@/sheep/hooks/useGoods'; import {useDurationTime, formatGoodsSwiper, fen2yuan} from '@/sheep/hooks/useGoods';
import CombinationApi from "@/sheep/api/promotion/combination";
import SpuApi from "@/sheep/api/product/spu";
const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-bg.png'); const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-bg.png');
@ -189,7 +158,6 @@
const disabledBtnBg = sheep.$url.css( const disabledBtnBg = sheep.$url.css(
'/static/img/shop/goods/activity-btn-disabled.png', '/static/img/shop/goods/activity-btn-disabled.png',
); );
const seckillBg = sheep.$url.css('/static/img/shop/goods/seckill-tip-bg.png');
const grouponBg = sheep.$url.css('/static/img/shop/goods/groupon-tip-bg.png'); const grouponBg = sheep.$url.css('/static/img/shop/goods/groupon-tip-bg.png');
onPageScroll(() => {}); onPageScroll(() => {});
@ -200,32 +168,16 @@
goodsSwiper: [], // goodsSwiper: [], //
showSelectSku: false, // showSelectSku: false, //
selectedSkuPrice: {}, // selectedSkuPrice: {}, //
activity: {}, //
grouponId: 0, // ID grouponId: 0, // ID
grouponType: '', //
grouponNum: 0, // grouponNum: 0, //
grouponAction: 'create', // grouponAction: 'create', //
}); combinationHeadId: null, //
//
const goodsPrice = computed(() => {
if (isEmpty(state.selectedSkuPrice)) {
return formatPrice(state.goodsInfo.price);
}
if(state.grouponNum === 0 && state.grouponType === 'groupon_ladder') {
return formatPrice(state.goodsInfo.price)
}
if (state.grouponType === 'groupon') {
return state.selectedSkuPrice.groupon_price;
}
if (state.grouponType === 'groupon_ladder') {
return state.selectedSkuPrice.ladder_price;
}
return '';
}); });
// //
const endTime = computed(() => { const endTime = computed(() => {
return useDurationTime(state.goodsInfo.activity.end_time); return useDurationTime(state.activity.endTime);
}); });
// //
@ -233,15 +185,6 @@
state.selectedSkuPrice = e; state.selectedSkuPrice = e;
} }
//
function onLadder(e) {
state.showSelectSku = false;
state.grouponNum = e
setTimeout(() => {
state.showSelectSku = true;
}, 80);
}
function onSkuClose() { function onSkuClose() {
state.showSelectSku = false; state.showSelectSku = false;
} }
@ -253,51 +196,53 @@
state.showSelectSku = true; state.showSelectSku = true;
} }
// /**
function onJoinGroupon(groupon) { * 去参团
* @param record 团长的团购记录
*/
function onJoinGroupon(record) {
state.grouponAction = 'join'; state.grouponAction = 'join';
state.grouponId = groupon.id; state.grouponId = record.activityId;
state.grouponNum = groupon.num; state.combinationHeadId = record.id;
state.grouponNum = record.userSize;
state.showSelectSku = true; state.showSelectSku = true;
} }
// //
function onBuy(e) { function onBuy(sku) {
sheep.$router.go('/pages/order/confirm', { sheep.$router.go('/pages/order/confirm', {
data: JSON.stringify({ data: JSON.stringify({
order_type: 'goods', order_type: 'goods',
buy_type: 'groupon', combinationActivityId: state.activity.id,
activity_id: state.goodsInfo.activity.id, combinationHeadId: state.combinationHeadId,
groupon_id: state.grouponId, items: [
groupon_num: state.grouponNum,
goods_list: [
{ {
goods_id: e.goods_id, skuId: sku.id,
goods_num: e.goods_num, count: sku.count,
goods_sku_price_id: e.id,
}, },
], ],
}), }),
}); });
} }
//
const shareInfo = computed(() => { const shareInfo = computed(() => {
if (isEmpty(state.goodsInfo?.activity)) return {}; if (isEmpty(state.activity)) return {};
return sheep.$platform.share.getShareInfo( return sheep.$platform.share.getShareInfo(
{ {
title: state.goodsInfo.title, title: state.activity.name,
image: sheep.$url.cdn(state.goodsInfo.image), image: sheep.$url.cdn(state.goodsInfo.picUrl),
params: { params: {
page: '3', page: '3',
query: state.goodsInfo.id + ',' + state.goodsInfo.activity.id, query: state.activity.id,
}, },
}, },
{ {
type: 'goods', // type: 'goods', //
title: state.goodsInfo.title, // title: state.activity.name, //
image: sheep.$url.cdn(state.goodsInfo.image), // image: sheep.$url.cdn(state.goodsInfo.picUrl), //
price: state.goodsInfo.price[0], // price: fen2yuan(state.goodsInfo.price), //
original_price: state.goodsInfo.original_price, // marketPrice: fen2yuan(state.goodsInfo.marketPrice), //
}, },
); );
}); });
@ -308,20 +253,22 @@
state.goodsInfo = null; state.goodsInfo = null;
return; return;
} }
state.goodsId = options.id; state.grouponId = options.id;
//
const { code, data: activity } = await CombinationApi.getCombinationActivity(state.grouponId);
state.activity = activity;
// //
const { error, data } = await sheep.$api.goods.detail(options.id, { const { data: spu } = await SpuApi.getSpuDetail(activity.spuId);
activity_id: options.activity_id, state.goodsId = spu.id;
activity.products.forEach(product => {
spu.price = Math.min(spu.price, product.combinationPrice); // SPU
}); });
// //
state.skeletonLoading = false; state.skeletonLoading = false;
if (error === 0) { if (code === 0) {
state.goodsInfo = data; state.goodsInfo = spu;
state.grouponType = state.goodsInfo.activity_type; state.grouponNum = activity.userSize;
if (state.grouponType === 'groupon') { state.goodsSwiper = formatGoodsSwiper(state.goodsInfo.sliderPicUrls);
state.grouponNum = state.goodsInfo.activity.rules.team_num;
}
state.goodsSwiper = formatGoodsSwiper(state.goodsInfo.images);
} else { } else {
// //
state.goodsInfo = null; state.goodsInfo = null;
@ -526,13 +473,6 @@
} }
} }
//
.seckill-box {
background: v-bind(seckillBg)
no-repeat;
background-size: 100% 100%;
}
.groupon-box { .groupon-box {
background: v-bind(grouponBg) background: v-bind(grouponBg)
no-repeat; no-repeat;

View File

@ -5,7 +5,7 @@
<detailNavbar /> <detailNavbar />
<!-- 骨架屏 --> <!-- 骨架屏 -->
<detailSkeleton v-if="state.skeletonLoading" /> <detailSkeleton v-if="state.skeletonLoading" />
<!-- 空置页 --> <!-- 下架/售罄提醒 -->
<s-empty <s-empty
v-else-if="state.goodsInfo === null || state.goodsInfo.activity_type !== 'seckill'" v-else-if="state.goodsInfo === null || state.goodsInfo.activity_type !== 'seckill'"
text="活动不存在或已结束" text="活动不存在或已结束"
@ -16,7 +16,7 @@
/> />
<block v-else> <block v-else>
<view class="detail-swiper-selector"> <view class="detail-swiper-selector">
<!-- 轮播 --> <!-- 商品图轮播 -->
<su-swiper <su-swiper
class="ss-m-b-14" class="ss-m-b-14"
isPreview isPreview
@ -63,14 +63,13 @@
<detail-progress :percent="state.percent" /> <detail-progress :percent="state.percent" />
</view> </view>
<view class="title-text ss-line-2 ss-m-b-6">{{ state.goodsInfo.name }}</view> <view class="title-text ss-line-2 ss-m-b-6">{{ state.goodsInfo?.name }}</view>
<view class="subtitle-text ss-line-1">{{ state.goodsInfo.introduction }}</view> <view class="subtitle-text ss-line-1">{{ state.goodsInfo.introduction }}</view>
</view> </view>
<!-- 功能卡片 --> <!-- 功能卡片 -->
<view class="detail-cell-card detail-card ss-flex-col"> <view class="detail-cell-card detail-card ss-flex-col">
<detail-cell-sku <detail-cell-sku
v-model="state.selectedSku.goods_sku_text"
:sku="state.selectedSku" :sku="state.selectedSku"
@tap="state.showSelectSku = true" @tap="state.showSelectSku = true"
/> />
@ -108,30 +107,27 @@
<button v-else class="ss-reset-button origin-price-btn ss-flex-col"> <button v-else class="ss-reset-button origin-price-btn ss-flex-col">
<view <view
class="no-original" class="no-original"
:class=" :class="state.goodsInfo.stock === 0 || timeStatusEnum !== TimeStatusEnum.STARTED ? '' : ''"
state.goodsInfo.stock === 0 || activity.status != 'ing' ? '' : ''
"
> >
秒杀价 秒杀价
</view> </view>
</button> </button>
<!-- TODO @疯狂status 判断不太对 -->
<button <button
class="ss-reset-button btn-box ss-flex-col" class="ss-reset-button btn-box ss-flex-col"
@tap="state.showSelectSku = true" @tap="state.showSelectSku = true"
:class=" :class="
activity.status === 'ing' && state.goodsInfo.stock != 0 timeStatusEnum === TimeStatusEnum.STARTED && state.goodsInfo.stock != 0
? 'check-btn-box' ? 'check-btn-box'
: 'disabled-btn-box' : 'disabled-btn-box'
" "
:disabled="state.goodsInfo.stock === 0 || activity.status != 'ing'" :disabled="state.goodsInfo.stock === 0 || timeStatusEnum !== TimeStatusEnum.STARTED"
> >
<view class="btn-price">{{ fen2yuan(state.goodsInfo.price) }}</view> <view class="btn-price">{{ fen2yuan(state.goodsInfo.price) }}</view>
<view v-if="activity.status === 'ing'"> <view v-if="timeStatusEnum === TimeStatusEnum.STARTED">
<view v-if="state.goodsInfo.stock === 0"></view> <view v-if="state.goodsInfo.stock === 0"></view>
<view v-else></view> <view v-else></view>
</view> </view>
<view v-else>{{ activity.status_text }}</view> <view v-else>{{ timeStatusEnum }}</view>
</button> </button>
</view> </view>
</detail-tabbar> </detail-tabbar>
@ -154,6 +150,7 @@
import detailProgress from './components/detail/detail-progress.vue'; import detailProgress from './components/detail/detail-progress.vue';
import SeckillApi from "@/sheep/api/promotion/seckill"; import SeckillApi from "@/sheep/api/promotion/seckill";
import SpuApi from "@/sheep/api/product/spu"; import SpuApi from "@/sheep/api/product/spu";
import {getTimeStatusEnum, TimeStatusEnum} from "@/sheep/util/const";
const headerBg = sheep.$url.css('/static/img/shop/goods/seckill-bg.png'); const headerBg = sheep.$url.css('/static/img/shop/goods/seckill-bg.png');
const btnBg = sheep.$url.css('/static/img/shop/goods/seckill-btn.png'); const btnBg = sheep.$url.css('/static/img/shop/goods/seckill-btn.png');
@ -186,49 +183,51 @@
} }
// //
function onBuy(e) { function onBuy(sku) {
sheep.$router.go('/pages/order/confirm', { sheep.$router.go('/pages/order/confirm', {
data: JSON.stringify({ data: JSON.stringify({
order_type: 'goods', order_type: 'goods',
buy_type: 'seckill', buy_type: 'seckill',
activityId: activity.value.id, seckillActivityId: activity.value.id,
goods_list: [ items: [
{ {
goods_id: e.goods_id, skuId: sku.id,
goods_num: e.goods_num, count: sku.count,
goods_sku_price_id: e.id,
}, },
], ],
}), }),
}); });
} }
//
const shareInfo = computed(() => { const shareInfo = computed(() => {
if (isEmpty(state.goodsInfo?.activity)) return {}; if (isEmpty(activity)) return {};
return sheep.$platform.share.getShareInfo( return sheep.$platform.share.getShareInfo(
{ {
title: state.goodsInfo.name, title: activity.value.name,
image: sheep.$url.cdn(state.goodsInfo.picUrl), image: sheep.$url.cdn(state.goodsInfo.picUrl),
params: { params: {
page: '4', page: '4',
query: state.goodsInfo.id + ',' + activity.value.id, query: activity.value.id,
}, },
}, },
{ {
type: 'goods', // type: 'goods', //
title: state.goodsInfo.name, // title: activity.value.name, //
image: sheep.$url.cdn(state.goodsInfo.picUrl), // image: sheep.$url.cdn(state.goodsInfo.picUrl), //
price: state.goodsInfo.price[0], // price: state.goodsInfo.price, //
marketPrice: state.goodsInfo.marketPrice, // marketPrice: state.goodsInfo.marketPrice, //
}, },
); );
}); });
const activity = ref() const activity = ref()
const timeStatusEnum = ref('')
// //
const getActivity = async (id) => { const getActivity = async (id) => {
const { data } = await SeckillApi.getSeckillActivity(id) const { data } = await SeckillApi.getSeckillActivity(id)
activity.value = data activity.value = data
timeStatusEnum.value = getTimeStatusEnum(activity.startTime, activity.endTime)
// //
await getSpu(data.spuId) await getSpu(data.spuId)
@ -247,7 +246,6 @@
// 使 // 使
data.skus.forEach(sku => { data.skus.forEach(sku => {
debugger
const product = activity.value.products.find(product => product.skuId === sku.id); const product = activity.value.products.find(product => product.skuId === sku.id);
if (product) { if (product) {
sku.price = product.seckillPrice; sku.price = product.seckillPrice;

View File

@ -1,35 +1,32 @@
<!-- 自定义页面支持装修 --> <!-- 自定义页面支持装修 -->
<template> <template>
<s-layout <s-layout
:title="page.name" :title="state.name"
navbar="custom" navbar="custom"
:bgStyle="page.style?.background" :bgStyle="state.page"
:navbarStyle="page.style?.navbar" :navbarStyle="state.navigationBar"
onShareAppMessage onShareAppMessage
showLeftButton showLeftButton
> >
<s-block v-for="(item, index) in page.list" :key="index" :styles="item.style"> <s-block v-for="(item, index) in state.components" :key="index" :styles="item.property.style">
<s-block-item :type="item.type" :data="item.data" :styles="item.style" /> <s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
</s-block> </s-block>
</s-layout> </s-layout>
</template> </template>
<script setup> <script setup>
import { computed, reactive } from 'vue'; import { reactive } from 'vue';
import sheep from '@/sheep';
import { onLoad, onPageScroll } from '@dcloudio/uni-app'; import { onLoad, onPageScroll } from '@dcloudio/uni-app';
import DiyPageApi from "@/sheep/api/promotion/diy/page";
const page = reactive({ const state = reactive({
name: '', name: '',
list: [], components: [],
style: {}, navigationBar: {},
page: {},
}); });
onLoad(async (options) => { onLoad(async (options) => {
let id; let id = options.id
if (options.id) {
id = options.id;
}
// #ifdef MP // #ifdef MP
// //
@ -39,12 +36,12 @@
} }
// #endif // #endif
// TODO @ const { code, data } = await DiyPageApi.getDiyPage(id);
const { error, data } = await sheep.$api.app.page(id); if (code === 0) {
if (error === 0) { state.name = data.name;
page.name = data.name; state.components = data.property?.components;
page.list = data.diypage?.page?.data; state.navigationBar = data.property?.navigationBar;
page.style = data.diypage?.page?.style; state.page = data.property?.page;
} }
}); });

View File

@ -31,32 +31,32 @@
<view class="cart-content"> <view class="cart-content">
<view <view
class="goods-box ss-r-10 ss-m-b-14" class="goods-box ss-r-10 ss-m-b-14"
v-for="item in state.pagination.data" v-for="item in state.pagination.list"
:key="item.id" :key="item.id"
> >
<view class="ss-flex ss-col-center"> <view class="ss-flex ss-col-center">
<label <label
class="check-box ss-flex ss-col-center ss-p-l-10" class="check-box ss-flex ss-col-center ss-p-l-10"
v-if="state.editMode" v-if="state.editMode"
@tap="onSelect(item.goods_id)" @tap="onSelect(item.spuId)"
> >
<radio <radio
:checked="state.selectedCollectList.includes(item.goods_id)" :checked="state.selectedSpuIdList.includes(item.spuId)"
color="var(--ui-BG-Main)" color="var(--ui-BG-Main)"
style="transform: scale(0.8)" style="transform: scale(0.8)"
@tap.stop="onSelect(item.goods_id)" @tap.stop="onSelect(item.spuId)"
/> />
</label> </label>
<s-goods-item <s-goods-item
:title="item.goods.title" :title="item.spuName"
:img="item.goods.image" :img="item.picUrl"
:price="item.goods.price[0]" :price="item.price"
:skuText="item.goods.subtitle" :skuText="item.introduction"
priceColor="#FF3000" priceColor="#FF3000"
:titleWidth="400" :titleWidth="400"
@tap=" @tap="
sheep.$router.go('/pages/goods/index', { sheep.$router.go('/pages/goods/index', {
id: item.goods_id, id: item.spuId,
}) })
" "
> >
@ -78,13 +78,23 @@
<view>全选</view> <view>全选</view>
</label> </label>
</view> </view>
<view class="footer-right"> <view class="footer-right ss-flex">
<button <button
class="ss-reset-button ui-BG-Main-Gradient pay-btn ss-font-28 ui-Shadow-Main" :class="['ss-reset-button pay-btn ss-font-28 ',
@tap="onCancel" {
'ui-BG-Main-Gradient': state.selectedSpuIdList.length > 0,
'ui-Shadow-Main': state.selectedSpuIdList.length > 0
}]"
@tap="onDelete"
> >
删除足迹 删除足迹
</button> </button>
<button
class="ss-reset-button ui-BG-Main-Gradient pay-btn ss-font-28 ui-Shadow-Main ml-2"
@tap="onClean"
>
清空
</button>
</view> </view>
</view> </view>
</su-fixed> </su-fixed>
@ -95,7 +105,7 @@
:content-text="{ :content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" }"
@tap="loadmore" @tap="loadMore"
/> />
<s-empty <s-empty
v-if="state.pagination.total === 0" v-if="state.pagination.total === 0"
@ -110,100 +120,105 @@
import { reactive } from 'vue'; import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app'; import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import _ from 'lodash'; import _ from 'lodash';
import SpuHistoryApi from "@/sheep/api/product/history";
import {cloneDeep} from "@/sheep/helper/utils";
const sys_navBar = sheep.$platform.navbar; const sys_navBar = sheep.$platform.navbar;
const pagination = { const pagination = {
data: [], list: [],
current_page: 1, pageNo: 1,
total: 1, total: 1,
last_page: 1, pageSize: 10,
}; };
const state = reactive({ const state = reactive({
pagination: { pagination: cloneDeep(pagination),
data: [],
current_page: 1,
total: 1,
last_page: 1,
},
loadStatus: '', loadStatus: '',
editMode: false, editMode: false,
selectedCollectList: [], selectedSpuIdList: [],
selectAll: false, selectAll: false,
}); });
async function getData(page = 1, list_rows = 10) { async function getList() {
state.loadStatus = 'loading'; state.loadStatus = 'loading';
let res = await sheep.$api.user.view.list({ const { code, data } = await SpuHistoryApi.getBrowseHistoryPage({
list_rows, pageNo: state.pagination.pageNo,
page, pageSize: state.pagination.pageSize,
}); });
if (res.error === 0) { if (code !== 0) {
let orderList = _.concat(state.pagination.data, res.data.data); return;
state.pagination = { }
...res.data,
data: orderList, state.pagination.list = _.concat(state.pagination.list, data.list);
}; state.pagination.total = data.total;
if (state.pagination.current_page < state.pagination.last_page) { if (state.pagination.list.length < state.pagination.total) {
state.loadStatus = 'more'; state.loadStatus = 'more';
} else { } else {
state.loadStatus = 'noMore'; state.loadStatus = 'noMore';
}
} }
}
//
function formatPrice(e) {
return e.length === 1 ? e[0] : e.join('~');
} }
// //
const onSelect = (id) => { const onSelect = (id) => {
if (!state.selectedCollectList.includes(id)) { if (!state.selectedSpuIdList.includes(id)) {
state.selectedCollectList.push(id); state.selectedSpuIdList.push(id);
} else { } else {
state.selectedCollectList.splice(state.selectedCollectList.indexOf(id), 1); state.selectedSpuIdList.splice(state.selectedSpuIdList.indexOf(id), 1);
} }
state.selectAll = state.selectedCollectList.length === state.pagination.data.length; state.selectAll = state.selectedSpuIdList.length === state.pagination.list.length;
}; };
// //
const onSelectAll = () => { const onSelectAll = () => {
state.selectAll = !state.selectAll; state.selectAll = !state.selectAll;
if (!state.selectAll) { if (!state.selectAll) {
state.selectedCollectList = []; state.selectedSpuIdList = [];
} else { } else {
state.pagination.data.forEach((item) => { state.pagination.list.forEach((item) => {
if (state.selectedCollectList.includes(item.goods_id)) { if (state.selectedSpuIdList.includes(item.spuId)) {
state.selectedCollectList.splice(state.selectedCollectList.indexOf(item.goods_id), 1); state.selectedSpuIdList.splice(state.selectedSpuIdList.indexOf(item.spuId), 1);
} }
state.selectedCollectList.push(item.goods_id); state.selectedSpuIdList.push(item.spuId);
}); });
} }
}; };
async function onCancel() { //
if (state.selectedCollectList) { async function onDelete() {
state.selectedCollectList = state.selectedCollectList.toString(); if (state.selectedSpuIdList.length <= 0) {
const { error } = await sheep.$api.user.view.delete({ return;
goods_id: state.selectedCollectList, }
});
if (error === 0) { const { code } = await SpuHistoryApi.deleteBrowseHistory(state.selectedSpuIdList);
state.editMode = false; if (code === 0) {
state.selectedCollectList = []; reload();
state.selectAll = false;
state.pagination = pagination;
getData();
}
} }
} }
//
async function onClean() {
const { code } = await SpuHistoryApi.cleanBrowseHistory();
if (code === 0) {
reload();
}
}
function reload() {
state.editMode = false;
state.selectedSpuIdList = [];
state.selectAll = false;
state.pagination = pagination;
getList();
}
// //
function loadmore() { function loadMore() {
if (state.loadStatus !== 'noMore') { if (state.loadStatus !== 'noMore') {
getData(state.pagination.current_page + 1); state.pagination.pageNo += 1;
getList();
} }
} }
onReachBottom(() => { onReachBottom(() => {
loadmore(); loadMore();
}); });
onLoad(() => { onLoad(() => {
getData(); getList();
}); });
</script> </script>

View File

@ -0,0 +1,35 @@
import request from '@/sheep/request';
const SpuHistoryApi = {
// 删除商品浏览记录
deleteBrowseHistory: (spuIds) => {
return request({
url: '/app-api/product/browse-history/delete',
method: 'DELETE',
data: { spuIds },
});
},
// 清空商品浏览记录
cleanBrowseHistory: () => {
return request({
url: '/app-api/product/browse-history/clean',
method: 'DELETE',
});
},
// 获得商品浏览记录分页
getBrowseHistoryPage: (data) => {
return request({
url: '/app-api/product/browse-history/page',
method: 'GET',
data
});
},
// 获得商品浏览记录数量
getBrowseHistoryCount: () => {
return request({
url: '/app-api/product/browse-history/get-count',
method: 'GET',
});
}
};
export default SpuHistoryApi;

View File

@ -5,7 +5,7 @@ const CombinationApi = {
// 获得拼团活动列表 // 获得拼团活动列表
getCombinationActivityList: (count) => { getCombinationActivityList: (count) => {
return request({ return request({
url: "promotion/combination-activity/list", url: "/app-api/promotion/combination-activity/list",
method: 'GET', method: 'GET',
params: {count} params: {count}
}); });
@ -14,7 +14,7 @@ const CombinationApi = {
// 获得拼团活动分页 // 获得拼团活动分页
getCombinationActivityPage: (params) => { getCombinationActivityPage: (params) => {
return request({ return request({
url: "promotion/combination-activity/page", url: "/app-api/promotion/combination-activity/page",
method: 'GET', method: 'GET',
params params
}); });
@ -23,7 +23,7 @@ const CombinationApi = {
// 获得拼团活动明细 // 获得拼团活动明细
getCombinationActivity: (id) => { getCombinationActivity: (id) => {
return request({ return request({
url: "promotion/combination-activity/get-detail", url: "/app-api/promotion/combination-activity/get-detail",
method: 'GET', method: 'GET',
params: { params: {
id id
@ -34,7 +34,7 @@ const CombinationApi = {
// 获得最近 n 条拼团记录(团长发起的) // 获得最近 n 条拼团记录(团长发起的)
getHeadCombinationRecordList: (activityId, status, count) => { getHeadCombinationRecordList: (activityId, status, count) => {
return request({ return request({
url: "promotion/combination-record/get-head-list", url: "/app-api/promotion/combination-record/get-head-list",
method: 'GET', method: 'GET',
params: { params: {
activityId, activityId,
@ -47,7 +47,7 @@ const CombinationApi = {
// 获得拼团记录明细 // 获得拼团记录明细
getCombinationRecordDetail: (id) => { getCombinationRecordDetail: (id) => {
return request({ return request({
url: "promotion/combination-record/get-detail", url: "/app-api/promotion/combination-record/get-detail",
method: 'GET', method: 'GET',
params: { params: {
id id
@ -58,7 +58,7 @@ const CombinationApi = {
// 获得拼团记录的概要信息 // 获得拼团记录的概要信息
getCombinationRecordSummary: () => { getCombinationRecordSummary: () => {
return request({ return request({
url: "promotion/combination-record/get-summary", url: "/app-api/promotion/combination-record/get-summary",
method: 'GET', method: 'GET',
}); });
} }

View File

@ -67,7 +67,20 @@ const CouponApi = {
auth: true, auth: true,
}, },
}); });
},
// 获得匹配指定商品的优惠劵列表
getMatchCouponList: (price, spuIds, skuIds, categoryIds) => {
return request({
url: '/app-api/promotion/coupon/match-list',
method: 'GET',
params: {
price,
spuIds: spuIds.join(','),
skuIds: skuIds.join(','),
categoryIds: categoryIds.join(','),
},
});
} }
}; };
export default CouponApi; export default CouponApi;

View File

@ -0,0 +1,15 @@
import request from '@/sheep/request';
const DiyPageApi = {
getDiyPage: (id) => {
return request({
url: '/app-api/promotion/diy-page/get',
method: 'GET',
params: {
id
}
});
},
};
export default DiyPageApi;

View File

@ -307,26 +307,17 @@
type: [Array, Object], type: [Array, Object],
default() { default() {
return { return {
// TODO @
//
title: { show: true },
//
subtitle: { show: true },
// //
price: { show: true }, price: { show: true },
//
original_price: { show: true },
//
sales: { show: true },
// //
stock: { show: true }, stock: { show: true },
// //
name: { show: true }, name: { show: true },
// //
introduction: { show: true }, introduction: { show: true },
// //
marketPrice: { show: true }, marketPrice: { show: true },
// //
salesCount: { show: true }, salesCount: { show: true },
}; };
}, },

View File

@ -1,124 +1,70 @@
<template> <template>
<!-- 拼团商品规格弹窗 --> <!-- 拼团商品规格弹窗 -->
<su-popup :show="show" round="10" @close="emits('close')"> <su-popup :show="show" round="10" @close="emits('close')">
<!-- SKU 信息 -->
<view class="ss-modal-box bg-white ss-flex-col"> <view class="ss-modal-box bg-white ss-flex-col">
<view class="modal-header ss-flex ss-col-center"> <view class="modal-header ss-flex ss-col-center">
<view class="header-left ss-m-r-30"> <view class="header-left ss-m-r-30">
<image <image class="sku-image" :src="sheep.$url.cdn(state.selectedSku.picUrl || goodsInfo.picUrl)" mode="aspectFill" />
class="sku-image"
:src="sheep.$url.cdn(state.selectedSkuPrice.image || goodsInfo.image)"
mode="aspectFill"
>
</image>
</view> </view>
<view class="header-right ss-flex-col ss-row-between ss-flex-1"> <view class="header-right ss-flex-col ss-row-between ss-flex-1">
<view class="goods-title ss-line-2"> <view class="goods-title ss-line-2">
<view class="tig ss-flex ss-col-center"> <view class="tig ss-flex ss-col-center">
<view class="tig-icon ss-flex ss-col-center ss-row-center"> <view class="tig-icon ss-flex ss-col-center ss-row-center">
<view class="groupon-tag"> <view class="groupon-tag">
<image :src="sheep.$url.static('/static/img/shop/goods/groupon-tag-white.png')"> <image :src="sheep.$url.static('/static/img/shop/goods/groupon-tag-white.png')" />
</image>
</view> </view>
</view> </view>
<view class="tig-title">拼团价</view> <view class="tig-title">拼团价</view>
</view> </view>
<view class="info-title"> <view class="info-title">
{{ goodsInfo.title }} {{ goodsInfo.name }}
</view> </view>
</view> </view>
<view class="header-right-bottom ss-flex ss-col-center ss-row-between"> <view class="header-right-bottom ss-flex ss-col-center ss-row-between">
<view class="price-text"> {{ goodsPrice }}</view> <view class="price-text"> {{ fen2yuan(goodsInfo.price) }}</view>
<view class="stock-text ss-m-l-20"> <view class="stock-text ss-m-l-20">
库存{{ state.selectedSkuPrice.stock || goodsInfo.stock }} 库存{{ state.selectedSku.stock || goodsInfo.stock }}
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="modal-content ss-flex-1"> <view class="modal-content ss-flex-1">
<scroll-view scroll-y="true" class="modal-content-scroll"> <scroll-view scroll-y="true" class="modal-content-scroll">
<view <view class="sku-item ss-m-b-20" v-for="property in propertyList" :key="property.id">
v-if="grouponAction === 'create' && activityType === 'groupon_ladder'" <view class="label-text ss-m-b-20">{{ property.name }}</view>
class="sku-item ss-m-b-20"
>
<view class="label-text ss-m-b-20">拼团人数</view>
<view class="ss-flex ss-col-center ss-flex-wrap"> <view class="ss-flex ss-col-center ss-flex-wrap">
<button <button class="ss-reset-button spec-btn" v-for="value in property.values" :class="[
v-for="(ladder, key) in goodsInfo.activity.rules.ladders"
:key="key"
class="ss-reset-button spec-btn"
:class="[
{ {
'checked-btn': grouponNum == ladder, 'checked-btn': state.currentPropertyArray[property.id] === value.id,
},
]"
@tap="onSelectLadder(ladder)"
>
{{ ladder }}人团
</button>
</view>
</view>
<view class="sku-item ss-m-b-20" v-for="sku1 in goodsInfo.skus" :key="sku1.id">
<view class="label-text ss-m-b-20">{{ sku1.name }}</view>
<view class="ss-flex ss-col-center ss-flex-wrap">
<button
class="ss-reset-button spec-btn"
v-for="sku2 in sku1.children"
:class="[
{
'checked-btn': state.currentSkuArray[sku2.parent_id] == sku2.id,
}, },
{ {
'disabled-btn': sku2.disabled == true, 'disabled-btn': value.disabled === true,
}, },
]" ]" :key="value.id" :disabled="value.disabled === true" @tap="onSelectSku(property.id, value.id)">
:key="sku2.id" {{ value.name }}
:disabled="sku2.disabled == true"
@tap="onSelectSku(sku2.parent_id, sku2.id)"
>
{{ sku2.name }}
</button> </button>
</view> </view>
</view> </view>
<view class="buy-num-box ss-flex ss-col-center ss-row-between"> <view class="buy-num-box ss-flex ss-col-center ss-row-between">
<view class="label-text">购买数量</view> <view class="label-text">购买数量</view>
<su-number-box <su-number-box :min="1" :max="state.selectedSku.stock" :step="1"
:min="1" v-model="state.selectedSku.count" @change="onNumberChange($event)" activity="groupon" />
:max="state.selectedSkuPrice.stock"
:step="1"
v-model="state.selectedSkuPrice.goods_num"
@change="onNumberChange($event)"
activity="groupon"
></su-number-box>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<!-- 操作区 -->
<view class="modal-footer ss-p-y-20"> <view class="modal-footer ss-p-y-20">
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center"> <view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center">
<view class="ss-flex"> <view class="ss-flex">
<button class="ss-reset-button origin-price-btn ss-flex-col"> <button class="ss-reset-button origin-price-btn ss-flex-col">
<view class="btn-title">{{ grouponNum === 0 ? '阶梯团' : grouponNum + '人团' }}</view> <view class="btn-title">{{ grouponNum + '人团' }}</view>
</button> </button>
<button class="ss-reset-button btn-tox ss-flex-col" @tap="onBuy"> <button class="ss-reset-button btn-tox ss-flex-col" @tap="onBuy">
<view class="btn-price"> <view class="btn-price">{{ fen2yuan(goodsInfo.price) }}</view>
{{ <view v-if="grouponAction === 'create'"></view>
grouponAction === 'create' && goodsInfo.activity.rules.is_leader_discount == 1
? leaderPrice
: goodsPrice
}}
</view>
<view
v-if="
grouponAction === 'create' && goodsInfo.activity.rules.is_leader_discount == 0
"
>立即开团</view
>
<view
v-else-if="
grouponAction === 'create' && goodsInfo.activity.rules.is_leader_discount == 1
"
>团长立减价</view
>
<view v-else-if="grouponAction === 'join'">参与拼团</view> <view v-else-if="grouponAction === 'join'">参与拼团</view>
</button> </button>
</view> </view>
@ -131,8 +77,7 @@
<script setup> <script setup>
import { computed, reactive, watch } from 'vue'; import { computed, reactive, watch } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { formatPrice } from '@/sheep/hooks/useGoods'; import {convertProductPropertyList, fen2yuan} from '@/sheep/hooks/useGoods';
import { isEmpty } from 'lodash';
const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-btn-long.png'); const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-btn-long.png');
const emits = defineEmits(['change', 'addCart', 'buy', 'close', 'ladder']); const emits = defineEmits(['change', 'addCart', 'buy', 'close', 'ladder']);
@ -143,7 +88,7 @@
}, },
goodsInfo: { goodsInfo: {
type: Object, type: Object,
default() {}, default () {},
}, },
grouponAction: { grouponAction: {
type: String, type: String,
@ -155,257 +100,186 @@
}, },
}); });
const state = reactive({ const state = reactive({
selectedSkuPrice: {}, selectedSku: {}, // SKU
currentSkuArray: [], currentPropertyArray: [], // Mapkey property value value
grouponNum: props.grouponNum, grouponNum: props.grouponNum,
}); });
//
function onNumberChange(e) {
if(e === 0) return;
if (state.selectedSkuPrice.goods_num === e) return;
state.selectedSkuPrice.goods_num = e;
}
// const propertyList = convertProductPropertyList(props.goodsInfo.skus);
if (!props.goodsInfo.is_sku) {
state.selectedSkuPrice = props.goodsInfo.sku_prices[0];
}
// // SKU
const activityType = props.goodsInfo.activity_type; const skuList = computed(() => {
let skuPrices = props.goodsInfo.skus;
// for (let price of skuPrices) {
const skuPrices = computed(() => { price.value_id_array = price.properties.map((item) => item.valueId)
let skuPrices = props.goodsInfo.sku_prices;
if (props.goodsInfo.is_sku) {
skuPrices.forEach((item) => {
item.goods_sku_id_arr = item.goods_sku_ids.split(',');
});
} }
return skuPrices; return skuPrices;
}); });
const skuList = props.goodsInfo.skus;
//
const goodsPrice = computed(() => {
if (isEmpty(state.selectedSkuPrice)) {
return formatPrice(props.goodsInfo.price);
}
if (props.grouponNum === 0 && activityType === 'groupon_ladder') {
return formatPrice(props.goodsInfo.price);
}
if (activityType === 'groupon') {
return state.selectedSkuPrice.groupon_price;
}
if (activityType === 'groupon_ladder') {
const ladder = getSkuPriceByLadder();
state.selectedSkuPrice.ladder_price = ladder.ladder_price;
return ladder.ladder_price;
}
});
//
const leaderPrice = computed(() => {
if (isEmpty(state.selectedSkuPrice)) {
return formatPrice(props.goodsInfo.price);
}
if (props.grouponNum === 0 && activityType === 'groupon_ladder') {
return formatPrice(props.goodsInfo.price);
}
if (activityType === 'groupon') {
return state.selectedSkuPrice.leader_price;
}
if (activityType === 'groupon_ladder') {
const ladder = getSkuPriceByLadder();
return ladder.leader_ladder_price;
}
});
//
function getSkuPriceByLadder() {
return state.selectedSkuPrice.ladders.find((item) => item.ladder == props.grouponNum);
}
watch( watch(
() => state.selectedSkuPrice, () => state.selectedSku,
(newVal) => { (newVal) => {
emits('change', newVal); emits('change', newVal);
}, }, {
{
immediate: true, // immediate: true, //
deep: true, // deep: true, //
}, },
); );
//
function onNumberChange(e) {
if (e === 0) return;
if (state.selectedSku.count === e) return;
state.selectedSku.count = e;
}
// //
function onBuy() { function onBuy() {
if (!state.selectedSkuPrice.goods_id) { if (!state.selectedSku.id || state.selectedSku.id <= 0) {
sheep.$helper.toast('请选择规格'); sheep.$helper.toast('请选择规格');
return; return;
} }
if (state.selectedSkuPrice.stock <= 0) { if (state.selectedSku.stock <= 0) {
sheep.$helper.toast('库存不足'); sheep.$helper.toast('库存不足');
return; return;
} }
emits('buy', state.selectedSkuPrice); emits('buy', state.selectedSku);
} }
// // property
function changeDisabled(isChecked = false, pid = 0, skuId = 0) { function changeDisabled(isChecked = false, propertyId = 0, valueId = 0) {
let newPrice = []; // skuPrice let newSkus = []; // sku
if (isChecked) { if (isChecked) {
// // property
// skuPrice // property SKU
for (let price of skuPrices.value) { for (let price of skuList.value) {
if (price.stock <= 0) { if (price.stock <= 0) {
// this.goodsNum uni-number-box stock goods_num
continue; continue;
} }
if (price.goods_sku_id_arr.indexOf(skuId.toString()) >= 0) { if (price.value_id_array.indexOf(valueId) >= 0) {
newPrice.push(price); newSkus.push(price);
} }
} }
} else { } else {
// // property
// skuPrice // property SKU
newPrice = getCanUseSkuPrice(); newSkus = getCanUseSkuList();
} }
// id // SKU value id
let noChooseSkuIds = []; let noChooseValueIds = [];
for (let price of newPrice) { for (let price of newSkus) {
noChooseSkuIds = noChooseSkuIds.concat(price.goods_sku_id_arr); noChooseValueIds = noChooseValueIds.concat(price.value_id_array);
} }
noChooseValueIds = Array.from(new Set(noChooseValueIds)); //
//
noChooseSkuIds = Array.from(new Set(noChooseSkuIds));
if (isChecked) { if (isChecked) {
// // value id
let index = noChooseSkuIds.indexOf(skuId.toString()); let index = noChooseValueIds.indexOf(valueId);
noChooseSkuIds.splice(index, 1); noChooseValueIds.splice(index, 1);
} else { } else {
// // value id
state.currentSkuArray.forEach((sku) => { state.currentPropertyArray.forEach((currentPropertyId) => {
if (sku.toString() != '') { if (currentPropertyId.toString() !== '') {
// sku return;
let index = noChooseSkuIds.indexOf(sku.toString()); }
if (index >= 0) { // currentPropertyId
// sku noChooseSkuIds let index = noChooseValueIds.indexOf(currentPropertyId);
noChooseSkuIds.splice(index, 1); if (index >= 0) {
} // currentPropertyId noChooseValueIds
noChooseValueIds.splice(index, 1);
} }
}); });
} }
// // property
let chooseSkuKey = []; let choosePropertyIds = [];
if (!isChecked) { if (!isChecked) {
// // property
state.currentSkuArray.forEach((sku, key) => { state.currentPropertyArray.forEach((currentPropertyId, currentValueId) => {
if (sku != '') { if (currentPropertyId !== '') {
// sku // currentPropertyId
chooseSkuKey.push(key); choosePropertyIds.push(currentValueId);
} }
}); });
} else { } else {
// // property
chooseSkuKey = [pid]; choosePropertyIds = [propertyId];
} }
for (let i in skuList) { for (let propertyIndex in propertyList) {
// // property property
if (chooseSkuKey.indexOf(skuList[i]['id']) >= 0) { if (choosePropertyIds.indexOf(propertyList[propertyIndex]['id']) >= 0) {
continue; continue;
} }
// property id SKU
for (let j in skuList[i]['children']) { for (let valueIndex in propertyList[propertyIndex]['values']) {
// id propertyList[propertyIndex]['values'][valueIndex]['disabled'] =
if (noChooseSkuIds.indexOf(skuList[i]['children'][j]['id'].toString()) >= 0) { noChooseValueIds.indexOf(propertyList[propertyIndex]['values'][valueIndex]['id']) < 0; // true or false
skuList[i]['children'][j]['disabled'] = false;
} else {
skuList[i]['children'][j]['disabled'] = true;
}
} }
} }
} }
// skuPrice // SKU
function getCanUseSkuPrice() { function getCanUseSkuList() {
let newPrice = []; let newSkus = [];
for (let sku of skuList.value) {
for (let price of skuPrices.value) { if (sku.stock <= 0) {
if (price.stock <= 0) {
// || price.stock < this.goodsNum uni-number-box stock goods_num
continue; continue;
} }
var isOk = true; let isOk = true;
state.currentPropertyArray.forEach((propertyId) => {
state.currentSkuArray.forEach((sku) => { // propertyId sku
// sku skuPrice , if (propertyId.toString() !== '' && sku.value_id_array.indexOf(propertyId) < 0) {
if (sku.toString() != '' && price.goods_sku_id_arr.indexOf(sku.toString()) < 0) {
isOk = false; isOk = false;
} }
}); });
if (isOk) { if (isOk) {
newPrice.push(price); newSkus.push(sku);
} }
} }
return newSkus;
return newPrice;
}
//
function onSelectLadder(ladder) {
emits('ladder', ladder);
} }
// //
function onSelectSku(pid, skuId) { function onSelectSku(propertyId, valueId) {
// //
if (activityType === 'groupon_ladder' && props.grouponNum == 0) {
sheep.$helper.toast('请选择拼团人数');
return;
}
let isChecked = true; // or let isChecked = true; // or
if (state.currentSkuArray[pid] != undefined && state.currentSkuArray[pid] == skuId) { if (state.currentPropertyArray[propertyId] !== undefined && state.currentPropertyArray[propertyId] === valueId) {
// '' // ''
isChecked = false; isChecked = false;
state.currentSkuArray.splice(pid, 1, ''); state.currentPropertyArray.splice(propertyId, 1, '');
} else { } else {
// //
state.currentSkuArray[pid] = skuId; state.currentPropertyArray[propertyId] = valueId;
} }
let chooseSkuId = []; // // property
state.currentSkuArray.forEach((sku) => { let choosePropertyId = [];
if (sku != '') { state.currentPropertyArray.forEach((currentPropertyId) => {
// sku if (currentPropertyId !== '') {
chooseSkuId.push(sku); // currentPropertyId
choosePropertyId.push(currentPropertyId);
} }
}); });
// skuPric // property SKU
let newPrice = getCanUseSkuPrice(); let newSkuList = getCanUseSkuList();
//
if (chooseSkuId.length == skuList.length && newPrice.length) { // property
newPrice[0].goods_num = state.selectedSkuPrice.goods_num || 1; if (choosePropertyId.length === propertyList.length && newSkuList.length) {
state.selectedSkuPrice = newPrice[0]; newSkuList[0].count = state.selectedSku.count || 1;
state.selectedSku = newSkuList[0];
} else { } else {
state.selectedSkuPrice = {}; state.selectedSku = {};
} }
// // property
changeDisabled(isChecked, pid, skuId); changeDisabled(isChecked, propertyId, valueId);
} }
changeDisabled(false); changeDisabled(false);
// TODO 12
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -281,7 +281,7 @@
// property // property
if (choosePropertyId.length === propertyList.length && newSkuList.length) { if (choosePropertyId.length === propertyList.length && newSkuList.length) {
newSkuList[0].goods_num = state.selectedSku.goods_num || 1; newSkuList[0].count = state.selectedSku.count || 1;
state.selectedSku = newSkuList[0]; state.selectedSku = newSkuList[0];
} else { } else {
state.selectedSku = {}; state.selectedSku = {};

View File

@ -74,12 +74,12 @@ const VIDEO_SUFFIX_LIST = ['.avi', '.mp4']
* @return {{src: string, type: 'video' | 'image' }[]} 转换后的链接列表 * @return {{src: string, type: 'video' | 'image' }[]} 转换后的链接列表
*/ */
export function formatGoodsSwiper(urlList) { export function formatGoodsSwiper(urlList) {
return urlList.filter(url => url).map((url, key) => { return urlList?.filter(url => url).map((url, key) => {
const isVideo = VIDEO_SUFFIX_LIST.some(suffix => url.includes(suffix)); const isVideo = VIDEO_SUFFIX_LIST.some(suffix => url.includes(suffix));
const type = isVideo ? 'video' : 'image' const type = isVideo ? 'video' : 'image'
const src = $url.cdn(url); const src = $url.cdn(url);
return { type, src } return { type, src }
}); }) || [];
} }
/** /**
@ -384,4 +384,4 @@ export function formatRewardActivityRule(activity, rule) {
return `${rule.limit} 件减 ${fen2yuan(rule.discountPrice)}`; return `${rule.limit} 件减 ${fen2yuan(rule.discountPrice)}`;
} }
return ''; return '';
} }

View File

@ -67,6 +67,7 @@ const buildSpmQuery = (params) => {
let shareId = '0'; // 设置分享者用户ID let shareId = '0'; // 设置分享者用户ID
if (typeof params.shareId === 'undefined') { if (typeof params.shareId === 'undefined') {
if (user.isLogin) { if (user.isLogin) {
// todo @芋艿 id为空
shareId = user.userInfo.id; shareId = user.userInfo.id;
} }
} }

View File

@ -9,8 +9,8 @@
class="cicon-move-round" class="cicon-move-round"
:class="{ :class="{
'uni-numbox--disabled': inputValue <= min || disabled, 'uni-numbox--disabled': inputValue <= min || disabled,
'groupon-btn': activity == 'groupon', 'groupon-btn': activity === 'groupon',
'seckill-btn': activity == 'seckill', 'seckill-btn': activity === 'seckill',
}" }"
@click="_calcValue('minus')" @click="_calcValue('minus')"
></text> ></text>
@ -31,8 +31,8 @@
class="cicon-add-round" class="cicon-add-round"
:class="{ :class="{
'uni-numbox--disabled': inputValue >= max || disabled, 'uni-numbox--disabled': inputValue >= max || disabled,
'groupon-btn': activity == 'groupon', 'groupon-btn': activity === 'groupon',
'seckill-btn': activity == 'seckill', 'seckill-btn': activity === 'seckill',
}" }"
@click="_calcValue('plus')" @click="_calcValue('plus')"
></text> ></text>

View File

@ -1,5 +1,7 @@
// ========== MALL - 营销模块 ========== // ========== MALL - 营销模块 ==========
import dayjs from "dayjs";
/** /**
* 优惠类型枚举 * 优惠类型枚举
*/ */
@ -45,3 +47,22 @@ export const PromotionProductScopeEnum = {
name: '品类劵' name: '品类劵'
} }
} }
// 时间段的状态枚举
export const TimeStatusEnum = {
WAIT_START: '即将开始',
STARTED: '进行中',
END: '已结束',
}
export const getTimeStatusEnum = (startTime, endTime) => {
const now = dayjs();
if (now.isBefore(startTime)) {
return TimeStatusEnum.WAIT_START;
} else if (now.isAfter(endTime)) {
return TimeStatusEnum.END;
} else {
return TimeStatusEnum.STARTED;
}
}