新增优惠券

This commit is contained in:
GaoHao
2024-10-26 16:17:34 +08:00
parent 865e1780db
commit 79b258243a
7 changed files with 396 additions and 100 deletions

View File

@@ -1,16 +1,13 @@
<template>
<!-- 顶部菜单 -->
<view class="tagClass">
<view class="tag-item" @tap="tagClick(item,index)" :class="{active:index===pageData.status.active}"
<view class="tag-item" @tap="tagClick(item)" :class="{active:item.type===pageData.query.type}"
v-for="(item,index) in pageData.status.list" :key="index">
{{item}}(0)
{{item.name}}
</view>
</view>
<!-- 搜搜 -->
<view class="search">
<!-- <view class="inputsearch">
搜索优惠券名称
</view> -->
<!-- <view class="search">
<up-input
placeholder="搜索优惠券名称"
prefixIcon="search"
@@ -23,27 +20,27 @@
<view class="searchBtn">
搜索
</view>
</view>
</view> -->
<!-- 内容 -->
<view class="couponContentList">
<view class="couponContent" v-for="(item,index) in 4" :key="index">
<view class="couponContent" v-for="(item,index) in pageData.couponList" :key="index">
<view class="couponContentListTop">
<view class="title"> 充值20元优惠券 </view>
<view> ID:258792 </view>
<view class="title"> {{ item.title }} </view>
<view> ID:{{item.id}} </view>
</view>
<view class="couponContentListcontent">
<view>
<view> 使用门槛 </view>
<view> 200.00元减20.00 </view>
<view> {{ item.fullAmount }} 元减 {{ item.discountAmount }} </view>
</view>
<view>
<view> 领取方式 </view>
<view> 店铺领取可 </view>
<view> 户不可自行领取 </view>
</view>
<view>
<view> 有效期 </view>
<view> 满200.00元减20.00 </view>
<view> 领券后{{ item.validDays }}天过期 </view>
</view>
<view class="JQclass">
<image :src="'/static/coupon/qrcode.svg'" mode="scaleToFill" />
@@ -51,27 +48,31 @@
</view>
<view class="couponContentListcontent2">
<view class="">
<view class="num"> 1000 </view>
<view class="num"> {{ item.number }} </view>
<view class="lable"> 发放数量 </view>
</view>
<view class="">
<view class="num"> 0 </view>
<view class="lable"> 发放数量 </view>
<view class="num"> {{ item.number-item.leftNumber }} </view>
<view class="lable"> 已领取 </view>
</view>
<view class="">
<view class="num"> 1000 </view>
<view class="lable"> 发放数量 </view>
<view class="num"> {{ item.leftNumber }} </view>
<view class="lable"> 剩余 </view>
</view>
<view class="">
<view class="num"> 0 </view>
<view class="lable"> 发放数量 </view>
<view class="num"> {{ item.useNumber }} </view>
<view class="lable"> 已使用 </view>
</view>
</view>
<view class="couponContentListbottom">
<button @tap="editCoupon(item)">编辑</button>
<button>删除</button>
<button @tap="delCoupon(item)">删除</button>
</view>
</view>
<template v-if="pageData.couponList.length">
<my-pagination :page="pageData.query.page" :totalElements="pageData.totalElements" :size="pageData.query.size"
@change="pageChange"></my-pagination>
</template>
</view>
@@ -82,50 +83,99 @@
<script setup>
import go from '@/commons/utils/go.js'
import { getTbShopCoupon , delTbShopCoupon} from '@/http/yskApi/coupon.js'
import {
reactive,
ref,
toRef,
watch
onMounted
} from 'vue';
import { onLoad, onShow,onPageScroll,
onPullDownRefresh,
onReachBottom, } from '@dcloudio/uni-app';
const pageData = reactive({
status: {
list: ['优惠券', '商品兑换券', ],
list: [
{name: '优惠券', type: 1},
{name: '商品兑换券', type: 2},
],
tagName: "优惠券",
active: 0,
}
},
query: {
type: 1,
page: 1,
size: 10,
},
couponList: [],
totalElements: 0,
})
onShow(() => {
getCoupon();
})
onReachBottom(() => {
// pageData.query.page++
// getCoupon()
})
/**
* tag切换
*/
let tagClick = ( name,index ) => {
pageData.status.active = index;
pageData.status.tagName = name;
let tagClick = ( item ) => {
pageData.query.type = item.type;
pageData.status.tagName = item.name;
pageData.query.page = 1;
getCoupon();
}
// 获取优惠券列表
let getCoupon = () => {
let params = pageData.query;
getTbShopCoupon(params).then((res) => {
console.log(res)
pageData.couponList = res.content;
pageData.totalElements = res.totalElements;
})
}
// 页数改变事件
function pageChange(page) {
console.log(page)
pageData.query.page = page
getCoupon()
}
/**
* 添加
*/
let addCoupon = ()=>{
if ( pageData.status.active == 0 ) {
if ( pageData.query.type == 1 ) {
go.to('PAGES_COUPON_DISCOUNTCOUPONS')
} else {
go.to('PAGES_COUPON_CERTIFICATE')
}
}
/**
* 添加
* 修改
*/
let editCoupon = ()=>{
if ( pageData.status.active == 0 ) {
go.to('PAGES_COUPON_DISCOUNTCOUPONS')
let editCoupon = (item)=>{
console.log(item.id)
if ( item.type == 1 ) {
go.to('PAGES_COUPON_DISCOUNTCOUPONS',{type: 'info', id: item.id})
} else {
go.to('PAGES_COUPON_CERTIFICATE')
go.to('PAGES_COUPON_CERTIFICATE',{type: 'info', id: item.id})
}
}
/**
* 删除
*/
let delCoupon = (item) => {
delTbShopCoupon([item.id]).then((res) => {
getCoupon();
})
}
</script>
<style lang='scss'>
@@ -138,7 +188,7 @@
overflow-x: auto;
-webkit-overflow-scrolling: touch;
padding-top: 44rpx;
padding: 0 28rpx;
padding: 32rpx 28rpx;
background-color: #fff;
.tag-item {
display: inline-block;
@@ -192,9 +242,9 @@
.couponContentList {
/* width: 694rpx; */
/* height: 544rpx; */
margin: 0 auto;
margin: 32rpx auto 0;
margin-bottom: 32rpx;
padding: 0 28rpx 32rpx 28rpx;
padding: 0 28rpx 182rpx 28rpx;
}
.couponContent {
/* background-color: #f9f9f9; */
@@ -315,7 +365,7 @@
}
}
.couponContent:last-of-type{
margin-bottom: 150rpx;
/* margin-bottom: 150rpx; */
}
.bottomPop {