增加添加券兑换码页面
This commit is contained in:
173
pageMarket/couponExchangeCode/add.vue
Normal file
173
pageMarket/couponExchangeCode/add.vue
Normal file
@@ -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>
|
||||
351
pageMarket/couponExchangeCode/index.vue
Normal file
351
pageMarket/couponExchangeCode/index.vue
Normal 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("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>
|
||||
Reference in New Issue
Block a user