新增添加优惠券页面

This commit is contained in:
gyq
2025-11-20 18:47:52 +08:00
parent 61447986c5
commit 05b9551126
10 changed files with 1062 additions and 14 deletions

View File

@@ -31,7 +31,7 @@
</view>
<view class="my-coupon-item-list">
<view class="my-coupon-item-item" v-for="item in tableData.list" :key="item.id">
<my-coupon-item :item="item">
<my-coupon-item :item="item" @delete="deleteHandle" @editor="editorHandle">
<view class="my-coupon-item-row-wrap">
<template v-if="couponType == 5">
<view class="row">
@@ -74,7 +74,9 @@
<text class="title">有效期</text>
<text class="info">
<template v-if="item.validType == 'fixed'">领券后{{ item.validDays }}天过期</template>
<template v-if="item.validType == 'custom'">{{ item.validStartTime }}{{ item.validEndTime }}</template>
<template v-if="item.validType == 'custom'">
{{ dayjs(item.validStartTime).format('YYYY-MM-DD') }} {{ dayjs(item.validEndTime).format('YYYY-MM-DD') }}
</template>
</text>
</view>
</template>
@@ -87,14 +89,15 @@
</view>
</view>
<u-loadmore :status="tableData.status"></u-loadmore>
<my-footer-btn confirmText="+ 添加商品兑换券" @confirm="go.to('PAGES_ADD_COUPON')"></my-footer-btn>
<my-footer-btn :confirmText="`+ 添加${getEmunListLabel('couponTypes', couponType)}`" @confirm="toAddCounpon"></my-footer-btn>
</view>
</template>
<script setup>
import dayjs from 'dayjs';
import { ref, reactive } from 'vue';
import go from '@/commons/utils/go.js';
import { couponPage } from '@/http/api/market/index.js';
import { couponPage, couponDel } from '@/http/api/market/index.js';
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app';
import { getEmunListLabel, emunList } from '../utils/couponUtils.js';
@@ -109,6 +112,7 @@ function searchHandle() {
resetGetData();
}
// 重置获取数据
function resetGetData() {
tableData.page = 1;
tableData.status = 'loading';
@@ -116,6 +120,52 @@ function resetGetData() {
couponPageAjax();
}
function toAddCounpon() {
if (couponType.value == 5) {
go.to('PAGES_ADD_CONSUME_COUPON');
} else {
go.to('PAGES_ADD_COUPON', { couponType: couponType.value });
}
}
// 删除
function deleteHandle(item) {
console.log('del', item);
uni.showModal({
title: '注意',
content: `确定要删除${item.title}优惠券吗?`,
success: async (res) => {
try {
uni.showLoading({
title: '删除中...',
mask: true
});
await couponDel(item.id);
uni.showToast({
title: '已删除',
icon: 'none'
});
let index = tableData.list.findIndex((val) => val.id == item.id);
tableData.list.splice(index, 1);
} catch (error) {
console.log(error);
}
setTimeout(() => {
uni.hideLoading();
}, 500);
}
});
}
// 编辑
function editorHandle(item) {
console.log('editor', item);
go.to('PAGES_ADD_COUPON', {
couponType: item.couponType,
id: item.id
});
}
// 获取优惠券
const couponType = ref(1);
const tableData = reactive({