lilishop-ui/buyer/src/pages/CouponCenter.vue

202 lines
5.1 KiB
Vue
Raw Normal View History

2021-07-31 11:05:34 +08:00
<template>
<div class="coupon-center">
<BaseHeader></BaseHeader>
<div class="content">
<div>
<div class="coupon-title">
<router-link to="/">
<img src="../assets/images/logo.png" width="120" alt="" />
2021-07-31 11:05:34 +08:00
</router-link>
<p>领券中心</p>
<Input
search
style="width: 400px"
@on-search="search"
enter-button="搜索"
placeholder="搜索优惠券"
/>
2021-07-31 11:05:34 +08:00
</div>
<div class="fontsize_18 recommend">推荐好券</div>
<empty v-if="list.length === 0" />
2021-07-31 11:05:34 +08:00
<ul class="coupon-list" v-else>
<li v-for="(item, index) in list" class="coupon-item" :key="index">
<div class="c-left">
<div>
<span
v-if="item.couponType === 'PRICE'"
class="fontsize_12 global_color"
><span class="price">{{
item.price | unitPrice
}}</span></span
>
<span
v-if="item.couponType === 'DISCOUNT'"
class="fontsize_12 global_color"
><span class="price">{{ item.couponDiscount }}</span
></span
>
<span class="describe"
>{{ item.consumeThreshold }}元可用</span
>
2021-07-31 11:05:34 +08:00
</div>
<p>使用范围{{ useScope(item.scopeType, item.storeName) }}</p>
<p>有效期{{ item.endTime }}</p>
2021-07-31 11:05:34 +08:00
</div>
<b></b>
<a class="c-right" @click="receive(item)"></a>
<i class="circle-top"></i>
<i class="circle-bottom"></i>
</li>
</ul>
<Page
:total="total"
@on-change="changePageNum"
2021-07-31 11:05:34 +08:00
class="pageration"
@on-page-size-change="changePageSize"
:page-size="params.pageSize"
show-total
show-sizer
>
2021-07-31 11:05:34 +08:00
</Page>
</div>
</div>
<BaseFooter></BaseFooter>
</div>
</template>
<script>
import { couponList, receiveCoupon } from "@/api/member.js";
2021-07-31 11:05:34 +08:00
export default {
data() {
2021-07-31 11:05:34 +08:00
return {
list: [], // 优惠券列表
total: 0, // 优惠券总数
params: {
// 请求参数
getType: "FREE",
2021-07-31 11:05:34 +08:00
pageNumber: 1,
pageSize: 20,
},
};
2021-07-31 11:05:34 +08:00
},
methods: {
// 搜索优惠券
search(item) {
this.params.couponName = item;
this.params.pageNumber = 1;
this.getList();
2021-07-31 11:05:34 +08:00
},
// 获取优惠券列表
getList() {
this.$Spin.show();
couponList(this.params)
.then((res) => {
this.$Spin.hide();
this.loading = false;
if (res.success) {
this.list = res.result.records;
this.total = res.result.total;
}
})
.catch(() => {
this.$Spin.hide();
});
2021-07-31 11:05:34 +08:00
},
// 分页 改变页码
changePageNum(val) {
2021-07-31 11:05:34 +08:00
this.params.pageNumber = val;
this.getList();
2021-07-31 11:05:34 +08:00
},
// 分页 改变每页数
changePageSize(val) {
2021-07-31 11:05:34 +08:00
this.params.pageNumber = 1;
this.params.pageSize = val;
this.getList();
2021-07-31 11:05:34 +08:00
},
// 领取优惠券
receive(item) {
receiveCoupon(item.id).then((res) => {
2021-07-31 11:05:34 +08:00
if (res.success) {
console.log(item);
2021-07-31 11:05:34 +08:00
this.$Modal.confirm({
title: "领取优惠券",
content: "<p>优惠券领取成功,可到我的优惠券页面查看</p>",
okText: "我的优惠券",
cancelText: "立即使用",
closable: true,
2021-07-31 11:05:34 +08:00
onOk: () => {
this.$router.push("/home/Coupons");
2021-07-31 11:05:34 +08:00
},
onCancel: () => {
this.$router.push({
path: "/goodsList",
query: { promotionsId: item.id, promotionType: "COUPON" },
});
},
2021-07-31 11:05:34 +08:00
});
}
});
2021-07-31 11:05:34 +08:00
},
// 优惠券可用范围
useScope(type, storeName) {
let shop = "平台";
let goods = "全部商品";
if (storeName !== "platform") shop = storeName;
2021-07-31 11:05:34 +08:00
switch (type) {
case "ALL":
goods = "全部商品";
2021-07-31 11:05:34 +08:00
break;
case "PORTION_GOODS":
goods = "部分商品";
2021-07-31 11:05:34 +08:00
break;
case "PORTION_GOODS_CATEGORY":
goods = "部分分类商品";
2021-07-31 11:05:34 +08:00
break;
}
return `${shop}${goods}可用`;
},
2021-07-31 11:05:34 +08:00
},
mounted() {
this.getList();
},
};
2021-07-31 11:05:34 +08:00
</script>
<style lang="scss" scoped>
@import "../assets/styles/coupon.scss";
.content {
width: 100%;
background-color: #fff;
2021-07-31 11:05:34 +08:00
> div {
margin: 10px auto;
width: 1200px;
2021-07-31 11:05:34 +08:00
}
}
.coupon-title {
display: flex;
align-items: center;
2021-07-31 11:05:34 +08:00
p {
font-size: 18px;
margin-right: 500px;
2021-07-31 11:05:34 +08:00
}
border-bottom: 2px solid $theme_color;
}
.recommend {
margin: 20px auto;
font-weight: bold;
width: 200px;
text-align: center;
}
.coupon-item {
b {
background: url("../assets/images/small-circle.png") top left repeat-y;
2021-07-31 11:05:34 +08:00
}
}
.pageration {
text-align: right;
padding-bottom: 10px;
}
2021-07-31 11:05:34 +08:00
</style>