满减送数据对接
This commit is contained in:
parent
9591ed7084
commit
21e8dbf985
5
.env.dev
5
.env.dev
@ -4,7 +4,8 @@ NODE_ENV=development
|
|||||||
VITE_DEV=true
|
VITE_DEV=true
|
||||||
|
|
||||||
# 请求路径
|
# 请求路径
|
||||||
VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn'
|
# VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn'
|
||||||
|
VITE_BASE_URL='http://dofast.demo.huizhizao.vip:20001'
|
||||||
|
|
||||||
# 上传路径
|
# 上传路径
|
||||||
VITE_UPLOAD_URL='http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload'
|
VITE_UPLOAD_URL='http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload'
|
||||||
@ -34,4 +35,4 @@ VITE_OUT_DIR=dist
|
|||||||
VITE_MALL_H5_DOMAIN='http://mall.yudao.iocoder.cn'
|
VITE_MALL_H5_DOMAIN='http://mall.yudao.iocoder.cn'
|
||||||
|
|
||||||
# 验证码的开关
|
# 验证码的开关
|
||||||
VITE_APP_CAPTCHA_ENABLE=false
|
VITE_APP_CAPTCHA_ENABLE=true
|
||||||
|
44
src/api/mall/promotion/reward/rewardActivity.ts
Normal file
44
src/api/mall/promotion/reward/rewardActivity.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
export interface DiscountActivityVO {
|
||||||
|
id?:number,
|
||||||
|
name?: string
|
||||||
|
startTime?:Date
|
||||||
|
endTime?:Date
|
||||||
|
remark?:string
|
||||||
|
conditionType?:number
|
||||||
|
productScope?:number
|
||||||
|
productSpuIds?:number[]
|
||||||
|
rules?:DiscountProductVO[]
|
||||||
|
}
|
||||||
|
//优惠规则
|
||||||
|
export interface DiscountProductVO {
|
||||||
|
limit: number
|
||||||
|
discountPrice: number
|
||||||
|
freeDelivery: boolean
|
||||||
|
point: number
|
||||||
|
couponIds: number[]
|
||||||
|
couponCounts: number[]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 新增满减送活动
|
||||||
|
export const createRewardActivity = async (data: DiscountActivityVO) => {
|
||||||
|
return await request.post({ url: '/promotion/reward-activity/create', data })
|
||||||
|
}
|
||||||
|
// 更新满减送活动
|
||||||
|
export const updateRewardActivity = async (data: DiscountActivityVO) => {
|
||||||
|
return await request.put({ url: '/promotion/reward-activity/update', data })
|
||||||
|
}
|
||||||
|
// 查询满减送活动列表
|
||||||
|
export const getRewardActivityPage = async (params) => {
|
||||||
|
return await request.get({ url: '/promotion/reward-activity/page', params })
|
||||||
|
}
|
||||||
|
// 查询满减送活动详情
|
||||||
|
export const getReward = async (id:number) => {
|
||||||
|
return await request.get({ url: '/promotion/reward-activity/get?id='+id, })
|
||||||
|
}
|
||||||
|
// 删除限时折扣活动
|
||||||
|
export const deleteRewardActivity = async (id: number) => {
|
||||||
|
return await request.delete({ url: '/promotion/reward-activity/delete?id=' + id })
|
||||||
|
}
|
@ -244,15 +244,15 @@ export const CouponTemplateTakeTypeEnum = {
|
|||||||
*/
|
*/
|
||||||
export const PromotionProductScopeEnum = {
|
export const PromotionProductScopeEnum = {
|
||||||
ALL: {
|
ALL: {
|
||||||
scope: 1,
|
scope: 10,
|
||||||
name: '通用劵'
|
name: '通用劵'
|
||||||
},
|
},
|
||||||
SPU: {
|
SPU: {
|
||||||
scope: 2,
|
scope: 20,
|
||||||
name: '商品劵'
|
name: '商品劵'
|
||||||
},
|
},
|
||||||
CATEGORY: {
|
CATEGORY: {
|
||||||
scope: 3,
|
scope: 30,
|
||||||
name: '品类劵'
|
name: '品类劵'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,36 @@
|
|||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="优惠设置">
|
<el-form-item label="优惠设置">
|
||||||
<!-- TODO 待实现!这个实现下哈 -->
|
<template v-for="(item,index) in formData.rules" :key="index">
|
||||||
|
<el-row type="flex">
|
||||||
|
<el-col :span="24" style="font-weight: bold;display: flex;">活动层级{{ index+1 }}<el-button link type="danger" style="margin-left: auto;" v-if="index!=0" @click="deleteStratum(index)">删除</el-button></el-col>
|
||||||
|
<e-form :ref="'formRef'+index" :model="item" >
|
||||||
|
<el-form-item label="优惠门槛:" prop="limit" label-width="100px" style="padding-left: 50px;">满<el-input style="width: 150px;padding:0 10px;" v-model="item.limit" type='number' placeholder="" /> 元
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="优惠内容:" label-width="100px" style="padding-left: 50px;">
|
||||||
|
<el-checkbox-group v-model="rules[index]" style="width:100%">
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-checkbox label="订单金额优惠" name="type" />
|
||||||
|
<el-form-item v-if="rules[index].includes('订单金额优惠')">
|
||||||
|
减<el-input style="width: 150px;padding:0 20px;" v-model="item.discountPrice" type='number' placeholder="" />元
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24"><el-checkbox v-model="item.freeDelivery" label="包邮" name="type" /></el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-checkbox label="送积分" name="type" />
|
||||||
|
<el-form-item v-if="rules[index].includes('送积分')">
|
||||||
|
送<el-input style="width: 150px;padding:0 20px;" v-model="item.point" type='number' placeholder="" />积分
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<!-- 优惠券待处理 也可以参考优惠劵的SpuShowcase-->
|
||||||
|
<!-- TODO 待实现!-->
|
||||||
|
<el-col :span="24"><el-checkbox label="送优惠券" name="type" /></el-col>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
</e-form>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
<el-button type="primary" @click="addStratum">添加活动层级</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="活动商品" prop="productScope">
|
<el-form-item label="活动商品" prop="productScope">
|
||||||
<el-radio-group v-model="formData.productScope">
|
<el-radio-group v-model="formData.productScope">
|
||||||
@ -78,7 +107,7 @@
|
|||||||
import { getSpuSimpleList } from '@/api/mall/product/spu'
|
import { getSpuSimpleList } from '@/api/mall/product/spu'
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import * as ProductBrandApi from '@/api/mall/product/brand'
|
import * as RewardActivityApi from '@/api/mall/promotion/reward/rewardActivity'
|
||||||
import {
|
import {
|
||||||
PromotionConditionTypeEnum,
|
PromotionConditionTypeEnum,
|
||||||
PromotionProductScopeEnum,
|
PromotionProductScopeEnum,
|
||||||
@ -112,8 +141,19 @@ const formData = ref({
|
|||||||
remark: undefined,
|
remark: undefined,
|
||||||
productScope: PromotionProductScopeEnum.ALL.scope,
|
productScope: PromotionProductScopeEnum.ALL.scope,
|
||||||
productSpuIds: undefined,
|
productSpuIds: undefined,
|
||||||
rules: undefined
|
rules: [{
|
||||||
|
limit: undefined,
|
||||||
|
discountPrice: undefined,
|
||||||
|
freeDelivery: undefined,
|
||||||
|
point: undefined,
|
||||||
|
couponIds: [],
|
||||||
|
couponCounts: []
|
||||||
|
}],
|
||||||
})
|
})
|
||||||
|
// 优惠设置
|
||||||
|
let rules=reactive([]);
|
||||||
|
// 优惠券列表
|
||||||
|
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
name: [{ required: true, message: '活动名称不能为空', trigger: 'blur' }],
|
name: [{ required: true, message: '活动名称不能为空', trigger: 'blur' }],
|
||||||
startAndEndTime: [{ required: true, message: '活动时间不能为空', trigger: 'blur' }],
|
startAndEndTime: [{ required: true, message: '活动时间不能为空', trigger: 'blur' }],
|
||||||
@ -121,7 +161,7 @@ const formRules = reactive({
|
|||||||
productScope: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }],
|
productScope: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }],
|
||||||
productSpuIds: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }]
|
productSpuIds: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref([]) // 表单 Ref
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
@ -133,19 +173,23 @@ const open = async (type: string, id?: number) => {
|
|||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
// formData.value = await ProductBrandApi.getBrand(id)
|
let data= await RewardActivityApi.getReward(id);
|
||||||
formData.value = {
|
data.startAndEndTime=[new Date(data.startTime), new Date(data.endTime)];
|
||||||
conditionType: 10,
|
rules.splice(0,rules.length);
|
||||||
description: '',
|
data.rules.forEach((item)=>{
|
||||||
id: undefined,
|
let ars:string[]=reactive([]);
|
||||||
name: '测试活动',
|
if(item.freeDelivery){
|
||||||
picUrl: '',
|
ars.push('包邮')
|
||||||
productScope: 2,
|
|
||||||
productSpuIds: [634],
|
|
||||||
remark: '测试备注',
|
|
||||||
startAndEndTime: [new Date(), new Date('2023-12-31')],
|
|
||||||
status: 0
|
|
||||||
}
|
}
|
||||||
|
if(item.point){
|
||||||
|
ars.push('送积分')
|
||||||
|
}
|
||||||
|
if(item.discountPrice){
|
||||||
|
ars.push('订单金额优惠')
|
||||||
|
}
|
||||||
|
rules.push(ars)
|
||||||
|
})
|
||||||
|
formData.value=data
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
@ -160,18 +204,33 @@ const submitForm = async () => {
|
|||||||
if (!formRef) return
|
if (!formRef) return
|
||||||
const valid = await formRef.value.validate()
|
const valid = await formRef.value.validate()
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
console.log(formData.value)
|
// 处理下数据兼容接口
|
||||||
message.success('已在控制台打印数据')
|
formData.value.startTime= +new Date(formData.value.startAndEndTime[0])
|
||||||
return
|
formData.value.endTime=+new Date(formData.value.startAndEndTime[1])
|
||||||
|
console.log(rules)
|
||||||
|
rules.forEach((item,index)=>{
|
||||||
|
if(item.includes('包邮')){
|
||||||
|
formData.value.rules[index].freeDelivery=true;
|
||||||
|
}else{
|
||||||
|
formData.value.rules[index].freeDelivery=false;
|
||||||
|
}
|
||||||
|
if(!item.includes('送积分')){
|
||||||
|
formData.value.rules[index].point=undefined;
|
||||||
|
}
|
||||||
|
if(!item.includes('订单金额优惠')){
|
||||||
|
formData.value.rules[index].discountPrice=undefined;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// 提交请求
|
// 提交请求
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = formData.value as ProductBrandApi.BrandVO
|
const data = formData.value as RewardActivityApi.DiscountActivityVO
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
await ProductBrandApi.createBrand(data)
|
await RewardActivityApi.createRewardActivity(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else {
|
} else {
|
||||||
await ProductBrandApi.updateBrand(data)
|
await RewardActivityApi.updateRewardActivity(data)
|
||||||
message.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
@ -182,15 +241,50 @@ const submitForm = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const addStratum =()=>{
|
||||||
|
formData.value.rules.push({
|
||||||
|
limit: undefined,
|
||||||
|
discountPrice: undefined,
|
||||||
|
freeDelivery: undefined,
|
||||||
|
point: undefined,
|
||||||
|
couponIds: [],
|
||||||
|
couponCounts: []
|
||||||
|
})
|
||||||
|
rules.push([]);
|
||||||
|
console.log(rules)
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteStratum=(index)=>{
|
||||||
|
formData.value.rules.splice(index,1)
|
||||||
|
rules.splice(index,1)
|
||||||
|
}
|
||||||
|
|
||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
name: '',
|
name: undefined,
|
||||||
picUrl: '',
|
startAndEndTime: undefined,
|
||||||
status: CommonStatusEnum.ENABLE,
|
startTime: undefined,
|
||||||
description: ''
|
endTime: undefined,
|
||||||
|
conditionType: PromotionConditionTypeEnum.PRICE.type,
|
||||||
|
remark: undefined,
|
||||||
|
productScope: PromotionProductScopeEnum.ALL.scope,
|
||||||
|
productSpuIds: undefined,
|
||||||
|
rules: [{
|
||||||
|
limit: undefined,
|
||||||
|
discountPrice: undefined,
|
||||||
|
freeDelivery: undefined,
|
||||||
|
point: undefined,
|
||||||
|
couponIds: [],
|
||||||
|
couponCounts: []
|
||||||
|
}],
|
||||||
}
|
}
|
||||||
|
rules.splice(0,rules.length);
|
||||||
|
rules.push(reactive([]));
|
||||||
|
// 解决下有时刷新页面第一次点编辑报错
|
||||||
|
nextTick(()=>{
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -65,13 +65,13 @@
|
|||||||
<el-table-column
|
<el-table-column
|
||||||
label="活动开始时间"
|
label="活动开始时间"
|
||||||
align="center"
|
align="center"
|
||||||
prop="sort[0]"
|
prop="startTime"
|
||||||
:formatter="dateFormatter"
|
:formatter="dateFormatter"
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="活动结束时间"
|
label="活动结束时间"
|
||||||
align="center"
|
align="center"
|
||||||
prop="sort[1]"
|
prop="endTime"
|
||||||
:formatter="dateFormatter"
|
:formatter="dateFormatter"
|
||||||
/>
|
/>
|
||||||
<el-table-column label="状态" align="center" prop="status">
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
@ -123,6 +123,7 @@
|
|||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import * as ProductBrandApi from '@/api/mall/product/brand'
|
import * as ProductBrandApi from '@/api/mall/product/brand'
|
||||||
|
import * as RewardActivityApi from '@/api/mall/promotion/reward/rewardActivity'
|
||||||
import RewardForm from './RewardForm.vue'
|
import RewardForm from './RewardForm.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'PromotionRewardActivity' })
|
defineOptions({ name: 'PromotionRewardActivity' })
|
||||||
@ -146,22 +147,7 @@ const queryFormRef = ref() // 搜索的表单
|
|||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
// const data = await ProductBrandApi.getBrandParam(queryParams)
|
const data = await RewardActivityApi.getRewardActivityPage(queryParams)
|
||||||
const data = {
|
|
||||||
list: [
|
|
||||||
{
|
|
||||||
createTime: 1693463998000,
|
|
||||||
description: '',
|
|
||||||
id: 3,
|
|
||||||
name: '索尼',
|
|
||||||
picUrl:
|
|
||||||
'http://127.0.0.1:48080/admin-api/infra/file/4/get/f5b7a536306cd1180a42a2211a8212dc23de6b949d30c30d036caa063042f928.png',
|
|
||||||
sort: [+new Date(), +new Date('2023-12-31')],
|
|
||||||
status: 10
|
|
||||||
}
|
|
||||||
],
|
|
||||||
total: 1
|
|
||||||
}
|
|
||||||
list.value = data.list
|
list.value = data.list
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
} finally {
|
} finally {
|
||||||
@ -171,16 +157,16 @@ const getList = async () => {
|
|||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = () => {
|
const handleQuery = () => {
|
||||||
console.log(queryParams)
|
// console.log(queryParams)
|
||||||
message.success('已打印搜索参数')
|
// message.success('已打印搜索参数')
|
||||||
return
|
// return
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
const resetQuery = () => {
|
const resetQuery = () => {
|
||||||
message.success('重置查询表单获取数据')
|
// message.success('重置查询表单获取数据')
|
||||||
return
|
// return
|
||||||
queryFormRef.value.resetFields()
|
queryFormRef.value.resetFields()
|
||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
@ -196,10 +182,10 @@ const handleDelete = async (id: number) => {
|
|||||||
try {
|
try {
|
||||||
// 删除的二次确认
|
// 删除的二次确认
|
||||||
await message.delConfirm()
|
await message.delConfirm()
|
||||||
message.success('您以确认删除')
|
// message.success('您以确认删除')
|
||||||
return
|
// return
|
||||||
// 发起删除
|
// 发起删除
|
||||||
await ProductBrandApi.deleteBrand(id)
|
await RewardActivityApi.deleteRewardActivity(id)
|
||||||
message.success(t('common.delSuccess'))
|
message.success(t('common.delSuccess'))
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await getList()
|
await getList()
|
||||||
|
Loading…
Reference in New Issue
Block a user