券兑换码增加下载功能

This commit is contained in:
2025-11-21 16:02:59 +08:00
parent 8269f619b8
commit b87ce7d43e
5 changed files with 482 additions and 194 deletions

View File

@@ -31,9 +31,9 @@
</view>
<up-line></up-line>
<view class="default-box-padding u-flex u-row-between">
<text class="font-bold">优惠券</text>
<view>
<text class="u-p-l-30">{{ returnCoupon }}</text>
<text class="font-bold no-wrap">优惠券</text>
<view class="u-p-l-30">
<text class="">{{ returnCoupon }}</text>
<text class="color-main u-font-32 u-m-l-20" @click="showModal"
>修改</text
>
@@ -58,10 +58,11 @@
placeholder="输入兑换码"
class="u-font-28 u-m-l-20"
placeholder-class="color-999 u-font-28"
v-model="query.name"
@input="codeChange"
v-model="query.code"
/>
</view>
<view class="daochu u-m-l-24">导出</view>
<view class="daochu u-m-l-24" @click="exportCode">导出</view>
</view>
</view>
@@ -130,7 +131,7 @@ import CouponList from "@/pageMarket/components/coupon-list.vue";
import Modal from "@/pageMarket/components/modal.vue";
import * as couponRedemptionApi from "@/http/api/market/couponRedemption.js";
import { saveFileFromTemp } from "@/utils/downloadFile.js";
import {
reactive,
toRefs,
@@ -188,6 +189,8 @@ const form = reactive({
onLoad((opt) => {
const item = uni.getStorageSync("couponRedemptionItem");
Object.assign(form, item);
console.log(form);
getList();
});
const query = reactive({
status: "",
@@ -233,10 +236,55 @@ function refresh() {
query.page = 1;
getList();
}
watch(() => query, refresh);
onMounted(() => {
getList();
watch(() => query.status, refresh);
//节流
const throttle = (fn, delay = 500) => {
let timer = null;
return function () {
if (timer) {
return;
}
timer = setTimeout(() => {
fn.apply(this, arguments);
timer = null;
}, delay);
};
};
const codeChange = throttle(() => {
console.log(query.code);
refresh();
});
function exportCode() {
couponRedemptionApi
.codeExport({
status: query.status,
redemptionId: form.id,
code: query.code,
})
.then((res) => {
console.log(res);
if (res.statusCode == 200) {
saveFileFromTemp({
tempFilePath: res.tempFilePath,
fileName: '优惠券兑换码.xlsx',
isNowOpen:true
});
// uni.getFileSystemManager().saveFile({
// tempFilePath: res.tempFilePath,
// success: function (res) {
// console.log(res);
// },
// fail: function (err) {
// console.log(err);
// }
// });
}
});
}
onReachBottom(() => {
console.log("触底");
if (isEnd.value) {