增加点餐智能推荐
This commit is contained in:
parent
bb4c2676e7
commit
ce3674be35
|
|
@ -46,4 +46,9 @@ function cancel() {
|
||||||
.zhanwei1{
|
.zhanwei1{
|
||||||
height: 240rpx;
|
height: 240rpx;
|
||||||
}
|
}
|
||||||
|
.fixed-bottom {
|
||||||
|
&.u-flex-column{
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,97 +1,118 @@
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<up-radio-group v-model="useTimeType" placement="row">
|
<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" :customStyle="customStyle"></up-radio>
|
<up-radio
|
||||||
</up-radio-group>
|
v-for="item in useTimeTypeList"
|
||||||
<view class="u-flex u-m-t-30 box" v-if="useTimeType == 'custom'">
|
:key="item.value"
|
||||||
<view class="u-flex u-flex-1">
|
:value="item.value"
|
||||||
<view class="item" @click="pirckerShow(startValue, 'startValue')">
|
:name="item.value"
|
||||||
<text class="u-m-r-12" v-if="!startValue">开始时间</text>
|
:label="item.label"
|
||||||
<text class="u-m-r-12" v-else>{{ startValue }}</text>
|
:customStyle="customStyle"
|
||||||
</view>
|
></up-radio>
|
||||||
<view class="u-m-l-8 u-m-r-8" style="padding: 0 30rpx">—</view>
|
</up-radio-group>
|
||||||
<view class="item" @click="pirckerShow(endValue, 'endValue')">
|
<view class="container" v-if="useTimeType == 'custom'">
|
||||||
<text class="u-m-r-12" v-if="!endValue">结束时间</text>
|
<view class="u-flex u-m-t-30 box" >
|
||||||
<text class="u-m-r-12" v-else>{{ endValue }}</text>
|
<view class="u-flex u-flex-1">
|
||||||
</view>
|
<view class="item" @click="pirckerShow(startValue, 'startValue')">
|
||||||
</view>
|
<text class="u-m-r-12" v-if="!startValue">开始时间</text>
|
||||||
<up-icon name="clock"></up-icon>
|
<text class="u-m-r-12" v-else>{{ startValue }}</text>
|
||||||
</view>
|
</view>
|
||||||
<up-datetime-picker :show="show" v-model="value1" closeOnClickOverlay @close="close" @cancel="close" @confirm="confirm" mode="time"></up-datetime-picker>
|
<view class="u-m-l-8 u-m-r-8" style="padding: 0 30rpx">—</view>
|
||||||
</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>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<up-datetime-picker
|
||||||
|
:show="show"
|
||||||
|
v-model="value1"
|
||||||
|
closeOnClickOverlay
|
||||||
|
@close="close"
|
||||||
|
@cancel="close"
|
||||||
|
@confirm="confirm"
|
||||||
|
mode="time"
|
||||||
|
></up-datetime-picker>
|
||||||
|
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from "vue";
|
||||||
|
function cancel(){
|
||||||
|
union.navigateBack()
|
||||||
|
}
|
||||||
const customStyle = ref({
|
const customStyle = ref({
|
||||||
marginRight: '15px'
|
marginRight: "15px",
|
||||||
});
|
});
|
||||||
|
|
||||||
const useTimeType = defineModel('useTimeType', {
|
const useTimeType = defineModel("useTimeType", {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'all'
|
default: "all",
|
||||||
});
|
});
|
||||||
const useTimeTypeList = [
|
const useTimeTypeList = [
|
||||||
{
|
{
|
||||||
value: 'all',
|
value: "all",
|
||||||
label: '全时段可用'
|
label: "全时段可用",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'custom',
|
value: "custom",
|
||||||
label: '指定时间段可用'
|
label: "指定时间段可用",
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
import dayjs from 'dayjs';
|
import dayjs from "dayjs";
|
||||||
const startValue = defineModel('startValue', {
|
const startValue = defineModel("startValue", {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: "",
|
||||||
});
|
});
|
||||||
const endValue = defineModel('endValue', {
|
const endValue = defineModel("endValue", {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
show.value = false;
|
show.value = false;
|
||||||
}
|
}
|
||||||
const value1 = ref('');
|
const value1 = ref("");
|
||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
const nowKey = ref('');
|
const nowKey = ref("");
|
||||||
|
|
||||||
function pirckerShow(date, key) {
|
function pirckerShow(date, key) {
|
||||||
nowKey.value = key;
|
nowKey.value = key;
|
||||||
show.value = true;
|
show.value = true;
|
||||||
value1.value = date || '';
|
value1.value = date || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirm(e) {
|
function confirm(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
if (nowKey.value == 'startValue') {
|
if (nowKey.value == "startValue") {
|
||||||
startValue.value = e.value;
|
startValue.value = e.value;
|
||||||
} else if (nowKey.value == 'endValue') {
|
} else if (nowKey.value == "endValue") {
|
||||||
endValue.value = e.value;
|
endValue.value = e.value;
|
||||||
}
|
}
|
||||||
value1.value = e.value;
|
value1.value = e.value;
|
||||||
show.value = false;
|
show.value = false;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.item {
|
.item {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #666;
|
color: #666;
|
||||||
line-height: 48rpx;
|
line-height: 48rpx;
|
||||||
padding: 0 12rpx;
|
padding: 0 12rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.box {
|
.box {
|
||||||
border: 2rpx solid #dddfe6;
|
border: 2rpx solid #dddfe6;
|
||||||
padding: 16rpx 30rpx;
|
padding: 16rpx 30rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 564rpx;
|
width: 564rpx;
|
||||||
border-radius: 4rpx;
|
border-radius: 4rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
<up-checkbox-group v-model="selectedWeek" :options="week">
|
<up-checkbox-group v-model="selectedWeek" :options="week">
|
||||||
<up-checkbox
|
<up-checkbox
|
||||||
:customStyle="customStyle"
|
:customStyle="customStyle"
|
||||||
|
:shape="shape"
|
||||||
v-for="item in week"
|
v-for="item in week"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
|
|
@ -19,7 +20,12 @@ const customStyle={
|
||||||
marginRight: '40rpx',
|
marginRight: '40rpx',
|
||||||
marginBottom: '16rpx',
|
marginBottom: '16rpx',
|
||||||
}
|
}
|
||||||
|
const props = defineProps({
|
||||||
|
shape: {
|
||||||
|
type: String,
|
||||||
|
default: 'square' // circle
|
||||||
|
},
|
||||||
|
});
|
||||||
const selectedWeek=defineModel({
|
const selectedWeek=defineModel({
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ export function editSuggest(params) {
|
||||||
}
|
}
|
||||||
export function deleteSuggest(params) {
|
export function deleteSuggest(params) {
|
||||||
return request({
|
return request({
|
||||||
url: urlType + `/admin/suggest`,
|
url: urlType + `/admin/suggest?id=${params.id}`,
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
params: {
|
params: {
|
||||||
...params,
|
...params,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,198 @@
|
||||||
|
<template>
|
||||||
|
<view class="">
|
||||||
|
<view @click="show = true">
|
||||||
|
<slot v-if="$slots.default"> </slot>
|
||||||
|
<view v-else class="choose-goods u-flex u-row-between">
|
||||||
|
<text class="color-999" v-if="!modelValue">请选择商品</text>
|
||||||
|
<text class="color-333 u-m-r-32 u-line-1" v-else>{{ goodsName }}</text>
|
||||||
|
<up-icon size="14" name="arrow-down"></up-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<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 { getProductList } from "@/http/api/product.js";
|
||||||
|
const show = ref(false);
|
||||||
|
const modelValue = defineModel({
|
||||||
|
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(() => {
|
||||||
|
getProductList().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>
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
<view class="">
|
||||||
<view class="color-333 u-font-32 font-bold">{{
|
<view class="color-333 u-font-32 font-bold">{{
|
||||||
item.accountPoints
|
item.consumeCount
|
||||||
}}</view>
|
}}</view>
|
||||||
|
|
||||||
<view class="u-flex u-m-t-12" style="align-items: baseline">
|
<view class="u-flex u-m-t-12" style="align-items: baseline">
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
<view
|
<view
|
||||||
class="text-center color-main font-bold"
|
class="text-center color-main font-bold"
|
||||||
:class="[ item.status == 'refund' ? 'color-red' : '']"
|
:class="[ item.status == 'refund' ? 'color-red' : '']"
|
||||||
>{{ 0 }}</view
|
>{{ item.rewardAmount }}</view
|
||||||
>
|
>
|
||||||
<view class="color-66 u-font-24">{{
|
<view class="color-66 u-font-24">{{
|
||||||
item.level == 1 ? "直接分成" : "间接分成"
|
item.level == 1 ? "直接分成" : "间接分成"
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
class="number-box"
|
class="number-box"
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
placeholder-class="color-999 u-font-28"
|
placeholder-class="color-999 u-font-28"
|
||||||
type="number"
|
type="digit"
|
||||||
v-model="form.discountAmount"
|
v-model="form.discountAmount"
|
||||||
/>
|
/>
|
||||||
<view class="unit">元</view>
|
<view class="unit">元</view>
|
||||||
|
|
@ -65,13 +65,13 @@
|
||||||
class="u-flex default-box-x-padding default-box-y-padding"
|
class="u-flex default-box-x-padding default-box-y-padding"
|
||||||
v-if="form.discountType === 'RANDOM'"
|
v-if="form.discountType === 'RANDOM'"
|
||||||
>
|
>
|
||||||
<view class="font-bold u-m-r-14">减免方式</view>
|
<view class="font-bold u-m-r-14 no-wrap">随机减免方案</view>
|
||||||
<my-button height="60rpx" @click="addItem">添加方案</my-button>
|
<my-button height="60rpx" @click="addItem"><text class="no-wrap">添加方案</text></my-button>
|
||||||
<text class="color-red u-font-24 u-m-l-14"
|
<text class="color-red u-font-24 u-m-l-14"
|
||||||
>所有概率相加必须等于100%</text
|
>所有概率相加必须等于100%</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
<view class="table">
|
<view class="table" v-if="form.discountType === 'RANDOM'">
|
||||||
<view
|
<view
|
||||||
class="header u-flex u-row-between color-666 default-box-x-padding u-p-t-48 u-p-b-48 bg-f7"
|
class="header u-flex u-row-between color-666 default-box-x-padding u-p-t-48 u-p-b-48 bg-f7"
|
||||||
>
|
>
|
||||||
|
|
@ -159,6 +159,8 @@ import Modal from "@/pageMarket/components/modal.vue";
|
||||||
|
|
||||||
import { ref, reactive, computed, watch, onMounted } from "vue";
|
import { ref, reactive, computed, watch, onMounted } from "vue";
|
||||||
import { useNewUserDiscountStore } from "@/store/market.js";
|
import { useNewUserDiscountStore } from "@/store/market.js";
|
||||||
|
|
||||||
|
const isLoading = ref(false);
|
||||||
const newUserDiscountStore = useNewUserDiscountStore();
|
const newUserDiscountStore = useNewUserDiscountStore();
|
||||||
|
|
||||||
const modalData = reactive({
|
const modalData = reactive({
|
||||||
|
|
@ -274,6 +276,7 @@ function save() {
|
||||||
watch(
|
watch(
|
||||||
() => newUserDiscountStore.config.isEnable,
|
() => newUserDiscountStore.config.isEnable,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
|
if(isLoading.value) return;
|
||||||
newUserDiscountStore.editConfig().then((res) => {
|
newUserDiscountStore.editConfig().then((res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
@ -296,6 +299,7 @@ async function init() {
|
||||||
};
|
};
|
||||||
console.log(data);
|
console.log(data);
|
||||||
Object.assign(form, data);
|
Object.assign(form, data);
|
||||||
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,190 @@
|
||||||
|
<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>
|
||||||
|
<chooseGoods v-model="form.foods"> </chooseGoods>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-16">
|
||||||
|
<view class="font-bold u-m-b-16">自定义引导语</view>
|
||||||
|
<up-input
|
||||||
|
placeholder="请输入内容"
|
||||||
|
border="none"
|
||||||
|
placeholder-class="color-999 u-font-28"
|
||||||
|
></up-input>
|
||||||
|
</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">
|
||||||
|
<my-week-sel shape="circle" v-model="form.useDays"></my-week-sel>
|
||||||
|
</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 chooseGoods from "@/pageMarket/components/choose-goods.vue";
|
||||||
|
import * as suggestApi from "@/http/api/market/suggest.js";
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onReady,
|
||||||
|
onShow,
|
||||||
|
onPageScroll,
|
||||||
|
onReachBottom,
|
||||||
|
onBackPress,
|
||||||
|
} from "@dcloudio/uni-app";
|
||||||
|
|
||||||
|
const form = reactive({
|
||||||
|
foods: "",
|
||||||
|
useDays: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
|
||||||
|
useStartTime: "",
|
||||||
|
useTimeType: "all",
|
||||||
|
useEndTime: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
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) => {
|
||||||
|
Object.assign(options,opt)
|
||||||
|
const type = opt.type;
|
||||||
|
if (type == "edit") {
|
||||||
|
const item = uni.getStorageSync("suggestItem");
|
||||||
|
form.title = item.title;
|
||||||
|
form.foods = item.foods;
|
||||||
|
form.useDays = item.useDays.split(",");
|
||||||
|
form.useStartTime = item.useStartTime;
|
||||||
|
form.useTimeType = item.useTimeType;
|
||||||
|
form.useEndTime = item.useEndTime;
|
||||||
|
form.id = item.id;
|
||||||
|
console.log(form);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</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>
|
||||||
|
|
@ -1,3 +1,280 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="min-page bg-f7"></view>
|
<view class="min-page bg-f7 u-font-28">
|
||||||
</template>
|
<up-sticky>
|
||||||
|
<view class="bg-fff default-box-padding">
|
||||||
|
<view class="u-flex">
|
||||||
|
<image
|
||||||
|
style="width: 60rpx; height: 60rpx"
|
||||||
|
src="/pageMarket/static/images/suggest.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"
|
||||||
|
>进入点单页X秒未点自动推荐商品,此推荐设置启用即生效
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<up-switch
|
||||||
|
v-model="accountInfoStore.shopInfo.isProductSuggest"
|
||||||
|
size="18"
|
||||||
|
:active-value="1"
|
||||||
|
:inactive-value="0"
|
||||||
|
></up-switch>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-32">
|
||||||
|
<view class="u-flex">
|
||||||
|
<view class="color-333 font-bold">首次弹窗触发时间 </view>
|
||||||
|
<view class="time" @click="showTimeModal">{{
|
||||||
|
accountInfoStore.shopInfo.suggestTime
|
||||||
|
}}</view>
|
||||||
|
<text class="u-m-l-10">秒</text>
|
||||||
|
</view>
|
||||||
|
<view class="color-666 u-font-24 u-m-t-8"
|
||||||
|
>多个弹窗时,每个弹窗之间关闭和弹出间隔为15秒
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</up-sticky>
|
||||||
|
<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.title }}</text>
|
||||||
|
<view class="status" :class="['status' + item.status]">{{
|
||||||
|
item.status == 1 ? "启用" : "禁用"
|
||||||
|
}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-22 color-666 u-font-24">
|
||||||
|
<view> {{ item.useDays }}</view>
|
||||||
|
<view class="u-m-t-16"> {{ returnUseTimeType(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_ORDER_RECOMMENDATION_ADD')"
|
||||||
|
>添加</my-button
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
v-model="modalData.show"
|
||||||
|
:title="modalData.title"
|
||||||
|
@confirm="handleConfirm"
|
||||||
|
>
|
||||||
|
<template v-if="modalData.key == 'timeModal'">
|
||||||
|
<view class="default-box-padding">
|
||||||
|
<view class="u-flex u-m-t-16">
|
||||||
|
<input
|
||||||
|
class="number-box"
|
||||||
|
placeholder="首次弹窗触发时间"
|
||||||
|
placeholder-class="color-999 u-font-28"
|
||||||
|
type="number"
|
||||||
|
v-model="firstModalTime"
|
||||||
|
/>
|
||||||
|
<view class="unit">秒</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-font-28 color-666 u-m-t-8"
|
||||||
|
>设置为0时,进入点餐页立即弹出</view
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</Modal>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onReady,
|
||||||
|
onShow,
|
||||||
|
onPageScroll,
|
||||||
|
onReachBottom,
|
||||||
|
onBackPress,
|
||||||
|
} from "@dcloudio/uni-app";
|
||||||
|
import Modal from "@/pageMarket/components/modal.vue";
|
||||||
|
import * as suggestApi from "@/http/api/market/suggest.js";
|
||||||
|
import { useAccountInfoStore } from "@/store/account.js";
|
||||||
|
import go from "@/commons/utils/go.js";
|
||||||
|
const accountInfoStore = useAccountInfoStore();
|
||||||
|
import { ref, reactive, onMounted } from "vue";
|
||||||
|
import { watch } from "vue";
|
||||||
|
const loadFinish = ref(false);
|
||||||
|
const form = reactive({
|
||||||
|
isEnable: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
const firstModalTime = ref(0);
|
||||||
|
const modalData = reactive({
|
||||||
|
show: false,
|
||||||
|
title: "",
|
||||||
|
key: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleDelete(item) {
|
||||||
|
uni.showModal({
|
||||||
|
title: "确认删除吗?",
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
suggestApi
|
||||||
|
.deleteSuggest({
|
||||||
|
id: item.id,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
uni.showToast({
|
||||||
|
title: "删除成功",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
refreshList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function showTimeModal() {
|
||||||
|
modalData.show = true;
|
||||||
|
firstModalTime.value = accountInfoStore.shopInfo.suggestTime || 0;
|
||||||
|
modalData.title = "首次弹窗触发时间";
|
||||||
|
modalData.key = "timeModal";
|
||||||
|
}
|
||||||
|
const handleConfirm = async () => {
|
||||||
|
if (firstModalTime.value < 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "请输入正确的时间",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
accountInfoStore.editShopInfo({
|
||||||
|
suggestTime: firstModalTime.value,
|
||||||
|
id: accountInfoStore.shopInfo.id,
|
||||||
|
});
|
||||||
|
uni.showToast({
|
||||||
|
title: "设置成功",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
modalData.show = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isEnd = ref(false);
|
||||||
|
const query = {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
};
|
||||||
|
const list = ref([]);
|
||||||
|
const getList = async () => {
|
||||||
|
loadFinish.value = false;
|
||||||
|
if (isEnd.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const res = await suggestApi.suggestPage(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 returnUseTimeType(item) {
|
||||||
|
if (item.useTimeType == "all") {
|
||||||
|
return "全天";
|
||||||
|
}
|
||||||
|
return `${item.useStartTime} - ${item.useEndTime}`;
|
||||||
|
}
|
||||||
|
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",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
onReachBottom(() => {
|
||||||
|
console.log("触底");
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
onMounted(() => {
|
||||||
|
getList();
|
||||||
|
getShopInfo();
|
||||||
|
});
|
||||||
|
onShow(() => {
|
||||||
|
refreshList();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.status {
|
||||||
|
padding: 8rpx 18rpx;
|
||||||
|
border: 2rpx solid transparent;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
&.status1 {
|
||||||
|
background-color: rgba(123, 209, 54, 0.12);
|
||||||
|
border-color: rgba(123, 209, 54, 1);
|
||||||
|
color: #7bd136;
|
||||||
|
}
|
||||||
|
&.status0 {
|
||||||
|
border-color: rgba(153, 153, 153, 1);
|
||||||
|
background-color: rgba(153, 153, 153, 0.12);
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
padding: 8rpx 42rpx;
|
||||||
|
border-radius: 100rpx;
|
||||||
|
&.del {
|
||||||
|
background-color: #f7f7fa;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
&.edit {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.fixed-bottom {
|
||||||
|
left: 70rpx;
|
||||||
|
right: 70rpx;
|
||||||
|
}
|
||||||
|
.time {
|
||||||
|
margin-left: 30rpx;
|
||||||
|
padding: 4rpx 20rpx;
|
||||||
|
border: 1px solid $my-main-color;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
color: $my-main-color;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 886 B |
|
|
@ -705,6 +705,13 @@
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "点餐智能推荐"
|
"navigationBarTitleText": "点餐智能推荐"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pageId": "PAGES_MARKET_ORDER_RECOMMENDATION_ADD",
|
||||||
|
"path": "orderRecommendation/add",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "添加"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
// stores/counter.js
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
import * as shopApi from "@/http/api/shop.js";
|
||||||
|
|
||||||
|
// 分销
|
||||||
|
export const useAccountInfoStore = defineStore("accountInfo", {
|
||||||
|
state: () => {
|
||||||
|
return {
|
||||||
|
shopInfo: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
getShopInfo() {
|
||||||
|
return shopApi.getShopInfo().then((res) => {
|
||||||
|
this.shopInfo = res;
|
||||||
|
return this.shopInfo;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
editShopInfo(data,autoRefresh = true) {
|
||||||
|
return shopApi.editShopInfo(data).then((res) => {
|
||||||
|
if(autoRefresh) {
|
||||||
|
this.getShopInfo()
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
unistorage: true, // 开启后对 state 的数据读写都将持久化
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue