完成智慧充值模块
This commit is contained in:
@@ -1,28 +1,16 @@
|
||||
<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)">
|
||||
<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"
|
||||
@@ -30,172 +18,169 @@
|
||||
></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>
|
||||
<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";
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
const modelValue = defineModel({
|
||||
type: String,
|
||||
default: "",
|
||||
type: String,
|
||||
default: ''
|
||||
});
|
||||
const show = defineModel("show", {
|
||||
type: String,
|
||||
default: "",
|
||||
const show = defineModel('show', {
|
||||
type: String,
|
||||
default: ''
|
||||
});
|
||||
const couponName = defineModel("couponName", {
|
||||
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: () => [],
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '选择优惠券'
|
||||
},
|
||||
confirmText: {
|
||||
type: String,
|
||||
default: '确认'
|
||||
},
|
||||
cancelText: {
|
||||
type: String,
|
||||
default: '取消'
|
||||
},
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
});
|
||||
|
||||
const selGoods = ref("");
|
||||
const selGoods = ref('');
|
||||
function itemClick(item) {
|
||||
if (selGoods.value && selGoods.value.id == item.id) {
|
||||
selGoods.value = "";
|
||||
return;
|
||||
}
|
||||
selGoods.value = 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;
|
||||
scrollTop.value = e.detail.scrollTop;
|
||||
}
|
||||
function preview(item) {
|
||||
uni.previewImage({
|
||||
urls: item.images || [item.coverImg],
|
||||
});
|
||||
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;
|
||||
}
|
||||
}
|
||||
() => 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;
|
||||
}
|
||||
}
|
||||
() => 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;
|
||||
show.value = false;
|
||||
}
|
||||
|
||||
const emit = defineEmits(["confirm"]);
|
||||
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);
|
||||
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;
|
||||
background: #fff;
|
||||
width: 640rpx;
|
||||
border-radius: 18rpx;
|
||||
}
|
||||
.top {
|
||||
padding: 40rpx 48rpx;
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
display: flex;
|
||||
padding: 24rpx;
|
||||
align-items: center;
|
||||
border-radius: 8rpx;
|
||||
border: 2rpx solid #d9d9d9;
|
||||
background: #fff;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,92 +1,79 @@
|
||||
<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>
|
||||
<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 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">{{ tips }}</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";
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import chooseCoupon from './choose-coupon.vue';
|
||||
import { couponPage } from '@/http/api/market/index.js';
|
||||
|
||||
const props = defineProps({
|
||||
tips: {
|
||||
type: String,
|
||||
default: '张/1个码'
|
||||
}
|
||||
});
|
||||
|
||||
const chooseCouponData = reactive({
|
||||
couponId: "",
|
||||
show: false,
|
||||
index: -1,
|
||||
item: null,
|
||||
couponId: '',
|
||||
show: false,
|
||||
index: -1,
|
||||
item: null
|
||||
});
|
||||
const modelValue = defineModel({
|
||||
type: Array,
|
||||
default: () => [],
|
||||
type: Array,
|
||||
default: () => []
|
||||
});
|
||||
const couponList = ref([]);
|
||||
function showCoupon(item, index) {
|
||||
chooseCouponData.couponId = item ? item.id : "";
|
||||
chooseCouponData.show = true;
|
||||
chooseCouponData.index = index;
|
||||
chooseCouponData.item = item;
|
||||
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;
|
||||
modelValue.value[chooseCouponData.index].id = e.id;
|
||||
modelValue.value[chooseCouponData.index].title = e.title;
|
||||
}
|
||||
function removeCoupon(index) {
|
||||
modelValue.value.splice(index, 1);
|
||||
modelValue.value.splice(index, 1);
|
||||
}
|
||||
onMounted(() => {
|
||||
couponPage({ size: 999 }).then((res) => {
|
||||
couponList.value = res.records;
|
||||
});
|
||||
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;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,174 +1,146 @@
|
||||
<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="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>
|
||||
<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";
|
||||
|
||||
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,
|
||||
});
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}
|
||||
|
||||
const form = reactive({
|
||||
name: "",
|
||||
startTime: "",
|
||||
endTime: "",
|
||||
stock: "",
|
||||
total: 0,
|
||||
couponInfoList: [
|
||||
{
|
||||
id: "",
|
||||
num: "",
|
||||
title: "",
|
||||
},
|
||||
],
|
||||
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.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.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);
|
||||
});
|
||||
//判断优惠券列表是否选择了优惠券,数量是否填写
|
||||
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: "",
|
||||
});
|
||||
form.couponInfoList.push({
|
||||
id: '',
|
||||
num: '',
|
||||
title: ''
|
||||
});
|
||||
}
|
||||
const options = reactive({});
|
||||
onLoad((opt) => {});
|
||||
@@ -176,16 +148,16 @@ onLoad((opt) => {});
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.my-hour-area .container) {
|
||||
padding: 32rpx 28rpx;
|
||||
background-color: #f7f7f7;
|
||||
border-radius: 8rpx;
|
||||
margin-top: 16rpx;
|
||||
padding: 32rpx 28rpx;
|
||||
background-color: #f7f7f7;
|
||||
border-radius: 8rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
:deep(.my-hour-area .box) {
|
||||
margin-top: 0 !important;
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
:deep(.fixed-bottom) {
|
||||
left: 110rpx;
|
||||
right: 110rpx;
|
||||
left: 110rpx;
|
||||
right: 110rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<u-loadmore :status="tableData.status"></u-loadmore>
|
||||
<my-footer-btn @confirm="go.to('PAGES_LIMIT_DISCOUNT_ADD')"></my-footer-btn>
|
||||
<my-footer-btn confirmText="添加" @confirm="go.to('PAGES_LIMIT_DISCOUNT_ADD')"></my-footer-btn>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user