修改霸王餐页面,增加私域引流,消费返现,满减活动页面
This commit is contained in:
349
pageMarket/discountActivity/add.vue
Normal file
349
pageMarket/discountActivity/add.vue
Normal file
@@ -0,0 +1,349 @@
|
||||
<template>
|
||||
<view class="box min-page">
|
||||
<view class="container ">
|
||||
<view class="u-flex u-row-between">
|
||||
<text class="font-bold color-333">满减优惠</text>
|
||||
<button class="add" @click="addThresholds">添加</button>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="u-m-t-32 u-flex u-row-between gap-40"
|
||||
v-for="(item, index) in form.thresholds"
|
||||
:key="index"
|
||||
>
|
||||
<view class="u-flex u-flex-1">
|
||||
<text class="text-tips">满</text>
|
||||
<input
|
||||
class="my-input"
|
||||
type="number"
|
||||
v-model="item.fullAmount"
|
||||
@blur="checkFullAmount(index)"
|
||||
placeholder=""
|
||||
/>
|
||||
<text class="text-tips text-tips1">元</text>
|
||||
</view>
|
||||
<view class="u-flex u-flex-1">
|
||||
<text class="text-tips">减</text>
|
||||
<input
|
||||
class="my-input"
|
||||
type="number"
|
||||
v-model="item.discountAmount"
|
||||
@blur="checkDiscountAmount(index)"
|
||||
placeholder=""
|
||||
/>
|
||||
<text class="text-tips text-tips1">元</text>
|
||||
</view>
|
||||
<text class="color-red" @click="deleteThreshold(index)">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="container" style="padding-left: 0; padding-right: 0">
|
||||
<view class="x-padding">
|
||||
<view class="u-flex u-row-between u-m-b-32">
|
||||
<text class="font-bold color-333">活动日期</text>
|
||||
</view>
|
||||
<timeArea
|
||||
v-model:startDate="form.validStartTime"
|
||||
v-model:endDate="form.validEndTime"
|
||||
></timeArea>
|
||||
</view>
|
||||
<view class="u-m-t-32">
|
||||
<up-line ></up-line>
|
||||
</view>
|
||||
<view class="u-m-t-32 x-padding">
|
||||
<view class="u-flex u-row-between">
|
||||
<text class="font-bold color-333 u-m-b-32">可用周期</text>
|
||||
</view>
|
||||
<weekSel v-model="form.useDays"></weekSel>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-32 container">
|
||||
<view class="u-flex u-row-between">
|
||||
<text class="font-bold color-333 u-m-b-32">指定时间段</text>
|
||||
</view>
|
||||
<hourSel
|
||||
v-model:useTimeType="form.useTimeType"
|
||||
v-model:startValue="form.useStartTime"
|
||||
v-model:endValue="form.useEndTime"
|
||||
></hourSel>
|
||||
</view>
|
||||
<view class="u-m-t-32 container">
|
||||
<view class="u-flex u-row-between">
|
||||
<text class="font-bold color-333 u-m-b-32">可使用类型</text>
|
||||
</view>
|
||||
<my-dine-types v-model="form.useType"></my-dine-types>
|
||||
</view>
|
||||
<view class="u-m-t-32 container">
|
||||
<view class="u-flex u-row-between">
|
||||
<text class="font-bold color-333 u-m-r-38">排序值</text>
|
||||
<up-input type="number" v-model="form.sort" placeholder="默认值:0" />
|
||||
</view>
|
||||
<view class="u-m-t-16 color-red u-font-24"
|
||||
>数值越大,排序越靠前。重复时段下,按照排序值最高的活动减免</view
|
||||
>
|
||||
</view>
|
||||
|
||||
<view class="container">
|
||||
<view class="u-flex u-col-center u-row-between">
|
||||
<view>
|
||||
<view class="color-333 u-font-28 font-bold">与优惠券同享</view>
|
||||
<view class="color-666 u-font-24 u-m-t-16">不能和优惠券同时使用</view>
|
||||
</view>
|
||||
<up-switch
|
||||
:activeValue="1"
|
||||
:inactiveValue="0"
|
||||
v-model="form.couponShare"
|
||||
size="18"
|
||||
></up-switch>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32 u-col-center u-row-between">
|
||||
<view>
|
||||
<view class="color-333 u-font-28 font-bold">与限时折扣同享</view>
|
||||
<view class="color-666 u-font-24 u-m-t-16"
|
||||
>开启后,计算门槛时将会按照折扣价计算</view
|
||||
>
|
||||
</view>
|
||||
<up-switch
|
||||
:activeValue="1"
|
||||
:inactiveValue="0"
|
||||
v-model="form.discountShare"
|
||||
size="18"
|
||||
></up-switch>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32 u-col-center u-row-between">
|
||||
<view>
|
||||
<view class="color-333 u-font-28 font-bold"
|
||||
>与会员价/会员折扣同享</view
|
||||
>
|
||||
<view class="color-666 u-font-24 u-m-t-16"
|
||||
>开启后,计算门槛时将会按照会员价/会员折扣价计算</view
|
||||
>
|
||||
</view>
|
||||
<up-switch
|
||||
:activeValue="1"
|
||||
:inactiveValue="0"
|
||||
v-model="form.vipPriceShare"
|
||||
size="18"
|
||||
></up-switch>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32 u-col-center u-row-between">
|
||||
<view>
|
||||
<view class="color-333 u-font-28 font-bold">与积分 抵扣同享</view>
|
||||
<view class="color-666 u-font-24 u-m-t-16"
|
||||
>开启后,可和积分抵扣同时使用</view
|
||||
>
|
||||
</view>
|
||||
<up-switch
|
||||
:activeValue="1"
|
||||
:inactiveValue="0"
|
||||
v-model="form.pointsShare"
|
||||
size="18"
|
||||
></up-switch>
|
||||
</view>
|
||||
</view>
|
||||
<bottomBtnGroup @save="save" @cancel="cancel"></bottomBtnGroup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import timeArea from "./components/time-area.vue";
|
||||
import weekSel from "./components/week-sel.vue";
|
||||
import hourSel from "./components/hour-area.vue";
|
||||
import bottomBtnGroup from "./components/bottom-btn-group.vue";
|
||||
import { reactive } from "vue";
|
||||
import * as discountActivityApi from "@/http/api/market/discountActivity.js";
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
onReachBottom,
|
||||
onBackPress,
|
||||
} from "@dcloudio/uni-app";
|
||||
|
||||
const form = reactive({
|
||||
thresholds: [],
|
||||
validStartTime: "",
|
||||
validEndTime: "",
|
||||
useDays: ['周一','周二','周三','周四','周五','周六','周日'],
|
||||
useTimeType: "all",
|
||||
useStartTime: "",
|
||||
useEndTime: "",
|
||||
useType: [],
|
||||
sort: 0,
|
||||
couponShare: 0,
|
||||
discountShare: 0,
|
||||
vipPriceShare: 0,
|
||||
pointsShare: 0,
|
||||
});
|
||||
function addThresholds() {
|
||||
form.thresholds.push({
|
||||
fullAmount: 0,
|
||||
discountAmount: 0,
|
||||
});
|
||||
}
|
||||
|
||||
function checkFullAmount(index){
|
||||
if(form.thresholds[index].fullAmount<=0){
|
||||
form.thresholds[index].fullAmount = 0;
|
||||
}
|
||||
console.log(form.thresholds[index].fullAmount);
|
||||
}
|
||||
function checkDiscountAmount(index){
|
||||
const { fullAmount, discountAmount } = form.thresholds[index];
|
||||
if(discountAmount<=0){
|
||||
form.thresholds[index].discountAmount = 0;
|
||||
}
|
||||
if(discountAmount>=fullAmount){
|
||||
form.thresholds[index].discountAmount = fullAmount;
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
console.log(form);
|
||||
const submitData = {
|
||||
...form,
|
||||
useDays: form.useDays.join(","),
|
||||
useType: form.useType.join(","),
|
||||
validStartTime:form.validStartTime,
|
||||
validEndTime:form.validEndTime
|
||||
// validStartTime:'',
|
||||
// validEndTime:'',
|
||||
};
|
||||
if(!submitData.thresholds.length){
|
||||
uni.showToast({
|
||||
title: "请添加门槛",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
return
|
||||
}
|
||||
if(!submitData.useDays.length){
|
||||
uni.showToast({
|
||||
title: "请选择可使用的周几",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
return
|
||||
}
|
||||
if(!submitData.useTimeType){
|
||||
uni.showToast({
|
||||
title: "请选择可使用的时间类型",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
return
|
||||
}
|
||||
if(!submitData.validStartTime || !submitData.validEndTime){
|
||||
uni.showToast({
|
||||
title: "请选择活动日期",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
return
|
||||
}
|
||||
if(submitData.useTimeType!='all'){
|
||||
if(!submitData.useStartTime || !submitData.useEndTime){
|
||||
uni.showToast({
|
||||
title: "请选择可使用的时间",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
return
|
||||
}
|
||||
}
|
||||
const res = !form.id
|
||||
? await discountActivityApi.add(submitData)
|
||||
:await discountActivityApi.update(submitData);
|
||||
uni.showToast({
|
||||
title: submitData.id ? "更新成功" : "添加成功",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
success: function () {
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 2000);
|
||||
},
|
||||
});
|
||||
}
|
||||
function cancel() {
|
||||
uni.navigateBack();
|
||||
}
|
||||
|
||||
function deleteThreshold(index) {
|
||||
form.thresholds.splice(index, 1);
|
||||
}
|
||||
function setForm(data) {
|
||||
data.useDays = data.useDays.split(",");
|
||||
data.useType = data.useType.split(",");
|
||||
data.validStartTime = data.validStartTime.split(" ")[0];
|
||||
data.validEndTime = data.validEndTime.split(" ")[0];
|
||||
Object.assign(form, data);
|
||||
console.log(form);
|
||||
}
|
||||
onLoad((opt) => {
|
||||
if(!opt.id){
|
||||
return
|
||||
}
|
||||
const data = uni.getStorageSync("discountActivity");
|
||||
if (data) {
|
||||
setForm(data);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.x-padding {
|
||||
padding: 0 24rpx;
|
||||
}
|
||||
.text-tips {
|
||||
color: #999999;
|
||||
font-size: 14px;
|
||||
padding: 0 28rpx;
|
||||
border-radius: 6rpx 0 0 6rpx;
|
||||
border: 2rpx solid #d9d9d9;
|
||||
background-color: #f7f7fa;
|
||||
line-height: 60rpx;
|
||||
}
|
||||
.text-tips1 {
|
||||
border-radius: 0 6rpx 6rpx 0;
|
||||
}
|
||||
.gap-40 {
|
||||
gap: 40rpx;
|
||||
}
|
||||
.my-input {
|
||||
border: 2rpx solid #d9d9d9;
|
||||
height: 60rpx;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 0 2px;
|
||||
font-size: 14px;
|
||||
|
||||
}
|
||||
.box {
|
||||
padding: 32rpx 28rpx 0 28rpx;
|
||||
font-size: 28rpx;
|
||||
background: #f7f7f7;
|
||||
}
|
||||
.container {
|
||||
background: #fff;
|
||||
padding: 32rpx 24rpx;
|
||||
margin-top: 32rpx;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.add {
|
||||
padding: 0 32rpx;
|
||||
border-radius: 60rpx;
|
||||
background: #318afe;
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
line-height: 56rpx;
|
||||
margin: 0;
|
||||
}
|
||||
.color-red {
|
||||
color: #ff2f2f;
|
||||
}
|
||||
</style>
|
||||
29
pageMarket/discountActivity/components/bottom-btn-group.vue
Normal file
29
pageMarket/discountActivity/components/bottom-btn-group.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<view>
|
||||
<view style="height: 180rpx"></view>
|
||||
|
||||
<view class="fixed-bottom u-flex gap-20">
|
||||
<view class="u-flex-1">
|
||||
<my-button type="primary" @click="save" shape="circle">
|
||||
保存
|
||||
</my-button>
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
<my-button bgColor="#fff" type="default" @click="cancel" shape="circle">
|
||||
取消
|
||||
</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const emit= defineEmits(["save", "cancel"]);
|
||||
|
||||
function save() {
|
||||
emit("save");
|
||||
}
|
||||
function cancel() {
|
||||
emit("cancel");
|
||||
}
|
||||
</script>
|
||||
111
pageMarket/discountActivity/components/hour-area.vue
Normal file
111
pageMarket/discountActivity/components/hour-area.vue
Normal file
@@ -0,0 +1,111 @@
|
||||
<template>
|
||||
<view >
|
||||
<up-radio-group v-model="useTimeType" placement="row">
|
||||
<up-radio
|
||||
v-for="item in useTimeTypeList"
|
||||
:key="item.value"
|
||||
:value="item.value"
|
||||
:name="item.value"
|
||||
:label="item.label"
|
||||
></up-radio>
|
||||
</up-radio-group>
|
||||
|
||||
<view class="u-flex u-m-t-30 box" v-if="useTimeType=='custom'">
|
||||
<view class="u-flex u-flex-1">
|
||||
<view class="item " @click="pirckerShow(startValue, 'startValue')">
|
||||
<text class="u-m-r-12" v-if="!startValue">开始时间</text>
|
||||
<text class="u-m-r-12" v-else>{{ startValue }}</text>
|
||||
</view>
|
||||
<view class="u-m-l-8 u-m-r-8" style="padding: 0 30rpx;">—</view>
|
||||
<view class="item " @click="pirckerShow(endValue, 'endValue')">
|
||||
<text class="u-m-r-12" v-if="!endValue">结束时间</text>
|
||||
<text class="u-m-r-12" v-else>{{ endValue }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<up-icon name="clock"></up-icon>
|
||||
</view>
|
||||
|
||||
<up-datetime-picker
|
||||
:show="show"
|
||||
v-model="value1"
|
||||
closeOnClickOverlay
|
||||
@close="close"
|
||||
@cancel="close"
|
||||
@confirm="confirm"
|
||||
mode="time"
|
||||
></up-datetime-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
const useTimeType = defineModel("useTimeType", {
|
||||
type: String,
|
||||
default: "all",
|
||||
});
|
||||
const useTimeTypeList = [
|
||||
{
|
||||
value: "all",
|
||||
label: "全时段可用",
|
||||
},
|
||||
{
|
||||
value: "custom",
|
||||
label: "指定时间段可用",
|
||||
},
|
||||
];
|
||||
import dayjs from "dayjs";
|
||||
const startValue = defineModel("startValue", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
const endValue = defineModel("endValue", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
const value1 = ref('');
|
||||
const show = ref(false);
|
||||
const nowKey = ref("");
|
||||
|
||||
function pirckerShow(date, key) {
|
||||
nowKey.value = key;
|
||||
show.value = true;
|
||||
value1.value = date||''
|
||||
}
|
||||
|
||||
function confirm(e) {
|
||||
console.log(e);
|
||||
|
||||
if (nowKey.value == "startValue") {
|
||||
startValue.value=e.value
|
||||
} else if (nowKey.value == "endValue") {
|
||||
endValue.value = e.value;
|
||||
}
|
||||
value1.value = e.value;
|
||||
show.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 48rpx;
|
||||
padding: 0 12rpx;
|
||||
display: flex;
|
||||
|
||||
}
|
||||
.box{
|
||||
border: 2rpx solid #dddfe6;
|
||||
padding: 16rpx 30rpx;
|
||||
box-sizing: border-box;
|
||||
width: 564rpx;
|
||||
border-radius: 4rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
79
pageMarket/discountActivity/components/time-area.vue
Normal file
79
pageMarket/discountActivity/components/time-area.vue
Normal file
@@ -0,0 +1,79 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="u-flex">
|
||||
<view class="item" @click="pirckerShow(startDate, 'startDate')">
|
||||
<text class="u-m-r-12" v-if="!startDate">请选择日期范围</text>
|
||||
<text class="u-m-r-12" v-else>{{ startDate }}</text>
|
||||
<up-icon name="arrow-down" size="14"></up-icon>
|
||||
</view>
|
||||
<view class="u-m-l-8 u-m-r-8">—</view>
|
||||
<view class="item" @click="pirckerShow(endDate, 'endDate')">
|
||||
<text class="u-m-r-12" v-if="!endDate">请选择日期范围</text>
|
||||
<text class="u-m-r-12" v-else>{{ endDate }}</text>
|
||||
<up-icon name="arrow-down" size="14"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<up-datetime-picker
|
||||
:show="show"
|
||||
v-model="value1"
|
||||
closeOnClickOverlay
|
||||
@close="close"
|
||||
@cancel="close"
|
||||
@confirm="confirm"
|
||||
mode="date"
|
||||
></up-datetime-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import dayjs from "dayjs";
|
||||
const startDate = defineModel("startDate", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
const endDate = defineModel("endDate", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
|
||||
const minDate = ref(0);
|
||||
const maxDate = ref(dayjs().add(80, "year").valueOf());
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
const value1 = ref(Date.now());
|
||||
const show = ref(false);
|
||||
const nowKey = ref("");
|
||||
|
||||
function pirckerShow(date, key) {
|
||||
nowKey.value = key;
|
||||
console.log(date);
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
function confirm(e) {
|
||||
console.log(e);
|
||||
|
||||
if (nowKey.value == "startDate") {
|
||||
startDate.value = dayjs(e.value).format("YYYY-MM-DD");
|
||||
} else if (nowKey.value == "endDate") {
|
||||
endDate.value = dayjs(e.value).format("YYYY-MM-DD");
|
||||
}
|
||||
value1.value = e.value
|
||||
show.value = false;
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 64rpx;
|
||||
border: 2rpx solid #dddfe6;
|
||||
padding: 0 12rpx;
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
57
pageMarket/discountActivity/components/week-sel.vue
Normal file
57
pageMarket/discountActivity/components/week-sel.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<view>
|
||||
<up-checkbox-group v-model="selectedWeek" :options="week">
|
||||
<up-checkbox
|
||||
:customStyle="customStyle"
|
||||
v-for="item in week"
|
||||
:key="item.value"
|
||||
:value="item.value"
|
||||
:name="item.value"
|
||||
:label="item.value"
|
||||
>{{ item.name }}</up-checkbox>
|
||||
</up-checkbox-group>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
|
||||
const customStyle={
|
||||
marginRight: '40rpx',
|
||||
marginBottom: '16rpx',
|
||||
}
|
||||
|
||||
const selectedWeek=defineModel({
|
||||
type: Array,
|
||||
default: () => [],
|
||||
});
|
||||
const week = ref([
|
||||
{
|
||||
name: "周一",
|
||||
value:"周一",
|
||||
},
|
||||
{
|
||||
name: "周二",
|
||||
value:"周二",
|
||||
},
|
||||
{
|
||||
name: "周三",
|
||||
value:"周三",
|
||||
},
|
||||
{
|
||||
name: "周四",
|
||||
value:"周四",
|
||||
},
|
||||
{
|
||||
name: "周五",
|
||||
value:"周五",
|
||||
},
|
||||
{
|
||||
name: "周六",
|
||||
value:"周六",
|
||||
},
|
||||
{
|
||||
name: "周日",
|
||||
value:"周日",
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
197
pageMarket/discountActivity/index.vue
Normal file
197
pageMarket/discountActivity/index.vue
Normal file
@@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<view class="box min-page">
|
||||
<view class="top">
|
||||
<my-button type="primary" height="72" @click="toAdd"
|
||||
>添加满减活动</my-button
|
||||
>
|
||||
</view>
|
||||
<view class="list u-font-28">
|
||||
<view class="u-m-t-32 item" v-for="item in list" :key="item.id">
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="color-999 u-font-24">
|
||||
<text> ID:{{ item.id }} </text>
|
||||
<text class="u-m-l-24"> 优先级:{{ item.sort }} </text>
|
||||
</view>
|
||||
<view class="tag success">进行中</view>
|
||||
</view>
|
||||
<view class="coor-333 font-bold u-m-t-16"
|
||||
>活动日期:{{ returnActivityDate(item) }}</view
|
||||
>
|
||||
<view class="u-font-24 color-666 u-m-t-16 u-flex u-row-between">
|
||||
<text class="no-wrap"> {{ returnActivityWeek(item) }}</text>
|
||||
<text class="no-wrap"> {{ returnCanUseTime(item) }}</text>
|
||||
</view>
|
||||
<view class="u-m-t-26">
|
||||
<u-line ></u-line>
|
||||
</view>
|
||||
<view class="color-333 u-m-t-24">
|
||||
<view>活动内容:</view>
|
||||
<view>{{ returnActivityContent(item) }}</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-right u-m-t-26" style="gap: 16rpx">
|
||||
<button class="my-btn edit-btn" @click="toEdit(item)">编辑</button>
|
||||
<button
|
||||
class="my-btn delete-btn"
|
||||
@click="deleteDiscountActivity(item)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-30">
|
||||
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
onReachBottom,
|
||||
onBackPress,
|
||||
} from "@dcloudio/uni-app";
|
||||
import { ref, onMounted } from "vue";
|
||||
import * as discountActivityApi from "@/http/api/market/discountActivity.js";
|
||||
import { is } from "immutable";
|
||||
|
||||
const list = ref([]);
|
||||
const pageNum = ref(1);
|
||||
const isEnd = ref(false);
|
||||
|
||||
async function getList() {
|
||||
const res = await discountActivityApi.getList({
|
||||
pageNum: pageNum.value,
|
||||
pageSize: 10,
|
||||
});
|
||||
if (res) {
|
||||
if( pageNum.value==1){
|
||||
list.value = res.records || [];
|
||||
}else{
|
||||
list.value = [...list.value, ...res.records || []];
|
||||
}
|
||||
isEnd.value = pageNum.value >= res.totalPage * 1 ? true : false;
|
||||
console.log(isEnd.value);
|
||||
}
|
||||
}
|
||||
|
||||
function returnActivityDate(item) {
|
||||
return `${item.validStartTime.split(" ")[0]} 至 ${
|
||||
item.validEndTime.split(" ")[0]
|
||||
}`;
|
||||
}
|
||||
function returnActivityWeek(item) {
|
||||
if (!item.useDays.length) {
|
||||
return "每天都不可用";
|
||||
}
|
||||
return "每" + item.useDays.replaceAll(",", "、");
|
||||
}
|
||||
function returnCanUseTime(item) {
|
||||
if (item.useTimeType != "all") {
|
||||
return `${item.useStartTime} 至 ${item.useEndTime}`;
|
||||
} else {
|
||||
return "全天可用";
|
||||
}
|
||||
}
|
||||
|
||||
function returnActivityContent(item) {
|
||||
return item.thresholds
|
||||
.map((cur) => {
|
||||
return `满${cur.fullAmount}减${cur.discountAmount}`;
|
||||
}, "")
|
||||
.join("、");
|
||||
}
|
||||
function toAdd() {
|
||||
clearDiscountActivity();
|
||||
uni.navigateTo({
|
||||
url: "/pageMarket/discountActivity/add",
|
||||
});
|
||||
}
|
||||
function clearDiscountActivity() {
|
||||
uni.removeStorageSync("discountActivity");
|
||||
}
|
||||
function toEdit(item) {
|
||||
uni.setStorageSync("discountActivity", { ...item });
|
||||
uni.navigateTo({
|
||||
url: "/pageMarket/discountActivity/add?id=" + item.id,
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDiscountActivity(item) {
|
||||
uni.showModal({
|
||||
title: "确认删除",
|
||||
content: `是否确认删除?`,
|
||||
success: async (res) => {
|
||||
console.log(res);
|
||||
if (res.confirm) {
|
||||
const res = await discountActivityApi.del(item.id);
|
||||
uni.showToast({
|
||||
title: "删除成功",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
success: function () {
|
||||
getList();
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
onReachBottom(() => {
|
||||
if (!isEnd.value) {
|
||||
pageNum.value++;
|
||||
getList();
|
||||
}
|
||||
});
|
||||
onShow(() => {
|
||||
pageNum.value = 1;
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.box {
|
||||
padding: 0 30rpx;
|
||||
background: #f7f7f7;
|
||||
}
|
||||
.top {
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
.list {
|
||||
.item {
|
||||
padding: 32rpx 24rpx;
|
||||
border-radius: 14rpx;
|
||||
background-color: #fff;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
.tag {
|
||||
border-radius: 12rpx;
|
||||
padding: 8rpx 22rpx;
|
||||
font-size: 28rpx;
|
||||
&.success {
|
||||
background-color: #edfff0;
|
||||
color: #5bbc6d;
|
||||
}
|
||||
&.end {
|
||||
background-color: #f7f7f7;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
.my-btn {
|
||||
font-size: 28rpx;
|
||||
line-height: 36rpx;
|
||||
padding: 8rpx 32rpx;
|
||||
border-radius: 12rpx;
|
||||
margin: 0;
|
||||
}
|
||||
.edit-btn {
|
||||
background: #e6f0ff;
|
||||
color: $my-main-color;
|
||||
}
|
||||
.delete-btn {
|
||||
background: #ffe7e6;
|
||||
color: #ff1c1c;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user