同步代码
This commit is contained in:
408
pageCoupon/index.vue
Normal file
408
pageCoupon/index.vue
Normal file
@@ -0,0 +1,408 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 顶部菜单 -->
|
||||
<view class="tagClass">
|
||||
<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.name}}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 搜搜 -->
|
||||
<!-- <view class="search">
|
||||
<up-input
|
||||
placeholder="搜索优惠券名称"
|
||||
prefixIcon="search"
|
||||
shape="circle"
|
||||
border="none"
|
||||
fontSize="14px"
|
||||
prefixIconStyle="font-size: 28px;color: #999;"
|
||||
:customStyle="{backgroundColor:'#F9F9F9',padding: '10rpx 18rpx'}"
|
||||
></up-input>
|
||||
<view class="searchBtn">
|
||||
搜索
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- 内容 -->
|
||||
<view class="couponContentList">
|
||||
<view class="couponContent" v-for="(item,index) in pageData.couponList" :key="index">
|
||||
|
||||
<view class="couponContentListTop">
|
||||
<view class="title"> {{ item.title }} </view>
|
||||
<view> ID:{{item.id}} </view>
|
||||
</view>
|
||||
<view class="couponContentListcontent">
|
||||
<view>
|
||||
<view> 使用门槛 </view>
|
||||
<view v-if="item.type == 1"> 满 {{ item.fullAmount }} 元减 {{ item.discountAmount }} 元 </view>
|
||||
<view v-if="item.type == 2"> 满 {{ item.fullAmount }} 元可用 </view>
|
||||
</view>
|
||||
<!-- <view>
|
||||
<view> 领取方式 </view>
|
||||
<view> 用户不可自行领取 </view>
|
||||
</view> -->
|
||||
<view v-if="item.type == 1">
|
||||
<view> 有效期 </view>
|
||||
<view> 领券后{{ item.validDays }}天过期 </view>
|
||||
</view>
|
||||
<view class="JQclass">
|
||||
<image :src="'/static/coupon/qrcode.svg'" mode="scaleToFill" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="couponContentListcontent2">
|
||||
<view class="">
|
||||
<view class="num"> {{ item.number }} </view>
|
||||
<view class="lable"> 发放数量 </view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="num"> {{ item.number-item.leftNumber }} </view>
|
||||
<view class="lable"> 已领取 </view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="num"> {{ item.leftNumber }} </view>
|
||||
<view class="lable"> 剩余 </view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="num"> {{ item.useNumber }} </view>
|
||||
<view class="lable"> 已使用 </view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="couponContentListbottom">
|
||||
<button @tap="editCoupon(item)">编辑</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>
|
||||
|
||||
|
||||
<view class="bottomPop">
|
||||
<button @click="addCoupon">+添加{{pageData.status.tagName}}</button>
|
||||
</view>
|
||||
<up-modal :show="pageData.delShow" title="确认是否删除当前优惠券" @confirm="delConfirm" @cancel="pageData.delShow=false" showCancelButton></up-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import go from '@/commons/utils/go.js'
|
||||
import { getTbShopCoupon , delTbShopCoupon} from '@/http/yskApi/coupon.js'
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import { onLoad, onShow,onPageScroll,
|
||||
onPullDownRefresh,
|
||||
onReachBottom, } from '@dcloudio/uni-app';
|
||||
const pageData = reactive({
|
||||
delShow: false,
|
||||
delItem: null,
|
||||
status: {
|
||||
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 = ( 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.query.type == 1 ) {
|
||||
go.to('PAGES_COUPON_DISCOUNTCOUPONS')
|
||||
} else {
|
||||
go.to('PAGES_COUPON_CERTIFICATE')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
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',{type: 'info', id: item.id})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
let delCoupon = (item) => {
|
||||
pageData.delShow = true;
|
||||
pageData.delItem = item;
|
||||
}
|
||||
let delConfirm = () => {
|
||||
pageData.delShow = false;
|
||||
delTbShopCoupon([pageData.delItem.id]).then((res) => {
|
||||
getCoupon();
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
body{
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.container{
|
||||
position: relative;
|
||||
}
|
||||
.tagClass {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding-top: 44rpx;
|
||||
padding: 32rpx 28rpx;
|
||||
background-color: #fff;
|
||||
position: fixed;
|
||||
top: 0rpx;
|
||||
z-index: 999;
|
||||
.tag-item {
|
||||
display: inline-block;
|
||||
padding: 10rpx 24rpx;
|
||||
margin-right: 32rpx;
|
||||
border-radius: 4rpx 4rpx 4rpx 4rpx;
|
||||
text-align: center;
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
background: #F7F7FA;
|
||||
|
||||
&.active {
|
||||
background: #E6F0FF;
|
||||
color: #318AFE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tagClass::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.search {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 32rpx;
|
||||
background-color: #fff;
|
||||
margin-bottom: 32rpx;
|
||||
.inputsearch {
|
||||
color: #999999;
|
||||
width: 542rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
background: #F9F9F9;
|
||||
border-radius: 32rpx 32rpx 32rpx 32rpx;
|
||||
}
|
||||
|
||||
.searchBtn {
|
||||
width: 120rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-left: 32rpx;
|
||||
text-align: center;
|
||||
color: #FFFFFF;
|
||||
background: #318AFE;
|
||||
border-radius: 32rpx 32rpx 32rpx 32rpx;
|
||||
}
|
||||
}
|
||||
.couponContentList {
|
||||
/* width: 694rpx; */
|
||||
/* height: 544rpx; */
|
||||
margin: 32rpx auto 0;
|
||||
margin-bottom: 32rpx;
|
||||
padding: 70rpx 28rpx 182rpx 28rpx;
|
||||
}
|
||||
.couponContent {
|
||||
/* background-color: #f9f9f9; */
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
background: #FFFFFF;
|
||||
padding: 32rpx 24rpx;
|
||||
margin-bottom: 32rpx;
|
||||
.couponContentListTop {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.title{
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
>view:last-child {
|
||||
width: 98rpx;
|
||||
height: 36rpx;
|
||||
line-height: 36rpx;
|
||||
text-align: center;
|
||||
background: #F7F7FA;
|
||||
border-radius: 4rpx 4rpx 4rpx 4rpx;
|
||||
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 500;
|
||||
font-size: 18rpx;
|
||||
color: #999999;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.couponContentListcontent {
|
||||
margin-top: 24rpx;
|
||||
padding-top: 1rpx;
|
||||
width: 646rpx;
|
||||
height: 228rpx;
|
||||
background: #F9F9F9;
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
position: relative;
|
||||
|
||||
>view {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 12rpx;
|
||||
|
||||
>view:first-child {
|
||||
width: 180rpx;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
>view:last-child {
|
||||
margin-left: 48rpx;
|
||||
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
line-height: 0rpx;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.JQclass {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
/* background-color: #318AFE; */
|
||||
position: absolute;
|
||||
right: 48rpx;
|
||||
top: 90rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.couponContentListcontent2 {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
text-align: center;
|
||||
padding-top: 24rpx;
|
||||
.num{
|
||||
font-weight: bold;
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
.lable{
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
}
|
||||
}
|
||||
|
||||
.couponContentListbottom {
|
||||
margin-top: 24rpx;
|
||||
overflow: hidden;
|
||||
>button {
|
||||
float: right;
|
||||
width: 140rpx;
|
||||
height: 56rpx;
|
||||
margin-left: 22rpx;
|
||||
line-height: 56rpx;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
background: #F7F7FA;
|
||||
border-radius: 28rpx 28rpx 28rpx 28rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
>button:first-child {
|
||||
background-color: #318afe;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
.couponContent:last-of-type{
|
||||
/* margin-bottom: 150rpx; */
|
||||
}
|
||||
|
||||
.bottomPop {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 150rpx;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
|
||||
>button {
|
||||
width: 530rpx;
|
||||
margin: 30rpx 0;
|
||||
margin-left: 50%;
|
||||
transform: translateX(-50%);
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
color: #fff;
|
||||
background: #318AFE;
|
||||
border-radius: 56rpx 56rpx 56rpx 56rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user