Переглянути джерело

拼团记录:接口对接

puhui999 1 рік тому
батько
коміт
c445173855

+ 33 - 0
src/api/mall/promotion/combination/combinationRecord.ts

@@ -0,0 +1,33 @@
+import request from '@/config/axios'
+
+export interface CombinationRecordVO {
+  id: number // 拼团记录编号
+  activityId: number // 拼团活动编号
+  nickname: string // 用户昵称
+  avatar: string // 用户头像
+  headId: number // 团长编号
+  expireTime: string // 过期时间
+  userSize: number // 可参团人数
+  userCount: number // 已参团人数
+  status: number // 拼团状态
+  spuName: string // 商品名字
+  picUrl: string // 商品图片
+  virtualGroup: boolean // 是否虚拟成团
+  startTime: string // 开始时间 (订单付款后开始的时间)
+  endTime: string // 结束时间(成团时间/失败时间)
+}
+
+// 查询拼团记录列表
+export const getCombinationRecordPage = async (params) => {
+  return await request.get({ url: '/promotion/combination-record/page', params })
+}
+
+// 获得拼团记录的概要信息
+export const getCombinationRecordSummary = async () => {
+  return await request.get({ url: '/promotion/combination-record/get-summary' })
+}
+
+// 获得拼团记录分页 tab count
+export const getCombinationRecordCount = async () => {
+  return await request.get({ url: '/promotion/combination-record/get-count' })
+}

+ 135 - 23
src/views/mall/promotion/combination/record/index.vue

@@ -12,7 +12,12 @@
           </div>
           <div class="ml-[20px]">
             <div class="mb-8px text-14px text-gray-400">参与人数(个)</div>
-            <CountTo :duration="2600" :end-val="2200" :start-val="0" class="text-20px" />
+            <CountTo
+              :duration="2600"
+              :end-val="recordSummary.userCount"
+              :start-val="0"
+              class="text-20px"
+            />
           </div>
         </div>
       </ContentWrap>
@@ -28,7 +33,33 @@
           </div>
           <div class="ml-[20px]">
             <div class="mb-8px text-14px text-gray-400">成团数量(个)</div>
-            <CountTo :duration="2600" :end-val="2200" :start-val="0" class="text-20px" />
+            <CountTo
+              :duration="2600"
+              :end-val="recordSummary.successCount"
+              :start-val="0"
+              class="text-20px"
+            />
+          </div>
+        </div>
+      </ContentWrap>
+    </el-col>
+    <el-col :span="6">
+      <ContentWrap class="h-[110px]">
+        <div class="flex items-center">
+          <div
+            class="h-[50px] w-[50px] flex items-center justify-center"
+            style="color: rgb(162, 119, 255); background-color: rgba(162, 119, 255, 0.1)"
+          >
+            <Icon :size="23" icon="fa:user-plus" />
+          </div>
+          <div class="ml-[20px]">
+            <div class="mb-8px text-14px text-gray-400">虚拟成团(个)</div>
+            <CountTo
+              :duration="2600"
+              :end-val="recordSummary.virtualGroupCount"
+              :start-val="0"
+              class="text-20px"
+            />
           </div>
         </div>
       </ContentWrap>
@@ -38,19 +69,7 @@
   <ContentWrap>
     <!-- 检索条件 -->
     <div class="mb-[10px]">
-      <span class="font-size-[14px]" style="font-weight: bold; color: #606266">时间选择:</span>
-      <el-button-group class="ml-[10px]">
-        <el-button>全部</el-button>
-        <el-button>今天</el-button>
-        <el-button>昨天</el-button>
-        <el-button>最近七天</el-button>
-        <el-button>最近30天</el-button>
-        <el-button>本月</el-button>
-        <el-button>本年</el-button>
-      </el-button-group>
-    </div>
-    <div class="mb-[10px]">
-      <span class="font-size-[14px]" style="font-weight: bold; color: #606266">时间区间选择:</span>
+      <span class="font-size-[14px]" style="font-weight: bold; color: #606266">时间段:</span>
       <el-date-picker
         v-model="queryParams.createTime"
         :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
@@ -60,9 +79,7 @@
         type="daterange"
         value-format="YYYY-MM-DD HH:mm:ss"
       />
-    </div>
-    <div class="mb-[10px]">
-      <span class="font-size-[14px]" style="font-weight: bold; color: #606266">拼团状态:</span>
+      <span class="ml-[10px] font-size-[14px] font-bold" style="color: #606266">拼团状态:</span>
       <el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="全部">
         <el-option
           v-for="(dict, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
@@ -73,6 +90,14 @@
       </el-select>
     </div>
     <!--   分页列表数据展示   -->
+    <el-tabs v-model="queryParams.dateType" @tab-click="handleTabClick">
+      <el-tab-pane
+        v-for="item in tabsData"
+        :key="item.type"
+        :label="item.name + '(' + item.count + ')'"
+        :name="item.value"
+      />
+    </el-tabs>
     <el-table v-loading="loading" :data="pageList">
       <el-table-column align="center" label="编号" prop="id" />
       <!-- TODO 是否需要做一个点击用户头像跳转或查看用户信息的功能  -->
@@ -133,25 +158,112 @@
 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
 import { dateFormatter } from '@/utils/formatTime'
 import { createImageViewer } from '@/components/ImageViewer'
+import * as CombinationRecordApi from '@/api/mall/promotion/combination/combinationRecord'
+import { TabsPaneContext } from 'element-plus'
 
 defineOptions({ name: 'CombinationRecord' })
 const queryParams = ref({
+  dateType: 0, // 日期类型
   status: undefined, // 拼团状态
   createTime: undefined, // 创建时间
   pageSize: 10,
   pageNo: 1
 })
-const loading = ref(false) // 列表的加载中
+const loading = ref(true) // 列表的加载中
 const total = ref(0) // 总记录数
 const pageList = ref([]) // 分页数据
-/**
- * 获取分页数据
- */
-const getList = async () => {}
+/** 查询列表 */
+const getList = async () => {
+  loading.value = true
+  try {
+    const data = await CombinationRecordApi.getCombinationRecordPage(queryParams.value)
+    pageList.value = data.list
+    total.value = data.total
+  } finally {
+    loading.value = false
+  }
+}
+// 拼团统计数据
+const recordSummary = ref({
+  successCount: 0,
+  userCount: 0,
+  virtualGroupCount: 0
+})
+/** 获得拼团记录统计信息 */
+const getSummary = async () => {
+  recordSummary.value = await CombinationRecordApi.getCombinationRecordSummary()
+}
+
+// tabs 数据
+const tabsData = ref([
+  {
+    count: 0,
+    name: '全部',
+    type: 'all',
+    value: 0
+  },
+  {
+    count: 0,
+    name: '今天',
+    type: 'toDay',
+    value: 1
+  },
+  {
+    count: 0,
+    name: '昨天',
+    type: 'yesterday',
+    value: 2
+  },
+  {
+    count: 0,
+    name: '最近七天',
+    type: 'lastSevenDays',
+    value: 3
+  },
+  {
+    count: 0,
+    name: '最近30天',
+    type: 'last30Days',
+    value: 4
+  },
+  {
+    count: 0,
+    name: '本月',
+    type: 'thisMonth',
+    value: 5
+  },
+  {
+    count: 0,
+    name: '今年',
+    type: 'thisYear',
+    value: 6
+  }
+])
+
+/** 获得每个 Tab 的数量 */
+const getTabsCount = async () => {
+  const res = await CombinationRecordApi.getCombinationRecordCount()
+  tabsData.value.forEach((tab) => {
+    tab.count = res[tab.type]
+  })
+}
+
+const handleTabClick = async (tab: TabsPaneContext) => {
+  queryParams.value.dateType = tab.paneName as number
+  await getList()
+}
+
 /** 商品图预览 */
 const imagePreview = (imgUrl: string) => {
   createImageViewer({
     urlList: [imgUrl]
   })
 }
+
+/** 初始化 **/
+onMounted(async () => {
+  await getSummary()
+  await getTabsCount()
+  await getList()
+})
 </script>