优化分店营销中心的权限问题

This commit is contained in:
gyq
2025-12-05 10:14:39 +08:00
parent e240f02e4a
commit ca77a403b5
8 changed files with 1140 additions and 1210 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,53 +1,37 @@
<template> <template>
<view class="boxconstant min-page"> <view class="boxconstant min-page">
<view class="bg-fff u-flex u-m-b-32 top"> <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-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-333 font-bold">霸王餐</view>
<view class="color-666 u-m-t-4 u-font-24">设置充值消费的N倍当前订单立即免单</view> <view class="color-666 u-m-t-4 u-font-24">设置充值消费的N倍当前订单立即免单</view>
</view> </view>
<up-switch v-model="form.enable" size="18" <up-switch v-model="form.enable" size="18" :active-value="1" :inactive-value="0" :disabled="isMainShop() ? false : true"></up-switch>
:active-value="1"
:inactive-value="0"
:disabled="isMainShop()?false:true"
></up-switch>
</view> </view>
</view> </view>
<view class="boxconstantbox" <view class="boxconstantbox">
> <view class="boxconstantbox_one">充值设置</view>
<view class="boxconstantbox_one">
充值设置
</view>
<view class="u-flex u-m-t-32"> <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 class="bei"></view>
</view> </view>
<view class="color-666 u-font-28 u-m-t-16"> <view class="color-666 u-font-28 u-m-t-16">用户消费结账时成功充值订单金额的X倍即可享受免单</view>
用户消费结账时成功充值订单金额的X倍即可享受免单
</view>
<view class="u-m-t-20 u-m-b-20"> <view class="u-m-t-20 u-m-b-20">
<up-line class=""></up-line> <up-line class=""></up-line>
</view> </view>
<view class="boxconstantbox_one"> <view class="boxconstantbox_one">充值门槛</view>
充值门槛
</view>
<view class="u-flex u-m-t-32"> <view class="u-flex u-m-t-32">
<input class="number-box" type="number" v-model="form.rechargeThreshold" @blur="rechargeThresholdInput" /> <input class="number-box" type="number" v-model="form.rechargeThreshold" @blur="rechargeThresholdInput" />
<view class="bei"></view> <view class="bei"></view>
</view> </view>
<view class="color-666 u-font-28 u-m-t-16"> <view class="color-666 u-font-28 u-m-t-16">订单的支付金额满足X元才能使用</view>
订单的支付金额满足X元才能使用
</view>
</view> </view>
<view class="boxconstantbox" <view class="boxconstantbox">
> <view class="boxconstantbox_one">可用门店</view>
<view class="boxconstantbox_one"> <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> </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>
</view> </view>
<!-- <view class="boxconstantbox" <!-- <view class="boxconstantbox"
style="margin-top:24rpx; padding:32rpx 24rpx; border-radius: 0 0 18px 18px;"> style="margin-top:24rpx; padding:32rpx 24rpx; border-radius: 0 0 18px 18px;">
@@ -59,15 +43,12 @@
</view> </view>
</view> --> </view> -->
<view class="boxconstantbox"> <view class="boxconstantbox">
<view class="boxconstantbox_one"> <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="u-m-t-16">
<my-dine-types v-model="form.useType"></my-dine-types>
</view>
</view> </view>
<view class="boxconstantbox "> <view class="boxconstantbox">
<view class="u-flex u-col-center u-row-between"> <view class="u-flex u-col-center u-row-between">
<view> <view>
<view class="color-333 u-font-32 font-bold">与优惠券同享</view> <view class="color-333 u-font-32 font-bold">与优惠券同享</view>
@@ -83,214 +64,212 @@
<up-switch v-model="form.withPoints" size="18"></up-switch> <up-switch v-model="form.withPoints" size="18"></up-switch>
</view> </view>
</view> </view>
<my-bottom-btn-group @cancel="cancel" @save="editFreeDing" isOpenPermission></my-bottom-btn-group>
<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> </view>
</template> </template>
<script setup> <script setup>
import { onShow, onLoad } from "@dcloudio/uni-app"; import { onShow, onLoad } from '@dcloudio/uni-app';
import { reactive, ref, watch } from "vue"; import { reactive, ref, watch } from 'vue';
import { isMainShop } from "@/store/account"; import { isMainShop, isMarketShow } from '@/store/account';
import { getFreeDing, updateFreeDing } from "@/http/api/freeDing.js"; import { getFreeDing, updateFreeDing } from '@/http/api/freeDing.js';
const form = reactive({ const form = reactive({
rechargeTimes: 2, rechargeTimes: 2,
rechargeThreshold: "", rechargeThreshold: '',
enable: false, enable: false,
rechargeDesc: "", rechargeDesc: '',
useShopType: "all", useShopType: 'all',
useType: [], useType: [],
shopIdList: [], shopIdList: [],
withCoupon: false, withCoupon: false,
withPoints: false, withPoints: false
}); });
onLoad(() => { onLoad(() => {
// uni.$utils.inputReg.bind()() // uni.$utils.inputReg.bind()()
}); });
onShow(() => { onShow(() => {
getlist(); getlist();
}); });
/** /**
* 获取配置信息 * 获取配置信息
*/ */
const getlist = async () => { const getlist = async () => {
let res = await getFreeDing(); let res = await getFreeDing();
res.shopIdList = res.shopIdList || []; res.shopIdList = res.shopIdList || [];
Object.assign(form, res); Object.assign(form, res);
}; };
let rechargeTimesInput = (e) => { let rechargeTimesInput = (e) => {
console.log(e); console.log(e);
if (e.detail.value == "" || e.detail.value < 2) { if (e.detail.value == '' || e.detail.value < 2) {
form.rechargeTimes = 2; form.rechargeTimes = 2;
uni.showToast({ uni.showToast({
title: "请输入大于等于2的整数", title: '请输入大于等于2的整数',
icon: "none", icon: 'none'
}); });
return; return;
} }
}; };
function rechargeThresholdInput(e){ function rechargeThresholdInput(e) {
if (e.detail.value == "" || e.detail.value <= 0.01) { if (e.detail.value == '' || e.detail.value <= 0.01) {
form.rechargeThreshold = 0.01; form.rechargeThreshold = 0.01;
uni.showToast({ uni.showToast({
title: "请输入大于0的数字", title: '请输入大于0的数字',
icon: "none", icon: 'none'
}); });
return; return;
} }
} }
/** /**
* 修改配置信息 * 修改配置信息
*/ */
const editFreeDing = async () => { const editFreeDing = async () => {
if (!form.rechargeTimes) { if (!form.rechargeTimes) {
uni.showToast({ uni.showToast({
title: "请输入充值设置", title: '请输入充值设置',
icon: "none", icon: 'none'
}); });
return; return;
} }
if (!form.rechargeThreshold) { if (!form.rechargeThreshold) {
uni.showToast({ uni.showToast({
title: "请输入充值门槛", title: '请输入充值门槛',
icon: "none", icon: 'none'
}); });
return; return;
} }
if (form.useShopType != "all" && !form.shopIdList.length) { if (form.useShopType != 'all' && !form.shopIdList.length) {
uni.showToast({ uni.showToast({
title: "请选择可用门店", title: '请选择可用门店',
icon: "none", icon: 'none'
}); });
return; return;
} }
if (form.useType.length == 0) { if (form.useType.length == 0) {
uni.showToast({ uni.showToast({
title: "请选择可使用类型", title: '请选择可使用类型',
icon: "none", icon: 'none'
}); });
return; return;
} }
let res = await updateFreeDing(form); let res = await updateFreeDing(form);
uni.showToast({ uni.showToast({
title: "保存成功", title: '保存成功'
}); });
Object.assign(form, res); Object.assign(form, res);
setTimeout(() => { setTimeout(() => {
// uni.navigateBack(); // uni.navigateBack();
}, 1500); }, 1500);
}; };
function cancel() { function cancel() {
uni.navigateBack(); uni.navigateBack();
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.boxconstant { .boxconstant {
background: #f7f7f7; background: #f7f7f7;
padding: 32rpx 28rpx; padding: 32rpx 28rpx;
.boxconstantbox { .boxconstantbox {
padding: 32rpx 24rpx; padding: 32rpx 24rpx;
border-radius: 16rpx; border-radius: 16rpx;
margin-top: 32rpx; margin-top: 32rpx;
width: 100%; width: 100%;
background: #ffffff; background: #ffffff;
.boxconstantbox_one { .boxconstantbox_one {
font-family: Source Han Sans CN, Source Han Sans CN; font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: bold; font-weight: bold;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
} }
.boxconstantbox_tow { .boxconstantbox_tow {
font-family: Source Han Sans CN, Source Han Sans CN; font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400; font-weight: 400;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
// display: flex; // display: flex;
// justify-content: flex-start; // justify-content: flex-start;
// align-items: center; // align-items: center;
// flex-wrap: wrap; // flex-wrap: wrap;
// align-content: flex-start; // align-content: flex-start;
.text { .text {
display: inline-flex; display: inline-flex;
text-align: center; text-align: center;
margin: 0 12rpx; margin: 0 12rpx;
width: 118rpx; width: 118rpx;
height: 48rpx; height: 48rpx;
line-height: 48rpx; line-height: 48rpx;
background: #ffffff; background: #ffffff;
border-radius: 8rpx 8rpx 8rpx 8rpx; border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #e5e5e5; border: 2rpx solid #e5e5e5;
} }
} }
} }
.oneboxconstant { .oneboxconstant {
margin-top: 32rpx; margin-top: 32rpx;
width: 100%; width: 100%;
background: #ffffff; background: #ffffff;
border-radius: 12rpx 12rpx 12rpx 12rpx; border-radius: 12rpx 12rpx 12rpx 12rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
padding: 32rpx 24rpx; padding: 32rpx 24rpx;
.oneboxconstant_one { .oneboxconstant_one {
font-family: Source Han Sans CN, Source Han Sans CN; font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 500; font-weight: 500;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
} }
} }
.save { .save {
margin: 100rpx auto 50rpx auto; margin: 100rpx auto 50rpx auto;
width: 530rpx; width: 530rpx;
height: 80rpx; height: 80rpx;
background: #318afe; background: #318afe;
border-radius: 56rpx 56rpx 56rpx 56rpx; border-radius: 56rpx 56rpx 56rpx 56rpx;
font-family: Source Han Sans CN, Source Han Sans CN; font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 500; font-weight: 500;
font-size: 32rpx; font-size: 32rpx;
color: #ffffff; color: #ffffff;
line-height: 80rpx; line-height: 80rpx;
text-align: center; text-align: center;
} }
} }
.top { .top {
padding: 24rpx 20rpx 28rpx 28rpx; padding: 24rpx 20rpx 28rpx 28rpx;
} }
.number-box { .number-box {
width: 260rpx; width: 260rpx;
font-size: 28rpx; font-size: 28rpx;
padding: 0 26rpx; padding: 0 26rpx;
border-radius: 6rpx 0 0 6rpx; border-radius: 6rpx 0 0 6rpx;
border-top: 2rpx solid #d9d9d9; border-top: 2rpx solid #d9d9d9;
border-bottom: 2rpx solid #d9d9d9; border-bottom: 2rpx solid #d9d9d9;
border-left: 2rpx solid #d9d9d9; border-left: 2rpx solid #d9d9d9;
background: #fff; background: #fff;
box-sizing: border-box; box-sizing: border-box;
height: 70rpx; height: 70rpx;
line-height: 70rpx; line-height: 70rpx;
} }
.bei { .bei {
display: flex; display: flex;
padding: 0 38rpx; padding: 0 38rpx;
height: 70rpx; height: 70rpx;
line-height: 70rpx; line-height: 70rpx;
align-items: center; align-items: center;
border-radius: 0 6rpx 6rpx 0; border-radius: 0 6rpx 6rpx 0;
border: 2rpx solid #d9d9d9; border: 2rpx solid #d9d9d9;
background: #f7f7fa; background: #f7f7fa;
font-size: 28rpx; font-size: 28rpx;
color: #999999; color: #999999;
} }
</style> </style>

View File

@@ -1,333 +1,293 @@
<template> <template>
<view class="box"> <view class="box">
<view class="bg-fff container u-flex u-m-b-32 top"> <view class="bg-fff container u-flex u-m-b-32 top">
<image <image style="width: 60rpx; height: 60rpx" src="/pageMarket/static/images/cost.png"></image>
style="width: 60rpx; height: 60rpx" <view class="u-flex-1 u-flex u-p-l-24">
src="/pageMarket/static/images/cost.png" <view class="u-font-28 u-flex-1 u-p-r-4">
></image> <view class="color-333 font-bold">消费返现</view>
<view class="u-flex-1 u-flex u-p-l-24"> <view class="color-666 u-m-t-4 u-font-24">用户下单后返现一定的金额到余额可促进复购</view>
<view class="u-font-28 u-flex-1 u-p-r-4"> </view>
<view class="color-333 font-bold">消费返现</view> <up-switch v-model="form.isEnable" :disabled="isMainShop() ? false : true" size="18" :active-value="1" :inactive-value="0"></up-switch>
<view class="color-666 u-m-t-4 u-font-24" </view>
>用户下单后返现一定的金额到余额可促进复购 </view </view>
> <view class="u-m-t-32 container">
</view> <view class="u-flex u-row-between u-m-b-16">
<up-switch <text class="font-bold color-333">可用门店</text>
v-model="form.isEnable" </view>
:disabled="isMainShop()?false:true" <my-shop-select v-model:selShops="form.shopIdList" v-model:useType="form.useType"></my-shop-select>
size="18" </view>
: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>
</view>
<view class="u-m-t-32 container"> <view class="u-m-t-32 container">
<view class="u-flex u-row-between"> <view class="u-flex u-row-between">
<text class="font-bold color-333 u-m-b-16">适用用户</text> <text class="font-bold color-333 u-m-b-16">适用用户</text>
</view> </view>
<userTypes v-model="form.applicableUser"></userTypes> <userTypes v-model="form.applicableUser"></userTypes>
</view> </view>
<view class="u-m-t-32 container"> <view class="u-m-t-32 container">
<view class="u-flex u-row-between"> <view class="u-flex u-row-between">
<text class="font-bold color-333">返现类型</text> <text class="font-bold color-333">返现类型</text>
</view> </view>
<view class="u-m-t-16"> <view class="u-m-t-16">
<up-radio-group v-model="form.cashbackType" placement="row"> <up-radio-group v-model="form.cashbackType" placement="row">
<up-radio <up-radio v-for="item in cashbackTypes" :key="item.value" :name="item.value" :label="item.label">
v-for="item in cashbackTypes" <template #label>
:key="item.value" <text>
:name="item.value" {{ item.label }}
:label="item.label" </text>
> </template>
<template #label> </up-radio>
<text> </up-radio-group>
{{ item.label }} </view>
</text> <view class="u-flex u-row-between u-m-t-32">
</template> <text class="font-bold color-333">阶梯设置</text>
</up-radio> </view>
</up-radio-group> <view class="u-m-t-32 u-flex u-row-between gap-40" v-for="(item, index) in form.cashbackStepList" :key="index">
</view> <view class="u-flex u-col-top">
<view class="u-flex u-row-between u-m-t-32"> <view class="no-wrap u-m-r-16 u-m-t-14">{{ returnName(index) }}</view>
<text class="font-bold color-333">阶梯设置</text> <view class="u-flex-1">
</view> <view class="u-flex">
<view <text class="u-m-r-24">返现门槛</text>
class="u-m-t-32 u-flex u-row-between gap-40" <input class="my-input" type="digit" v-model="item.amount" placeholder="" />
v-for="(item, index) in form.cashbackStepList" <text class="text-tips text-tips1"></text>
:key="index" </view>
> <view class="u-flex u-m-t-24">
<view class="u-flex u-col-top"> <text class="u-m-r-24">{{ form.cashbackType === 'percentage' ? '返现比例' : '返现金额' }}</text>
<view class="no-wrap u-m-r-16 u-m-t-14">{{ returnName(index) }}</view> <input
<view class="u-flex-1"> class="my-input"
<view class="u-flex"> type="number"
<text class="u-m-r-24"> 返现门槛</text> v-model="item.cashbackAmount"
<input @blur="inputBlur($event, index)"
class="my-input" :max="form.cashbackType === 'percentage' ? 100 : 999999"
type="digit" placeholder=""
v-model="item.amount" />
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"></text> </view>
</view> </view>
<view class="u-flex u-m-t-24"> </view>
<text class="u-m-r-24"> {{form.cashbackType === 'percentage' ? '返现比例' : '返现金额'}}</text> </view>
<input
class="my-input"
type="number"
v-model="item.cashbackAmount"
@blur="inputBlur($event, index)"
: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
>
</view>
</view>
</view>
</view>
<button class="add u-m-t-32" @click="addcashbackStepList">添加</button> <button class="add u-m-t-32" @click="addcashbackStepList">添加</button>
</view> </view>
<my-bottom-btn-group @save="save" isOpenPermission @cancel="cancel"></my-bottom-btn-group> <my-bottom-btn-group @save="save" isOpenPermission @cancel="cancel"></my-bottom-btn-group>
</view> </view>
</template> </template>
<script setup> <script setup>
import { reactive, computed, onMounted } from "vue"; import { reactive, computed, onMounted } from 'vue';
import userTypes from "./user-types.vue"; import userTypes from './user-types.vue';
import * as consumeCashbackApi from "@/http/api/market/consumeCashback.js"; import * as consumeCashbackApi from '@/http/api/market/consumeCashback.js';
import { isMainShop } from "@/store/account"; import { isMainShop } from '@/store/account';
import { import { onLoad, onReady, onShow, onPageScroll, onReachBottom, onBackPress } from '@dcloudio/uni-app';
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
//返现类型 //返现类型
const cashbackTypes = [ const cashbackTypes = [
{ {
value: "percentage", value: 'percentage',
label: "按比例返现", label: '按比例返现'
}, },
{ {
value: "fix", value: 'fix',
label: "固定金额", label: '固定金额'
}, }
]; ];
const form = reactive({ const form = reactive({
isEnable: 0, isEnable: 0,
cashbackStepList: [], cashbackStepList: [],
shopIdList: [], shopIdList: [],
useType: "all", useType: 'all',
applicableUser: "all", applicableUser: 'all',
cashbackType: "percentage", cashbackType: 'percentage'
}); });
function addcashbackStepList() { function addcashbackStepList() {
form.cashbackStepList.push({ form.cashbackStepList.push({
amount: 0, amount: 0,
cashbackAmount: 0, cashbackAmount: 0
}); });
} }
function inputBlur(e, index) { function inputBlur(e, index) {
const value = e.detail.value; const value = e.detail.value;
if (form.cashbackType === "percentage") { if (form.cashbackType === 'percentage') {
if (e.detail.value >= 100) { if (e.detail.value >= 100) {
form.cashbackStepList[index].cashbackAmount = 100; form.cashbackStepList[index].cashbackAmount = 100;
} else if (e.detail.value < 0) { } else if (e.detail.value < 0) {
form.cashbackStepList[index].cashbackAmount = 0; form.cashbackStepList[index].cashbackAmount = 0;
} else { } else {
form.cashbackStepList[index].cashbackAmount =e.detail.value; form.cashbackStepList[index].cashbackAmount = e.detail.value;
} }
} else { } else {
if (e.detail.value < 0) { if (e.detail.value < 0) {
form.cashbackStepList[index].cashbackAmount = 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; form.cashbackStepList[index].cashbackAmount = form.cashbackStepList[index].amount;
} else { } else {
form.cashbackStepList[index].cashbackAmount =e.detail.value; form.cashbackStepList[index].cashbackAmount = e.detail.value;
} }
} }
} }
async function save() { async function save() {
console.log(form); console.log(form);
const submitData = { const submitData = {
...form, ...form
}; };
const res = await consumeCashbackApi.update(submitData); const res = await consumeCashbackApi.update(submitData);
uni.showToast({ uni.showToast({
title: "更新成功", title: '更新成功',
icon: "none", icon: 'none',
duration: 2000, duration: 2000,
success: function () {}, success: function () {}
}); });
} }
function cancel() { function cancel() {
uni.navigateBack(); uni.navigateBack();
} }
function deleteThreshold(index) { function deleteThreshold(index) {
form.cashbackStepList.splice(index, 1); form.cashbackStepList.splice(index, 1);
} }
function setForm(data) { function setForm(data) {
data.cashbackStepList=data.cashbackStepList||[] data.cashbackStepList = data.cashbackStepList || [];
Object.assign(form, data); Object.assign(form, data);
console.log(form); console.log(form);
} }
const returnUnit = computed(() => { const returnUnit = computed(() => {
return form.cashbackType === "percentage" ? "%" : "元"; return form.cashbackType === 'percentage' ? '%' : '元';
}); });
const numChineseMap = { const numChineseMap = {
0: "零", 0: '零',
1: "一", 1: '一',
2: "二", 2: '二',
3: "三", 3: '三',
4: "四", 4: '四',
5: "五", 5: '五',
6: "六", 6: '六',
7: "七", 7: '七',
8: "八", 8: '八',
9: "九", 9: '九',
10: "十", 10: '十',
100: "百", 100: '百',
1000: "千", 1000: '千'
}; };
// 辅助函数:将数字转换为中文数字 // 辅助函数:将数字转换为中文数字
function numberToChinese(n) { function numberToChinese(n) {
if (n < 10) { if (n < 10) {
return numChineseMap[n]; return numChineseMap[n];
} }
// 处理10-99 // 处理10-99
if (n < 100) { if (n < 100) {
const ten = Math.floor(n / 10); const ten = Math.floor(n / 10);
const unit = n % 10; const unit = n % 10;
if (ten === 1) { if (ten === 1) {
return unit === 0 ? "十" : `${numChineseMap[unit]}`; return unit === 0 ? '十' : `${numChineseMap[unit]}`;
} else { } else {
return unit === 0 return unit === 0 ? `${numChineseMap[ten]}` : `${numChineseMap[ten]}${numChineseMap[unit]}`;
? `${numChineseMap[ten]}` }
: `${numChineseMap[ten]}${numChineseMap[unit]}`; }
}
}
// 处理100-999 // 处理100-999
if (n < 1000) { if (n < 1000) {
const hundred = Math.floor(n / 100); const hundred = Math.floor(n / 100);
const remainder = n % 100; const remainder = n % 100;
if (remainder === 0) { if (remainder === 0) {
return `${numChineseMap[hundred]}`; return `${numChineseMap[hundred]}`;
} else { } else {
return `${numChineseMap[hundred]}${ return `${numChineseMap[hundred]}${remainder < 10 ? '零' : ''}${numberToChinese(remainder)}`;
remainder < 10 ? "零" : "" }
}${numberToChinese(remainder)}`; }
}
}
// 处理1000-9999 // 处理1000-9999
if (n < 10000) { if (n < 10000) {
const thousand = Math.floor(n / 1000); const thousand = Math.floor(n / 1000);
const remainder = n % 1000; const remainder = n % 1000;
if (remainder === 0) { if (remainder === 0) {
return `${numChineseMap[thousand]}`; return `${numChineseMap[thousand]}`;
} else { } else {
return `${numChineseMap[thousand]}${ return `${numChineseMap[thousand]}${remainder < 100 ? '零' : ''}${numberToChinese(remainder)}`;
remainder < 100 ? "零" : "" }
}${numberToChinese(remainder)}`; }
}
}
// 更大的数字可以继续扩展(如万、亿等),这里以千为单位示例 // 更大的数字可以继续扩展(如万、亿等),这里以千为单位示例
return n.toString(); // 超过范围时返回数字本身(可根据需求扩展) return n.toString(); // 超过范围时返回数字本身(可根据需求扩展)
} }
// 主函数:根据索引返回对应的组名 // 主函数:根据索引返回对应的组名
function returnName(index) { function returnName(index) {
const groupNumber = index + 1; // 索引从0开始组号从1开始 const groupNumber = index + 1; // 索引从0开始组号从1开始
const chineseNumber = numberToChinese(groupNumber); const chineseNumber = numberToChinese(groupNumber);
return `${chineseNumber}`; return `${chineseNumber}`;
} }
const emits = defineEmits(['get']);
async function getData() { async function getData() {
const res = await consumeCashbackApi.getConfig(); const res = await consumeCashbackApi.getConfig();
if (res) { emits('get', res);
setForm(res); if (res) {
} setForm(res);
}
} }
onMounted(() => { onMounted(() => {
getData(); getData();
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
page { page {
background: #f7f7f7; background: #f7f7f7;
} }
.x-padding { .x-padding {
padding: 0 24rpx; padding: 0 24rpx;
} }
.text-tips { .text-tips {
color: #999999; color: #999999;
font-size: 14px; font-size: 14px;
padding: 0 28rpx; padding: 0 28rpx;
border-radius: 6rpx 0 0 6rpx; border-radius: 6rpx 0 0 6rpx;
border: 2rpx solid #d9d9d9; border: 2rpx solid #d9d9d9;
background-color: #f7f7fa; background-color: #f7f7fa;
line-height: 60rpx; line-height: 60rpx;
} }
.text-tips1 { .text-tips1 {
border-radius: 0 6rpx 6rpx 0; border-radius: 0 6rpx 6rpx 0;
} }
.gap-40 { .gap-40 {
gap: 40rpx; gap: 40rpx;
} }
.my-input { .my-input {
border: 2rpx solid #d9d9d9; border: 2rpx solid #d9d9d9;
height: 60rpx; height: 60rpx;
border-right: none; border-right: none;
width: 240rpx; width: 240rpx;
text-align: center; text-align: center;
padding: 0 2px; padding: 0 2px;
font-size: 14px; font-size: 14px;
} }
.box { .box {
padding: 0 28rpx; padding: 0 28rpx;
font-size: 28rpx; font-size: 28rpx;
} }
.container { .container {
background: #fff; background: #fff;
padding: 32rpx 24rpx; padding: 32rpx 24rpx;
margin-top: 32rpx; margin-top: 32rpx;
border-radius: 16rpx; border-radius: 16rpx;
overflow: hidden; overflow: hidden;
} }
.add { .add {
padding: 8rpx 32rpx; padding: 8rpx 32rpx;
border-radius: 12rpx; border-radius: 12rpx;
background: #318afe; background: #318afe;
color: #ffffff; color: #ffffff;
font-size: 28rpx; font-size: 28rpx;
line-height: 56rpx; line-height: 56rpx;
margin: 0; margin: 0;
} }
.color-red { .color-red {
color: #ff2f2f; color: #ff2f2f;
} }
</style> </style>

View File

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

View File

@@ -1,359 +1,325 @@
<template> <template>
<view class="min-page bg-f7 u-font-28"> <view class="min-page bg-f7 u-font-28">
<up-sticky> <up-sticky>
<view class="bg-fff default-box-padding"> <view class="bg-fff default-box-padding">
<view class="u-flex"> <view class="u-flex">
<image <image style="width: 60rpx; height: 60rpx" src="/pageMarket/static/images/coupon_code.png"></image>
style="width: 60rpx; height: 60rpx" <view class="u-flex-1 u-flex u-p-l-24">
src="/pageMarket/static/images/coupon_code.png" <view class="u-font-28 u-flex-1 u-p-r-24">
></image> <view class="color-333 font-bold">券兑换码</view>
<view class="u-flex-1 u-flex u-p-l-24"> <view class="color-666 u-m-t-4 u-font-24">可添加多券组合兑换</view>
<view class="u-font-28 u-flex-1 u-p-r-24"> </view>
<view class="color-333 font-bold">券兑换码 </view> <up-switch
<view class="color-666 u-m-t-4 u-font-24" v-model="accountInfoStore.shopInfo.isProductSuggest"
>可添加多券组合兑换 :disabled="isMainShop() ? false : true"
</view> size="18"
</view> :active-value="1"
<up-switch :inactive-value="0"
v-model="accountInfoStore.shopInfo.isProductSuggest" ></up-switch>
:disabled="isMainShop()?false:true" </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>
size="18" <view class="btn edit" @click="handleEdit(item)">查看</view>
:active-value="1" </view>
:inactive-value="0" <!-- <view class="u-flex u-row-right gap-20 u-m-t-24">
></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 del" @click="handleDelete(item)">删除</view>
<view class="btn edit" @click="handleEdit(item)">查看</view> <view class="btn edit" @click="handleEdit(item)">查看</view>
</view> --> </view> -->
</view> </view>
</view> </view>
<template v-if="isMainShop()"> <template v-if="isMainShop()">
<view style="height: 100rpx"></view> <view style="height: 100rpx"></view>
<view class="fixed-bottom"> <view class="fixed-bottom">
<my-button @click="go.to('PAGES_MARKET_COUPON_EXCHANGE_CODE_ADD')" <my-button @click="go.to('PAGES_MARKET_COUPON_EXCHANGE_CODE_ADD')">添加兑换码</my-button>
>添加兑换码</my-button </view>
> </template>
</view>
</template>
<Modal <Modal v-model="modalData.show" :title="modalData.title" @confirm="handleConfirm">
v-model="modalData.show" <template v-if="modalData.key == 'selShop'">
:title="modalData.title" <view class="default-box-padding">
@confirm="handleConfirm" <my-shop-select @shop-select="shopSelect" v-model:selShops="form.shopIdList" v-model:useType="form.useType"></my-shop-select>
> </view>
<template v-if="modalData.key == 'selShop'"> </template>
<view class="default-box-padding"> </Modal>
<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 <u-action-sheet
:actions="actions" :actions="actions"
cancelText="取消" cancelText="取消"
:closeOnClickAction="true" :closeOnClickAction="true"
round="6" round="6"
@close="showAction = false" @close="showAction = false"
@select="selectStatus" @select="selectStatus"
:show="showAction" :show="showAction"
></u-action-sheet> ></u-action-sheet>
</view> <my-marketing-mask name="充值兑换码" v-if="isMarketShow(form)"></my-marketing-mask>
</view>
</template> </template>
<script setup> <script setup>
import { import { onLoad, onReady, onShow, onPageScroll, onReachBottom, onBackPress } from '@dcloudio/uni-app';
onLoad, import Modal from '@/pageMarket/components/modal.vue';
onReady, import * as couponRedemptionApi from '@/http/api/market/couponRedemption.js';
onShow, import { useAccountInfoStore } from '@/store/account.js';
onPageScroll, import go from '@/commons/utils/go.js';
onReachBottom, import { isMainShop, isMarketShow } from '@/store/account.js';
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";
const accountInfoStore = useAccountInfoStore(); const accountInfoStore = useAccountInfoStore();
import { ref, reactive, onMounted, computed, watch } from "vue"; import { ref, reactive, onMounted, computed, watch } from 'vue';
const loadFinish = ref(false); const loadFinish = ref(false);
const form = reactive({ const form = reactive({
isEnable: 0, isEnable: 0,
useType: "all", useType: 'all',
shopIdList: [], shopIdList: []
}); });
const actions = [ const actions = [
{ {
name: "全部", name: '全部',
value: "", value: ''
}, },
{ {
name: "有效", name: '有效',
value: "0", value: '0'
}, },
{ {
name: "无效", name: '无效',
value: "1", value: '1'
}, }
]; ];
const returnStatusText = computed(() => { const returnStatusText = computed(() => {
return actions.find((item) => item.value == query.status)?.name || "全部"; return actions.find((item) => item.value == query.status)?.name || '全部';
}); });
function returnCoupon(item) { function returnCoupon(item) {
return item.couponInfoList return item.couponInfoList.reduce((prev, cur) => prev + cur.title + '*' + cur.num + '、', '').slice(0, -1);
.reduce((prev, cur) => prev + cur.title + "*" + cur.num + "、", "")
.slice(0, -1);
} }
const showAction = ref(false); const showAction = ref(false);
function selectStatus(item) { function selectStatus(item) {
console.log(item); console.log(item);
query.status = item.value; query.status = item.value;
} }
function showStatusModal() { function showStatusModal() {
showAction.value = true; showAction.value = true;
} }
function showShopModal() { function showShopModal() {
modalData.show = true; modalData.show = true;
modalData.title = "适用门店"; modalData.title = '适用门店';
modalData.key = "selShop"; modalData.key = 'selShop';
} }
const firstModalTime = ref(0); const firstModalTime = ref(0);
const modalData = reactive({ const modalData = reactive({
show: false, show: false,
title: "", title: '',
key: "", key: ''
}); });
function handleDelete(item) { function handleDelete(item) {
uni.showModal({ uni.showModal({
title: "确认删除吗?", title: '确认删除吗?',
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
couponRedemptionApi couponRedemptionApi
.delete({ .delete({
id: item.id, id: item.id
}) })
.then((res) => { .then((res) => {
uni.showToast({ uni.showToast({
title: "删除成功", title: '删除成功',
icon: "none", icon: 'none'
}); });
refreshList(); refreshList();
}); });
} }
}, }
}); });
} }
const isEnd = ref(false); const isEnd = ref(false);
const query = reactive({ const query = reactive({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
status: "", status: ''
}); });
const list = ref([]); const list = ref([]);
function refreshList() { function refreshList() {
query.pageNum = 1; query.pageNum = 1;
isEnd.value = false; isEnd.value = false;
getList(); getList();
} }
function handleEdit(item) { function handleEdit(item) {
uni.setStorageSync("couponRedemptionItem", item); uni.setStorageSync('couponRedemptionItem', item);
go.to("PAGES_MARKET_COUPON_EXCHANGE_CODE_DETAIL", { go.to('PAGES_MARKET_COUPON_EXCHANGE_CODE_DETAIL', {
type: "edit", type: 'edit'
}); });
} }
const handleConfirm = async () => { const handleConfirm = async () => {
if (form.useType == "custom") { if (form.useType == 'custom') {
if (form.shopIdList.length == 0) { if (form.shopIdList.length == 0) {
uni.showToast({ uni.showToast({
title: "请选择适用门店", title: '请选择适用门店',
icon: "none", icon: 'none'
}); });
return; return;
} }
} }
couponRedemptionApi.enable({ couponRedemptionApi.enable({
shopIdList: form.shopIdList || [], shopIdList: form.shopIdList || [],
useType: form.useType, useType: form.useType,
isEnable: form.isEnable, isEnable: form.isEnable
}); });
uni.showToast({ uni.showToast({
title: "修改成功", title: '修改成功',
icon: "none", icon: 'none'
}); });
modalData.show = false; modalData.show = false;
}; };
const getList = async () => { const getList = async () => {
loadFinish.value = false; loadFinish.value = false;
if (isEnd.value) { if (isEnd.value) {
return; return;
} }
const res = await couponRedemptionApi.couponRedemptionList(query); const res = await couponRedemptionApi.couponRedemptionList(query);
loadFinish.value = true; loadFinish.value = true;
if (query.pageNum >= res.totalPage * 1) { if (query.pageNum >= res.totalPage * 1) {
isEnd.value = true; isEnd.value = true;
} }
if (query.pageNum == 1) { if (query.pageNum == 1) {
list.value = res.records || []; list.value = res.records || [];
} else { } else {
list.value = list.value.concat(res.records || []); list.value = list.value.concat(res.records || []);
} }
console.log(list.value); console.log(list.value);
query.pageNum++; query.pageNum++;
}; };
function getShopInfo() { function getShopInfo() {
accountInfoStore.getShopInfo().then((res) => { accountInfoStore.getShopInfo().then((res) => {
console.log(res); console.log(res);
}); });
} }
watch( watch(
() => accountInfoStore.shopInfo.isProductSuggest, () => accountInfoStore.shopInfo.isProductSuggest,
(newVal, oldVal) => { (newVal, oldVal) => {
if(!isMainShop()) return; if (!isMainShop()) return;
if (!loadFinish.value) return; if (!loadFinish.value) return;
accountInfoStore.editShopInfo({ accountInfoStore.editShopInfo({
isProductSuggest: newVal, isProductSuggest: newVal,
id: accountInfoStore.shopInfo.id, id: accountInfoStore.shopInfo.id
}); });
uni.showToast({ uni.showToast({
title: "修改成功", title: '修改成功',
icon: "none", icon: 'none'
}); });
} }
); );
watch( watch(
() => query.status, () => query.status,
(newval) => { (newval) => {
console.log(newval); console.log(newval);
refreshList(); refreshList();
} }
); );
async function getConfig() { async function getConfig() {
couponRedemptionApi.status().then((res) => { couponRedemptionApi.status().then((res) => {
res.shopIdList = res.shopIdList || []; res.shopIdList = res.shopIdList || [];
Object.assign(form, res); Object.assign(form, res);
}); });
} }
onReachBottom(() => { onReachBottom(() => {
console.log("触底"); console.log('触底');
getList(); getList();
}); });
onMounted(() => { onMounted(() => {
getShopInfo(); getShopInfo();
getConfig(); getConfig();
}); });
onShow(() => { onShow(() => {
refreshList(); refreshList();
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.status { .status {
padding: 8rpx 18rpx; padding: 8rpx 18rpx;
border: 2rpx solid transparent; border: 2rpx solid transparent;
border-radius: 8rpx; border-radius: 8rpx;
&.status0 { &.status0 {
background-color: rgba(123, 209, 54, 0.12); background-color: rgba(123, 209, 54, 0.12);
border-color: rgba(123, 209, 54, 1); border-color: rgba(123, 209, 54, 1);
color: #7bd136; color: #7bd136;
} }
&.status1 { &.status1 {
border-color: rgba(153, 153, 153, 1); border-color: rgba(153, 153, 153, 1);
background-color: rgba(153, 153, 153, 0.12); background-color: rgba(153, 153, 153, 0.12);
color: #999; color: #999;
} }
} }
.btn { .btn {
padding: 8rpx 42rpx; padding: 8rpx 42rpx;
white-space: nowrap; white-space: nowrap;
border-radius: 100rpx; border-radius: 100rpx;
&.del { &.del {
background-color: #f7f7fa; background-color: #f7f7fa;
color: #999; color: #999;
} }
&.edit { &.edit {
background-color: $my-main-color; background-color: $my-main-color;
color: #fff; color: #fff;
} }
} }
.fixed-bottom { .fixed-bottom {
} }
.time { .time {
margin-left: 30rpx; margin-left: 30rpx;
padding: 4rpx 20rpx; padding: 4rpx 20rpx;
border: 1px solid $my-main-color; border: 1px solid $my-main-color;
border-radius: 8rpx; border-radius: 8rpx;
color: $my-main-color; color: $my-main-color;
} }
.shop { .shop {
background-color: rgba(49, 138, 254, 0.07); background-color: rgba(49, 138, 254, 0.07);
color: $my-main-color; color: $my-main-color;
border: 1px solid $my-main-color; border: 1px solid $my-main-color;
padding: 20rpx; padding: 20rpx;
border-radius: 8rpx; border-radius: 8rpx;
} }
.status-sel { .status-sel {
min-width: 266rpx; min-width: 266rpx;
padding: 18rpx 32rpx; padding: 18rpx 32rpx;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
border-radius: 8rpx; border-radius: 8rpx;
} }
</style> </style>

View File

@@ -1,372 +1,335 @@
<template> <template>
<view class="min-page bg-f7 u-font-28"> <view class="min-page bg-f7 u-font-28">
<up-sticky> <up-sticky>
<view class="bg-fff default-box-padding"> <view class="bg-fff default-box-padding">
<view class="u-flex"> <view class="u-flex">
<image <image style="width: 60rpx; height: 60rpx" src="/pageMarket/static/images/coupon_code.png"></image>
style="width: 60rpx; height: 60rpx" <view class="u-flex-1 u-flex u-p-l-24">
src="/pageMarket/static/images/coupon_code.png" <view class="u-font-28 u-flex-1 u-p-r-24">
></image> <view class="color-333 font-bold">充值兑换码</view>
<view class="u-flex-1 u-flex u-p-l-24"> <view class="color-666 u-m-t-4 u-font-24">兑换码直充余额可当作礼品赠送</view>
<view class="u-font-28 u-flex-1 u-p-r-24"> </view>
<view class="color-333 font-bold">充值兑换码 </view> <up-switch
<view class="color-666 u-m-t-4 u-font-24" v-model="accountInfoStore.shopInfo.isProductSuggest"
>兑换码直充余额可当作礼品赠送 size="18"
</view> :disabled="isMainShop() ? false : true"
</view> :active-value="1"
<up-switch :inactive-value="0"
v-model="accountInfoStore.shopInfo.isProductSuggest" ></up-switch>
size="18" </view>
:disabled="isMainShop()?false:true" </view>
:active-value="1" </view>
:inactive-value="0" </up-sticky>
></up-switch> <view class="u-p-t-60 default-box-x-padding">
</view> <view class="u-flex u-row-between">
</view> <view class="shop" @click="showShopModal">适用门店</view>
</view> <view class="u-flex status-sel u-row-between bg-fff u-line-1" @click="showStatusModal">
</up-sticky> <text class="color-999" v-if="returnStatusText == '全部'">全部</text>
<view class="u-p-t-60 default-box-x-padding"> <text class="color-333" v-else>{{ returnStatusText }}</text>
<view class="u-flex u-row-between"> <up-icon name="arrow-down" size="14"></up-icon>
<view class="shop" @click="showShopModal">适用门店</view> </view>
<view </view>
class="u-flex status-sel u-row-between bg-fff u-line-1" </view>
@click="showStatusModal" <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">
<text class="color-999" v-if="returnStatusText == '全部'">全部</text> <view class="u-flex u-row-between">
<text class="color-333" v-else>{{ returnStatusText }}</text> <view>
<up-icon name="arrow-down" size="14"></up-icon> <text class="u-font-32 font-bold color-333">{{ item.name }}</text>
</view> <text class="u-font-24 color-666 u-m-l-20">金额{{ item.amount }}</text>
</view> </view>
</view> <view class="status" :class="['status' + item.status]">{{ item.status == 0 ? '有效' : '无效' }}</view>
<view class="default-box-padding"> </view>
<view <view class="u-m-t-22 color-666 u-font-24 u-flex">
v-for="(item, index) in list" <view>
class="u-m-b-56 default-box-radius bg-fff default-box-padding" <view>{{ item.startTime }} {{ item.endTime }}</view>
> <view class="u-m-t-16 u-flex">
<view class="u-flex u-row-between"> <view>
<view> <text>总数</text>
<text class="u-font-32 font-bold color-333">{{ item.name }}</text> <text class="color-333 u-font-28 font-bold">{{ item.total }}</text>
<text class="u-font-24 color-666 u-m-l-20" </view>
>金额{{ item.amount }}</text <view>
> <text class="u-m-l-20">库存</text>
</view> <text class="color-333 u-font-28 font-bold">{{ item.stock }}</text>
<view class="status" :class="['status' + item.status]">{{ </view>
item.status == 0 ? "有效" : "无效" </view>
}}</view> <!-- <view class="u-m-t-16">{{ returnCoupon(item) }}</view> -->
</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 u-flex">
<view>
<text>总数</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>
</view>
</view>
<!-- <view class="u-m-t-16">{{ returnCoupon(item) }}</view> -->
</view>
<view class="btn edit" @click="handleEdit(item)">查看</view> <view class="btn edit" @click="handleEdit(item)">查看</view>
</view> </view>
<!-- <view class="u-flex u-row-right gap-20 u-m-t-24"> <!-- <view class="u-flex u-row-right gap-20 u-m-t-24">
<view class="btn del" @click="handleDelete(item)">删除</view> <view class="btn del" @click="handleDelete(item)">删除</view>
<view class="btn edit" @click="handleEdit(item)">查看</view> <view class="btn edit" @click="handleEdit(item)">查看</view>
</view> --> </view> -->
</view> </view>
</view> </view>
<template v-if="isMainShop()"> <template v-if="isMainShop()">
<view style="height: 100rpx"></view> <view style="height: 100rpx"></view>
<view class="fixed-bottom"> <view class="fixed-bottom">
<my-button @click="go.to('PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD')" <my-button @click="go.to('PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD')">添加兑换码</my-button>
>添加兑换码</my-button </view>
> </template>
</view>
</template>
<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>
<Modal <u-action-sheet
v-model="modalData.show" :actions="actions"
:title="modalData.title" cancelText="取消"
@confirm="handleConfirm" :closeOnClickAction="true"
> round="6"
<template v-if="modalData.key == 'selShop'"> @close="showAction = false"
<view class="default-box-padding"> @select="selectStatus"
<my-shop-select :show="showAction"
@shop-select="shopSelect" ></u-action-sheet>
v-model:selShops="form.shopIdList"
v-model:useType="form.useType"
></my-shop-select>
</view>
</template>
</Modal>
<u-action-sheet <my-marketing-mask name="充值兑换码" v-if="isMarketShow(form)"></my-marketing-mask>
:actions="actions" </view>
cancelText="取消"
:closeOnClickAction="true"
round="6"
@close="showAction = false"
@select="selectStatus"
:show="showAction"
></u-action-sheet>
</view>
</template> </template>
<script setup> <script setup>
import { import { onLoad, onReady, onShow, onPageScroll, onReachBottom, onBackPress } from '@dcloudio/uni-app';
onLoad, import Modal from '@/pageMarket/components/modal.vue';
onReady, import * as rechargeRedemptionApi from '@/http/api/market/rechargeRedemption.js';
onShow, import { useAccountInfoStore } from '@/store/account.js';
onPageScroll, import go from '@/commons/utils/go.js';
onReachBottom, import { isMainShop, isMarketShow } from '@/store/account.js';
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";
const accountInfoStore = useAccountInfoStore(); const accountInfoStore = useAccountInfoStore();
import { ref, reactive, onMounted, computed, watch } from "vue"; import { ref, reactive, onMounted, computed, watch } from 'vue';
const loadFinish = ref(false); const loadFinish = ref(false);
const form = reactive({ const form = reactive({
isEnable: 0, isEnable: 0,
useType: "all", useType: 'all',
shopIdList:[] shopIdList: []
}); });
const actions = [ const actions = [
{ {
name: "全部", name: '全部',
value: "", value: ''
}, },
{ {
name: "有效", name: '有效',
value: "0", value: '0'
}, },
{ {
name: "无效", name: '无效',
value: "1", value: '1'
}, }
]; ];
const returnStatusText = computed(() => { const returnStatusText = computed(() => {
return actions.find((item) => item.value == query.status)?.name || "全部"; return actions.find((item) => item.value == query.status)?.name || '全部';
}); });
function returnCoupon(item) { function returnCoupon(item) {
return item.couponInfoList return item.couponInfoList.reduce((prev, cur) => prev + cur.title + '*' + cur.num + '、', '').slice(0, -1);
.reduce((prev, cur) => prev + cur.title + "*" + cur.num + "、", "")
.slice(0, -1);
} }
const showAction = ref(false); const showAction = ref(false);
function selectStatus(item) { function selectStatus(item) {
console.log(item); console.log(item);
query.status = item.value; query.status = item.value;
} }
function showStatusModal() { function showStatusModal() {
showAction.value = true; showAction.value = true;
} }
function showShopModal() { function showShopModal() {
modalData.show = true; modalData.show = true;
modalData.title = "适用门店"; modalData.title = '适用门店';
modalData.key = "selShop"; modalData.key = 'selShop';
} }
const firstModalTime = ref(0); const firstModalTime = ref(0);
const modalData = reactive({ const modalData = reactive({
show: false, show: false,
title: "", title: '',
key: "", key: ''
}); });
function handleDelete(item) { function handleDelete(item) {
uni.showModal({ uni.showModal({
title: "确认删除吗?", title: '确认删除吗?',
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
rechargeRedemptionApi rechargeRedemptionApi
.delete({ .delete({
id: item.id, id: item.id
}) })
.then((res) => { .then((res) => {
uni.showToast({ uni.showToast({
title: "删除成功", title: '删除成功',
icon: "none", icon: 'none'
}); });
refreshList(); refreshList();
}); });
} }
}, }
}); });
} }
const isEnd = ref(false); const isEnd = ref(false);
const query = reactive({ const query = reactive({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
status: "", status: ''
}); });
const list = ref([]); const list = ref([]);
function refreshList() { function refreshList() {
query.pageNum = 1; query.pageNum = 1;
isEnd.value = false; isEnd.value = false;
getList(); getList();
} }
function handleEdit(item) { function handleEdit(item) {
uni.setStorageSync("rechargeRedemption", item); uni.setStorageSync('rechargeRedemption', item);
go.to("PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD_DWTAIL", { go.to('PAGES_MARKET_RECHARGE_EXCHANGE_CODE_ADD_DWTAIL', {
type: "edit", type: 'edit'
}); });
} }
const handleConfirm = async () => { const handleConfirm = async () => {
if (form.useType == "custom") { if (form.useType == 'custom') {
if (form.shopIdList.length == 0) { if (form.shopIdList.length == 0) {
uni.showToast({ uni.showToast({
title: "请选择适用门店", title: '请选择适用门店',
icon: "none", icon: 'none'
}); });
return; return;
} }
} }
rechargeRedemptionApi.enable({ rechargeRedemptionApi.enable({
shopIdList: form.shopIdList||[], shopIdList: form.shopIdList || [],
useType: form.useType, useType: form.useType,
isEnable: form.isEnable, isEnable: form.isEnable
}); });
uni.showToast({ uni.showToast({
title: "修改成功", title: '修改成功',
icon: "none", icon: 'none'
}); });
modalData.show = false; modalData.show = false;
}; };
const getList = async () => { const getList = async () => {
loadFinish.value = false; loadFinish.value = false;
if (isEnd.value) { if (isEnd.value) {
return; return;
} }
const res = await rechargeRedemptionApi.couponRedemptionList(query); const res = await rechargeRedemptionApi.couponRedemptionList(query);
loadFinish.value = true; loadFinish.value = true;
if (query.pageNum >= res.totalPage * 1) { if (query.pageNum >= res.totalPage * 1) {
isEnd.value = true; isEnd.value = true;
} }
if (query.pageNum == 1) { if (query.pageNum == 1) {
list.value = res.records || []; list.value = res.records || [];
} else { } else {
list.value = list.value.concat(res.records || []); list.value = list.value.concat(res.records || []);
} }
console.log(list.value); console.log(list.value);
query.pageNum++; query.pageNum++;
}; };
function getShopInfo() { function getShopInfo() {
accountInfoStore.getShopInfo().then((res) => { accountInfoStore.getShopInfo().then((res) => {
console.log(res); console.log(res);
}); });
} }
watch( watch(
() => accountInfoStore.shopInfo.isProductSuggest, () => accountInfoStore.shopInfo.isProductSuggest,
(newVal, oldVal) => { (newVal, oldVal) => {
if(!isMainShop()) return; if (!isMainShop()) return;
if (!loadFinish.value) return; if (!loadFinish.value) return;
accountInfoStore.editShopInfo({ accountInfoStore.editShopInfo({
isProductSuggest: newVal, isProductSuggest: newVal,
id: accountInfoStore.shopInfo.id, id: accountInfoStore.shopInfo.id
}); });
uni.showToast({ uni.showToast({
title: "修改成功", title: '修改成功',
icon: "none", icon: 'none'
}); });
} }
); );
watch( watch(
() => query.status, () => query.status,
(newval) => { (newval) => {
console.log(newval); console.log(newval);
refreshList(); refreshList();
} }
); );
async function getConfig() { async function getConfig() {
rechargeRedemptionApi.status().then((res) => { rechargeRedemptionApi.status().then((res) => {
res.shopIdList = res.shopIdList || []; res.shopIdList = res.shopIdList || [];
Object.assign(form, res); Object.assign(form, res);
}); });
} }
onReachBottom(() => { onReachBottom(() => {
console.log("触底"); console.log('触底');
getList(); getList();
}); });
onMounted(() => { onMounted(() => {
getShopInfo(); getShopInfo();
getConfig(); getConfig();
}); });
onShow(() => { onShow(() => {
refreshList(); refreshList();
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.status { .status {
padding: 8rpx 18rpx; padding: 8rpx 18rpx;
border: 2rpx solid transparent; border: 2rpx solid transparent;
border-radius: 8rpx; border-radius: 8rpx;
&.status0 { &.status0 {
background-color: rgba(123, 209, 54, 0.12); background-color: rgba(123, 209, 54, 0.12);
border-color: rgba(123, 209, 54, 1); border-color: rgba(123, 209, 54, 1);
color: #7bd136; color: #7bd136;
} }
&.status1 { &.status1 {
border-color: rgba(153, 153, 153, 1); border-color: rgba(153, 153, 153, 1);
background-color: rgba(153, 153, 153, 0.12); background-color: rgba(153, 153, 153, 0.12);
color: #999; color: #999;
} }
} }
.btn { .btn {
padding: 8rpx 42rpx; padding: 8rpx 42rpx;
white-space: nowrap; white-space: nowrap;
border-radius: 100rpx; border-radius: 100rpx;
&.del { &.del {
background-color: #f7f7fa; background-color: #f7f7fa;
color: #999; color: #999;
} }
&.edit { &.edit {
background-color: $my-main-color; background-color: $my-main-color;
color: #fff; color: #fff;
} }
} }
.fixed-bottom { .fixed-bottom {
} }
.time { .time {
margin-left: 30rpx; margin-left: 30rpx;
padding: 4rpx 20rpx; padding: 4rpx 20rpx;
border: 1px solid $my-main-color; border: 1px solid $my-main-color;
border-radius: 8rpx; border-radius: 8rpx;
color: $my-main-color; color: $my-main-color;
} }
.shop { .shop {
background-color: rgba(49, 138, 254, 0.07); background-color: rgba(49, 138, 254, 0.07);
color: $my-main-color; color: $my-main-color;
border: 1px solid $my-main-color; border: 1px solid $my-main-color;
padding: 20rpx; padding: 20rpx;
border-radius: 8rpx; border-radius: 8rpx;
} }
.status-sel { .status-sel {
min-width: 266rpx; min-width: 266rpx;
padding: 18rpx 32rpx; padding: 18rpx 32rpx;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
border-radius: 8rpx; border-radius: 8rpx;
} }
</style> </style>

View File

@@ -87,6 +87,7 @@
</template> </template>
<my-model ref="model" :desc="modelData.desc"></my-model> <my-model ref="model" :desc="modelData.desc"></my-model>
<my-date-pickerview @confirm="datePickerConfirm" ref="datePicker"></my-date-pickerview> <my-date-pickerview @confirm="datePickerConfirm" ref="datePicker"></my-date-pickerview>
<my-marketing-mask name="智慧充值" v-if="isMarketShow(shopRechargeRes)"></my-marketing-mask>
</view> </view>
</template> </template>
@@ -105,7 +106,7 @@ import $util from '@/commons/utils/getDateArea.js';
import go from '@/commons/utils/go.js'; import go from '@/commons/utils/go.js';
import { shopRechargePost, shopRechargeGet } from '@/http/api/market/index.js'; import { shopRechargePost, shopRechargeGet } from '@/http/api/market/index.js';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { isMainShop } from '@/store/account.js'; import { isMainShop, isMarketShow } from '@/store/account.js';
const isCanEdit = computed(() => { const isCanEdit = computed(() => {
return isMainShop(); return isMainShop();
@@ -192,11 +193,12 @@ function useTypeChange(e) {
} }
// 获取设置 // 获取设置
const shopRechargeRes = ref({});
async function shopRechargeGetAjax() { async function shopRechargeGetAjax() {
try { try {
const res = await shopRechargeGet(); shopRechargeRes.value = await shopRechargeGet();
isOpen.value = res.isEnable; isOpen.value = shopRechargeRes.value.isEnable;
res.rechargeDetailList.forEach((item) => { shopRechargeRes.value.rechargeDetailList.forEach((item) => {
item.couponInfoList.forEach((val) => { item.couponInfoList.forEach((val) => {
if (val.coupon && val.coupon !== null) { if (val.coupon && val.coupon !== null) {
val.id = val.coupon.id; val.id = val.coupon.id;
@@ -204,8 +206,8 @@ async function shopRechargeGetAjax() {
} }
}); });
}); });
settingForm.value = res; settingForm.value = shopRechargeRes.value;
rechargeLists.value = res.rechargeDetailList; rechargeLists.value = shopRechargeRes.value.rechargeDetailList;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }

View File

@@ -1,41 +1,65 @@
// stores/counter.js // stores/counter.js
import { defineStore } from "pinia"; import {
defineStore
} from "pinia";
import * as shopApi from "@/http/api/shop.js"; import * as shopApi from "@/http/api/shop.js";
//判断是否是主店 // 判断是否是主店,并且是否有查看权限
export const isMainShop = (shopId) => { export const isMainShop = (shopId) => {
const shopInfo=uni.getStorageSync("shopInfo"); const shopInfo = uni.getStorageSync("shopInfo");
if(shopInfo.isHeadShop){ if (shopInfo.isHeadShop) {
return true return true
} }
if(shopInfo.shopType=='only'){ if (shopInfo.shopType == 'only') {
return true return true
} }
return false 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", { export const useAccountInfoStore = defineStore("accountInfo", {
state: () => { state: () => {
return { return {
shopInfo: {}, shopInfo: {},
}; };
}, },
actions: { actions: {
getShopInfo() { getShopInfo() {
return shopApi.getShopInfo().then((res) => { return shopApi.getShopInfo().then((res) => {
this.shopInfo = res; this.shopInfo = res;
return this.shopInfo; return this.shopInfo;
}); });
}, },
editShopInfo(data,autoRefresh = true) { editShopInfo(data, autoRefresh = true) {
return shopApi.editShopInfo(data).then((res) => { return shopApi.editShopInfo(data).then((res) => {
if(autoRefresh) { if (autoRefresh) {
this.getShopInfo() this.getShopInfo()
} }
return res return res
}); });
}, },
}, },
unistorage: true, // 开启后对 state 的数据读写都将持久化 unistorage: true, // 开启后对 state 的数据读写都将持久化
}); });