This commit is contained in:
gyq
2025-11-21 18:15:46 +08:00
12 changed files with 1053 additions and 20 deletions

View File

@@ -3,7 +3,9 @@
<view class="bg-fff default-box-radius">
<view class="default-box-padding u-flex u-row-between">
<text class="font-bold">兑换码名称</text>
<text class="color-666">{{ form.name }}</text>
<view >
<up-input v-model="form.name" placeholder="请输入兑换码名称"></up-input>
</view>
</view>
<up-line></up-line>
<view class="default-box-padding u-flex u-row-between">
@@ -128,6 +130,7 @@ import {
} from "@dcloudio/uni-app";
import couponStatus from "./components/status.vue";
import CouponList from "@/pageMarket/components/coupon-list.vue";
import DateTimePicker from "@/pageMarket/components/date-time-picker.vue";
import Modal from "@/pageMarket/components/modal.vue";
import * as couponRedemptionApi from "@/http/api/market/couponRedemption.js";
@@ -325,4 +328,12 @@ onReachBottom(() => {
border-bottom: none;
}
}
:deep(.uni-input-input){
text-align: right;
}
:deep(.input-placeholder){
text-align: right;
color: #999;
font-size: 28rpx;
}
</style>

View File

@@ -122,6 +122,7 @@ const loadFinish = ref(false);
const form = reactive({
isEnable: 0,
useType: "all",
shopIdList:[]
});
const actions = [
@@ -222,7 +223,7 @@ const handleConfirm = async () => {
}
couponRedemptionApi.enable({
shopIdList: form.shopIdList,
shopIdList: form.shopIdList||[],
useType: form.useType,
isEnable: form.isEnable,
});
@@ -281,6 +282,7 @@ watch(
async function getConfig() {
couponRedemptionApi.status().then((res) => {
res.shopIdList = res.shopIdList || [];
Object.assign(form, res);
});
}

View File

@@ -17,14 +17,24 @@
<view class="font-bold u-m-b-16">选择商品</view>
<chooseGoods v-model="form.foods"> </chooseGoods>
</view>
<view class="u-m-t-16">
<view class="u-m-t-16 u-p-b-16">
<view class="font-bold u-m-b-16">自定义引导语</view>
<up-input
placeholder="请输入内容"
border="none"
v-model="form.guideDetail"
:maxlength="12"
placeholder-class="color-999 u-font-28"
></up-input>
</view>
<up-line></up-line>
<view class="u-m-t-16 u-flex u-row-between">
<view class="font-bold ">是否启用</view>
<up-switch v-model="form.status" size="18"
:active-value="1"
:inactive-value="0"
></up-switch>
</view>
</view>
<view class="default-box-padding bg-fff default-box-radius u-m-t-32">
<view class="font-bold">可用周期</view>
@@ -63,12 +73,20 @@ import {
onBackPress,
} from "@dcloudio/uni-app";
function cancel() {
uni.navigateBack({
delta: 1,
});
}
const form = reactive({
foods: "",
useDays: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
useStartTime: "",
useTimeType: "all",
useEndTime: "",
guideDetail:'',
status:1
});
function save() {
@@ -109,16 +127,18 @@ function save() {
});
return;
}
if(!form.guideDetail){
uni.showToast({
title: "请输入自定义引导语",
icon: "none",
});
return;
}
if(options.type=='edit'){
suggestApi
.editSuggest({
title: form.title,
id: form.id,
foods: form.foods,
...form,
useDays: form.useDays.join(","),
useStartTime: form.useStartTime,
useTimeType: form.useTimeType,
useEndTime: form.useEndTime,
})
.then((res) => {
uni.showToast({
@@ -136,12 +156,8 @@ function save() {
}
suggestApi
.addSuggest({
title: form.title,
foods: form.foods,
useDays: form.useDays.join(","),
useStartTime: form.useStartTime,
useTimeType: form.useTimeType,
useEndTime: form.useEndTime,
...form,
useDays: form.useDays.join(",")
})
.then((res) => {
uni.showToast({
@@ -168,8 +184,14 @@ onLoad((opt) => {
form.useTimeType = item.useTimeType;
form.useEndTime = item.useEndTime;
form.id = item.id;
form.guideDetail=item.guideDetail
form.status=item.status
console.log(form);
}
uni.setNavigationBarTitle({
title:opt.type=="edit"?"编辑":"添加",
});
});
</script>

View File

@@ -31,7 +31,7 @@
<text class="u-m-l-10"></text>
</view>
<view class="color-666 u-font-24 u-m-t-8"
>多个弹窗时每个弹窗之间关闭和弹出间隔为15
>多个弹窗时每个弹窗之间关闭和弹出间隔为30
</view>
</view>
</view>

View File

@@ -0,0 +1,161 @@
<template>
<view class="min-page bg-f7 default-box-padding u-font-28 color-333">
<view class="default-box-padding bg-fff default-box-radius">
<view>
<view class="font-bold u-m-b-16">兑换码名称</view>
<up-input
placeholder="请输入兑换码名称"
border="none"
v-model="form.name"
placeholder-class="color-999 u-font-28"
></up-input>
<view class="u-m-t-24">
<up-line></up-line>
</view>
</view>
<view class="u-m-t-24">
<view class="font-bold u-m-b-16">活动日期</view>
<DateTimePicker
v-model:startTime="form.startTime"
v-model:endTime="form.endTime"
>
</DateTimePicker>
</view>
</view>
<view class="default-box-padding bg-fff default-box-radius u-m-t-32">
<view class="font-bold u-m-b-16">发放数量</view>
<view class="u-flex u-m-t-16">
<input
class="number-box"
placeholder="填写数量"
placeholder-class="color-999 u-font-28"
type="number"
v-model="form.total"
/>
<view class="unit"></view>
</view>
<view class="u-m-t-24">
<up-line></up-line>
</view>
<view class="font-bold u-m-t-24">金额</view>
<view class="u-flex u-m-t-16">
<input
class="number-box"
placeholder="请输入金额"
placeholder-class="color-999 u-font-28"
type="number"
v-model="form.amount"
/>
<view class="unit"></view>
</view>
</view>
<my-bottom-btn-group
@cancel="cancel"
@save="save"
direction="column"
></my-bottom-btn-group>
</view>
</template>
<script setup>
import { reactive, onMounted } from "vue";
import DateTimePicker from "@/pageMarket/components/date-time-picker.vue";
import CouponList from "@/pageMarket/components/coupon-list.vue";
import * as rechargeRedemptionApi from "@/http/api/market/rechargeRedemption.js";
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
function cancel() {
uni.navigateBack({
delta: 1,
});
}
const form = reactive({
name: "",
startTime: "",
endTime: "",
stock: "",
total: '',
amount:'',
});
function save() {
if (!form.name) {
uni.showToast({
title: "请输入兑换码名称",
icon: "none",
});
return;
}
if (!form.startTime || !form.endTime) {
uni.showToast({
title: "请选择活动日期",
icon: "none",
});
return;
}
if (!form.total) {
uni.showToast({
title: "请输入发行数量",
icon: "none",
});
return;
}
if (!form.amount) {
uni.showToast({
title: "请输入金额",
icon: "none",
});
return;
}
rechargeRedemptionApi.add(form).then((res) => {
uni.showToast({
title: "添加成功",
icon: "none",
});
setTimeout(() => {
uni.navigateBack({
delta: 1,
});
}, 1500);
});
}
function addCoupon() {
form.couponInfoList.push({
id: "",
num: "",
title: "",
});
}
const options = reactive({});
onLoad((opt) => {});
</script>
<style lang="scss" scoped>
:deep(.my-hour-area .container) {
padding: 32rpx 28rpx;
background-color: #f7f7f7;
border-radius: 8rpx;
margin-top: 16rpx;
}
:deep(.my-hour-area .box) {
margin-top: 0 !important;
}
:deep(.fixed-bottom) {
left: 110rpx;
right: 110rpx;
}
</style>

View File

@@ -0,0 +1,52 @@
<template>
<view class="u-flex">
<view @click="show = true">
<slot v-if="$slots.default"> </slot>
<view v-else class="choose-goods u-flex u-row-between">
<text class="color-333 u-font-28 font-bold">{{ statusText }}</text>
<up-icon size="14" name="arrow-down" color="#333" bold></up-icon>
</view>
</view>
<up-action-sheet
:show="show"
cancel-text="取消"
closeOnClickAction
@close="show = false"
:actions="actions"
@select="confirm"
></up-action-sheet>
</view>
</template>
<script setup>
import { ref ,computed } from "vue";
const show = ref(false);
const modelValue = defineModel({
type: String,
default: "",
});
function confirm(item) {
modelValue.value = item.value;
}
const actions = ref([
{
name: "全部",
value: "",
},
{
name: "已兑换",
value: "1",
},
{
name: "未兑换",
value: "0",
},
]);
const statusText = computed(() => {
if (modelValue.value === "") {
return "全部";
}
return modelValue.value === "1" ? "已兑换" : "未兑换";
});
</script>

View File

@@ -0,0 +1,321 @@
<template>
<view class="min-page bg-f7 default-box-padding u-font-28 color-333">
<view class="bg-fff default-box-radius">
<view class="default-box-padding u-flex u-row-between">
<text class="font-bold">兑换码名称</text>
<view>
<up-input v-model="form.name"></up-input>
</view>
</view>
<up-line></up-line>
<view class="default-box-padding u-flex u-row-between">
<text class="font-bold">活动日期</text>
<text class="color-666 u-font-24"
>{{ form.startTime }} {{ form.endTime }}</text
>
</view>
<up-line></up-line>
<view class="default-box-padding u-flex u-row-between">
<text class="font-bold">金额</text>
<text class="color-666 u-font-24">{{ form.amount }}</text>
</view>
<up-line></up-line>
<view class="default-box-padding u-flex u-row-between">
<text class="font-bold">总数</text>
<text class="color-666 u-font-24">{{ form.total }}</text>
</view>
<up-line></up-line>
<view class="default-box-padding u-flex u-row-between">
<text class="font-bold">库存</text>
<view style="width: 158rpx">
<up-input
v-model="form.stock"
type="number"
placeholder="库存"
placeholder-class="color-999 u-font-28"
></up-input>
</view>
</view>
</view>
<view class="u-p-t-48 u-p-b-48 u-p-l-60 u-p-r-60">
<my-button type="primary" shape="circle" @click="save">保存</my-button>
</view>
<view class="bg-fff default-box-radius">
<view class="default-box-x-padding u-p-t-32 u-flex u-row-between">
<couponStatus v-model="query.status"></couponStatus>
<view class="u-flex">
<view class="border u-flex default-box-radius search-box">
<up-icon name="search"></up-icon>
<input
style="width: 140rpx"
placeholder="输入兑换码"
class="u-font-28 u-m-l-20"
placeholder-class="color-999 u-font-28"
@input="codeChange"
v-model="query.code"
/>
</view>
<view class="daochu u-m-l-24" @click="exportCode">导出</view>
</view>
</view>
<view class="list u-m-t-48">
<view
class="item default-box-padding"
v-for="(item, index) in list"
:key="index"
>
<view class="u-flex u-row-between">
<text class="status" :class="['status-' + item.status]">{{
item.status == 0 ? "未兑换" : "已兑换"
}}</text>
<view>
<text class="color-666">{{ item.code }}</text>
<text class="color-main u-m-l-20" @click="copyCode(item.code)"
>复制</text
>
</view>
</view>
<view class="u-m-t-16 u-flex u-row-between color-666">
<text>{{ item.redemptionTime }}</text>
<view>
<text>{{ item.nickName }}</text>
<text>{{ item.phone }}</text>
</view>
</view>
</view>
</view>
</view>
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
<Modal
:title="ModalData.title"
v-model="ModalData.show"
@confirm="modelConfirm"
>
<view class="default-box-padding">
<CouponList v-model="form.couponInfoList"></CouponList>
<view class="u-m-t-16 u-flex">
<view class="u-flex" @click="addCoupon">
<up-icon
name="plus-circle-fill"
color="#318AFE"
size="18"
></up-icon>
<text class="font-bold u-m-l-20">添加</text>
</view>
</view>
</view>
</Modal>
</view>
</template>
<script setup>
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
import couponStatus from "./components/status.vue";
import CouponList from "@/pageMarket/components/coupon-list.vue";
import Modal from "@/pageMarket/components/modal.vue";
import * as rechargeRedemptionApi from "@/http/api/market/rechargeRedemption.js";
import { saveFileFromTemp } from "@/utils/downloadFile.js";
import {
reactive,
toRefs,
computed,
watch,
onMounted,
onUnmounted,
ref,
} from "vue";
function addCoupon() {
form.couponInfoList.push({
id: "",
num: "",
title: "",
});
}
function modelConfirm() {
ModalData.show = false;
}
const ModalData = reactive({
show: false,
title: "修改优惠券",
});
function save() {
if (form.stock === "" || form.stock === null) {
uni.showToast({
title: "请填写库存",
icon: "none",
});
return;
}
rechargeRedemptionApi.edit(form).then((res) => {
uni.showToast({
title: "修改成功",
icon: "none",
});
ModalData.show = false;
refresh();
});
}
function showModal() {
ModalData.show = true;
}
const form = reactive({
couponInfoList: [],
});
onLoad((opt) => {
const item = uni.getStorageSync("rechargeRedemption");
Object.assign(form, item);
console.log(form);
getList();
});
const query = reactive({
status: "",
code: "",
page: 1,
size: 10,
});
function copyCode(code) {
uni.setClipboardData({
data: code,
success: () => {
uni.showToast({
title: "复制成功",
icon: "none",
});
},
});
}
const list = ref([]);
const isEnd = ref(false);
function getList() {
rechargeRedemptionApi
.codeList({ ...query, redemptionId: form.id })
.then((res) => {
if (query.page == 1) {
list.value = res.records;
} else {
list.value = [...list.value, ...res.records];
}
if (query.page >= res.totalPage * 1) {
isEnd.value = true;
}
});
}
function refresh() {
isEnd.value = false;
query.page = 1;
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() {
rechargeRedemptionApi
.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) {
return;
}
query.page++;
getList();
});
</script>
<style scoped lang="scss">
.border {
border: 1rpx solid #dddfe6;
}
.search-box {
padding: 18rpx 32rpx;
}
.daochu {
border: 1rpx solid $my-main-color;
padding: 12rpx 34rpx;
border-radius: 8rpx;
white-space: nowrap;
color: $my-main-color;
min-height: 72rpx;
}
.status {
font-weight: 700;
&.status-0 {
color: #5bbc6d;
}
&.status-1 {
color: #ff895c;
}
}
.item {
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
}
:deep(.uni-input-input){
text-align: right;
}
:deep(.input-placeholder){
text-align: right;
color: #999;
font-size: 28rpx;
}
</style>

View File

@@ -0,0 +1,366 @@
<template>
<view class="min-page bg-f7 u-font-28">
<up-sticky>
<view class="bg-fff default-box-padding">
<view class="u-flex">
<image
style="width: 60rpx; height: 60rpx"
src="/pageMarket/static/images/coupon_code.png"
></image>
<view class="u-flex-1 u-flex u-p-l-24">
<view class="u-font-28 u-flex-1 u-p-r-24">
<view class="color-333 font-bold">充值兑换码 </view>
<view class="color-666 u-m-t-4 u-font-24"
>兑换码直充余额可当作礼品赠送
</view>
</view>
<up-switch
v-model="accountInfoStore.shopInfo.isProductSuggest"
size="18"
:active-value="1"
:inactive-value="0"
></up-switch>
</view>
</view>
</view>
</up-sticky>
<view class="u-p-t-60 default-box-x-padding">
<view class="u-flex u-row-between">
<view class="shop" @click="showShopModal">适用门店</view>
<view
class="u-flex status-sel u-row-between bg-fff u-line-1"
@click="showStatusModal"
>
<text class="color-999" v-if="returnStatusText == '全部'">全部</text>
<text class="color-333" v-else>{{ returnStatusText }}</text>
<up-icon name="arrow-down" size="14"></up-icon>
</view>
</view>
</view>
<view class="default-box-padding">
<view
v-for="(item, index) in list"
class="u-m-b-56 default-box-radius bg-fff default-box-padding"
>
<view class="u-flex u-row-between">
<view>
<text class="u-font-32 font-bold color-333">{{ item.name }}</text>
<text class="u-font-24 color-666 u-m-l-20"
>金额{{ item.amount }}</text
>
</view>
<view class="status" :class="['status' + item.status]">{{
item.status == 0 ? "有效" : "无效"
}}</view>
</view>
<view class="u-m-t-22 color-666 u-font-24 u-flex">
<view>
<view>{{ item.startTime }} {{ item.endTime }}</view>
<view class="u-m-t-16 u-flex">
<view>
<text>总数</text>
<text class="color-333 u-font-28 font-bold">{{
item.total
}}</text>
</view>
<view>
<text class="u-m-l-20" >库存</text>
<text class="color-333 u-font-28 font-bold">{{
item.stock
}}</text>
</view>
</view>
<!-- <view class="u-m-t-16">{{ returnCoupon(item) }}</view> -->
</view>
<view class="btn edit" @click="handleEdit(item)">查看</view>
</view>
<!-- <view class="u-flex u-row-right gap-20 u-m-t-24">
<view class="btn del" @click="handleDelete(item)">删除</view>
<view class="btn edit" @click="handleEdit(item)">查看</view>
</view> -->
</view>
</view>
<view style="height: 100rpx"></view>
<view class="fixed-bottom">
<my-button @click="go.to('PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD')"
>添加兑换码</my-button
>
</view>
<Modal
v-model="modalData.show"
:title="modalData.title"
@confirm="handleConfirm"
>
<template v-if="modalData.key == 'selShop'">
<view class="default-box-padding">
<my-shop-select
@shop-select="shopSelect"
v-model:selShops="form.shopIdList"
v-model:useType="form.useType"
></my-shop-select>
</view>
</template>
</Modal>
<u-action-sheet
:actions="actions"
cancelText="取消"
:closeOnClickAction="true"
round="6"
@close="showAction = false"
@select="selectStatus"
:show="showAction"
></u-action-sheet>
</view>
</template>
<script setup>
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
import Modal from "@/pageMarket/components/modal.vue";
import * as rechargeRedemptionApi from "@/http/api/market/rechargeRedemption.js";
import { useAccountInfoStore } from "@/store/account.js";
import go from "@/commons/utils/go.js";
const accountInfoStore = useAccountInfoStore();
import { ref, reactive, onMounted, computed, watch } from "vue";
const loadFinish = ref(false);
const form = reactive({
isEnable: 0,
useType: "all",
shopIdList:[]
});
const actions = [
{
name: "全部",
value: "",
},
{
name: "有效",
value: "0",
},
{
name: "无效",
value: "1",
},
];
const returnStatusText = computed(() => {
return actions.find((item) => item.value == query.status)?.name || "全部";
});
function returnCoupon(item) {
return item.couponInfoList
.reduce((prev, cur) => prev + cur.title + "*" + cur.num + "、", "")
.slice(0, -1);
}
const showAction = ref(false);
function selectStatus(item) {
console.log(item);
query.status = item.value;
}
function showStatusModal() {
showAction.value = true;
}
function showShopModal() {
modalData.show = true;
modalData.title = "适用门店";
modalData.key = "selShop";
}
const firstModalTime = ref(0);
const modalData = reactive({
show: false,
title: "",
key: "",
});
function handleDelete(item) {
uni.showModal({
title: "确认删除吗?",
success: (res) => {
if (res.confirm) {
rechargeRedemptionApi
.delete({
id: item.id,
})
.then((res) => {
uni.showToast({
title: "删除成功",
icon: "none",
});
refreshList();
});
}
},
});
}
const isEnd = ref(false);
const query = reactive({
pageNum: 1,
pageSize: 10,
status: "",
});
const list = ref([]);
function refreshList() {
query.pageNum = 1;
isEnd.value = false;
getList();
}
function handleEdit(item) {
uni.setStorageSync("rechargeRedemption", item);
go.to("PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD_DWTAIL", {
type: "edit",
});
}
const handleConfirm = async () => {
if (form.useType == "custom") {
if (form.shopIdList.length == 0) {
uni.showToast({
title: "请选择适用门店",
icon: "none",
});
return;
}
}
rechargeRedemptionApi.enable({
shopIdList: form.shopIdList||[],
useType: form.useType,
isEnable: form.isEnable,
});
uni.showToast({
title: "修改成功",
icon: "none",
});
modalData.show = false;
};
const getList = async () => {
loadFinish.value = false;
if (isEnd.value) {
return;
}
const res = await rechargeRedemptionApi.couponRedemptionList(query);
loadFinish.value = true;
if (query.pageNum >= res.totalPage * 1) {
isEnd.value = true;
}
if (query.pageNum == 1) {
list.value = res.records || [];
} else {
list.value = list.value.concat(res.records || []);
}
console.log(list.value);
query.pageNum++;
};
function getShopInfo() {
accountInfoStore.getShopInfo().then((res) => {
console.log(res);
});
}
watch(
() => accountInfoStore.shopInfo.isProductSuggest,
(newVal, oldVal) => {
if (!loadFinish.value) return;
accountInfoStore.editShopInfo({
isProductSuggest: newVal,
id: accountInfoStore.shopInfo.id,
});
uni.showToast({
title: "修改成功",
icon: "none",
});
}
);
watch(
() => query.status,
(newval) => {
console.log(newval);
refreshList();
}
);
async function getConfig() {
rechargeRedemptionApi.status().then((res) => {
res.shopIdList = res.shopIdList || [];
Object.assign(form, res);
});
}
onReachBottom(() => {
console.log("触底");
getList();
});
onMounted(() => {
getShopInfo();
getConfig();
});
onShow(() => {
refreshList();
});
</script>
<style lang="scss" scoped>
.status {
padding: 8rpx 18rpx;
border: 2rpx solid transparent;
border-radius: 8rpx;
&.status0 {
background-color: rgba(123, 209, 54, 0.12);
border-color: rgba(123, 209, 54, 1);
color: #7bd136;
}
&.status1 {
border-color: rgba(153, 153, 153, 1);
background-color: rgba(153, 153, 153, 0.12);
color: #999;
}
}
.btn {
padding: 8rpx 42rpx;
white-space: nowrap;
border-radius: 100rpx;
&.del {
background-color: #f7f7fa;
color: #999;
}
&.edit {
background-color: $my-main-color;
color: #fff;
}
}
.fixed-bottom {
}
.time {
margin-left: 30rpx;
padding: 4rpx 20rpx;
border: 1px solid $my-main-color;
border-radius: 8rpx;
color: $my-main-color;
}
.shop {
background-color: rgba(49, 138, 254, 0.07);
color: $my-main-color;
border: 1px solid $my-main-color;
padding: 20rpx;
border-radius: 8rpx;
}
.status-sel {
min-width: 266rpx;
padding: 18rpx 32rpx;
border: 1px solid #d9d9d9;
border-radius: 8rpx;
}
</style>