增加添加券兑换码页面
This commit is contained in:
parent
ce3674be35
commit
0ad4b5daa7
|
|
@ -495,7 +495,7 @@
|
|||
right: 0;
|
||||
bottom: 0;
|
||||
top: 0;
|
||||
z-index: 999;
|
||||
z-index: 9999;
|
||||
background-color: rgba(51, 51, 51, .5);
|
||||
|
||||
.item {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
import http from "@/http/http.js";
|
||||
const request = http.request;
|
||||
const urlType = "market";
|
||||
|
||||
export function enable(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/couponRedemption/enable`,
|
||||
method: "PUT",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function status(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/couponRedemption/enable/status`,
|
||||
method: "get",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
export function couponRedemption(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/couponRedemption`,
|
||||
method: "get",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
export function couponRedemptionList(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/couponRedemption/list`,
|
||||
method: "get",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
export function add(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/couponRedemption`,
|
||||
method: "POST",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
export function edit(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/couponRedemption`,
|
||||
method: "PUT",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
export function codeList(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/couponRedemption/code/list`,
|
||||
method: "GET",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
export function codeExport(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/couponRedemption/code/export`,
|
||||
method: "GET",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"module": "ESNext",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"] // 适配 uni-app 的 @ 路径别名(关键,避免导入路径报错)
|
||||
},
|
||||
"jsx": "preserve",
|
||||
"allowJs": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"pages.json",
|
||||
"uni.pages.json" // 包含 uni-app 配置文件,让 Vetur 识别页面结构
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"unpackage" // 排除编译产物和依赖目录
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
<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
|
||||
: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.name }}</text>
|
||||
</view>
|
||||
<text class="u-font-32 color-red u-p-l-30"
|
||||
>¥{{ item.lowPrice }}</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</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";
|
||||
import { getCouponList } from "@/http/api/coupon.js";
|
||||
const modelValue = defineModel({
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
const show = defineModel("show", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
const goodsName = defineModel("goodsName", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: "选择优惠券",
|
||||
},
|
||||
confirmText: {
|
||||
type: String,
|
||||
default: "确认",
|
||||
},
|
||||
cancelText: {
|
||||
type: String,
|
||||
default: "取消",
|
||||
},
|
||||
});
|
||||
|
||||
const selGoods = ref("");
|
||||
function itemClick(item) {
|
||||
if (selGoods.value && selGoods.value.id == item.id) {
|
||||
selGoods.value = "";
|
||||
return;
|
||||
}
|
||||
selGoods.value = item;
|
||||
}
|
||||
const list = ref([]);
|
||||
|
||||
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 = list.value.find((item) => item.id == newVal);
|
||||
console.log(selGoods.value);
|
||||
if (selGoods.value) {
|
||||
goodsName.value = selGoods.value.name;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => list.value.length,
|
||||
(newVal, oldVal) => {
|
||||
selGoods.value = list.value.find((item) => item.id == modelValue.value);
|
||||
console.log(selGoods.value);
|
||||
if (selGoods.value) {
|
||||
modelValue.value = selGoods.value.id;
|
||||
goodsName.value = selGoods.value.name;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
function confirm() {
|
||||
if (!selGoods.value) {
|
||||
uni.showToast({
|
||||
title: "请选择优惠券",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
modelValue.value = selGoods.value.id;
|
||||
show.value = false;
|
||||
}
|
||||
onMounted(() => {
|
||||
getCouponList().then((res) => {
|
||||
list.value = res;
|
||||
});
|
||||
});
|
||||
</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>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<template>
|
||||
<view>
|
||||
|
||||
|
||||
<chooseCoupon v-model="chooseCouponData.couponId" :show="chooseCouponData.show"></chooseCoupon>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive } from "vue";
|
||||
import chooseCoupon from "./choose-coupon.vue";
|
||||
const chooseCouponData=reactive({
|
||||
couponId:'',
|
||||
show:true
|
||||
})
|
||||
const modelValue = defineModel({
|
||||
type: Array,
|
||||
default: () => [],
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
|
|
@ -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>
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
<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.title"
|
||||
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">优惠券</view>
|
||||
<view class="u-m-t-16 u-p-b-24">
|
||||
<CouponList v-model="form.couponInfoList"></CouponList>
|
||||
</view>
|
||||
<up-line></up-line>
|
||||
<view class="font-bold u-m-t-24 u-m-b-16">指定时间段可用</view>
|
||||
<view class="my-hour-area">
|
||||
<my-hour-area
|
||||
v-model:useTimeType="form.useTimeType"
|
||||
v-model:startValue="form.useStartTime"
|
||||
v-model:endValue="form.useEndTime"
|
||||
></my-hour-area>
|
||||
</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 suggestApi from "@/http/api/market/suggest.js";
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
onReachBottom,
|
||||
onBackPress,
|
||||
} from "@dcloudio/uni-app";
|
||||
|
||||
const form = reactive({
|
||||
useStartTime: "",
|
||||
useTimeType: "all",
|
||||
useEndTime: "",
|
||||
startTime:'',
|
||||
endTime:'',
|
||||
couponInfoList: [],
|
||||
});
|
||||
|
||||
function save() {
|
||||
if (!form.title) {
|
||||
uni.showToast({
|
||||
title: "请输入模版名称",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (form.useTimeType == "custom") {
|
||||
if (!form.useStartTime) {
|
||||
uni.showToast({
|
||||
title: "请选择开始时间",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!form.useEndTime) {
|
||||
uni.showToast({
|
||||
title: "请选择结束时间",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (form.useDays.length == 0) {
|
||||
uni.showToast({
|
||||
title: "请选择可用周期",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!form.foods) {
|
||||
uni.showToast({
|
||||
title: "请选择商品",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(options.type=='edit'){
|
||||
suggestApi
|
||||
.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
|
||||
}
|
||||
suggestApi
|
||||
.addSuggest({
|
||||
title: form.title,
|
||||
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);
|
||||
});
|
||||
}
|
||||
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>
|
||||
|
|
@ -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("suggestItem", item);
|
||||
go.to("PAGES_MARKET_ORDER_RECOMMENDATION_ADD", {
|
||||
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>
|
||||
|
|
@ -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 |
16
pages.json
16
pages.json
|
|
@ -712,7 +712,23 @@
|
|||
"style": {
|
||||
"navigationBarTitleText": "添加"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_MARKET_COUPON_EXCHANGE_CODE",
|
||||
"path": "couponExchangeCode/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "券兑换码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_MARKET_COUPON_EXCHANGE_CODE_ADD",
|
||||
"path": "couponExchangeCode/add",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加券兑换码"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ const menuList = ref([
|
|||
{
|
||||
title: '券兑换码',
|
||||
icon: '',
|
||||
pageUrl: '',
|
||||
pageUrl: 'PAGES_MARKET_COUPON_EXCHANGE_CODE',
|
||||
intro: '可添加多券组合兑换'
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue