feat: 增加优惠券领取详情和优化pc端跳转使用优惠券页面

This commit is contained in:
paulGao
2023-01-11 11:28:28 +08:00
parent c8649caf1a
commit db33b34f18
13 changed files with 1004 additions and 211 deletions

View File

@@ -4,47 +4,47 @@ import { getRequest, postRequest, postRequestWithNoForm, putRequest, deleteReque
// 获取店铺直播间列表
export const getLiveList = (params) => {
return getRequest('/broadcast/studio', params)
return getRequest('/broadcast/studio', params)
}
// 添加直播间
export const addLive = (params) => {
return postRequest('/broadcast/studio', params)
return postRequest('/broadcast/studio', params)
}
// 获取直播间详情
export const getLiveInfo = (studioId) => {
return getRequest(`/broadcast/studio/studioInfo/${studioId}`)
return getRequest(`/broadcast/studio/studioInfo/${studioId}`)
}
// 修改直播间
export const editLive = (params) => {
return putRequest('/broadcast/studio/edit', params)
return putRequest('/broadcast/studio/edit', params)
}
// 获取店铺直播商品
export const getLiveGoods = (params) => {
return getRequest('/broadcast/commodity', params)
return getRequest('/broadcast/commodity', params)
}
// 店铺直播间删除商品
export const delLiveGoods = (goodsId) => {
return deleteRequest(`/broadcast/commodity/${goodsId}`)
return deleteRequest(`/broadcast/commodity/${goodsId}`)
}
// 直播间删除商品
export const delRoomLiveGoods = (roomId,liveGoodsId) => {
return deleteRequest(`/broadcast/studio/deleteInRoom/${roomId}/${liveGoodsId}`)
export const delRoomLiveGoods = (roomId, liveGoodsId) => {
return deleteRequest(`/broadcast/studio/deleteInRoom/${roomId}/${liveGoodsId}`)
}
// 添加店铺直播商品
export const addLiveStoreGoods = (params) => {
return postRequestWithNoForm('/broadcast/commodity', params)
return postRequestWithNoForm('/broadcast/commodity', params)
}
// 店铺直播间添加
export const addLiveGoods = (params) => {
return putRequest(`/broadcast/studio/push/${params.roomId}/${params.liveGoodsId}`, {goodsId: params.goodsId})
return putRequest(`/broadcast/studio/push/${params.roomId}/${params.liveGoodsId}`, { goodsId: params.goodsId })
}
// 获取拼团列表
@@ -53,11 +53,11 @@ export const getPintuanList = (params) => {
}
// 新建 拼团
export const savePintuan = (params) => {
return postRequest('/promotion/pintuan', params,{'Content-type': 'application/json'})
return postRequest('/promotion/pintuan', params, { 'Content-type': 'application/json' })
}
// 编辑 拼团
export const editPintuan = (params) => {
return putRequest('/promotion/pintuan', params,{'Content-type': 'application/json'})
return putRequest('/promotion/pintuan', params, { 'Content-type': 'application/json' })
}
// 手动开启拼团活动
export const editPintuanStatus = (pintuanId, params) => {
@@ -76,17 +76,17 @@ export const getPintuanDetail = (id) => {
// 获取拼团商品列表
export const getPintuanGoodsList = (params) => {
return getRequest(`/promotion/pintuan/goods/${params.pintuanId}`,params)
return getRequest(`/promotion/pintuan/goods/${params.pintuanId}`, params)
}
// 新增优惠券
export const saveShopCoupon = (params) => {
return postRequest('/promotion/coupon', params,{'Content-type': 'application/json'})
return postRequest('/promotion/coupon', params, { 'Content-type': 'application/json' })
}
// 修改优惠券
export const editShopCoupon = (params) => {
return putRequest('/promotion/coupon', params,{'Content-type': 'application/json'})
return putRequest('/promotion/coupon', params, { 'Content-type': 'application/json' })
}
// 获取优惠券列表
@@ -95,7 +95,7 @@ export const getShopCouponList = (params) => {
}
// 更新优惠券状态
export const updateCouponStatus = ( params) => {
export const updateCouponStatus = (params) => {
return putRequest(`/promotion/coupon/status`, params)
}
@@ -123,17 +123,17 @@ export const deleteMemberReceiveCoupon = (ids, params) => {
// 限时秒杀活动列表
export const seckillList = (params) => {
return getRequest(`/promotion/seckill`,params)
return getRequest(`/promotion/seckill`, params)
}
// 限时秒杀活动商品
export const seckillGoodsList = (params) => {
return getRequest(`/promotion/seckill/apply`,params)
return getRequest(`/promotion/seckill/apply`, params)
}
// 添加限时抢购 商品
export const setSeckillGoods = (params) => {
return postRequest(`/promotion/seckill/apply/${params.seckillId}`,params.applyVos,{'Content-type': 'application/json'})
return postRequest(`/promotion/seckill/apply/${params.seckillId}`, params.applyVos, { 'Content-type': 'application/json' })
}
// 添加限时抢购 商品
@@ -148,20 +148,20 @@ export const seckillDetail = (seckillId) => {
// 删除秒杀商品
export const delSeckillGoods = params => {
return deleteRequest(`/promotion/seckill/apply/${params.seckillId}/${params.id}`);
};
};
// 满减满赠活动列表
export const getFullDiscountList = (params) => {
return getRequest(`/promotion/fullDiscount`,params)
return getRequest(`/promotion/fullDiscount`, params)
}
// 新增满减活动
export const newFullDiscount = (params) => {
return postRequest(`/promotion/fullDiscount`,params,{'Content-type': 'application/json'})
return postRequest(`/promotion/fullDiscount`, params, { 'Content-type': 'application/json' })
}
// 编辑满减活动
export const editFullDiscount = (params) => {
return putRequest(`/promotion/fullDiscount`,params,{'Content-type': 'application/json'})
return putRequest(`/promotion/fullDiscount`, params, { 'Content-type': 'application/json' })
}
// 通过id获取满减活动
@@ -177,3 +177,8 @@ export const delFullDiscount = (id) => {
export const updateFullDiscount = (id, params) => {
return putRequest(`/promotion/fullDiscount/status/${id}`, params)
}
// 获取优惠券领取记录
export const getCouponReceiveList = (params) => {
return getRequest("/promotion/coupon/received", params);
};

View File

@@ -158,6 +158,12 @@ export const otherRouter = {
name: "renovation",
component: () => import("@/views/shop/renovation.vue")
},
{
path: "promotions/coupon-receive",
title: "优惠券领取记录",
name: "coupon-receive",
component: () => import("@/views/promotion/coupon/coupon-receive.vue"),
},
// {
// path: "/*",
// name: "error-404",

View File

@@ -57,4 +57,31 @@ export function promotionsScopeTypeRender(h, params) {
]);
}
export function memberPromotionsStatusRender(h, status) {
let text = "未知",
color = "red";
if (status == "NEW") {
text = "已领取";
color = "geekblue";
} else if (status == "USED") {
text = "已使用";
color = "green";
} else if (status == "EXPIRE") {
text = "已过期";
color = "red";
} else if (status == "CLOSED") {
text = "已作废";
color = "red";
}
return h("div", [
h(
"Tag",
{
props: {
color: color,
},
},
text
),
]);
}

View File

@@ -0,0 +1,285 @@
<template>
<div class="search">
<Card>
<Button style="margin-bottom: 10px" @click="back()">返回</Button>
<Form
ref="searchForm"
:model="searchForm"
inline
:label-width="75"
class="search-form mb_10"
>
<Form-item label="优惠券名称" prop="couponName">
<Input
type="text"
v-model="searchForm.couponName"
placeholder="请输入优惠券名称"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="会员名称" prop="memberName">
<Input
type="text"
v-model="searchForm.memberName"
placeholder="请输入会员名称"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="优惠券状态" prop="memberCouponStatus">
<Select
v-model="searchForm.memberCouponStatus"
placeholder="请选择"
clearable
style="width: 200px"
>
<Option value="NEW">已领取</Option>
<Option value="USED">已使用</Option>
<Option value="EXPIRE">已过期</Option>
<Option value="CLOSED">已作废</Option>
</Select>
</Form-item>
<Form-item label="活动时间">
<DatePicker
v-model="selectDate"
type="daterange"
clearable
placeholder="选择起始时间"
style="width: 200px"
></DatePicker>
</Form-item>
<Button
@click="handleSearch"
type="primary"
icon="ios-search"
class="search-btn"
>搜索</Button
>
</Form>
<Table
v-if="refreshTable"
:loading="loading"
border
:columns="columns"
:data="data"
ref="table"
class="mt_10"
@on-selection-change="changeSelect"
>
</Table>
<Row type="flex" justify="end" class="mt_10">
<Page
:current="searchForm.pageNumber"
:total="total"
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</Card>
</div>
</template>
<script>
import { getCouponReceiveList } from "@/api/promotion";
import {
memberPromotionsStatusRender,
promotionsScopeTypeRender,
} from "@/utils/promotions";
export default {
name: "coupon-recevie",
data() {
return {
loading: true, // 表单加载状态
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "create_time", // 默认排序字段
order: "desc", // 默认排序方式
getType: "", // 默认排序方式
couponId: this.$route.query.couponId, // 优惠券id
},
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
// 表头
{
title: "会员名称",
key: "memberName",
fixed: "left",
},
{
title: "优惠券名称",
key: "couponName",
minWidth: 100,
tooltip: true,
},
{
title: "面额/折扣",
key: "price",
width: 100,
render: (h, params) => {
if (params.row.price) {
return h(
"div",
this.$options.filters.unitPrice(params.row.price, "¥")
);
} else {
return h("div", params.row.discount + "折");
}
},
},
{
title: "使用门槛",
key: "consumeThreshold",
width: 130,
},
{
title: "会员优惠券状态",
width: 130,
key: "memberCouponStatus",
render: (h, params) => {
return memberPromotionsStatusRender(
h,
params.row.memberCouponStatus
);
},
},
{
title: "优惠券类型",
key: "couponType",
width: 120,
render: (h, params) => {
if (params.row.couponType === "DISCOUNT") {
return h("Tag", { props: { color: "orange" } }, "打折");
} else if (params.row.couponType === "PRICE") {
return h("Tag", { props: { color: "magenta" } }, "减免现金");
} else {
return h("Tag", { props: { color: "purple" } }, "未知");
}
},
},
{
title: "品类描述",
key: "scopeType",
width: 120,
render: (h, params) => {
return promotionsScopeTypeRender(h, params);
},
},
{
title: "有效时间",
width: 150,
render: (h, params) => {
if (
params?.row?.getType === "ACTIVITY" &&
params?.row?.rangeDayType === "DYNAMICTIME"
) {
return h("div", "长期有效");
} else if (params?.row?.startTime && params?.row?.endTime) {
return h("div", {
domProps: {
innerHTML:
params.row.startTime + "<br/>" + params.row.endTime,
},
});
}
},
},
],
data: [], // 表单数据
total: 0, // 表单数据总数
refreshTable: true, // 修改选中状态后刷新表格
selectDate: [], //选中的信息
};
},
props: {
promotionStatus: {
type: String,
default: "",
},
},
watch: {
$route(e) {
// 监听路由,参数变化调取接口
this.searchForm.couponId = e.query.couponId;
if (this.couponId) {
this.getDataList();
} else {
this.$refs.form.resetFields();
}
},
},
methods: {
back() {
this.$store.commit("removeTag", "coupon-receive");
this.$router.go(-1);
},
check() {
// 选中的优惠券
this.$emit("selected", this.selectList);
},
// 初始化数据
init() {
this.getDataList();
},
changePage(v) {
// 改变页码
this.searchForm.pageNumber = v;
this.getDataList();
},
changePageSize(v) {
// 改变页数
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
// 搜索
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getDataList();
},
/**
* 选择优惠券
*/
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
if (this.getType === "ACTIVITY") this.check();
},
getDataList() {
// 获取数据
this.loading = true;
if (this.selectDate && this.selectDate[0] && this.selectDate[1]) {
this.searchForm.startTime = this.selectDate[0].getTime();
this.searchForm.endTime = this.selectDate[1].getTime();
} else {
this.searchForm.startTime = null;
this.searchForm.endTime = null;
}
getCouponReceiveList(this.searchForm).then((res) => {
this.loading = false;
if (res.success) {
console.log(res);
this.data = res.result.records;
this.total = res.result.total;
}
});
this.total = this.data.length;
this.loading = false;
},
},
mounted() {
this.init();
},
};
</script>

View File

@@ -53,6 +53,7 @@
<Row class="operator padding-row">
<Button @click="add" type="primary">添加</Button>
<Button @click="delAll" class="ml_10">批量关闭</Button>
<Button @click="receivePage()" class="ml_10" type="info">优惠券领取记录</Button>
</Row>
<Table
class="mt_10"
@@ -86,6 +87,13 @@
@click="remove(row)"
>关闭</Button
>
<Button
style="margin: 5px"
type="info"
size="small"
@click="receivePage(row.id)"
>领取记录
</Button>
</template>
</Table>
<Row type="flex" justify="end" class="mt_10">
@@ -136,11 +144,6 @@ export default {
align: "center",
fixed: "left",
},
{
title: "活动名称",
key: "promotionName",
fixed: "left",
},
{
title: "优惠券名称",
key: "couponName",
@@ -204,7 +207,7 @@ export default {
},
{
title: "活动时间",
width: 150,
render: (h, params) => {
if (
params?.row?.getType === "ACTIVITY" &&
@@ -246,6 +249,13 @@ export default {
init() {
this.getDataList();
},
receivePage(id) {
if (id) {
this.$router.push({ name: "coupon-receive", query: { couponId: id } });
} else {
this.$router.push({ name: "coupon-receive" });
}
},
add() {
this.$router.push({ name: "add-coupon" });
},