Skip to content

Commit b41d8f0

Browse files
YunaiVgitee-org
authored andcommitted
!184 同步最新商城实现
Merge pull request !184 from 芋道源码/dev
2 parents f908c12 + a003b59 commit b41d8f0

File tree

19 files changed

+828
-171
lines changed

19 files changed

+828
-171
lines changed

src/api/mall/product/spu.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ export const getSpu = (id: number) => {
8686
return request.get({ url: `/product/spu/get-detail?id=${id}` })
8787
}
8888

89+
// 获得商品 Spu 详情列表
90+
export const getSpuDetailList = (ids: number[]) => {
91+
return request.get({ url: `/product/spu/list?spuIds=${ids}` })
92+
}
93+
8994
// 删除商品 Spu
9095
export const deleteSpu = (id: number) => {
9196
return request.delete({ url: `/product/spu/delete?id=${id}` })
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import request from '@/config/axios'
2+
import { Sku, Spu } from '@/api/mall/product/spu'
3+
4+
// TODO @puhui999: combinationActivity.ts
5+
6+
export interface CombinationActivityVO {
7+
id?: number
8+
name?: string
9+
spuId?: number
10+
totalLimitCount?: number
11+
singleLimitCount?: number
12+
startTime?: Date
13+
endTime?: Date
14+
userSize?: number
15+
totalNum?: number
16+
successNum?: number
17+
orderUserCount?: number
18+
virtualGroup?: number
19+
status?: number
20+
limitDuration?: number
21+
products: CombinationProductVO[]
22+
}
23+
24+
// 拼团活动所需属性
25+
export interface CombinationProductVO {
26+
spuId: number
27+
skuId: number
28+
activePrice: number // 拼团价格
29+
}
30+
31+
// 扩展 Sku 配置
32+
export type SkuExtension = Sku & {
33+
productConfig: CombinationProductVO
34+
}
35+
36+
export interface SpuExtension extends Spu {
37+
skus: SkuExtension[] // 重写类型
38+
}
39+
40+
// 查询拼团活动列表
41+
export const getCombinationActivityPage = async (params) => {
42+
return await request.get({ url: '/promotion/combination-activity/page', params })
43+
}
44+
45+
// 查询拼团活动详情
46+
export const getCombinationActivity = async (id: number) => {
47+
return await request.get({ url: '/promotion/combination-activity/get?id=' + id })
48+
}
49+
50+
// 新增拼团活动
51+
export const createCombinationActivity = async (data: CombinationActivityVO) => {
52+
return await request.post({ url: '/promotion/combination-activity/create', data })
53+
}
54+
55+
// 修改拼团活动
56+
export const updateCombinationActivity = async (data: CombinationActivityVO) => {
57+
return await request.put({ url: '/promotion/combination-activity/update', data })
58+
}
59+
60+
// 删除拼团活动
61+
export const deleteCombinationActivity = async (id: number) => {
62+
return await request.delete({ url: '/promotion/combination-activity/delete?id=' + id })
63+
}

src/api/mall/promotion/seckill/seckillActivity.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,34 @@ import request from '@/config/axios'
22
import { Sku, Spu } from '@/api/mall/product/spu'
33

44
export interface SeckillActivityVO {
5-
id: number
6-
spuIds: number[]
7-
name: string
8-
status: number
9-
remark: string
10-
startTime: Date
11-
endTime: Date
12-
sort: number
13-
configIds: string
14-
orderCount: number
15-
userCount: number
16-
totalPrice: number
17-
totalLimitCount: number
18-
singleLimitCount: number
19-
stock: number
20-
totalStock: number
21-
products: SeckillProductVO[]
5+
id?: number
6+
spuId?: number
7+
name?: string
8+
status?: number
9+
remark?: string
10+
startTime?: Date
11+
endTime?: Date
12+
sort?: number
13+
configIds?: string
14+
orderCount?: number
15+
userCount?: number
16+
totalPrice?: number
17+
totalLimitCount?: number
18+
singleLimitCount?: number
19+
stock?: number
20+
totalStock?: number
21+
products?: SeckillProductVO[]
2222
}
2323

2424
// 秒杀活动所需属性
2525
export interface SeckillProductVO {
26-
spuId: number
2726
skuId: number
2827
seckillPrice: number
2928
stock: number
3029
}
3130

3231
// 扩展 Sku 配置
33-
type SkuExtension = Sku & {
32+
export type SkuExtension = Sku & {
3433
productConfig: SeckillProductVO
3534
}
3635

src/api/mall/promotion/seckill/seckillConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface SeckillConfigVO {
55
name: string
66
startTime: string
77
endTime: string
8-
picUrl: string
8+
sliderPicUrls: string[]
99
status: number
1010
}
1111

src/utils/formatTime.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ export function formatDate(date: Date, format?: string): string {
2323
return dayjs(date).format(format)
2424
}
2525

26+
/**
27+
* 获取当前的日期+时间
28+
*/
29+
export function getNowDateTime() {
30+
return dayjs()
31+
}
32+
2633
/**
2734
* 获取当前日期是第几周
2835
* @param dateTime 当前传入的日期值

src/views/mall/product/spu/components/SkuList.vue

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- 情况一:添加/修改 -->
33
<el-table
44
v-if="!isDetail && !isActivityComponent"
5-
:data="isBatch ? skuList : formData!.skus"
5+
:data="isBatch ? skuList : formData!.skus!"
66
border
77
class="tabNumWidth"
88
max-height="500"
@@ -113,7 +113,8 @@
113113
<!-- 情况二:详情 -->
114114
<el-table
115115
v-if="isDetail"
116-
:data="formData!.skus"
116+
ref="activitySkuListRef"
117+
:data="formData!.skus!"
117118
border
118119
max-height="500"
119120
size="small"
@@ -194,7 +195,7 @@
194195
<!-- 情况三:作为活动组件 -->
195196
<el-table
196197
v-if="isActivityComponent"
197-
:data="formData!.skus"
198+
:data="formData!.skus!"
198199
border
199200
max-height="500"
200201
size="small"
@@ -259,7 +260,8 @@ import { UploadImg } from '@/components/UploadFile'
259260
import type { Property, Sku, Spu } from '@/api/mall/product/spu'
260261
import { createImageViewer } from '@/components/ImageViewer'
261262
import { RuleConfig } from '@/views/mall/product/spu/components/index'
262-
import { Properties } from './index'
263+
import { PropertyAndValues } from './index'
264+
import { ElTable } from 'element-plus'
263265
264266
defineOptions({ name: 'SkuList' })
265267
const message = useMessage() // 消息弹窗
@@ -270,7 +272,7 @@ const props = defineProps({
270272
default: () => {}
271273
},
272274
propertyList: {
273-
type: Array as PropType<Properties[]>,
275+
type: Array as PropType<PropertyAndValues[]>,
274276
default: () => []
275277
},
276278
ruleConfig: {
@@ -480,7 +482,7 @@ const build = (propertyValuesList: Property[][]) => {
480482
/** 监听属性列表,生成相关参数和表头 */
481483
watch(
482484
() => props.propertyList,
483-
(propertyList: Properties[]) => {
485+
(propertyList: PropertyAndValues[]) => {
484486
// 如果不是多规格则结束
485487
if (!formData.value!.specType) {
486488
return
@@ -514,7 +516,6 @@ watch(
514516
// name加属性项index区分属性值
515517
tableHeaders.value.push({ prop: `name${index}`, label: item.name })
516518
})
517-
518519
// 如果回显的 sku 属性和添加的属性一致则不处理
519520
if (validateData(propertyList)) {
520521
return
@@ -531,6 +532,10 @@ watch(
531532
immediate: true
532533
}
533534
)
535+
const activitySkuListRef = ref<InstanceType<typeof ElTable>>()
536+
const clearSelection = () => {
537+
activitySkuListRef.value.clearSelection()
538+
}
534539
// 暴露出生成 sku 方法,给添加属性成功时调用
535-
defineExpose({ generateTableData, validateSku })
540+
defineExpose({ generateTableData, validateSku, clearSelection })
536541
</script>

src/views/mall/product/spu/components/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import SkuList from './SkuList.vue'
77

88
import { Spu } from '@/api/mall/product/spu'
99

10-
// TODO @puhui999:Properties 改成 Property 更合适?
11-
interface Properties {
10+
// TODO @puhui999:Properties 改成 Property 更合适?Property 在 Spu 中已存在避免冲突 PropertyAndValues
11+
interface PropertyAndValues {
1212
id: number
1313
name: string
14-
values?: Properties[]
14+
values?: PropertyAndValues[]
1515
}
1616

1717
interface RuleConfig {
@@ -23,7 +23,7 @@ interface RuleConfig {
2323
// 例:需要校验价格必须大于0.01
2424
// {
2525
// name:'price',
26-
// rule:(arg) => arg > 0.01
26+
// rule:(arg: number) => arg > 0.01
2727
// }
2828
rule: (arg: any) => boolean
2929
// 校验不通过时的消息提示
@@ -34,11 +34,11 @@ interface RuleConfig {
3434
* 获得商品的规格列表
3535
*
3636
* @param spu
37-
* @return Property 规格列表
37+
* @return PropertyAndValues 规格列表
3838
*/
39-
const getPropertyList = (spu: Spu): Properties[] => {
39+
const getPropertyList = (spu: Spu): PropertyAndValues[] => {
4040
// 直接拿返回的 skus 属性逆向生成出 propertyList
41-
const properties: Properties[] = []
41+
const properties: PropertyAndValues[] = []
4242
// 只有是多规格才处理
4343
if (spu.specType) {
4444
spu.skus?.forEach((sku) => {
@@ -66,6 +66,6 @@ export {
6666
ProductPropertyAddForm,
6767
SkuList,
6868
getPropertyList,
69-
Properties,
69+
PropertyAndValues,
7070
RuleConfig
7171
}

0 commit comments

Comments
 (0)