This commit is contained in:
2025-12-05 11:11:02 +08:00
8 changed files with 1186 additions and 1214 deletions

View File

@@ -0,0 +1,41 @@
<template>
<view class="mask-conetnt">
<text class="t">门店未参与{{ name }}活动或主店未开启活动如需开启参与请联系主店</text>
</view>
</template>
<script setup>
import { ref } from 'vue';
const props = defineProps({
name: {
type: String,
default: '活动'
}
});
</script>
<style scoped lang="scss">
.mask-conetnt {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
z-index: 999;
background-color: rgba(255, 255, 255, 0.6);
backdrop-filter: blur(10px);
display: flex;
align-items: center;
justify-content: center;
padding-bottom: 5vh;
.t {
width: 80vw;
font-size: 28upx;
color: #333;
display: flex;
justify-content: center;
text-align: center;
}
}
</style>

View File

@@ -1,50 +1,34 @@
<template>
<view class="boxconstant min-page">
<view class="bg-fff u-flex u-m-b-32 top">
<image style="width: 60rpx;height:60rpx;" src="/pageBwc/static/images/bwc.png"></image>
<image style="width: 60rpx; height: 60rpx" src="/pageBwc/static/images/bwc.png"></image>
<view class="u-flex-1 u-flex u-p-l-24">
<view class=" u-font-28 u-flex-1 u-p-r-4">
<view class="u-font-28 u-flex-1 u-p-r-4">
<view class="color-333 font-bold">霸王餐</view>
<view class="color-666 u-m-t-4 u-font-24">设置充值消费的N倍当前订单立即免单</view>
</view>
<up-switch v-model="form.enable" size="18"
:active-value="1"
:inactive-value="0"
:disabled="isMainShop()?false:true"
></up-switch>
<up-switch v-model="form.enable" size="18" :active-value="1" :inactive-value="0" :disabled="isMainShop() ? false : true"></up-switch>
</view>
</view>
<view class="boxconstantbox"
>
<view class="boxconstantbox_one">
充值设置
</view>
<view class="boxconstantbox">
<view class="boxconstantbox_one">充值设置</view>
<view class="u-flex u-m-t-32">
<input class="number-box" type="number" :min='2' v-model="form.rechargeTimes" @blur="rechargeTimesInput" />
<input class="number-box" type="number" :min="2" v-model="form.rechargeTimes" @blur="rechargeTimesInput" />
<view class="bei"></view>
</view>
<view class="color-666 u-font-28 u-m-t-16">
用户消费结账时成功充值订单金额的X倍即可享受免单
</view>
<view class="color-666 u-font-28 u-m-t-16">用户消费结账时成功充值订单金额的X倍即可享受免单</view>
<view class="u-m-t-20 u-m-b-20">
<up-line class=""></up-line>
</view>
<view class="boxconstantbox_one">
充值门槛
</view>
<view class="boxconstantbox_one">充值门槛</view>
<view class="u-flex u-m-t-32">
<input class="number-box" type="number" v-model="form.rechargeThreshold" @blur="rechargeThresholdInput" />
<view class="bei"></view>
</view>
<view class="color-666 u-font-28 u-m-t-16">
订单的支付金额满足X元才能使用
</view>
</view>
<view class="boxconstantbox"
>
<view class="boxconstantbox_one">
可用门店
<view class="color-666 u-font-28 u-m-t-16">订单的支付金额满足X元才能使用</view>
</view>
<view class="boxconstantbox">
<view class="boxconstantbox_one">可用门店</view>
<view class="u-m-t-16">
<my-shop-select @shop-select="shopSelect" v-model:selShops="form.shopIdList" v-model:useType="form.useShopType"></my-shop-select>
</view>
@@ -59,15 +43,12 @@
</view>
</view> -->
<view class="boxconstantbox">
<view class="boxconstantbox_one">
可使用类型
</view>
<view class="boxconstantbox_one">可使用类型</view>
<view class="u-m-t-16">
<my-dine-types v-model="form.useType"></my-dine-types>
</view>
</view>
<view class="boxconstantbox ">
<view class="boxconstantbox">
<view class="u-flex u-col-center u-row-between">
<view>
<view class="color-333 u-font-32 font-bold">与优惠券同享</view>
@@ -83,28 +64,26 @@
<up-switch v-model="form.withPoints" size="18"></up-switch>
</view>
</view>
<my-bottom-btn-group @cancel="cancel" @save="editFreeDing" isOpenPermission></my-bottom-btn-group>
<my-marketing-mask name="霸王餐" v-if="isMarketShow(form)"></my-marketing-mask>
</view>
</template>
<script setup>
import { onShow, onLoad } from "@dcloudio/uni-app";
import { reactive, ref, watch } from "vue";
import { isMainShop } from "@/store/account";
import { getFreeDing, updateFreeDing } from "@/http/api/freeDing.js";
import { onShow, onLoad } from '@dcloudio/uni-app';
import { reactive, ref, watch } from 'vue';
import { isMainShop, isMarketShow } from '@/store/account';
import { getFreeDing, updateFreeDing } from '@/http/api/freeDing.js';
const form = reactive({
rechargeTimes: 2,
rechargeThreshold: "",
rechargeThreshold: '',
enable: false,
rechargeDesc: "",
useShopType: "all",
rechargeDesc: '',
useShopType: 'all',
useType: [],
shopIdList: [],
withCoupon: false,
withPoints: false,
withPoints: false
});
onLoad(() => {
// uni.$utils.inputReg.bind()()
@@ -123,21 +102,21 @@ const getlist = async () => {
let rechargeTimesInput = (e) => {
console.log(e);
if (e.detail.value == "" || e.detail.value < 2) {
if (e.detail.value == '' || e.detail.value < 2) {
form.rechargeTimes = 2;
uni.showToast({
title: "请输入大于等于2的整数",
icon: "none",
title: '请输入大于等于2的整数',
icon: 'none'
});
return;
}
};
function rechargeThresholdInput(e){
if (e.detail.value == "" || e.detail.value <= 0.01) {
function rechargeThresholdInput(e) {
if (e.detail.value == '' || e.detail.value <= 0.01) {
form.rechargeThreshold = 0.01;
uni.showToast({
title: "请输入大于0的数字",
icon: "none",
title: '请输入大于0的数字',
icon: 'none'
});
return;
}
@@ -148,35 +127,35 @@ function rechargeThresholdInput(e){
const editFreeDing = async () => {
if (!form.rechargeTimes) {
uni.showToast({
title: "请输入充值设置",
icon: "none",
title: '请输入充值设置',
icon: 'none'
});
return;
}
if (!form.rechargeThreshold) {
uni.showToast({
title: "请输入充值门槛",
icon: "none",
title: '请输入充值门槛',
icon: 'none'
});
return;
}
if (form.useShopType != "all" && !form.shopIdList.length) {
if (form.useShopType != 'all' && !form.shopIdList.length) {
uni.showToast({
title: "请选择可用门店",
icon: "none",
title: '请选择可用门店',
icon: 'none'
});
return;
}
if (form.useType.length == 0) {
uni.showToast({
title: "请选择可使用类型",
icon: "none",
title: '请选择可使用类型',
icon: 'none'
});
return;
}
let res = await updateFreeDing(form);
uni.showToast({
title: "保存成功",
title: '保存成功'
});
Object.assign(form, res);
setTimeout(() => {

View File

@@ -1,34 +1,20 @@
<template>
<view class="box">
<view class="bg-fff container u-flex u-m-b-32 top">
<image
style="width: 60rpx; height: 60rpx"
src="/pageMarket/static/images/cost.png"
></image>
<image style="width: 60rpx; height: 60rpx" src="/pageMarket/static/images/cost.png"></image>
<view class="u-flex-1 u-flex u-p-l-24">
<view class="u-font-28 u-flex-1 u-p-r-4">
<view class="color-333 font-bold">消费返现</view>
<view class="color-666 u-m-t-4 u-font-24"
>用户下单后返现一定的金额到余额可促进复购 </view
>
<view class="color-666 u-m-t-4 u-font-24">用户下单后返现一定的金额到余额可促进复购</view>
</view>
<up-switch
v-model="form.isEnable"
:disabled="isMainShop()?false:true"
size="18"
:active-value="1"
:inactive-value="0"
></up-switch>
<up-switch v-model="form.isEnable" :disabled="isMainShop() ? false : true" size="18" :active-value="1" :inactive-value="0"></up-switch>
</view>
</view>
<view class="u-m-t-32 container">
<view class="u-flex u-row-between u-m-b-16">
<text class="font-bold color-333">可用门店</text>
</view>
<my-shop-select
v-model:selShops="form.shopIdList"
v-model:useType="form.useType"
></my-shop-select>
<my-shop-select v-model:selShops="form.shopIdList" v-model:useType="form.useType"></my-shop-select>
</view>
<view class="u-m-t-32 container">
@@ -44,12 +30,7 @@
</view>
<view class="u-m-t-16">
<up-radio-group v-model="form.cashbackType" placement="row">
<up-radio
v-for="item in cashbackTypes"
:key="item.value"
:name="item.value"
:label="item.label"
>
<up-radio v-for="item in cashbackTypes" :key="item.value" :name="item.value" :label="item.label">
<template #label>
<text>
{{ item.label }}
@@ -61,26 +42,17 @@
<view class="u-flex u-row-between u-m-t-32">
<text class="font-bold color-333">阶梯设置</text>
</view>
<view
class="u-m-t-32 u-flex u-row-between gap-40"
v-for="(item, index) in form.cashbackStepList"
:key="index"
>
<view class="u-m-t-32 u-flex u-row-between gap-40" v-for="(item, index) in form.cashbackStepList" :key="index">
<view class="u-flex u-col-top">
<view class="no-wrap u-m-r-16 u-m-t-14">{{ returnName(index) }}</view>
<view class="u-flex-1">
<view class="u-flex">
<text class="u-m-r-24"> 返现门槛</text>
<input
class="my-input"
type="digit"
v-model="item.amount"
placeholder=""
/>
<text class="u-m-r-24">返现门槛</text>
<input class="my-input" type="digit" v-model="item.amount" placeholder="" />
<text class="text-tips text-tips1"></text>
</view>
<view class="u-flex u-m-t-24">
<text class="u-m-r-24"> {{form.cashbackType === 'percentage' ? '返现比例' : '返现金额'}}</text>
<text class="u-m-r-24">{{ form.cashbackType === 'percentage' ? '返现比例' : '返现金额' }}</text>
<input
class="my-input"
type="number"
@@ -89,10 +61,8 @@
:max="form.cashbackType === 'percentage' ? 100 : 999999"
placeholder=""
/>
<text class="text-tips text-tips1">{{ returnUnit }} </text>
<text class="color-red u-m-l-10" @click="deleteThreshold(index)"
>删除</text
>
<text class="text-tips text-tips1">{{ returnUnit }}</text>
<text class="color-red u-m-l-10" @click="deleteThreshold(index)">删除</text>
</view>
</view>
</view>
@@ -104,63 +74,56 @@
</view>
</template>
<script setup>
import { reactive, computed, onMounted } from "vue";
import userTypes from "./user-types.vue";
import * as consumeCashbackApi from "@/http/api/market/consumeCashback.js";
import { isMainShop } from "@/store/account";
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
<script setup>
import { reactive, computed, onMounted } from 'vue';
import userTypes from './user-types.vue';
import * as consumeCashbackApi from '@/http/api/market/consumeCashback.js';
import { isMainShop } from '@/store/account';
import { onLoad, onReady, onShow, onPageScroll, onReachBottom, onBackPress } from '@dcloudio/uni-app';
//返现类型
const cashbackTypes = [
{
value: "percentage",
label: "按比例返现",
value: 'percentage',
label: '按比例返现'
},
{
value: "fix",
label: "固定金额",
},
value: 'fix',
label: '固定金额'
}
];
const form = reactive({
isEnable: 0,
cashbackStepList: [],
shopIdList: [],
useType: "all",
applicableUser: "all",
cashbackType: "percentage",
useType: 'all',
applicableUser: 'all',
cashbackType: 'percentage'
});
function addcashbackStepList() {
form.cashbackStepList.push({
amount: 0,
cashbackAmount: 0,
cashbackAmount: 0
});
}
function inputBlur(e, index) {
const value = e.detail.value;
if (form.cashbackType === "percentage") {
if (form.cashbackType === 'percentage') {
if (e.detail.value >= 100) {
form.cashbackStepList[index].cashbackAmount = 100;
} else if (e.detail.value < 0) {
form.cashbackStepList[index].cashbackAmount = 0;
} else {
form.cashbackStepList[index].cashbackAmount =e.detail.value;
form.cashbackStepList[index].cashbackAmount = e.detail.value;
}
} else {
if (e.detail.value < 0) {
form.cashbackStepList[index].cashbackAmount = 0;
} else if(e.detail.value > form.cashbackStepList[index].amount) {
} else if (e.detail.value > form.cashbackStepList[index].amount) {
form.cashbackStepList[index].cashbackAmount = form.cashbackStepList[index].amount;
} else {
form.cashbackStepList[index].cashbackAmount =e.detail.value;
form.cashbackStepList[index].cashbackAmount = e.detail.value;
}
}
}
@@ -168,14 +131,14 @@ function inputBlur(e, index) {
async function save() {
console.log(form);
const submitData = {
...form,
...form
};
const res = await consumeCashbackApi.update(submitData);
uni.showToast({
title: "更新成功",
icon: "none",
title: '更新成功',
icon: 'none',
duration: 2000,
success: function () {},
success: function () {}
});
}
function cancel() {
@@ -186,28 +149,28 @@ function deleteThreshold(index) {
form.cashbackStepList.splice(index, 1);
}
function setForm(data) {
data.cashbackStepList=data.cashbackStepList||[]
data.cashbackStepList = data.cashbackStepList || [];
Object.assign(form, data);
console.log(form);
}
const returnUnit = computed(() => {
return form.cashbackType === "percentage" ? "%" : "元";
return form.cashbackType === 'percentage' ? '%' : '元';
});
const numChineseMap = {
0: "零",
1: "一",
2: "二",
3: "三",
4: "四",
5: "五",
6: "六",
7: "七",
8: "八",
9: "九",
10: "十",
100: "百",
1000: "千",
0: '零',
1: '一',
2: '二',
3: '三',
4: '四',
5: '五',
6: '六',
7: '七',
8: '八',
9: '九',
10: '十',
100: '百',
1000: '千'
};
// 辅助函数:将数字转换为中文数字
@@ -221,11 +184,9 @@ function numberToChinese(n) {
const ten = Math.floor(n / 10);
const unit = n % 10;
if (ten === 1) {
return unit === 0 ? "十" : `${numChineseMap[unit]}`;
return unit === 0 ? '十' : `${numChineseMap[unit]}`;
} else {
return unit === 0
? `${numChineseMap[ten]}`
: `${numChineseMap[ten]}${numChineseMap[unit]}`;
return unit === 0 ? `${numChineseMap[ten]}` : `${numChineseMap[ten]}${numChineseMap[unit]}`;
}
}
@@ -236,9 +197,7 @@ function numberToChinese(n) {
if (remainder === 0) {
return `${numChineseMap[hundred]}`;
} else {
return `${numChineseMap[hundred]}${
remainder < 10 ? "零" : ""
}${numberToChinese(remainder)}`;
return `${numChineseMap[hundred]}${remainder < 10 ? '零' : ''}${numberToChinese(remainder)}`;
}
}
@@ -249,9 +208,7 @@ function numberToChinese(n) {
if (remainder === 0) {
return `${numChineseMap[thousand]}`;
} else {
return `${numChineseMap[thousand]}${
remainder < 100 ? "零" : ""
}${numberToChinese(remainder)}`;
return `${numChineseMap[thousand]}${remainder < 100 ? '零' : ''}${numberToChinese(remainder)}`;
}
}
@@ -265,8 +222,11 @@ function returnName(index) {
const chineseNumber = numberToChinese(groupNumber);
return `${chineseNumber}`;
}
const emits = defineEmits(['get']);
async function getData() {
const res = await consumeCashbackApi.getConfig();
emits('get', res);
if (res) {
setForm(res);
}
@@ -276,7 +236,7 @@ onMounted(() => {
});
</script>
<style lang="scss" scoped>
<style lang="scss" scoped>
page {
background: #f7f7f7;
}

View File

@@ -5,29 +5,27 @@
<my-tabs v-model="active" :list="tabs" textKey="label"></my-tabs>
<view class="u-flex u-m-t-40" v-if="active == 1">
<view class="u-flex color-333" @click="showShopSelActionSheetFun">
<text class="u-line-1" style="max-width: 300rpx;">{{selShop.shopName || "全部门店"}}</text>
<text class="u-line-1" style="max-width: 300rpx">{{ selShop.shopName || '全部门店' }}</text>
<up-icon name="arrow-down-fill" size="12" color="#333"></up-icon>
</view>
<view class="u-flex-1 u-p-l-16">
<up-search bgColor="#F9F9F9" height="60rpx" :showAction="false" placeholder="搜索订单号"
@search="search" @clear="search" v-model="searchText"></up-search>
<up-search bgColor="#F9F9F9" height="60rpx" :showAction="false" placeholder="搜索订单号" @search="search" @clear="search" v-model="searchText"></up-search>
</view>
</view>
</view>
</up-sticky>
<configVue v-if="active == 0"></configVue>
<configVue v-if="active == 0" @get="getConfigData"></configVue>
<view class="list u-font-28" v-if="active == 1">
<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">
<view> 关联订单:{{ item.orderNo }} </view>
<view>关联订单:{{ item.orderNo }}</view>
<view class="u-m-t-14">
<text class="color-333 font-bold u-m-r-20"> {{ item.shopName }}</text>
<text class="color-333 font-bold u-m-r-20">{{ item.shopName }}</text>
<text class="color-666 u-font-24">{{ item.createTime }}</text>
</view>
</view>
<text class="color-999 u-font-24"> ID:{{ item.id }} </text>
<text class="color-999 u-font-24">ID:{{ item.id }}</text>
</view>
<view class="u-m-t-22">
<u-line></u-line>
@@ -40,16 +38,15 @@
<view class="u-flex u-text-center">
<view>
<view class="color-666">返现金额</view>
<view class="color-333 u-m-t-24">{{ item.cashbackAmount ||0 }}</view>
<view class="color-333 u-m-t-24">{{ item.cashbackAmount || 0 }}</view>
</view>
<view style="margin-left: 54rpx;">
<view style="margin-left: 54rpx">
<view class="color-666">支付金额</view>
<view class="color-333 u-m-t-24">{{ item.amount || 0 }}</view>
</view>
</view>
</view>
<view style="height: 32rpx;"></view>
<view style="height: 32rpx"></view>
</view>
<view class="u-p-30">
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
@@ -57,67 +54,65 @@
</view>
<!-- 选择门店 -->
<shopSelActionSheetVue @choose="chooseShop" v-model="showShopSelActionSheet" title="选择门店">
</shopSelActionSheetVue>
<shopSelActionSheetVue @choose="chooseShop" v-model="showShopSelActionSheet" title="选择门店"></shopSelActionSheetVue>
<my-marketing-mask name="消费返现" v-if="isMarketShow(configInfo)"></my-marketing-mask>
</view>
</template>
<script setup>
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
import { isMainShop } from "@/store/account.js";
import {
ref,
onMounted,
watch
} from "vue";
import * as consumeCashbackApi from "@/http/api/market/consumeCashback.js";
import configVue from './components/config.vue'
import shopSelActionSheetVue from '@/pageMarket/components/shop-sel-action-sheet.vue'
const tabs = [{
label: "基本设置",
value: "basic"
import { onLoad, onReady, onShow, onPageScroll, onReachBottom, onBackPress } from '@dcloudio/uni-app';
import { isMainShop, isMarketShow } from '@/store/account.js';
import { ref, onMounted, watch } from 'vue';
import * as consumeCashbackApi from '@/http/api/market/consumeCashback.js';
import configVue from './components/config.vue';
import shopSelActionSheetVue from '@/pageMarket/components/shop-sel-action-sheet.vue';
const tabs = [
{
label: '基本设置',
value: 'basic'
},
{
label: "返现明细",
value: "recoders"
},
];
label: '返现明细',
value: 'recoders'
}
];
const configInfo = ref({});
function getConfigData(e) {
configInfo.value = e;
}
const list = ref([]);
const pageNum = ref(1);
const isEnd = ref(false);
const selShop = ref({
shopId: "",
shopName: "",
})
const searchText = ref("");
const list = ref([]);
const pageNum = ref(1);
const isEnd = ref(false);
const selShop = ref({
shopId: '',
shopName: ''
});
const searchText = ref('');
function search() {
function search() {
pageNum.value = 1;
getList();
}
}
function chooseShop(e) {
function chooseShop(e) {
selShop.value = e;
}
}
watch(()=>selShop.value.shopId,(newval)=>{
watch(
() => selShop.value.shopId,
(newval) => {
pageNum.value = 1;
getList();
})
}
);
async function getList() {
async function getList() {
const res = await consumeCashbackApi.getList({
pageNum: pageNum.value,
pageSize: 10,
shopId: selShop.value.shopId,
key: searchText.value,
key: searchText.value
});
if (res) {
if (pageNum.value == 1) {
@@ -128,47 +123,47 @@
isEnd.value = pageNum.value >= res.totalPage * 1 ? true : false;
console.log(isEnd.value);
}
}
}
// 显示选择门店弹窗
const showShopSelActionSheet = ref(false);
// 显示选择门店弹窗
const showShopSelActionSheet = ref(false);
function showShopSelActionSheetFun() {
function showShopSelActionSheetFun() {
showShopSelActionSheet.value = true;
}
const active = ref(0);
watch(
}
const active = ref(0);
watch(
() => active.value,
(newval) => {
console.log(newval);
pageNum.value = 1;
getList();
}
);
onReachBottom(() => {
);
onReachBottom(() => {
if (!isEnd.value) {
pageNum.value++;
getList();
}
});
onShow(() => {
});
onShow(() => {
pageNum.value = 1;
getList();
});
});
</script>
<style lang="scss" scoped>
.min-page {
.min-page {
background: #f7f7f7;
}
}
.box {}
.box {
}
.top {
.top {
padding: 32rpx 24rpx;
}
}
.list {
.list {
padding: 0 30rpx;
.item {
@@ -177,9 +172,9 @@
background-color: #fff;
overflow: hidden;
}
}
}
.tag {
.tag {
border-radius: 12rpx;
padding: 8rpx 22rpx;
font-size: 28rpx;
@@ -193,23 +188,23 @@
background-color: #f7f7f7;
color: #999;
}
}
}
.my-btn {
.my-btn {
font-size: 28rpx;
line-height: 36rpx;
padding: 8rpx 32rpx;
border-radius: 12rpx;
margin: 0;
}
}
.edit-btn {
.edit-btn {
background: #e6f0ff;
color: $my-main-color;
}
}
.delete-btn {
.delete-btn {
background: #ffe7e6;
color: #ff1c1c;
}
}
</style>

View File

@@ -3,21 +3,15 @@
<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>
<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 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"
:disabled="isMainShop()?false:true"
:disabled="isMainShop() ? false : true"
size="18"
:active-value="1"
:inactive-value="0"
@@ -29,10 +23,7 @@
<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"
>
<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>
@@ -40,25 +31,18 @@
</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 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 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>有效期{{ 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>
@@ -73,24 +57,14 @@
<template v-if="isMainShop()">
<view style="height: 100rpx"></view>
<view class="fixed-bottom">
<my-button @click="go.to('PAGES_MARKET_COUPON_EXCHANGE_CODE_ADD')"
>添加兑换码</my-button
>
<my-button @click="go.to('PAGES_MARKET_COUPON_EXCHANGE_CODE_ADD')">添加兑换码</my-button>
</view>
</template>
<Modal
v-model="modalData.show"
:title="modalData.title"
@confirm="handleConfirm"
>
<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>
<my-shop-select @shop-select="shopSelect" v-model:selShops="form.shopIdList" v-model:useType="form.useType"></my-shop-select>
</view>
</template>
</Modal>
@@ -104,54 +78,46 @@
@select="selectStatus"
:show="showAction"
></u-action-sheet>
<my-marketing-mask name="充值兑换码" v-if="isMarketShow(form)"></my-marketing-mask>
</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";
import { isMainShop } from "@/store/account.js";
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';
import { isMainShop, isMarketShow } from '@/store/account.js';
const accountInfoStore = useAccountInfoStore();
import { ref, reactive, onMounted, computed, watch } from "vue";
import { ref, reactive, onMounted, computed, watch } from 'vue';
const loadFinish = ref(false);
const form = reactive({
isEnable: 0,
useType: "all",
shopIdList: [],
useType: 'all',
shopIdList: []
});
const actions = [
{
name: "全部",
value: "",
name: '全部',
value: ''
},
{
name: "有效",
value: "0",
name: '有效',
value: '0'
},
{
name: "无效",
value: "1",
},
name: '无效',
value: '1'
}
];
const returnStatusText = computed(() => {
return actions.find((item) => item.value == query.status)?.name || "全部";
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);
return item.couponInfoList.reduce((prev, cur) => prev + cur.title + '*' + cur.num + '、', '').slice(0, -1);
}
const showAction = ref(false);
function selectStatus(item) {
@@ -165,42 +131,42 @@ function showStatusModal() {
function showShopModal() {
modalData.show = true;
modalData.title = "适用门店";
modalData.key = "selShop";
modalData.title = '适用门店';
modalData.key = 'selShop';
}
const firstModalTime = ref(0);
const modalData = reactive({
show: false,
title: "",
key: "",
title: '',
key: ''
});
function handleDelete(item) {
uni.showModal({
title: "确认删除吗?",
title: '确认删除吗?',
success: (res) => {
if (res.confirm) {
couponRedemptionApi
.delete({
id: item.id,
id: item.id
})
.then((res) => {
uni.showToast({
title: "删除成功",
icon: "none",
title: '删除成功',
icon: 'none'
});
refreshList();
});
}
},
}
});
}
const isEnd = ref(false);
const query = reactive({
pageNum: 1,
pageSize: 10,
status: "",
status: ''
});
const list = ref([]);
function refreshList() {
@@ -210,18 +176,18 @@ function refreshList() {
}
function handleEdit(item) {
uni.setStorageSync("couponRedemptionItem", item);
go.to("PAGES_MARKET_COUPON_EXCHANGE_CODE_DETAIL", {
type: "edit",
uni.setStorageSync('couponRedemptionItem', item);
go.to('PAGES_MARKET_COUPON_EXCHANGE_CODE_DETAIL', {
type: 'edit'
});
}
const handleConfirm = async () => {
if (form.useType == "custom") {
if (form.useType == 'custom') {
if (form.shopIdList.length == 0) {
uni.showToast({
title: "请选择适用门店",
icon: "none",
title: '请选择适用门店',
icon: 'none'
});
return;
}
@@ -230,11 +196,11 @@ const handleConfirm = async () => {
couponRedemptionApi.enable({
shopIdList: form.shopIdList || [],
useType: form.useType,
isEnable: form.isEnable,
isEnable: form.isEnable
});
uni.showToast({
title: "修改成功",
icon: "none",
title: '修改成功',
icon: 'none'
});
modalData.show = false;
};
@@ -266,15 +232,15 @@ function getShopInfo() {
watch(
() => accountInfoStore.shopInfo.isProductSuggest,
(newVal, oldVal) => {
if(!isMainShop()) return;
if (!isMainShop()) return;
if (!loadFinish.value) return;
accountInfoStore.editShopInfo({
isProductSuggest: newVal,
id: accountInfoStore.shopInfo.id,
id: accountInfoStore.shopInfo.id
});
uni.showToast({
title: "修改成功",
icon: "none",
title: '修改成功',
icon: 'none'
});
}
);
@@ -293,7 +259,7 @@ async function getConfig() {
});
}
onReachBottom(() => {
console.log("触底");
console.log('触底');
getList();
});
onMounted(() => {

View File

@@ -3,21 +3,16 @@
<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>
<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 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"
:disabled="isMainShop()?false:true"
:disabled="isMainShop() ? false : true"
:active-value="1"
:inactive-value="0"
></up-switch>
@@ -28,10 +23,7 @@
<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"
>
<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>
@@ -39,20 +31,13 @@
</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 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">
<view>
<text class="u-font-32 font-bold color-333">{{ item.name }}</text>
<text class="u-font-24 color-666 u-m-l-20"
>金额{{ item.amount }}</text
>
<text class="u-font-24 color-666 u-m-l-20">金额{{ item.amount }}</text>
</view>
<view class="status" :class="['status' + item.status]">{{
item.status == 0 ? "有效" : "无效"
}}</view>
<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>
@@ -60,15 +45,11 @@
<view class="u-m-t-16 u-flex">
<view>
<text>总数</text>
<text class="color-333 u-font-28 font-bold">{{
item.total
}}</text>
<text class="color-333 u-font-28 font-bold">{{ item.total }}</text>
</view>
<view>
<text class="u-m-l-20" >库存</text>
<text class="color-333 u-font-28 font-bold">{{
item.stock
}}</text>
<text class="u-m-l-20">库存</text>
<text class="color-333 u-font-28 font-bold">{{ item.stock }}</text>
</view>
</view>
<!-- <view class="u-m-t-16">{{ returnCoupon(item) }}</view> -->
@@ -85,25 +66,14 @@
<template v-if="isMainShop()">
<view style="height: 100rpx"></view>
<view class="fixed-bottom">
<my-button @click="go.to('PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD')"
>添加兑换码</my-button
>
<my-button @click="go.to('PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD')">添加兑换码</my-button>
</view>
</template>
<Modal
v-model="modalData.show"
:title="modalData.title"
@confirm="handleConfirm"
>
<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>
<my-shop-select @shop-select="shopSelect" v-model:selShops="form.shopIdList" v-model:useType="form.useType"></my-shop-select>
</view>
</template>
</Modal>
@@ -117,54 +87,47 @@
@select="selectStatus"
:show="showAction"
></u-action-sheet>
<my-marketing-mask name="充值兑换码" v-if="isMarketShow(form)"></my-marketing-mask>
</view>
</template>
<script setup>
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
import Modal from "@/pageMarket/components/modal.vue";
import * as rechargeRedemptionApi from "@/http/api/market/rechargeRedemption.js";
import { useAccountInfoStore } from "@/store/account.js";
import go from "@/commons/utils/go.js";
import {isMainShop} from "@/store/account.js";
import { onLoad, onReady, onShow, onPageScroll, onReachBottom, onBackPress } from '@dcloudio/uni-app';
import Modal from '@/pageMarket/components/modal.vue';
import * as rechargeRedemptionApi from '@/http/api/market/rechargeRedemption.js';
import { useAccountInfoStore } from '@/store/account.js';
import go from '@/commons/utils/go.js';
import { isMainShop, isMarketShow } from '@/store/account.js';
const accountInfoStore = useAccountInfoStore();
import { ref, reactive, onMounted, computed, watch } from "vue";
import { ref, reactive, onMounted, computed, watch } from 'vue';
const loadFinish = ref(false);
const form = reactive({
isEnable: 0,
useType: "all",
shopIdList:[]
useType: 'all',
shopIdList: []
});
const actions = [
{
name: "全部",
value: "",
name: '全部',
value: ''
},
{
name: "有效",
value: "0",
name: '有效',
value: '0'
},
{
name: "无效",
value: "1",
},
name: '无效',
value: '1'
}
];
const returnStatusText = computed(() => {
return actions.find((item) => item.value == query.status)?.name || "全部";
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);
return item.couponInfoList.reduce((prev, cur) => prev + cur.title + '*' + cur.num + '、', '').slice(0, -1);
}
const showAction = ref(false);
function selectStatus(item) {
@@ -178,42 +141,42 @@ function showStatusModal() {
function showShopModal() {
modalData.show = true;
modalData.title = "适用门店";
modalData.key = "selShop";
modalData.title = '适用门店';
modalData.key = 'selShop';
}
const firstModalTime = ref(0);
const modalData = reactive({
show: false,
title: "",
key: "",
title: '',
key: ''
});
function handleDelete(item) {
uni.showModal({
title: "确认删除吗?",
title: '确认删除吗?',
success: (res) => {
if (res.confirm) {
rechargeRedemptionApi
.delete({
id: item.id,
id: item.id
})
.then((res) => {
uni.showToast({
title: "删除成功",
icon: "none",
title: '删除成功',
icon: 'none'
});
refreshList();
});
}
},
}
});
}
const isEnd = ref(false);
const query = reactive({
pageNum: 1,
pageSize: 10,
status: "",
status: ''
});
const list = ref([]);
function refreshList() {
@@ -223,31 +186,31 @@ function refreshList() {
}
function handleEdit(item) {
uni.setStorageSync("rechargeRedemption", item);
go.to("PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD_DWTAIL", {
type: "edit",
uni.setStorageSync('rechargeRedemption', item);
go.to('PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD_DWTAIL', {
type: 'edit'
});
}
const handleConfirm = async () => {
if (form.useType == "custom") {
if (form.useType == 'custom') {
if (form.shopIdList.length == 0) {
uni.showToast({
title: "请选择适用门店",
icon: "none",
title: '请选择适用门店',
icon: 'none'
});
return;
}
}
rechargeRedemptionApi.enable({
shopIdList: form.shopIdList||[],
shopIdList: form.shopIdList || [],
useType: form.useType,
isEnable: form.isEnable,
isEnable: form.isEnable
});
uni.showToast({
title: "修改成功",
icon: "none",
title: '修改成功',
icon: 'none'
});
modalData.show = false;
};
@@ -279,15 +242,15 @@ function getShopInfo() {
watch(
() => accountInfoStore.shopInfo.isProductSuggest,
(newVal, oldVal) => {
if(!isMainShop()) return;
if (!isMainShop()) return;
if (!loadFinish.value) return;
accountInfoStore.editShopInfo({
isProductSuggest: newVal,
id: accountInfoStore.shopInfo.id,
id: accountInfoStore.shopInfo.id
});
uni.showToast({
title: "修改成功",
icon: "none",
title: '修改成功',
icon: 'none'
});
}
);
@@ -306,7 +269,7 @@ async function getConfig() {
});
}
onReachBottom(() => {
console.log("触底");
console.log('触底');
getList();
});
onMounted(() => {

View File

@@ -5,6 +5,17 @@
<myTabs :defaultIndex="tabsCurrent" :list="tabsList" @change="tabsChange"></myTabs>
</view>
</view>
<view class="switch-container">
<view class="switch-wrap">
<view class="title">
<text class="t">是否开启</text>
</view>
<view class="switch">
<!-- <u-switch size="large" v-model="isOpen" :active-value="1" :inactive-value="0"></u-switch> -->
<switch :checked="!!isOpen" foreColor="#33a0ff" color="#33a0ff" @change="isOpenChange"></switch>
</view>
</view>
</view>
<template v-if="tabsCurrent === 0">
<view class="u-p-30">
<view class="u-flex bg-fff u-p-30 border-r-12" @tap="toAddRecharge">
@@ -14,7 +25,6 @@
<view class="">添加充值面额</view>
</view>
</view>
<view class="u-p-30">
<view class="u-m-b-32" v-for="(item, index) in rechargeLists" :key="index">
<recharge-item @del="rechargeItemDel" :index="index" :data="item" :isCanEdit="isCanEdit"></recharge-item>
@@ -77,12 +87,13 @@
</template>
<my-model ref="model" :desc="modelData.desc"></my-model>
<my-date-pickerview @confirm="datePickerConfirm" ref="datePicker"></my-date-pickerview>
<my-marketing-mask name="智慧充值" v-if="isMarketShow(shopRechargeRes)"></my-marketing-mask>
</view>
</template>
<script setup>
import { computed, reactive, ref } from 'vue';
import {onShow} from '@dcloudio/uni-app'
import { onShow } from '@dcloudio/uni-app';
import myTabs from '@/components/my-components/my-tabs.vue';
import myIcons from '@/components/my-components/my-icons.vue';
import mySwitch from '@/components/my-components/my-switch.vue';
@@ -95,11 +106,25 @@ import $util from '@/commons/utils/getDateArea.js';
import go from '@/commons/utils/go.js';
import { shopRechargePost, shopRechargeGet } from '@/http/api/market/index.js';
import { onLoad } from '@dcloudio/uni-app';
import { isMainShop } from "@/store/account.js";
import { isMainShop, isMarketShow } from '@/store/account.js';
const isCanEdit=computed(()=>{
return isMainShop()
})
const isCanEdit = computed(() => {
return isMainShop();
});
const isOpen = ref(0);
async function isOpenChange(e) {
console.log(e);
isOpen.value = e.detail.value;
try {
const data = await shopRechargeGet();
data.isEnable = isOpen.value ? 1 : 0;
await shopRechargePost(data);
} catch (error) {
console.log(error);
}
}
const model = ref(null);
const modelData = reactive({
@@ -168,10 +193,12 @@ function useTypeChange(e) {
}
// 获取设置
const shopRechargeRes = ref({});
async function shopRechargeGetAjax() {
try {
const res = await shopRechargeGet();
res.rechargeDetailList.forEach((item) => {
shopRechargeRes.value = await shopRechargeGet();
isOpen.value = shopRechargeRes.value.isEnable;
shopRechargeRes.value.rechargeDetailList.forEach((item) => {
item.couponInfoList.forEach((val) => {
if (val.coupon && val.coupon !== null) {
val.id = val.coupon.id;
@@ -179,8 +206,8 @@ async function shopRechargeGetAjax() {
}
});
});
settingForm.value = res;
rechargeLists.value = res.rechargeDetailList;
settingForm.value = shopRechargeRes.value;
rechargeLists.value = shopRechargeRes.value.rechargeDetailList;
} catch (error) {
console.log(error);
}
@@ -259,6 +286,23 @@ onShow(() => {
</script>
<style lang="scss" scoped>
.switch-container {
padding: 28upx;
}
.switch-wrap {
background-color: #fff;
border-radius: 20upx;
padding: 28upx;
display: flex;
align-items: center;
justify-content: space-between;
.title {
.t {
font-size: 32upx;
color: #333;
}
}
}
.u-overflow-hide {
overflow: hidden;
}

View File

@@ -1,19 +1,43 @@
// stores/counter.js
import { defineStore } from "pinia";
import {
defineStore
} from "pinia";
import * as shopApi from "@/http/api/shop.js";
//判断是否是主店
// 判断是否是主店,并且是否有查看权限
export const isMainShop = (shopId) => {
const shopInfo=uni.getStorageSync("shopInfo");
if(shopInfo.isHeadShop){
const shopInfo = uni.getStorageSync("shopInfo");
if (shopInfo.isHeadShop) {
return true
}
if(shopInfo.shopType=='only'){
if (shopInfo.shopType == 'only') {
return true
}
return false
}
/**
* 主店在配置该功能时未选择分店
* 判断分店是否显示活动信息
* @param {Object} activit
* 活动信息
*/
export function isMarketShow(activit = null, key = 'shopIdList') {
console.log('isMarketShow===', activit);
if (activit == null || !activit.id) return false
let flag = false
const shopInfo = uni.getStorageSync("shopInfo");
if (!shopInfo.isHeadShop && (!activit[key].some(item => item == shopInfo.id) || !activit.isEnable)) {
flag = true
} else {
flag = false
}
console.log('isMarketShow===', flag);
return flag
}
// 分销
export const useAccountInfoStore = defineStore("accountInfo", {
state: () => {
@@ -28,9 +52,9 @@ export const useAccountInfoStore = defineStore("accountInfo", {
return this.shopInfo;
});
},
editShopInfo(data,autoRefresh = true) {
editShopInfo(data, autoRefresh = true) {
return shopApi.editShopInfo(data).then((res) => {
if(autoRefresh) {
if (autoRefresh) {
this.getShopInfo()
}
return res