完成分销基础设置页面,分销员列表

This commit is contained in:
2025-11-19 18:26:00 +08:00
parent 3f860e4733
commit f03d8fdbb4
10 changed files with 1784 additions and 408 deletions

View File

@@ -0,0 +1,84 @@
<template>
<view>
<up-popup :show="show" mode="center">
<view class="popup-content">
<view class="top u-flex u-row-between">
<text class="font-bold u-font-32 color-333">{{title}}</text>
<up-icon size="18" name="close" @click="show=false"></up-icon>
</view>
<up-line></up-line>
<scroll-view style="max-height:50vh;">
<slot></slot>
</scroll-view>
<up-line></up-line>
<view class="bottom">
<view class="btn success" @click="confirm">{{confirmText}}</view>
<view class="btn cancel" @click="close">{{cancelText}}</view>
</view>
</view>
</up-popup>
</view>
</template>
<script setup>
import { ref } from "vue";
const props = defineProps({
title: {
type: String,
default: "标题",
},
confirmText: {
type: String,
default: "保存",
},
cancelText: {
type: String,
default: "取消",
},
});
const show = defineModel({
type: Boolean,
default: false,
})
const emits=defineEmits(['close','confirm'])
function close(){
show.value=false
emits('close')
}
function confirm(){
emits('confirm')
}
</script>
<style lang="scss">
.popup-content{
background: #fff;
width: 640rpx;
border-radius: 18rpx;
}
.top{
padding: 40rpx 48rpx;
}
.bottom{
padding: 48rpx 52rpx;
display: flex;
justify-content: space-between;
gap: 50rpx;
.btn{
flex:1;
text-align: center;
padding: 34rpx 20rpx;
border-radius: 4rpx;
font-size: 32rpx;
border: 2rpx solid transparent;
&.success{
background-color: $my-main-color;
color:#fff;
}
&.cancel{
border-color:#D9D9D9;
box-shadow: 0 4rpx 0 0 #00000005;
}
}
}
</style>

View File

@@ -1,93 +1,175 @@
<template>
<view class="box">
<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-flex u-row-between">
<text class="font-bold color-333 u-m-b-16">适用用户</text>
</view>
<userTypes v-model="form.applicableUser"></userTypes>
</view>
<view class="u-m-t-32 container">
<view class="u-flex u-row-between">
<text class="font-bold color-333">返现类型</text>
</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"
>
<template #label>
<text>
{{ item.label }}
</text>
</template>
</up-radio>
</up-radio-group>
</view>
<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-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="text-tips text-tips1"></text>
</view>
<view class="u-flex u-m-t-24">
<text class="u-m-r-24"> {{form.cashbackType === 'percentage' ? '返现比例' : '返现金额'}}</text>
<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 class="u-m-t-32 container" style="padding-left: 0; padding-right: 0">
<view class="x-padding">
<view class="u-flex u-row-between">
<text class="font-bold color-333">开通方式</text>
</view>
<view class="u-m-t-16">
<up-radio-group v-model="form.openType" placement="row">
<up-radio
v-for="item in opentypes"
:key="item.value"
:name="item.value"
:label="item.label"
>
<template #label>
<text>
{{ item.label }}
</text>
</template>
</up-radio>
</up-radio-group>
</view>
</view>
<button class="add u-m-t-32" @click="addcashbackStepList">添加</button>
<template v-if="form.openType == 'auto'">
<view class="u-m-t-24">
<up-line></up-line>
</view>
<view class="x-padding u-m-t-24">
<view class="u-flex u-row-between">
<text class="font-bold color-333">获得佣金条件</text>
</view>
<view class="u-flex u-m-t-16">
<input
class="number-box"
placeholder="请输入"
placeholder-class="color-999 u-font-28"
type="number"
v-model="form.inviteCount"
/>
<view class="unit"></view>
</view>
<view class="color-999 u-font-24 u-m-t-8"
>邀请达到指定人数才可赚取佣金</view
>
<view class="u-m-t-24">
<up-line></up-line>
</view>
<view class="u-flex u-row-between u-m-t-20">
<text class="font-bold color-333">被邀请人消费有效</text>
<up-switch :active-value="1" :inactive-value="0" v-model="form.inviteConsume"></up-switch>
</view>
</view>
</template>
<template v-if="form.openType == 'pay'">
<view class="u-m-t-24">
<up-line></up-line>
</view>
<view class="x-padding u-m-t-24">
<view class="u-flex u-row-between">
<text class="font-bold color-333">付费金额</text>
</view>
<view class="u-flex u-m-t-16">
<input
class="number-box"
placeholder="请输入"
placeholder-class="color-999 u-font-28"
type="number"
v-model="form.payAmount"
/>
<view class="unit"></view>
</view>
</view>
</template>
</view>
<view class="u-m-t-32 container" style="padding-left: 0; padding-right: 0">
<view class="x-padding">
<view class="u-flex u-row-between">
<text class="font-bold color-333">分销奖励次数</text>
</view>
<view class="u-m-t-16">
<up-radio-group v-model="isLimitCount" placement="row">
<up-radio
v-for="item in isLimitCounts"
:key="item.value"
:name="item.value"
:label="item.label"
>
<template #label>
<text>
{{ item.label }}
</text>
</template>
</up-radio>
</up-radio-group>
</view>
</view>
<template v-if="isLimitCount == 0">
<view class="u-m-t-24 x-padding">
<up-line></up-line>
</view>
<view class="x-padding u-m-t-24">
<view class="u-flex u-row-between">
<text class="font-bold color-333">每人奖励</text>
</view>
<view class="u-flex u-m-t-16">
<input
class="number-box"
placeholder="请输入"
placeholder-class="color-999 u-font-28"
type="number"
v-model="form.rewardCount"
/>
<view class="unit"></view>
</view>
<view class="u-m-t-24">
<up-line></up-line>
</view>
</view>
</template>
<view class="x-padding u-m-t-24">
<view class="u-flex u-row-between">
<text class="font-bold color-333">结算时长</text>
</view>
<view class="u-flex u-m-t-16">
<input
class="number-box"
placeholder="请输入"
placeholder-class="color-999 u-font-28"
type="number"
v-model="form.settlementDay"
/>
<view class="unit"></view>
</view>
<view class="u-m-t-24">
<up-line></up-line>
</view>
</view>
</view>
<view class="u-m-t-32 container">
<view
class="u-flex u-row-between u-p-b-26"
@click="go.to('PAGES_DISTRIBUTION_LEVEL_LIST')"
>
<text class="font-bold color-333">分销员等级</text>
<view class="u-flex">
<text class="u-font-24">去设置</text>
<up-icon name="arrow-right"></up-icon>
</view>
</view>
<up-line></up-line>
<view class="u-flex u-row-between u-p-t-26">
<text class="font-bold color-333">未开通页面</text>
<view class="u-flex">
<text class="u-font-28 color-999">请前往PC端设置</text>
</view>
</view>
</view>
<my-bottom-btn-group @save="save" @cancel="cancel"></my-bottom-btn-group>
</view>
</template>
<script setup>
import { reactive, computed, onMounted } from "vue";
<script setup>
import { reactive, computed, onMounted, ref, inject } from "vue";
import userTypes from "./user-types.vue";
import * as consumeCashbackApi from "@/http/api/market/consumeCashback.js";
import {
onLoad,
onReady,
@@ -96,60 +178,67 @@ import {
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
import go from "@/commons/utils/go.js";
//返现类型
const cashbackTypes = [
import { watch } from "vue";
const distributionStore = inject("distributionStore");
//分销奖励次数
const isLimitCount = ref(0);
const isLimitCounts = [
{
value: "percentage",
label: "按比例返现",
value: 0,
label: "限制",
},
{
value: "fix",
label: "固定金额",
value: 1,
label: "不限制",
},
];
//开通方式
const opentypes = [
{
value: "auto",
label: "自动开通",
},
{
value: "manual",
label: "手动开通",
},
{
value: "pay",
label: "付费开通",
},
];
const form = reactive({
isEnable: 0,
cashbackStepList: [],
shopIdList: [],
useType: "all",
applicableUser: "all",
cashbackType: "percentage",
isEnable: 1,
openType: "pay",
inviteCount: 1,
inviteConsume: 0,
payAmount: 0,
rewardCount: 1,
settlementDay: 1,
upgradeType: "auto",
notActivatedPage: null,
levelConfigList: [],
});
function addcashbackStepList() {
form.cashbackStepList.push({
amount: 0,
cashbackAmount: 0,
});
}
function inputBlur(e, index) {
const value = e.detail.value;
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;
watch(
() => isLimitCount.value,
(newval) => {
if (newval) {
form.rewardCount = -1;
} else {
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) {
form.cashbackStepList[index].cashbackAmount = form.cashbackStepList[index].amount;
} else {
form.cashbackStepList[index].cashbackAmount =e.detail.value;
form.rewardCount = "";
}
}
}
);
async function save() {
console.log(form);
const submitData = {
...form,
};
const res = await consumeCashbackApi.update(submitData);
const res = await distributionStore.editConfig(submitData);
uni.showToast({
title: "更新成功",
icon: "none",
@@ -160,105 +249,26 @@ async function save() {
function cancel() {
uni.navigateBack();
}
watch(
() => distributionStore.config,
(newval) => {
setForm(newval);
}
);
function deleteThreshold(index) {
form.cashbackStepList.splice(index, 1);
}
function setForm(data) {
data.cashbackStepList=data.cashbackStepList||[]
if (data.rewardCount == -1) {
isLimitCount.value = 1;
}
Object.assign(form, data);
console.log(form);
}
const returnUnit = computed(() => {
return form.cashbackType === "percentage" ? "%" : "元";
});
const numChineseMap = {
0: "零",
1: "一",
2: "二",
3: "三",
4: "四",
5: "五",
6: "六",
7: "七",
8: "八",
9: "九",
10: "十",
100: "百",
1000: "千",
};
// 辅助函数:将数字转换为中文数字
function numberToChinese(n) {
if (n < 10) {
return numChineseMap[n];
}
// 处理10-99
if (n < 100) {
const ten = Math.floor(n / 10);
const unit = n % 10;
if (ten === 1) {
return unit === 0 ? "十" : `${numChineseMap[unit]}`;
} else {
return unit === 0
? `${numChineseMap[ten]}`
: `${numChineseMap[ten]}${numChineseMap[unit]}`;
}
}
// 处理100-999
if (n < 1000) {
const hundred = Math.floor(n / 100);
const remainder = n % 100;
if (remainder === 0) {
return `${numChineseMap[hundred]}`;
} else {
return `${numChineseMap[hundred]}${
remainder < 10 ? "零" : ""
}${numberToChinese(remainder)}`;
}
}
// 处理1000-9999
if (n < 10000) {
const thousand = Math.floor(n / 1000);
const remainder = n % 1000;
if (remainder === 0) {
return `${numChineseMap[thousand]}`;
} else {
return `${numChineseMap[thousand]}${
remainder < 100 ? "零" : ""
}${numberToChinese(remainder)}`;
}
}
// 更大的数字可以继续扩展(如万、亿等),这里以千为单位示例
return n.toString(); // 超过范围时返回数字本身(可根据需求扩展)
}
// 主函数:根据索引返回对应的组名
function returnName(index) {
const groupNumber = index + 1; // 索引从0开始组号从1开始
const chineseNumber = numberToChinese(groupNumber);
return `${chineseNumber}`;
}
async function getData() {
const res = await consumeCashbackApi.getConfig();
if (res) {
setForm(res);
}
}
onMounted(() => {
getData();
});
onMounted(() => {});
</script>
<style lang="scss" scoped>
page {
background: #f7f7f7;
}
<style lang="scss" scoped>
.x-padding {
padding: 0 24rpx;
}
@@ -309,4 +319,30 @@ page {
.color-red {
color: #ff2f2f;
}
</style>
$height: 70rpx;
.number-box {
font-size: 28rpx;
padding: 0 26rpx;
border-radius: 6rpx 0 0 6rpx;
border-top: 2rpx solid #d9d9d9;
border-bottom: 2rpx solid #d9d9d9;
border-left: 2rpx solid #d9d9d9;
background: #fff;
box-sizing: border-box;
height: $height;
flex: 1;
line-height: $height;
}
.unit {
display: flex;
padding: 0 38rpx;
height: $height;
line-height: $height;
align-items: center;
border-radius: 0 6rpx 6rpx 0;
border: 2rpx solid #d9d9d9;
background: #f7f7fa;
font-size: 28rpx;
color: #999999;
}
</style>

View File

@@ -0,0 +1,268 @@
<template>
<view class="list u-font-28">
<view class="u-m-t-32 item" v-for="item in list" :key="item.id">
<view class="u-flex u-row-between">
<view class="color-333 u-font-28">
<view> 用户昵称 </view>
<view class="u-m-t-4">
<text class="color-333 font-bold"> {{ item.shopUserName }}</text>
</view>
</view>
<view>
<view class="color-main font-bold">{{
item.distributionLevelName
}}</view>
<view class="color-666 u-font-24 u-m-t-4">{{ item.createTime }}</view>
</view>
</view>
<view class="color-333 u-flex u-row-between u-font-28 u-m-t-16 money">
<view>
<view class="color-666">总收益</view>
<view class="color-333 u-m-t-16 font-700 u-font-32">{{
item.totalIncome || 0
}}</view>
</view>
<view>
<view class="color-666">已入账</view>
<view class="color-333 u-m-t-16 font-700 u-font-32">{{
item.receivedIncome || 0
}}</view>
</view>
<view>
<view class="color-666">未入账</view>
<view class="color-333 u-m-t-16 font-700 u-font-32">{{
item.pendingIncome || 0
}}</view>
</view>
</view>
<view class="u-m-t-16 u-flex u-row-right">
<view class="more" @click="moreShow(item)">更多</view>
</view>
</view>
<view class="u-p-30">
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
</view>
<view style="height: 100rpx"></view>
<view class="bottom">
<my-button>添加分销员</my-button>
</view>
<up-action-sheet
:show="showActions"
:actions="actions"
@select="handleSelect"
@close="showActions = false"
cancel-text="取消"
></up-action-sheet>
<Modal v-model="modalData.show" :title="modalData.title"
@confirm="handleConfirm"
>
<view class="u-p-48" v-if="modalData.key == 'change-group'">
<view class="u-m-r-36 u-m-b-24">分销组</view>
<up-radio-group v-model="group" placement="row" place="row">
<up-radio
v-for="item in distributionStore.config.levelConfigList"
:key="item.id"
:name="item.id"
:label="item.name"
>
<template #label>
<text>
{{ item.name }}
</text>
</template>
</up-radio>
</up-radio-group>
</view>
<view class="u-p-48 u-flex" v-if="modalData.key == 'reset-group'">
<up-icon name="info-circle" color="#FF2F2F" size="20"></up-icon>
<view class="u-font-32 color-333 u-m-l-20"
>是否确认重置分销组 重置后将会按照用户的实际数据匹配分销组</view
>
</view>
<view class="u-p-48 u-flex" v-if="modalData.key == 'cancel-group'">
<up-icon name="info-circle" color="#FF2F2F" size="20"></up-icon>
<view class="u-font-32 color-333 u-m-l-20">是否确认取消分销员</view>
</view>
</Modal>
</view>
</template>
<script setup>
import {
ref,
reactive,
watch,
toRaw,
onMounted,
onUnmounted,
inject,
} from "vue";
import Modal from "@/pageMarket/components/modal.vue";
const props = defineProps({
list: {
type: Array,
default: () => [],
},
isEnd: {
type: Boolean,
default: false,
},
});
//选中的分销组
const group = ref("");
const distributionStore = inject("distributionStore");
const distributionApi = inject("distributionApi");
const modalData = reactive({
show: false,
title: "",
key: "",
data: null,
});
const showActions = ref(false);
const $actions = [
{
name: "更改分销组",
value: "change-group",
},
{
name: "重置分销组",
value: "reset-group",
},
{
name: "恢复分销员",
value: "back-fenxiao",
},
{
name: "取消分销员",
value: "cancel-fenxiao",
},
];
const actions = ref($actions);
function moreShow(item) {
modalData.data = item;
group.value = item.distributionLevelId;
if (item.isAssignLevel == 0) {
actions.value = $actions.filter((item) => item.value !== "reset-group");
} else {
actions.value = $actions.filter((item) => item.value !== "change-group");
}
if(item.status == 1){
actions.value = actions.value.filter((item) => item.value !== "back-fenxiao");
}
if(item.status == 9){
actions.value = actions.value.filter((item) => item.value !== "cancel-fenxiao");
}
showActions.value = true;
}
function handleSelect(item) {
console.log(item);
modalData.title = item.name;
modalData.key = item.value;
showActions.value = false;
modalData.show = true;
}
const emits=defineEmits(["refresh"]);
async function handleConfirm() {
if (modalData.key == "reset-group") {
await distributionApi.resetLevel({
id: modalData.data.id,
shopId: uni.getSystemInfoSync("shopInfo").id || "",
});
}
if (modalData.key == "change-group") {
const level=distributionStore.config.levelConfigList.find((item) => item.id == group.value)
await distributionApi.editDistributionUser({
id: modalData.data.id,
isAssignLevel:1,
distributionLevelId:group.value,
distributionLevelName:level.name,
});
emits("refresh");
}
if (modalData.key == "cancel-fenxiao") {
await distributionApi.editDistributionUser({
id: modalData.data.id,
status:9
});
emits("refresh");
}
if (modalData.key == "back-fenxiao") {
await distributionApi.editDistributionUser({
id: modalData.data.id,
status:1
});
emits("refresh");
}
group.value = "";
modalData.show = false;
}
</script>
<style lang="scss">
.list {
padding: 0 30rpx;
.item {
padding: 32rpx 24rpx;
border-radius: 14rpx;
background-color: #fff;
overflow: hidden;
}
}
.tag {
border-radius: 12rpx;
padding: 8rpx 22rpx;
font-size: 28rpx;
&.success {
background-color: #edfff0;
color: #5bbc6d;
}
&.end {
background-color: #f7f7f7;
color: #999;
}
}
.my-btn {
font-size: 28rpx;
line-height: 36rpx;
padding: 8rpx 32rpx;
border-radius: 12rpx;
margin: 0;
}
.money {
background-color: #f8f8f8;
border-radius: 8rpx;
padding: 16rpx 28rpx;
}
.more {
display: flex;
height: 56rpx;
padding: 8rpx 28rpx;
justify-content: center;
align-items: center;
gap: 20rpx;
border-radius: 28rpx;
border: 2rpx solid $my-main-color;
color: $my-main-color;
background: #fff;
}
.bottom {
position: fixed;
bottom: calc(env(safe-area-inset-bottom) + 30rpx);
left: 30rpx;
right: 30rpx;
}
</style>

View File

@@ -1,221 +1,324 @@
<template>
<view class="min-page">
<up-sticky>
<view class="bg-fff top">
<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>
<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>
</view>
</view>
</view>
</up-sticky>
<configVue v-if="active == 0"></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 class="u-m-t-14">
<text class="color-333 font-bold"> {{ 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>
</view>
<view class="u-m-t-22">
<u-line></u-line>
</view>
<view class="color-333 u-flex u-row-between u-font-28" style="margin-top: 52rpx">
<view>
<view class="color-666">用户昵称</view>
<view class="color-333 u-m-t-24 u-line-1">{{ item.nickName }}</view>
</view>
<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>
<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 class="min-page u-font-28">
<up-sticky>
<view class="bg-fff top">
<view class="bg-fff container u-flex u-m-b-48">
<image
style="width: 60rpx; height: 60rpx"
src="/pageMarket/static/images/distribution.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>
<up-switch
v-model="distributionStore.config.isEnable"
size="18"
:active-value="1"
:inactive-value="0"
></up-switch>
</view>
</view>
<my-tabs v-model="active" :list="tabs" textKey="label"></my-tabs>
<view
v-if="active == 1"
class="u-flex u-row-between u-m-t-32"
style="gap: 58rpx"
>
<view class="u-flex-1 filter-box" style="border-radius: 100rpx">
<up-icon name="search" size="18"></up-icon>
<input
class="u-m-l-10 u-font-28"
type="text"
placeholder-class="color-999 u-font-28"
placeholder="搜索关键词"
v-model="keyWord"
@blur="keyWordBlur"
/>
</view>
<view
class="u-flex-1 u-font-28 filter-box u-flex u-row-between"
@click="showTimeArea = true"
>
<template
v-if="userComponentQuery.startTime && userComponentQuery.endTime"
>
<text class="u-font-20">
{{ userComponentQuery.startTime }} -
{{ userComponentQuery.endTime }}
</text>
</template>
<template v-else>
<text class="color-999">请选择日期范围</text>
<up-icon name="arrow-right" size="12"></up-icon>
</template>
</view>
</view>
<!-- <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>
<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>
</view>
</view> -->
</view>
</up-sticky>
<configVue v-if="active == 0"></configVue>
<fenxiaoUserListVue
v-if="active == 1"
:list="list"
:isEnd="isEnd"
@refresh="fenxaioListRefresh"
></fenxiaoUserListVue>
</view>
<view class="u-p-30">
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
</view>
</view>
<!-- 选择门店 -->
<shopSelActionSheetVue
@choose="chooseShop"
v-model="showShopSelActionSheet"
title="选择门店"
>
</shopSelActionSheetVue>
<!-- 选择门店 -->
<shopSelActionSheetVue @choose="chooseShop" v-model="showShopSelActionSheet" title="选择门店">
</shopSelActionSheetVue>
</view>
<dateAreaSel
:show="showTimeArea"
:minYear="2022"
@close="showTimeArea = false"
@confirm="confirmTimeArea"
></dateAreaSel>
</view>
</template>
<script setup>
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
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: "user"
},
{
label: "开通记录",
value: "recoders"
},
{
label: "分销明细",
value: "details"
},
];
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
const list = ref([]);
const pageNum = ref(1);
const isEnd = ref(false);
const selShop = ref({
shopId: "",
shopName: "",
})
const searchText = ref("");
import { ref, onMounted, watch, provide } from "vue";
import * as consumeCashbackApi from "@/http/api/market/consumeCashback.js";
import * as distributionApi from "@/http/api/market/distribution.js";
import configVue from "./components/config.vue";
import shopSelActionSheetVue from "@/pageMarket/components/shop-sel-action-sheet.vue";
import dateAreaSel from "@/components/date-range-picker/date-range-picker.vue";
import fenxiaoUserListVue from "./components/fenxiao-user-list.vue";
function search() {
pageNum.value = 1;
getList();
}
import { useDistributionStore } from "@/store/market.js";
import { reactive } from "vue";
const distributionStore = useDistributionStore();
distributionStore.getConfig();
provide("distributionStore", distributionStore);
provide("distributionApi", distributionApi);
const showTimeArea = ref(false);
function confirmTimeArea(e) {
console.log(e);
userComponentQuery.startTime = e[0];
userComponentQuery.endTime = e[1];
}
const tabs = [
{
label: "基础设置",
value: "basic",
},
{
label: "分销员",
value: "user",
},
{
label: "开通记录",
value: "recoders",
},
{
label: "分销明细",
value: "details",
},
];
function chooseShop(e) {
selShop.value = e;
}
watch(()=>selShop.value.shopId,(newval)=>{
pageNum.value = 1;
getList();
})
const keyWord = ref("");
function keyWordBlur() {
userComponentQuery.user = keyWord.value;
}
const userComponentQuery = reactive({
user: "",
startTime: "",
endTime: "",
});
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 form = ref({
isEnable: 0,
});
// 显示选择门店弹窗
const showShopSelActionSheet = ref(false);
const list = ref([]);
const pageNum = ref(1);
const isEnd = ref(false);
const selShop = ref({
shopId: "",
shopName: "",
});
const searchText = ref("");
function showShopSelActionSheetFun() {
showShopSelActionSheet.value = true;
}
const active = ref(0);
watch(
() => active.value,
(newval) => {
console.log(newval);
pageNum.value = 1;
getList();
function search() {
pageNum.value = 1;
getList();
}
}
);
onReachBottom(() => {
if (!isEnd.value) {
pageNum.value++;
getList();
}
});
onShow(() => {
pageNum.value = 1;
getList();
});
function chooseShop(e) {
selShop.value = e;
}
watch(
() => selShop.value.shopId,
(newval) => {
pageNum.value = 1;
getList();
}
);
watch(
() => userComponentQuery,
(newval) => {
isEnd.value = false;
pageNum.value = 1;
getList();
},
{
deep: true,
}
);
function fenxaioListRefresh(){
isEnd.value = false;
pageNum.value = 1;
getList();
}
async function getList() {
const res = await distributionApi.distributionUser({
page: pageNum.value,
size: 10,
user: userComponentQuery.user,
startTime: userComponentQuery.startTime? userComponentQuery.startTime+' 00:00:00' :'',
endTime: userComponentQuery.endTime? userComponentQuery.endTime+' 23:59:59' :'',
});
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(1);
watch(
() => active.value,
(newval) => {
console.log(newval);
pageNum.value = 1;
getList();
}
);
onReachBottom(() => {
if (!isEnd.value) {
pageNum.value++;
getList();
}
});
onShow(() => {
pageNum.value = 1;
getList();
});
</script>
<style lang="scss" scoped>
.min-page {
background: #f7f7f7;
}
.min-page {
background: #f7f7f7;
}
.box {}
.box {
}
.top {
padding: 32rpx 24rpx;
}
.top {
padding: 32rpx 24rpx;
}
.list {
padding: 0 30rpx;
.list {
padding: 0 30rpx;
.item {
padding: 32rpx 24rpx;
border-radius: 14rpx;
background-color: #fff;
overflow: hidden;
}
}
.item {
padding: 32rpx 24rpx;
border-radius: 14rpx;
background-color: #fff;
overflow: hidden;
}
}
.tag {
border-radius: 12rpx;
padding: 8rpx 22rpx;
font-size: 28rpx;
.tag {
border-radius: 12rpx;
padding: 8rpx 22rpx;
font-size: 28rpx;
&.success {
background-color: #edfff0;
color: #5bbc6d;
}
&.success {
background-color: #edfff0;
color: #5bbc6d;
}
&.end {
background-color: #f7f7f7;
color: #999;
}
}
&.end {
background-color: #f7f7f7;
color: #999;
}
}
.my-btn {
font-size: 28rpx;
line-height: 36rpx;
padding: 8rpx 32rpx;
border-radius: 12rpx;
margin: 0;
}
.my-btn {
font-size: 28rpx;
line-height: 36rpx;
padding: 8rpx 32rpx;
border-radius: 12rpx;
margin: 0;
}
.edit-btn {
background: #e6f0ff;
color: $my-main-color;
}
.edit-btn {
background: #e6f0ff;
color: $my-main-color;
}
.delete-btn {
background: #ffe7e6;
color: #ff1c1c;
}
</style>
.delete-btn {
background: #ffe7e6;
color: #ff1c1c;
}
.filter-box {
display: flex;
padding: 8rpx 24rpx;
align-items: center;
border-radius: 8rpx;
border: 2rpx solid #d9d9d9;
background: #f7f7f7;
min-height: 62rpx;
box-sizing: border-box;
}
</style>

View File

@@ -0,0 +1,292 @@
<template>
<view class="min-page u-font-28">
<view class="container first">
<view class="title">升级条件</view>
<view class="u-m-t-16">
<up-radio-group v-model="form.upgradeType" placement="row">
<up-radio
v-for="item in distributionStore.upgradeTypes"
:key="item.value"
:name="item.value"
:label="item.label"
>
<template #label>
<text>
{{ item.label }}
</text>
</template>
</up-radio>
</up-radio-group>
</view>
</view>
<view class="container" v-for="(item,index) in form.levelConfigList">
<view class="u-flex u-row-between">
<text class="font-bold color-333 u-font-32">{{index+1}}{{ item.name }}</text>
<view class="u-flex" @click="toggle(index)">
<text class="color-main u-m-r-14">展开</text>
<view class="u-flex arrow" :class="[!showDetailListSwitch[index]?'rotate' : '']">
<up-icon name="arrow-down" color="#318AFE" ></up-icon>
</view>
</view>
</view>
<template v-if="showDetailListSwitch[index]">
<view class="u-m-t-60">
<view class="title">名称</view>
<view class="u-p-t-16 u-p-b-24">
<input placeholder="请输入名称" placeholder-class="color-999 u-font-28" v-model="item.name"></input>
</view>
<up-line></up-line>
<view class="title u-m-t-24">分成比例</view>
<view class="u-m-t-16 u-p-b-24">
<view class="u-flex u-m-t-16">
<input
class="number-box"
placeholder="请输入"
placeholder-class="color-999 u-font-28"
type="digit"
@input="checkNumberCommission($event,index)"
v-model="item.levelOneCommission"
/>
<view class="unit">%</view>
</view>
</view>
<up-line></up-line>
<view class="title u-m-t-24">有效人数</view>
<view class="u-m-t-16 u-p-b-8">
<view class="u-flex u-m-t-16">
<input
class="number-box"
placeholder="请输入"
placeholder-class="color-999 u-font-28"
type="number"
v-model="item.inviteCount"
/>
<view class="unit"></view>
</view>
</view>
<view class="color-999 u-font-24">有效人数被邀请人在店铺消费过即有一笔订单完成</view>
<view class="u-m-t-24 u-flex u-row-right" style="gap: 40rpx;">
<view class="u-flex" v-if="index==0||index==form.levelConfigList.length-1" @click="addLevelConfig">
<up-icon name="plus-circle-fill" color="#318AFE" ></up-icon>
<text class="u-m-l-16">{{index==0? '添加':'继续添加'}}</text>
</view>
<view class="u-flex" @click="remove(index)">
<up-icon name="minus-circle-fill" color="#EB4F4F" ></up-icon>
<text class="u-m-l-16">删除</text>
</view>
</view>
</view>
</template>
</view>
<my-bottom-btn-group @save="save" @cancel="cancel"></my-bottom-btn-group>
</view>
</template>
<script setup>
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
import { ref, onMounted, watch, reactive , computed} from "vue";
import { useDistributionStore } from "@/store/market.js";
const distributionStore = useDistributionStore();
const form = reactive({
upgradeType: "",
levelConfigList:[]
});
const showDetailListSwitch=ref([true])
function toggle(index) {
showDetailListSwitch.value[index] = !showDetailListSwitch.value[index];
}
//现在全部的分成比例总和
const allCommission=()=>{
let sum=0
for(let item of form.levelConfigList){
sum+=parseFloat(item.levelOneCommission)
}
return sum
}
let timer=null
//全部的分成比例加起来不能超过100%
function checkNumberCommission(e,index){
const value=e.detail.value
const total=allCommission()
if(total>100){
uni.showToast({
title:'分成比例加起来不能超过100%',
icon:'none'
})
form.levelConfigList[index].levelOneCommission=''
return false
}
clearInterval(timer)
//输入最多两位小数,两位小数点后的去除掉不让输入
if(value.indexOf('.')!=-1){
const arr=value.split('.')
if(arr[1].length>2){
timer= setTimeout(()=>{
form.levelConfigList[index].levelOneCommission=arr[0]+'.'+arr[1].substring(0,2)
},30)
}
}
}
function remove(index){
form.levelConfigList.splice(index,1)
showDetailListSwitch.value.splice(index,1)
}
function addLevelConfig(){
form.levelConfigList.push({
name:'',
levelOneCommission:'',
inviteCount:''
})
showDetailListSwitch.value.push(true)
}
//判断输入每一项是否为空
function checkInput(){
for(let item of form.levelConfigList){
if(!item.name){
uni.showToast({
title:'请输入名称',
icon:'none'
})
return false
}
if(!item.levelOneCommission){
uni.showToast({
title:'请输入分成比例',
icon:'none'
})
return false
}
if(item.inviteCount===''){
uni.showToast({
title:'请输入有效人数',
icon:'none'
})
return false
}
}
return true
}
async function save(){
const isPas=checkInput()
if(!isPas){
return
}
await distributionStore.editConfig(form)
uni.showToast({
title:'保存成功',
icon:'none'
})
setTimeout(() => {
uni.navigateBack({
delta:1
})
}, 1500);
}
function cancel(){
uni.navigateBack({
delta:1
})
}
onLoad(()=>{
showDetailListSwitch.value=distributionStore.config.levelConfigList.map(()=>true)
form.levelConfigList=[...distributionStore.config.levelConfigList||[]]
form.upgradeType=distributionStore.config.upgradeType
})
</script>
<style lang="scss" scoped>
.min-page {
background: #f7f7f7;
padding: 56rpx 28rpx;
}
.container {
background: #fff;
padding: 32rpx 24rpx;
margin-top: 32rpx;
border-radius: 16rpx;
overflow: hidden;
}
.x-padding {
padding: 0 24rpx;
}
$height: 70rpx;
.number-box {
font-size: 28rpx;
padding: 0 26rpx;
border-radius: 6rpx 0 0 6rpx;
border-top: 2rpx solid #d9d9d9;
border-bottom: 2rpx solid #d9d9d9;
border-left: 2rpx solid #d9d9d9;
background: #fff;
box-sizing: border-box;
height: $height;
flex: 1;
line-height: $height;
}
.unit {
display: flex;
padding: 0 38rpx;
height: $height;
line-height: $height;
align-items: center;
border-radius: 0 6rpx 6rpx 0;
border: 2rpx solid #d9d9d9;
background: #f7f7fa;
font-size: 28rpx;
color: #999999;
}
.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;
}
.title {
font-weight: 700;
color: #333;
font-size: 28rpx;
}
.first {
border-bottom: 2rpx solid #e5e5e5;
}
.arrow{
transition: all 0.3s ease-in-out;
&.rotate{
transform: rotate(180deg);
}
}
</style>