This commit is contained in:
gyq
2025-11-21 16:03:10 +08:00
17 changed files with 1939 additions and 254 deletions

View File

@@ -0,0 +1,201 @@
<template>
<view class="">
<up-popup :show="show" mode="bottom">
<view class="">
<view class="top u-flex u-row-between">
<text class="font-bold u-font-32 color-333">{{ title }}</text>
<up-icon size="18" name="close" @click="show = false"></up-icon>
</view>
<scroll-view
ref="couponScroll"
:scroll-y="true"
style="max-height: 50vh"
@scroll="scroll"
:scroll-top="scrollTop"
>
<view
v-for="(item, index) in list"
:key="index"
class="item"
@click="itemClick(item)"
:class="[selGoods && selGoods.id == item.id ? 'selected' : '']"
>
<view class="u-flex u-row-between">
<view class="u-flex gap-20">
<!-- <view class="u-flex" @click.stop="preview(item)">
<up-image
:src="item.coverImg"
width="80rpx"
height="80rpx"
></up-image>
</view> -->
<text class="u-font-32 color-333">{{ item.title }}</text>
</view>
<text class="u-font-32 color-red u-p-l-30"
></text
>
</view>
</view>
<up-empty v-if="list.length == 0" class="u-p-30" text="暂无数据"></up-empty>
</scroll-view>
<view class="bottom">
<view class="btn cancel" @click="close">{{ cancelText }}</view>
<view class="btn success" @click="confirm">{{ confirmText }}</view>
</view>
</view>
</up-popup>
</view>
</template>
<script setup>
import { ref, onMounted, watch } from "vue";
const modelValue = defineModel({
type: String,
default: "",
});
const show = defineModel("show", {
type: String,
default: "",
});
const couponName = defineModel("couponName", {
type: String,
default: "",
});
const props = defineProps({
title: {
type: String,
default: "选择优惠券",
},
confirmText: {
type: String,
default: "确认",
},
cancelText: {
type: String,
default: "取消",
},
list: {
type: Array,
default: () => [],
},
});
const selGoods = ref("");
function itemClick(item) {
if (selGoods.value && selGoods.value.id == item.id) {
selGoods.value = "";
return;
}
selGoods.value = item;
}
const scrollTop = ref(0);
function scroll(e) {
scrollTop.value = e.detail.scrollTop;
}
function preview(item) {
uni.previewImage({
urls: item.images || [item.coverImg],
});
}
watch(
() => modelValue.value,
(newVal, oldVal) => {
console.log(newVal, oldVal);
selGoods.value = props.list.find((item) => item.id == newVal);
console.log(selGoods.value);
if (selGoods.value) {
couponName.value = selGoods.value.title;
}
}
);
watch(
() => props.list.length,
(newVal, oldVal) => {
selGoods.value = props.list.find((item) => item.id == modelValue.value);
console.log(selGoods.value);
if (selGoods.value) {
modelValue.value = selGoods.value.id;
couponName.value = selGoods.value.title;
}
}
);
function close() {
show.value = false;
}
const emit = defineEmits(["confirm"]);
function confirm() {
if (!selGoods.value) {
uni.showToast({
title: "请选择优惠券",
icon: "none",
});
return;
}
modelValue.value = selGoods.value.id;
show.value = false;
emit("confirm", selGoods.value);
}
</script>
<style lang="scss">
.popup-content {
background: #fff;
width: 640rpx;
border-radius: 18rpx;
}
.top {
padding: 40rpx 48rpx;
border-bottom: 1px solid #d9d9d9;
}
.bottom {
padding: 48rpx 52rpx;
display: flex;
justify-content: space-between;
border-top: 1px solid #d9d9d9;
gap: 50rpx;
.btn {
flex: 1;
text-align: center;
padding: 18rpx 60rpx;
border-radius: 100rpx;
font-size: 32rpx;
border: 2rpx solid transparent;
&.success {
background-color: $my-main-color;
color: #fff;
}
&.cancel {
border-color: #d9d9d9;
box-shadow: 0 4rpx 0 0 #00000005;
}
}
}
.item {
padding: 10rpx 30rpx;
border: 1px solid #d9d9d9;
margin: 10rpx;
border-radius: 8rpx;
transition: all 0.3s ease-in-out;
box-shadow: 0 0 10px transparent;
&.selected {
border-color: $my-main-color;
box-shadow: 0 0 10px $my-main-color;
}
}
.choose-goods {
display: flex;
padding: 24rpx;
align-items: center;
border-radius: 8rpx;
border: 2rpx solid #d9d9d9;
background: #fff;
font-size: 28rpx;
font-weight: 400;
}
</style>

View File

@@ -0,0 +1,92 @@
<template>
<view>
<view
class="u-flex u-row-between u-m-b-24"
style="gap: 40rpx"
v-for="(item, index) in modelValue"
:key="index"
>
<view
class="choose-coupon u-flex-1 u-flex u-row-between"
@click="showCoupon(item, index)"
>
<template v-if="item.title">
<text>{{ item.title }}</text>
<view class="u-flex" @click.stop="item.title = ''">
<up-icon name="close" size="14"></up-icon>
</view>
</template>
<template v-else>
<text class="color-999">选择赠送券</text>
<up-icon name="arrow-down" size="14"></up-icon>
</template>
</view>
<view class="u-flex-1 u-flex">
<view class="u-flex-1 choose-coupon u-flex">
<input
class="u-flex-1"
placeholder=""
type="number"
v-model="item.num"
placeholder-class="color-999 u-font-28"
/>
<text class="no-wrap color-999">/1个码</text>
</view>
<view class="u-m-l-20">
<up-icon name="minus-circle-fill" color="#EB4F4F" size="18" @click="removeCoupon(index)"></up-icon>
</view>
</view>
</view>
<chooseCoupon
v-model="chooseCouponData.couponId"
v-model:show="chooseCouponData.show"
@confirm="confirmCoupon"
:list="couponList"
></chooseCoupon>
</view>
</template>
<script setup>
import { reactive, ref, onMounted } from "vue";
import chooseCoupon from "./choose-coupon.vue";
import { couponPage } from "@/http/api/market/index.js";
const chooseCouponData = reactive({
couponId: "",
show: false,
index: -1,
item: null,
});
const modelValue = defineModel({
type: Array,
default: () => [],
});
const couponList = ref([]);
function showCoupon(item, index) {
chooseCouponData.couponId = item ? item.id : "";
chooseCouponData.show = true;
chooseCouponData.index = index;
chooseCouponData.item = item;
}
function confirmCoupon(e) {
modelValue.value[chooseCouponData.index].id = e.id;
modelValue.value[chooseCouponData.index].title = e.title;
}
function removeCoupon(index) {
modelValue.value.splice(index, 1);
}
onMounted(() => {
couponPage({ size: 999 }).then((res) => {
couponList.value = res.records;
});
});
</script>
<style lang="scss" scoped>
.choose-coupon {
padding: 10rpx 20rpx;
border-radius: 8rpx;
border: 1px solid #d9d9d9;
}
</style>

View File

@@ -0,0 +1,108 @@
<template>
<view>
<view @click="open">
<slot v-if="$slots.default"> </slot>
<view v-else class="choose-goods u-flex u-row-between">
<text class="color-999" v-if="!startTime && !endTime"
>请选择日期范围</text
>
<text class="color-333 u-font-24 u-m-r-32 " v-else
>{{ startTime }} - {{ endTime }}</text
>
<view class="u-flex" v-if="startTime&&endTime" @click.stop="clear">
<up-icon name="close" size="14"></up-icon>
</view>
<up-icon size="14" name="arrow-right" v-else ></up-icon>
</view>
</view>
<my-date-pickerview
@confirm="datePickerConfirm"
mode="all"
ref="datePicker"
></my-date-pickerview>
</view>
</template>
<script setup>
import { ref } from "vue";
const datePicker = ref(null);
const startTime = defineModel("startTime", {
default: () => "",
type: String,
});
const endTime = defineModel("endTime", {
default: () => "",
type: String,
});
function clear(){
startTime.value = "";
endTime.value = "";
}
function open() {
datePicker.value.toggle();
}
function datePickerConfirm(e) {
startTime.value = e.start;
endTime.value = e.end;
console.log(e);
}
</script>
<style lang="scss">
.popup-content {
background: #fff;
width: 640rpx;
border-radius: 18rpx;
}
.top {
padding: 40rpx 48rpx;
border-bottom: 1px solid #d9d9d9;
}
.bottom {
padding: 48rpx 52rpx;
display: flex;
justify-content: space-between;
border-top: 1px solid #d9d9d9;
gap: 50rpx;
.btn {
flex: 1;
text-align: center;
padding: 18rpx 60rpx;
border-radius: 100rpx;
font-size: 32rpx;
border: 2rpx solid transparent;
&.success {
background-color: $my-main-color;
color: #fff;
}
&.cancel {
border-color: #d9d9d9;
box-shadow: 0 4rpx 0 0 #00000005;
}
}
}
.item {
padding: 10rpx 30rpx;
border: 1px solid #d9d9d9;
margin: 10rpx;
border-radius: 8rpx;
transition: all 0.3s ease-in-out;
box-shadow: 0 0 10px transparent;
&.selected {
border-color: $my-main-color;
box-shadow: 0 0 10px $my-main-color;
}
}
.choose-goods {
display: flex;
padding: 24rpx;
align-items: center;
border-radius: 8rpx;
border: 2rpx solid #d9d9d9;
background: #fff;
font-size: 28rpx;
font-weight: 400;
min-height: 90rpx;
}
</style>

View File

@@ -1,84 +1,84 @@
<template>
<view>
<up-popup :show="show" mode="center">
<view class="popup-content">
<view class="top u-flex u-row-between">
<text class="font-bold u-font-32 color-333">{{title}}</text>
<up-icon size="18" name="close" @click="show=false"></up-icon>
</view>
<up-line></up-line>
<scroll-view style="max-height:50vh;">
<slot></slot>
</scroll-view>
<up-line></up-line>
<view>
<up-popup :show="show" mode="center">
<view class="popup-content">
<view class="top u-flex u-row-between">
<text class="font-bold u-font-32 color-333">{{ title }}</text>
<up-icon size="18" name="close" @click="show = false"></up-icon>
</view>
<up-line></up-line>
<scroll-view style="max-height: 50vh" :scroll-y="true">
<slot></slot>
</scroll-view>
<up-line></up-line>
<view class="bottom">
<view class="btn success" @click="confirm">{{confirmText}}</view>
<view class="btn cancel" @click="close">{{cancelText}}</view>
</view>
</view>
</up-popup>
</view>
<view class="bottom">
<view class="btn cancel" @click="close">{{ cancelText }}</view>
<view class="btn success" @click="confirm">{{ confirmText }}</view>
</view>
</view>
</up-popup>
</view>
</template>
<script setup>
<script setup>
import { ref } from "vue";
const props = defineProps({
title: {
type: String,
default: "标题",
},
confirmText: {
type: String,
default: "保存",
},
cancelText: {
type: String,
default: "取消",
},
title: {
type: String,
default: "标题",
},
confirmText: {
type: String,
default: "保存",
},
cancelText: {
type: String,
default: "取消",
},
});
const show = defineModel({
type: Boolean,
default: false,
})
const emits=defineEmits(['close','confirm'])
function close(){
show.value=false
emits('close')
type: Boolean,
default: false,
});
const emits = defineEmits(["close", "confirm"]);
function close() {
show.value = false;
emits("close");
}
function confirm(){
emits('confirm')
function confirm() {
emits("confirm");
}
</script>
<style lang="scss">
.popup-content{
background: #fff;
width: 640rpx;
border-radius: 18rpx;
.popup-content {
background: #fff;
width: 640rpx;
border-radius: 18rpx;
}
.top{
padding: 40rpx 48rpx;
.top {
padding: 40rpx 48rpx;
}
.bottom{
padding: 48rpx 52rpx;
display: flex;
justify-content: space-between;
gap: 50rpx;
.btn{
flex:1;
text-align: center;
padding: 18rpx 60rpx;
border-radius: 100rpx;
font-size: 32rpx;
border: 2rpx solid transparent;
&.success{
background-color: $my-main-color;
color:#fff;
}
&.cancel{
border-color:#D9D9D9;
box-shadow: 0 4rpx 0 0 #00000005;
}
.bottom {
padding: 48rpx 52rpx;
display: flex;
justify-content: space-between;
gap: 50rpx;
.btn {
flex: 1;
text-align: center;
padding: 18rpx 60rpx;
border-radius: 100rpx;
font-size: 32rpx;
border: 2rpx solid transparent;
&.success {
background-color: $my-main-color;
color: #fff;
}
&.cancel {
border-color: #d9d9d9;
box-shadow: 0 4rpx 0 0 #00000005;
}
}
}
</style>
</style>

View File

@@ -0,0 +1,191 @@
<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 class="u-m-t-24">
<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>
</view>
<view class="default-box-padding bg-fff default-box-radius u-m-t-32">
<view class="font-bold">优惠券</view>
<view class="u-m-t-16">
<CouponList v-model="form.couponInfoList"></CouponList>
</view>
<up-line></up-line>
<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>
<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 couponRedemptionApi from "@/http/api/market/couponRedemption.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: 0,
couponInfoList: [
{
id: "",
num: "",
title: "",
},
],
});
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 (options.type == "edit") {
couponRedemptionApi
.editSuggest({
title: form.title,
id: form.id,
foods: form.foods,
useDays: form.useDays.join(","),
useStartTime: form.useStartTime,
useTimeType: form.useTimeType,
useEndTime: form.useEndTime,
})
.then((res) => {
uni.showToast({
title: "修改成功",
icon: "none",
});
setTimeout(() => {
uni.navigateBack({
delta: 1,
});
}, 1500);
});
return;
}
console.log('form.couponInfoList',form.couponInfoList)
//判断优惠券列表是否选择了优惠券,数量是否填写
if (form.couponInfoList.some((item) => !item.id || !item.num)) {
uni.showToast({
title: "请选择优惠券并填写数量",
icon: "none",
});
return;
}
couponRedemptionApi.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,328 @@
<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>
<text class="color-666">{{ form.name }}</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.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.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>
<up-line></up-line>
<view class="default-box-padding u-flex u-row-between">
<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
>
</view>
</view>
<up-line></up-line>
<view class="u-p-b-24"></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 couponRedemptionApi from "@/http/api/market/couponRedemption.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() {
//判断优惠券列表是否选择了优惠券,数量是否填写
if (form.couponInfoList.some((item) => !item.id || !item.num)) {
uni.showToast({
title: "请选择优惠券并填写数量",
icon: "none",
});
return;
}
ModalData.show = false;
}
const ModalData = reactive({
show: false,
title: "修改优惠券",
});
function save() {
if (form.stock === "" || form.stock === null) {
uni.showToast({
title: "请填写库存",
icon: "none",
});
return;
}
couponRedemptionApi.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("couponRedemptionItem");
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 returnCoupon = computed(() => {
return form.couponInfoList
.reduce((prev, cur) => prev + cur.title + "*" + cur.num + "、", "")
.slice(0, -1);
});
const list = ref([]);
const isEnd = ref(false);
function getList() {
couponRedemptionApi
.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() {
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) {
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;
}
}
</style>

View File

@@ -0,0 +1,351 @@
<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">
<text class="u-font-32 font-bold color-333">{{ item.name }}</text>
<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"
>优惠券
<text class="color-333 u-font-28 font-bold">{{
item.couponNum
}}</text></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_COUPON_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 couponRedemptionApi from "@/http/api/market/couponRedemption.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",
});
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) {
couponRedemptionApi
.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("couponRedemptionItem", item);
go.to("PAGES_MARKET_COUPON_EXCHANGE_CODE_DETAIL", {
type: "edit",
});
}
const handleConfirm = async () => {
if (form.useType == "custom") {
if (form.shopIdList.length == 0) {
uni.showToast({
title: "请选择适用门店",
icon: "none",
});
return;
}
}
couponRedemptionApi.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 couponRedemptionApi.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() {
couponRedemptionApi.status().then((res) => {
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>

View File

@@ -246,7 +246,7 @@ function save() {
});
return;
}
if(form.discountType == "FIXED" && form.discountAmount == ""){
if(form.discountType == "FIXED" && !form.discountAmount ){
uni.showToast({
title:'请填写减免金额',
icon:'none'

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB