Skip to content

Commit c445173

Browse files
author
puhui999
committed
拼团记录:接口对接
1 parent eee3d0f commit c445173

File tree

2 files changed

+168
-23
lines changed

2 files changed

+168
-23
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import request from '@/config/axios'
2+
3+
export interface CombinationRecordVO {
4+
id: number // 拼团记录编号
5+
activityId: number // 拼团活动编号
6+
nickname: string // 用户昵称
7+
avatar: string // 用户头像
8+
headId: number // 团长编号
9+
expireTime: string // 过期时间
10+
userSize: number // 可参团人数
11+
userCount: number // 已参团人数
12+
status: number // 拼团状态
13+
spuName: string // 商品名字
14+
picUrl: string // 商品图片
15+
virtualGroup: boolean // 是否虚拟成团
16+
startTime: string // 开始时间 (订单付款后开始的时间)
17+
endTime: string // 结束时间(成团时间/失败时间)
18+
}
19+
20+
// 查询拼团记录列表
21+
export const getCombinationRecordPage = async (params) => {
22+
return await request.get({ url: '/promotion/combination-record/page', params })
23+
}
24+
25+
// 获得拼团记录的概要信息
26+
export const getCombinationRecordSummary = async () => {
27+
return await request.get({ url: '/promotion/combination-record/get-summary' })
28+
}
29+
30+
// 获得拼团记录分页 tab count
31+
export const getCombinationRecordCount = async () => {
32+
return await request.get({ url: '/promotion/combination-record/get-count' })
33+
}

src/views/mall/promotion/combination/record/index.vue

Lines changed: 135 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
</div>
1313
<div class="ml-[20px]">
1414
<div class="mb-8px text-14px text-gray-400">参与人数(个)</div>
15-
<CountTo :duration="2600" :end-val="2200" :start-val="0" class="text-20px" />
15+
<CountTo
16+
:duration="2600"
17+
:end-val="recordSummary.userCount"
18+
:start-val="0"
19+
class="text-20px"
20+
/>
1621
</div>
1722
</div>
1823
</ContentWrap>
@@ -28,7 +33,33 @@
2833
</div>
2934
<div class="ml-[20px]">
3035
<div class="mb-8px text-14px text-gray-400">成团数量(个)</div>
31-
<CountTo :duration="2600" :end-val="2200" :start-val="0" class="text-20px" />
36+
<CountTo
37+
:duration="2600"
38+
:end-val="recordSummary.successCount"
39+
:start-val="0"
40+
class="text-20px"
41+
/>
42+
</div>
43+
</div>
44+
</ContentWrap>
45+
</el-col>
46+
<el-col :span="6">
47+
<ContentWrap class="h-[110px]">
48+
<div class="flex items-center">
49+
<div
50+
class="h-[50px] w-[50px] flex items-center justify-center"
51+
style="color: rgb(162, 119, 255); background-color: rgba(162, 119, 255, 0.1)"
52+
>
53+
<Icon :size="23" icon="fa:user-plus" />
54+
</div>
55+
<div class="ml-[20px]">
56+
<div class="mb-8px text-14px text-gray-400">虚拟成团(个)</div>
57+
<CountTo
58+
:duration="2600"
59+
:end-val="recordSummary.virtualGroupCount"
60+
:start-val="0"
61+
class="text-20px"
62+
/>
3263
</div>
3364
</div>
3465
</ContentWrap>
@@ -38,19 +69,7 @@
3869
<ContentWrap>
3970
<!-- 检索条件 -->
4071
<div class="mb-[10px]">
41-
<span class="font-size-[14px]" style="font-weight: bold; color: #606266">时间选择:</span>
42-
<el-button-group class="ml-[10px]">
43-
<el-button>全部</el-button>
44-
<el-button>今天</el-button>
45-
<el-button>昨天</el-button>
46-
<el-button>最近七天</el-button>
47-
<el-button>最近30天</el-button>
48-
<el-button>本月</el-button>
49-
<el-button>本年</el-button>
50-
</el-button-group>
51-
</div>
52-
<div class="mb-[10px]">
53-
<span class="font-size-[14px]" style="font-weight: bold; color: #606266">时间区间选择:</span>
72+
<span class="font-size-[14px]" style="font-weight: bold; color: #606266">时间段:</span>
5473
<el-date-picker
5574
v-model="queryParams.createTime"
5675
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
@@ -60,9 +79,7 @@
6079
type="daterange"
6180
value-format="YYYY-MM-DD HH:mm:ss"
6281
/>
63-
</div>
64-
<div class="mb-[10px]">
65-
<span class="font-size-[14px]" style="font-weight: bold; color: #606266">拼团状态:</span>
82+
<span class="ml-[10px] font-size-[14px] font-bold" style="color: #606266">拼团状态:</span>
6683
<el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="全部">
6784
<el-option
6885
v-for="(dict, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
@@ -73,6 +90,14 @@
7390
</el-select>
7491
</div>
7592
<!-- 分页列表数据展示 -->
93+
<el-tabs v-model="queryParams.dateType" @tab-click="handleTabClick">
94+
<el-tab-pane
95+
v-for="item in tabsData"
96+
:key="item.type"
97+
:label="item.name + '(' + item.count + ')'"
98+
:name="item.value"
99+
/>
100+
</el-tabs>
76101
<el-table v-loading="loading" :data="pageList">
77102
<el-table-column align="center" label="编号" prop="id" />
78103
<!-- TODO 是否需要做一个点击用户头像跳转或查看用户信息的功能 -->
@@ -133,25 +158,112 @@
133158
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
134159
import { dateFormatter } from '@/utils/formatTime'
135160
import { createImageViewer } from '@/components/ImageViewer'
161+
import * as CombinationRecordApi from '@/api/mall/promotion/combination/combinationRecord'
162+
import { TabsPaneContext } from 'element-plus'
136163
137164
defineOptions({ name: 'CombinationRecord' })
138165
const queryParams = ref({
166+
dateType: 0, // 日期类型
139167
status: undefined, // 拼团状态
140168
createTime: undefined, // 创建时间
141169
pageSize: 10,
142170
pageNo: 1
143171
})
144-
const loading = ref(false) // 列表的加载中
172+
const loading = ref(true) // 列表的加载中
145173
const total = ref(0) // 总记录数
146174
const pageList = ref([]) // 分页数据
147-
/**
148-
* 获取分页数据
149-
*/
150-
const getList = async () => {}
175+
/** 查询列表 */
176+
const getList = async () => {
177+
loading.value = true
178+
try {
179+
const data = await CombinationRecordApi.getCombinationRecordPage(queryParams.value)
180+
pageList.value = data.list
181+
total.value = data.total
182+
} finally {
183+
loading.value = false
184+
}
185+
}
186+
// 拼团统计数据
187+
const recordSummary = ref({
188+
successCount: 0,
189+
userCount: 0,
190+
virtualGroupCount: 0
191+
})
192+
/** 获得拼团记录统计信息 */
193+
const getSummary = async () => {
194+
recordSummary.value = await CombinationRecordApi.getCombinationRecordSummary()
195+
}
196+
197+
// tabs 数据
198+
const tabsData = ref([
199+
{
200+
count: 0,
201+
name: '全部',
202+
type: 'all',
203+
value: 0
204+
},
205+
{
206+
count: 0,
207+
name: '今天',
208+
type: 'toDay',
209+
value: 1
210+
},
211+
{
212+
count: 0,
213+
name: '昨天',
214+
type: 'yesterday',
215+
value: 2
216+
},
217+
{
218+
count: 0,
219+
name: '最近七天',
220+
type: 'lastSevenDays',
221+
value: 3
222+
},
223+
{
224+
count: 0,
225+
name: '最近30天',
226+
type: 'last30Days',
227+
value: 4
228+
},
229+
{
230+
count: 0,
231+
name: '本月',
232+
type: 'thisMonth',
233+
value: 5
234+
},
235+
{
236+
count: 0,
237+
name: '今年',
238+
type: 'thisYear',
239+
value: 6
240+
}
241+
])
242+
243+
/** 获得每个 Tab 的数量 */
244+
const getTabsCount = async () => {
245+
const res = await CombinationRecordApi.getCombinationRecordCount()
246+
tabsData.value.forEach((tab) => {
247+
tab.count = res[tab.type]
248+
})
249+
}
250+
251+
const handleTabClick = async (tab: TabsPaneContext) => {
252+
queryParams.value.dateType = tab.paneName as number
253+
await getList()
254+
}
255+
151256
/** 商品图预览 */
152257
const imagePreview = (imgUrl: string) => {
153258
createImageViewer({
154259
urlList: [imgUrl]
155260
})
156261
}
262+
263+
/** 初始化 **/
264+
onMounted(async () => {
265+
await getSummary()
266+
await getTabsCount()
267+
await getList()
268+
})
157269
</script>

0 commit comments

Comments
 (0)