This commit is contained in:
gyq 2025-11-20 10:27:44 +08:00
commit 3106d22783
17 changed files with 3144 additions and 547 deletions

View File

@ -418,4 +418,13 @@ text {
::v-deep .u-m-t-16 .u-textarea{
border-width: 1px!important;
}
.font-700{
font-weight: 700;
}
.text-center{
text-align: center;
}
.bg-f7{
background-color: #F7F7F7;
}

View File

@ -0,0 +1,52 @@
#时间范围选择器
#### 参数文档
| 参数 | 说明 | 类型 | 默认值 | 其他 |
| :---- | :---- | :---- | :---- | :---- |
| show | 显示选择器 | Boolean | false | - |
| defaultDate | 默认日期 | String | - | 不传则默认今天 |
| minYear | 最小年份 | Number | 1990 | - |
| themeColor | 主题色 | String | #43b983 | - |
| startText | 开始时间文字 | String | 开始时间 | - |
| endText | 结束时间文字 | String | 结束时间 | - |
#### case
```vue
<template>
<view style="padding: 30rpx;">
<view style="margin-top: 30rpx" @click="show=true">
显示日期选择器
</view>
<view style="margin-top: 30rpx">
所选日期 {{ date.join(',') }}
</view>
<dateRangePicker
:show="show"
:minYear="2022"
@close="show=false"
@confirm="confirm"
>
</dateRangePicker>
</view>
</template>
<script>
import dateRangePicker from '@/components/date-range-picker/date-range-picker.vue'
export default {
components: {dateRangePicker},
data() {
return {
show: false,
date: []
}
},
methods: {
confirm(v) {
console.log(v);
this.date = v
}
}
}
</script>
```

View File

@ -0,0 +1,342 @@
<template>
<view :class="{'remark':show}" :style="{'--theme-color': themeColor}" @click="close" @touchmove.stop.prevent="returnHandle">
<view class="picker-box" :class="{show: show}">
<view class="operate-box" @touchmove.stop.prevent="returnHandle" @tap.stop="returnHandle">
<view @click="touchSelect(0)" class="time-item" :style="{color:touchIndex?'#303030':themeColor}">
<view class="label">{{ startText }}</view>
<view class="date">{{ resultDate[0] }}</view>
</view>
<view></view>
<view @click="touchSelect(1)" class="time-item" :style="{color:touchIndex?themeColor:'#303030'}">
<view class="label">{{ endText }}</view>
<view class="date">{{ resultDate[1] }}</view>
</view>
</view>
<picker-view
:value="pickerValue"
@change="pickerChange"
class="picker-view"
:immediate-change="true"
indicator-class="select-line"
:indicator-style="indicatorStyle"
mask-style="background: transparent"
@tap.stop="returnHandle"
>
<picker-view-column class="column-left">
<view class="picker-item" :class="index == pickerValue[0] ? 'picker-select' : ''" v-for="(item, index) in years" :key="index">
{{ item }}
</view>
</picker-view-column>
<picker-view-column class="column-center">
<view class="picker-item" :class="index == pickerValue[1] ? 'picker-select' : ''" v-for="(item, index) in months" :key="index">
{{ item }}
</view>
</picker-view-column>
<picker-view-column class="column-right" v-if="days.length > 0">
<view class="picker-item" :class="index == pickerValue[2] ? 'picker-select' : ''" v-for="(item, index) in days" :key="index">
{{ item }}
</view>
</picker-view-column>
</picker-view>
<view class="button-group">
<view class="item cancel" @click.stop="close">取消</view>
<view class="item confirm" @click.stop="pickerConfirm">确认</view>
</view>
</view>
</view>
</template>
<script>
const date = new Date();
const years = [];
const currentYear = date.getFullYear();
const months = [];
const currentMonth = date.getMonth() + 1;
const currentDay = date.getDate();
export default {
name: 'dateRangePicker',
props: {
show: {
type: Boolean,
default: false
},
defaultDate: {
type: Array,
default: () => []
},
minYear: {
type: Number,
default: 1990,
},
themeColor: {
type: String,
default: '#43b983'
},
startText: {
type: String,
default: '开始时间'
},
endText: {
type: String,
default: '结束时间'
}
},
data() {
for (let i = this.minYear; i <= currentYear; i++) {
years.push(i);
}
for (let i = 1; i <= 12; i++) {
months.push(this.padStart(i));
}
return {
indicatorStyle: `height: ${uni.upx2px(84)}px`,
touchIndex: 0,
year: currentYear,
month: currentMonth,
day: currentDay,
years,
months,
days: [],
pickerValue: [],
resultDate: []
};
},
mounted() {
this.setDate()
},
methods: {
returnHandle() {},
setDate() {
if (this.defaultDate.length > 0) {
const date = this.defaultDate[0]
this.resultDate = this.defaultDate
this.setPicker(date)
} else {
const month = this.month.toString().padStart(2, 0)
const day = this.day.toString().padStart(2, 0)
const nowTime = `${this.year}-${month}-${day}`
this.resultDate = [nowTime, nowTime]
this.setPicker(nowTime)
}
},
setPicker(date) {
const splitVal = date.split('-')
const year = this.years.indexOf(Number(splitVal[0]))
const month = Number(splitVal[1]) - 1
const day = Number(splitVal[2]) - 1
this.pickerChange({
detail: {
value: [year, month, day]
}
})
},
touchSelect(val) {
const date = this.resultDate[val]
this.touchIndex = val
this.setPicker(date)
},
getDateTime(date) {
const year = this.years[date[0]]
const month = this.months[Number(date[1])] || this.padStart(currentMonth)
const day = this.days[Number(date[2])] || this.padStart(currentDay)
this.resultDate[this.touchIndex] = `${year}-${month}-${day}`
},
pickerChange(e) {
const currents = e.detail.value
//
if (this.years[currents[0]] === currentYear) {
const allmonths = JSON.parse(JSON.stringify(months))
const m = allmonths.splice(0, currentMonth)
this.months = m
if(currents[1] > currentMonth - 1) {
currents[1] = currentMonth - 1
}
} else {
this.months = months
}
//
let days = []
if (currents[1] + 1 === 2) {
if (
((currents[0] + this.minYear) % 4 === 0 &&
(currents[0] + this.minYear) % 100 !== 0) ||
(currents[0] + this.minYear) % 400 === 0
) {
for (let i = 1; i < 30; i++) {
days.push(this.padStart(i))
}
} else {
for (let i = 1; i < 29; i++) {
days.push(this.padStart(i))
}
}
} else if ([4, 6, 9, 11].some((item) => currents[1] + 1 === item)) {
for (let i = 1; i < 31; i++) {
days.push(this.padStart(i))
}
} else if ([1, 3, 5, 7, 8, 10, 12].some((item) => currents[1] + 1 === item)) {
for (let i = 1; i < 32; i++) {
days.push(this.padStart(i))
}
}
//
if (this.years[currents[0]] === currentYear && this.months[currents[1]]*1 === currentMonth) {
days = days.splice(0, currentDay)
if(currents[2] > currentDay - 1) {
currents[2] = currentDay - 1
}
}
this.days = days
this.pickerValue = currents
this.getDateTime(currents)
},
close() {
this.$emit('close', false)
},
pickerConfirm() {
const { resultDate } = this
let startTime = new Date(resultDate[0]).getTime()
let endTime = new Date(resultDate[1]).getTime()
let nowTime = endTime
if (startTime <= endTime && endTime <= nowTime) {
this.$emit('confirm', resultDate)
this.close()
return
}
if (startTime > endTime) {
uni.showToast({
title: '开始时间应小于结束时间',
icon: 'none',
duration: 3500
})
}
if (endTime > nowTime) {
uni.showToast({
title: '请正确选择时间范围',
icon: 'none'
})
}
},
padStart(val) {
return val.toString().padStart(2, 0)
},
}
}
</script>
<style lang="scss" scoped>
::v-deep.column-left,
::v-deep.column-center,
::v-deep.column-right {
.select-line {
background: #F9FAFC;
z-index: -1;
&::before, &::after {
border: none ;
}
}
}
::v-deep.column-left .select-line {
border-radius: 42rpx 0 0 42rpx;
}
::v-deep.column-right .select-line {
border-radius: 0 42rpx 42rpx 0;
}
.remark {
position: fixed;
z-index: 998;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
}
.picker-box {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
transition: all 0.3s ease;
transform: translateY(100%);
padding: 0 30rpx;
box-sizing: border-box;
background-color: #FFFFFF;
z-index: 998;
border-radius: 24rpx 24rpx 0 0;
overflow: hidden;
padding-bottom: calc(40rpx + constant(safe-area-inset-bottom)/2) !important;
padding-bottom: calc(40rpx + env(safe-area-inset-bottom)/2) !important;
&.show {
transform: translateY(0);
}
.operate-box {
display: flex;
align-items: center;
justify-content: space-around;
padding: 34rpx 30rpx 20rpx;
background-color: #FFFFFF;
text-align: center;
border-bottom: 2rpx solid #f6f6f6;
.label {
font-size: 26rpx;
}
.date {
font-size: 32rpx;
}
}
.picker-view {
width: 100%;
height: 420rpx;
background-color: #FFFFFF;
.picker-item {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
transition: all 0.2s ease;
height: 84rpx;
line-height: 84rpx;
font-size: 32rpx;
color: rgba(94, 104, 128, 0.6);
&.picker-select {
color: var(--theme-color);
font-size: 38rpx;
transition: all 0.2s ease;
}
}
}
.button-group {
display: flex;
justify-content: space-around;
margin-top: 30rpx;
.item {
width: 280rpx;
height: 84rpx;
text-align: center;
line-height: 84rpx;
border-radius: 42rpx;
&.cancel {
background: #f8f8f8;
color: #333;
}
&.confirm {
background: var(--theme-color);
color: #fff;
}
}
}
}
</style>

View File

@ -0,0 +1,139 @@
import http from '@/http/http.js'
const request = http.request
const urlType='market'
export function getConfig(data) {
return request({
url: `${urlType}/admin/distribution`,
method: "GET",
data: {
...data
}
})
}
export function editConfig(data) {
return request({
url: `${urlType}/admin/distribution`,
method: "PUT",
data: {
...data
}
})
}
export function moneyRecoders(data) {
return request({
url: `${urlType}/admin/distribution/flow`,
method: "GET",
data: {
...data
}
})
}
export function cashPay(data) {
return request({
url: `${urlType}/admin/distribution/cashPay`,
method: "POST",
data: {
...data
}
})
}
export function openFlow(data) {
return request({
url: `${urlType}/admin/distribution/openFlow`,
method: "GET",
data: {
...data
}
})
}
export function distributionFlow(data) {
return request({
url: `${urlType}/admin/distribution/distributionFlow`,
method: "GET",
data: {
...data
}
})
}
export function rechargeQrCode(data) {
return request({
url: `${urlType}/admin/distribution/rechargeQrCode`,
method: "GET",
data: {
...data
}
})
}
export function withdrawFlow(data) {
return request({
url: `${urlType}/admin/distribution/withdrawFlow`,
method: "GET",
data: {
...data
}
})
}
export function distributionUser(data) {
return request({
url: `${urlType}/admin/distribution/user`,
method: "GET",
data: {
...data
}
})
}
export function addDistributionUser(data) {
return request({
url: `${urlType}/admin/distribution/user`,
method: "POST",
data: {
...data
}
})
}
export function editDistributionUser(data) {
return request({
url: `${urlType}/admin/distribution/user`,
method: "PUT",
data: {
...data
}
})
}
export function deleteDistributionUser(data) {
return request({
url: `${urlType}/admin/distribution/user`,
method: "DELETE",
data: {
...data
}
})
}
export function inviteUser(data) {
return request({
url: `${urlType}/admin/distribution/user/inviteUser`,
method: "GET",
data: {
...data
}
})
}
export function resetLevel(data) {
return request({
url: `${urlType}/admin/distribution/user/resetLevel`,
method: "POST",
data: {
...data
}
})
}

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

@ -0,0 +1,317 @@
<template>
<view class="min-page u-font-28">
<up-sticky>
<view class="top">
<up-search
v-model="searchText"
placeholder="搜索昵称、手机号"
@clear="refresh"
@search="refresh"
@custom="refresh"
></up-search>
</view>
</up-sticky>
<view class="list u-m-t-32">
<template v-if="list.length > 0">
<view class="box">
<view
v-for="(item, index) in list"
:key="index"
class="item"
@tap="chooseUser(index, item)"
>
<view class="u-flex u-row-between u-relative">
<view class="u-flex">
<view class="headimg u-flex u-row-center u-col-center">
<image
v-if="item.headImg"
:src="item.headImg"
class="img"
mode=""
></image>
</view>
<view class="u-m-l-12">
<view class="u-flex">
<view>{{ item.nickName }}</view>
<view class="u-m-l-14">{{ item.phone }}</view>
</view>
</view>
</view>
<view class="vip" v-if="item.isVip"
>会员等级{{ item.memberLevelName }}</view
>
</view>
<view class="u-flex u-row-between">
<view class="u-m-t-16 u-flex money" style="gap: 64rpx">
<view class="">
<view class="color-333 u-font-32 font-bold">{{
item.amount
}}</view>
<view class="u-flex u-m-t-12" style="align-items: baseline">
<text class="color-666">余额</text>
<up-icon name="arrow-right" size="14"></up-icon>
</view>
</view>
<view class="">
<view class="color-333 u-font-32 font-bold">{{
item.accountPoints
}}</view>
<view class="u-flex u-m-t-12" style="align-items: baseline">
<text class="color-666">积分</text>
<up-icon name="arrow-right" size="14"></up-icon>
</view>
</view>
<view class="">
<view class="color-333 u-font-32 font-bold">{{
item.accountPoints
}}</view>
<view class="u-flex u-m-t-12" style="align-items: baseline">
<text class="color-666">优惠券</text>
<up-icon name="arrow-right" size="14"></up-icon>
</view>
</view>
</view>
<my-radio
v-if="!isFenxiaoYuan(item)"
shape="square"
@change="chooseUser(index, item)"
v-model="item.checked"
:size="18"
border-color="#d1d1d1"
></my-radio>
</view>
</view>
</view>
<view class="u-m-t-32">
<my-pagination
:page="query.page"
:totalElements="query.totalElements"
:size="query.size"
@change="pageChange"
></my-pagination>
</view>
</template>
<template v-if="hasAjax && list.length <= 0">
<my-img-empty tips="未找到相关用户"></my-img-empty>
</template>
</view>
<view class="fixed-bottom">
<view class="u-flex-1 btn">已选择{{ hasSelected.length }}名用户</view>
<view class="u-flex-1 btn" @click="back">取消</view>
<view class="u-flex-1 btn my-bg-main" @click="confirm">确认</view>
</view>
<view style="height: 160rpx"></view>
</view>
</template>
<script setup>
import { ref, onMounted, computed } from "vue";
import { shopUserList } from "@/http/api/shopUser.js";
import * as distributionApi from "@/http/api/market/distribution.js";
const searchText = ref("");
const list = ref([]);
const pageNum = ref(1);
const isEnd = ref(false);
async function getList() {
const res = await shopUserList({
page: pageNum.value,
size: 10,
key:searchText.value
});
if (res) {
if (pageNum.value == 1) {
list.value = (res.records || []).map((item) => {
item.checked = false;
return item;
});
} else {
const newArr = (res.records || []).map((item) => {
item.checked = false;
return item;
});
list.value = [...list.value, ...newArr];
}
isEnd.value = pageNum.value >= res.totalPage * 1 ? true : false;
console.log(isEnd.value);
}
}
const hasSelected = computed(() => {
return list.value.filter((item) => item.checked);
});
function refresh(){
pageNum.value = 1;
isEnd.value = false;
getList()
}
//
function back() {
uni.navigateBack({
delta: 1,
});
}
//
function isFenxiaoYuan(item) {
const isFenxiao = item.distributionShops.split("_")[1];
return isFenxiao;
}
async function confirm() {
//
if (hasSelected.value.length <= 0) {
uni.showToast({
title: "请选择用户",
icon: "none",
});
return;
}
try {
// 1. Promise
const requestPromises = hasSelected.value.map((item) =>
distributionApi.addDistributionUser({
id: item.id,
openingMethod: "手动添加",
shopId: uni.getStorageSync("shopId"),
userId: item.userId,
})
);
// 2. 使 Promise.all
//
await Promise.all(requestPromises);
// 3.
uni.showToast({
title: `成功添加 ${hasSelected.value.length} 个用户`,
icon: "none",
});
refresh()
} catch (error) {
// 4. catch
uni.showToast({
title: "添加失败,请重试",
icon: "none",
});
console.error("用户添加失败:", error); // 便
}
}
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.min-page {
background: #f7f7f7;
}
.top {
background-color: #fff;
padding: 32rpx 28rpx;
}
:deep(.u-search__action) {
display: flex;
width: 120rpx !important;
color: #fff !important;
padding: 10rpx 32rpx;
justify-content: center;
align-items: center;
gap: 20rpx;
border-radius: 32rpx;
margin-left: 78rpx !important;
background: #318afe;
}
.scale7 {
transform: scale(0.7);
}
.search {
padding-right: 28rpx;
.icon-saoma {
margin-left: 20rpx;
width: 34rpx;
height: 32rpx;
}
}
.list {
.no-choose {
padding: 36rpx 30rpx 36rpx 24rpx;
}
.box {
// padding: 32rpx 30rpx 78rpx 24rpx;
.item {
padding: 32rpx 30rpx;
margin-bottom: 16rpx;
background-color: #fff;
.headimg {
border-radius: 12rpx 12rpx 12rpx 12rpx;
font-size: 0;
width: 84rpx;
height: 84rpx;
background-color: #eee;
overflow: hidden;
.img {
width: 84rpx;
height: 84rpx;
}
}
}
}
}
.vip {
position: absolute;
top: 0;
right: 0;
color: $my-main-color;
font-size: 32rpx;
font-weight: 700;
}
.money {
padding: 16rpx 24rpx;
border-radius: 8rpx;
background: #f8f8f8;
}
.fixed-bottom {
position: fixed;
text-align: center;
padding: 0;
bottom: calc(env(safe-area-inset-bottom) + 30rpx);
left: 0;
right: 0;
z-index: 10;
border-radius: 100rpx;
background-color: #3e3a3a;
color: #fff;
display: flex;
overflow: hidden;
.btn {
padding: 16rpx;
line-height: 40rpx;
&:first-child {
position: relative;
}
&:first-child::after {
content: "";
position: absolute;
display: block;
top: 20rpx;
right: 0;
bottom: 20rpx;
width: 1px;
border-radius: 1px;
background-color: #f7f7f7aa;
}
}
}
</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; // 01
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,197 @@
<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-666 u-font-24 u-flex">
<text class="no-wrap"> 关联订单:</text>
<text> {{ item.orderNo }} </text>
</view>
<view class="status" :class="[item.status]">
{{ returnStatus(item.status) }}</view
>
</view>
<view class="u-flex u-row-between u-m-t-16">
<view>
<view class="color-333 u-font-28 u-flex u-line-1">
<text class="font-bold"> 分销员 </text>
<text class="color-666 u-font-24 u-m-l-28">
{{ item.nickName }}
</text>
<text class="color-666 u-font-24 u-m-l-10"> {{ item.phone }} </text>
</view>
<view class="color-333 u-font-28 u-flex u-m-t-16 u-line-1">
<text class="font-bold"> 下级用户 </text>
<text class="color-666 u-font-24 u-m-l-28">
{{ item.sourceNickName }}
</text>
<text class="color-666 u-font-24 u-m-l-10"> {{ item.sourcePhone }} </text>
</view>
<view class="color-333 u-font-28 u-flex u-m-t-16 u-line-1">
<text class="font-bold"> 创建时间 </text>
<text class="color-666 u-font-24 u-m-l-28">
{{ item.sourceNickName }}
</text>
<text class="color-666 u-font-24 u-m-l-10"> {{ item.createTime }} </text>
</view>
</view>
<view>
<view
class="text-center color-main font-bold"
:class="[ item.status == 'refund' ? 'color-red' : '']"
>{{ 0 }}</view
>
<view class="color-66 u-font-24">{{
item.level == 1 ? "直接分成" : "间接分成"
}}</view>
</view>
</view>
</view>
<view class="u-p-30">
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
</view>
</view>
</template>
<script setup>
import {
ref,
reactive,
watch,
toRaw,
onMounted,
onUnmounted,
inject,
} from "vue";
const props = defineProps({
list: {
type: Array,
default: () => [],
},
isEnd: {
type: Boolean,
default: false,
},
});
const statusMap = {
success: "已入账",
refund: "已退款",
pending: "待入账",
};
function returnStatus(status) {
return status in statusMap ? statusMap[status] : status;
}
const $actions = [
{
name: "更改分销组",
value: "change-group",
},
{
name: "重置分销组",
value: "reset-group",
},
{
name: "恢复分销员",
value: "back-fenxiao",
},
{
name: "取消分销员",
value: "cancel-fenxiao",
},
];
const actions = ref($actions);
const emits = defineEmits(["refresh"]);
</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;
}
.status {
display: flex;
padding: 8rpx 18rpx;
justify-content: center;
align-items: center;
gap: 20rpx;
font-size: 28rpx;
border-radius: 0 0 8rpx 8rpx;
border: 1px solid transparent;
&.success {
color: rgba(123, 209, 54, 1);
border-color: rgba(123, 209, 54, 1);
background-color: rgba(123, 209, 54, 0.12);
}
&.refund {
border-color: rgba(249, 50, 40, 1);
background-color: rgba(209, 64, 54, 0.12);
color: rgba(255, 47, 47, 1);
}
&.pending {
border-color: rgba(153, 153, 153, 1);
background-color: rgba(153, 153, 153, 0.12);
color: rgba(153, 153, 153, 1);
}
}
.color-red {
color: #ff2f2f;
}
.text-center{
text-align: center;
}
</style>

View File

@ -0,0 +1,270 @@
<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 @click="go.to('PAGES_DISTRIBUTION_ADD_FENXIAO_USER')">添加分销员</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 go from "@/commons/utils/go.js";
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

@ -0,0 +1,254 @@
<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-666 u-font-24 u-flex">
<text class="no-wrap"> 订单号:</text>
<text> {{ item.orderNo }} </text>
</view>
<view>
<view class="color-999 u-font-20">{{ item.createTime }}</view>
</view>
</view>
<view class="u-flex u-row-between u-m-t-16">
<view class="color-333 u-font-28 color-666">
<view> 用户昵称 </view>
<view class="u-m-t-4">
<text class=""> {{ item.nickName }}</text>
</view>
</view>
<text class="color-main u-font-32 font-700">{{ item.changeAmount }}</text>
</view>
</view>
<view class="u-p-30">
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
</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 go from "@/commons/utils/go.js";
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,444 @@
<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 || active == 2"
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
v-if="active ==3"
class="u-flex u-row-between u-m-t-32"
style="gap: 30rpx"
>
<view
class="u-font-28 filter-box u-flex u-row-between"
@click="showTimeArea = true"
>
<template
v-if="false"
>
<text class="u-font-20">
</text>
</template>
<template v-else>
<text class="color-999 u-m-r-10">全部</text>
<up-icon name="arrow-down" size="12"></up-icon>
</template>
</view>
<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 v-if="active==2" class="u-flex u-p-l-32 u-p-r-32 u-m-t-32">
<view class="u-flex-1 u-text-center">
<view class="u-font-32 color-main font-bold">{{ listRes.totalCount}}</view>
<view class="u-font-24 color-666 u-m-t-16">支付开通人数</view>
</view>
<view class="u-flex-1 u-text-center">
<view class="u-font-32 color-main font-bold">{{ listRes.totalAmount}}</view>
<view class="u-font-24 color-666 u-m-t-16">支付开通人数</view>
</view>
</view>
<view v-if="active==3" class="u-flex u-m-t-32">
<view class="u-flex-1 u-text-center">
<view class="u-font-32 color-main font-bold">{{ listRes.successAmount}}</view>
<view class="u-font-24 color-666 u-m-t-16">已入账金额</view>
</view>
<view class="u-flex-1 u-text-center">
<view class="u-font-32 color-main font-bold">{{ listRes.pendingAmount||0}}</view>
<view class="u-font-24 color-666 u-m-t-16">待入账金额</view>
</view>
<view class="u-flex-1 u-text-center">
<view class="u-font-32 color-main font-bold">{{ listRes.balanceAmount}}</view>
<view class="u-font-24 color-666 u-m-t-16 ">
<text>运营余额</text>
<text class="color-main" @click="go.to('PAGES_PAY')">充值></text>
</view>
</view>
</view>
</view>
</up-sticky>
<configVue v-if="active == 0"></configVue>
<fenxiaoUserListVue
v-if="active == 1"
:list="list"
:isEnd="isEnd"
@refresh="refresh"
></fenxiaoUserListVue>
</view>
<view class="u-p-30">
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
</view>
</view>
<openListVue
v-if="active == 2"
:list="list"
:isEnd="isEnd"
@refresh="refresh"
></openListVue>
<fenxiaoMingxiVue
v-if="active == 3"
:list="list"
:isEnd="isEnd"
@refresh="refresh"
></fenxiaoMingxiVue>
<!-- 选择门店 -->
<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";
import go from "@/commons/utils/go.js";
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";
import openListVue from "./components/open-list.vue";
import fenxiaoMingxiVue from "./components/fenxiao-mingxi.vue";
const list = ref([]);
const pageNum = ref(1);
const isEnd = ref(false);
const selShop = ref({
shopId: "",
shopName: "",
})
const searchText = ref("");
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 search() {
pageNum.value = 1;
getList();
}
const keyWord = ref("");
function keyWordBlur() {
userComponentQuery.user = keyWord.value;
}
const userComponentQuery = reactive({
user: "",
startTime: "",
endTime: "",
});
function chooseShop(e) {
selShop.value = e;
}
watch(()=>selShop.value.shopId,(newval)=>{
pageNum.value = 1;
getList();
})
const form = ref({
isEnable: 0,
});
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 list = ref([]);
const pageNum = ref(1);
const isEnd = ref(false);
const selShop = ref({
shopId: "",
shopName: "",
});
const searchText = ref("");
//
const showShopSelActionSheet = ref(false);
function search() {
pageNum.value = 1;
getList();
}
function showShopSelActionSheetFun() {
showShopSelActionSheet.value = true;
}
const active = ref(0);
watch(
() => active.value,
(newval) => {
console.log(newval);
pageNum.value = 1;
getList();
function chooseShop(e) {
selShop.value = e;
}
}
);
onReachBottom(() => {
if (!isEnd.value) {
pageNum.value++;
getList();
}
});
onShow(() => {
pageNum.value = 1;
getList();
});
watch(
() => selShop.value.shopId,
(newval) => {
pageNum.value = 1;
getList();
}
);
watch(
() => userComponentQuery,
(newval) => {
isEnd.value = false;
pageNum.value = 1;
getList();
},
{
deep: true,
}
);
function refresh() {
isEnd.value = false;
pageNum.value = 1;
getList();
}
const listRes=ref({})
async function getList() {
let res = null;
if (active.value == 1) {
//
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 (active.value == 2) {
//
res = await distributionApi.openFlow({
page: pageNum.value,
size: 10,
key: userComponentQuery.user,
startTime: userComponentQuery.startTime
? userComponentQuery.startTime + " 00:00:00"
: "",
endTime: userComponentQuery.endTime
? userComponentQuery.endTime + " 23:59:59"
: "",
});
}
if (active.value == 3) {
//
res = await distributionApi.distributionFlow({
page: pageNum.value,
size: 10,
key: userComponentQuery.user,
startTime: userComponentQuery.startTime
? userComponentQuery.startTime + " 00:00:00"
: "",
endTime: userComponentQuery.endTime
? userComponentQuery.endTime + " 23:59:59"
: "",
});
}
if (res) {
listRes.value=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(3);
watch(
() => active.value,
(newval) => {
console.log(newval);
pageNum.value = 1;
getList();
}
);
watch(
() => active.value,
(newval) => {
refresh();
}
);
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>

View File

@ -0,0 +1,328 @@
<template>
<view class="box min-page">
<up-sticky>
<view class="bg-fff top">
<view class="u-flex u-row-between" style="gap: 58rpx">
<view
class="u-font-28 u-flex-1 filter-box u-flex u-row-between"
@click="showActions = true"
>
<template v-if="selType && selType.value">
<text class="u-font-28">{{ selType.name }}</text>
</template>
<template v-else>
<text class="color-999 u-m-r-10">全部</text>
</template>
<up-icon name="arrow-down" size="12"></up-icon>
</view>
<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
v-if="false"
class="u-flex-1 u-font-28 filter-box u-flex u-row-between"
@click="showTimeArea = true"
>
<template v-if="query.startTime && query.endTime">
<text class="u-font-20">
{{ query.startTime }} -
{{ query.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-p-l-32 u-p-r-32 u-m-t-32">
<view class="u-flex-1 u-text-center">
<view class="u-font-32 color-main font-bold">{{
state.totalRecharge
}}</view>
<view class="u-font-24 color-666 u-m-t-16">已充值金额</view>
</view>
<view class="u-flex-1 u-text-center">
<view class="u-font-32 color-main font-bold">{{
state.totalSub
}}</view>
<view class="u-font-24 color-666 u-m-t-16">已扣减金额</view>
</view>
</view>
</view>
</up-sticky>
<view class="recoders-list" v-if="state.records.length">
<view class="item" v-for="(item, index) in state.records" :key="index">
<view class="u-flex u-flex-between u-font-24">
<view class="color-666">
{{ returnState(item.type) }}
</view>
<text class="color-999">{{ item.createTime }}</text>
</view>
<view class="u-flex u-flex-between u-font-28 color-666 u-m-t-16">
<view>
<text>关联订单WX1987787224197300224</text>
<text></text>
</view>
<view>
<view class="price">
<text>{{ item.changeAmount }}</text>
</view>
<view class="u-m-t-4 u-font-24 color-999">变动后{{item.amount}}</view>
</view>
</view>
</view>
<up-loadmore :status="isEnd ? 'nomore' : 'loadmore'"></up-loadmore>
</view>
<view style="height: 60rpx"></view>
<dateAreaSel
:show="showTimeArea"
:minYear="2022"
@close="showTimeArea = false"
@confirm="confirmTimeArea"
></dateAreaSel>
<up-action-sheet
:show="showActions"
:actions="actions"
@select="handleSelect"
@close="showActions = false"
cancel-text="取消"
></up-action-sheet>
</view>
</template>
<script setup>
import * as distributionApi from "@/http/api/market/distribution.js";
import { onMounted, ref, reactive, watch } from "vue";
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
import dateAreaSel from "@/components/date-range-picker/date-range-picker.vue";
import go from "@/commons/utils/go.js";
const showActions = ref(false);
const selType = ref(null);
const actions = [
{
name: "全部",
value: "",
},
{
name: "充值",
value: "manual_recharge",
},
{
name: "自助充值",
value: "self_recharge",
},
{
name: "退款",
value: "refund",
},
{
name: "手动扣减",
value: "manual_sub",
},
{
name: "系统扣减",
value: "sub",
},
];
function returnState(type) {
const item = actions.find((item) => item.value === type);
if (item) {
return item.name;
}
return "";
}
const keyWord = ref("");
function keyWordBlur() {
query.key = keyWord.value;
}
function handleSelect(item) {
console.log(item);
selType.value = item;
query.type = item.value;
}
const options = ref({});
function parseQueryString(queryString) {
const queryParams = queryString.split("&").map((param) => param.split("="));
const params = {};
for (const [key, value] of queryParams) {
params[key] = value;
}
return params;
}
onLoad((opt) => {
console.log(opt);
if (opt.q) {
const q = decodeURIComponent(opt.q);
const params = parseQueryString(q.split("?")[1]);
Object.assign(options.value, params);
} else {
Object.assign(options.value, opt);
}
console.log(options.value);
if (options.value.shopId) {
price.value = options.value.amount;
selChargeIndex.value = chargeList.value.findIndex(
(item) => item.price * 1 === options.value.amount * 1
);
init();
}
flow();
});
const showTimeArea = ref(false);
function confirmTimeArea(e) {
console.log(e);
query.startTime = e[0];
query.endTime = e[1];
}
function refresh() {
query.page = 1;
flow();
}
const query = reactive({
page: 1,
size: 10,
type: "",
key: "",
});
const state = reactive({
records: [],
totalRecharge: 0,
});
const listRes = ref({});
const isEnd = ref(false);
async function flow() {
console.log(selType.value);
const res = await distributionApi.moneyRecoders(query);
if (query.page == 1) {
Object.assign(state, res);
} else {
state.records = state.records.concat(res.records || []);
state.totalRecharge = res.totalRecharge || 0;
}
isEnd.value = query.page >= res.totalPage * 1;
}
onReachBottom(() => {
if (isEnd.value) {
return;
}
query.page++;
flow();
});
watch(
() => query.key,
(newval) => {
isEnd.value = false;
query.page = 1;
flow();
},
{
deep: true,
}
);
watch(
() => query.type,
(newval) => {
isEnd.value = false;
query.page = 1;
flow();
},
{
deep: true,
}
);
</script>
<style scoped lang="scss">
.min-page {
background: #f5f5f5;
}
.box {
position: relative;
}
.container {
padding: 32rpx 24rpx;
border-radius: 16rpx;
background-color: #fff;
}
.chrage-box {
border-radius: 74rpx;
background: #ffffff4d;
padding: 42rpx 28rpx;
}
.title-bg {
position: relative;
.image {
position: absolute;
height: 14rpx;
width: 94rpx;
right: -10rpx;
bottom: 0;
z-index: -1;
}
}
.xieyi {
color: #ecb592;
}
.u-text-nowrap {
white-space: nowrap;
}
.input-box {
padding: 24rpx 16rpx;
border-radius: 8rpx;
background: #f6f6f6;
}
.recoders-list {
margin-top: 40rpx;
.item {
margin-bottom: 36rpx;
background-color: #fff;
padding: 32rpx 28rpx;
border-radius: 16rpx;
.price {
font-weight: 700;
color: $my-main-color;
font-size: 32rpx;
.yuan {
font-weight: 400;
font-size: 28rpx;
}
}
}
}
.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;
}
.top {
padding: 32rpx 24rpx;
}
</style>

View File

@ -93,8 +93,7 @@
"path": "pages/pay",
"pageId": "PAGES_PAY",
"style": {
"navigationBarTitleText": "分销",
"navigationStyle": "custom"
"navigationBarTitleText": "运营余额"
}
}
],
@ -658,6 +657,24 @@
"path": "addCoupon/index",
"style": {
"navigationBarTitleText": "添加优惠券"
"pageId": "PAGES_DISTRIBUTION_LEVEL_LIST",
"path": "distribution/level-list",
"style": {
"navigationBarTitleText": "分销员等级"
}
},
{
"pageId": "PAGES_DISTRIBUTION_ADD_FENXIAO_USER",
"path": "distribution/add-fenxiao-user",
"style": {
"navigationBarTitleText": "添加分销员"
}
},
{
"pageId": "PAGES_DISTRIBUTION_MONEY_RECODERS",
"path": "distribution/money-recoders",
"style": {
"navigationBarTitleText": "运营余额"
}
}
]

View File

@ -1,115 +1,105 @@
<template>
<view class="box">
<up-navbar
title="分销"
bg-color="transparent"
:placeholder="true"
@leftClick="back"
></up-navbar>
<view class="top">
<image
src="/static/market/top-bg.png"
class="image"
mode="widthFix"
></image>
</view>
<view style="height: 38rpx"></view>
<view class="box min-page">
<view class="chrage-box">
<view class="u-flex u-flex-between">
<view class="u-flex">
<image
src="/static/market/gold.png"
style="width: 44rpx; height: 44rpx"
></image>
<view class="title-bg">
<image src="/static/market/title-bg.png" class="image"></image>
<view class="font-bold u-font-32 color-333 u-m-l-24">立即充值</view>
<view class="bg-fff container">
<view class="u-flex u-flex-between">
<view class="u-flex">
<view class="title-bg">
<view class="font-bold u-font-32 color-333">当前余额{{distributionFlowRes.balanceAmount}}</view>
</view>
</view>
<view>
<text class="u-font-32 color-main" @click="go.to('PAGES_DISTRIBUTION_MONEY_RECODERS')"> 查看记录</text>
</view>
</view>
<view>
<text class="u-font-24 color-999"> 充值代表接受</text>
<text class="u-font-24 xieyi"> 用户隐私协议 </text>
<view
class="list u-m-t-32 u-flex u-m-t-60"
style="align-items: flex-start"
>
<text class="font-bold u-font-32 color-333 u-text-nowrap"
>选择金额</text
>
<view class="u-m-l-60 chargeList">
<view
class="item"
v-for="(item, index) in chargeList"
:key="index"
:class="{ active: selChargeIndex == index }"
@click="changeCharge(index)"
>
<view class="price">
<text class="u-font-28">¥ </text>
<text class="font-bold u-font-32">{{ item.price }}</text>
</view>
<image
class="sel"
v-show="selChargeIndex == index"
src="/static/iconimg/icon-sel.png"
></image>
</view>
</view>
</view>
<view class="u-flex input-box">
<text class="color-333 u-font-28 font-bold">其他金额</text>
<view class="u-flex-1 u-flex u-m-l-28">
<input
:min="0.01"
placeholder-class="u-font-24"
type="digit"
class="u-flex-1 u-font-28"
placeholder="请输入充值金额"
@input="inputEvent"
v-model="price"
/>
</view>
</view>
</view>
<view
class="list u-m-t-32 u-flex u-m-t-60"
style="align-items: flex-start"
>
<text class="font-bold u-font-32 color-333 u-text-nowrap"
>选择金额</text
>
<view class="u-m-l-60 chargeList">
<view class="u-m-t-32"></view>
<my-button @click="buy">立即充值</my-button>
<view class="container u-m-t-32">
<view class="u-flex u-flex-between ">
<view class="u-flex">
<view class="title-bg">
<image src="/static/market/title-bg.png" class="image"></image>
<view class="font-bold u-font-32 color-333 u-m-l-24"
>充值记录</view
>
</view>
</view>
<view>
<text class="u-font-28 color-333">
总计{{ state.totalRecharge || 0 }}</text
>
</view>
</view>
<view class="recoders-list" v-if="state.records.length">
<view
class="item"
v-for="(item, index) in chargeList"
v-for="(item, index) in state.records"
:key="index"
:class="{ active: selChargeIndex == index }"
@click="changeCharge(index)"
>
<view class="price">
<text class="u-font-28">¥ </text>
<text class="font-bold" style="font-size: 48rpx">{{
item.price
}}</text>
</view>
<image
class="sel"
v-show="selChargeIndex == index"
src="/static/market/sel.png"
></image>
</view>
</view>
</view>
<view class="u-flex input-box u-m-t-30">
<text class="color-333 u-font-28 font-700">其他金额</text>
<view class="u-flex-1 u-flex u-m-l-28">
<input
:min="0.01"
placeholder-class="u-font-24"
type="digit"
class="u-flex-1 u-font-28"
placeholder="请输入充值金额"
@input="inputEvent"
v-model="price"
/>
</view>
</view>
<view class="buy" @click="buy">立即充值</view>
<view class="u-flex u-flex-between u-m-t-60">
<view class="u-flex">
<view class="title-bg">
<image src="/static/market/title-bg.png" class="image"></image>
<view class="font-bold u-font-32 color-333 u-m-l-24">充值记录</view>
</view>
</view>
<view>
<text class="u-font-28 color-333">
总计{{ state.totalRecharge || 0 }}</text
>
</view>
</view>
<view class="recoders-list" v-if="state.records.length">
<view class="item" v-for="(item, index) in state.records" :key="index">
<view class="u-flex u-flex-between">
<view class="u-font-28">
<view class="color-666">
<text v-if="item.type === 'self_recharge'">自助充值</text>
<text v-if="item.type === 'manual_recharge'">手动充值</text>
<view class="u-flex u-flex-between">
<view class="u-font-28">
<view class="color-666">
<text v-if="item.type === 'self_recharge'">自助充值</text>
<text v-if="item.type === 'manual_recharge'">手动充值</text>
</view>
<view class="u-m-t-16">
<text class="color-666">时间</text>
<text class="color-333">{{ item.createTime }}</text>
</view>
</view>
<view class="u-m-t-16">
<text class="color-666">时间</text>
<text class="color-333">{{ item.createTime }}</text>
<view class="price">
<text>{{ item.changeAmount }}</text>
<text class="yuan"></text>
</view>
</view>
<view class="price">
<text>{{ item.changeAmount }}</text>
<text class="yuan"></text>
</view>
</view>
<up-loadmore :status="isEnd ? 'nomore' : 'loadmore'"></up-loadmore>
</view>
<up-loadmore :status="isEnd ? 'nomore' : 'loadmore'"></up-loadmore>
</view>
</view>
</view>
@ -117,9 +107,11 @@
<script setup>
import { mchRecharge } from "@/http/api/pay";
import * as distributionFlowApi from "@/http/api/market/distributionFlow.js";
import * as distributionApi from "@/http/api/market/distribution.js";
import { onMounted, ref, reactive, watch } from "vue";
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
import go from "@/commons/utils/go.js";
function back() {
uni.navigateBack();
}
@ -158,11 +150,12 @@ onLoad((opt) => {
if (options.value.shopId) {
price.value = options.value.amount;
selChargeIndex.value = chargeList.value.findIndex(
(item) => item.price*1 === options.value.amount*1
(item) => item.price * 1 === options.value.amount * 1
);
init();
}
flow();
distributionFlow();
});
let timer = null;
@ -202,7 +195,7 @@ function inputEvent(e) {
//
timer = setTimeout(() => {
selChargeIndex.value = chargeList.value.findIndex(
(item) => item.price*1 === value*1
(item) => item.price * 1 === value * 1
);
price.value = value;
}, 30);
@ -308,6 +301,7 @@ async function buy() {
function refresh() {
query.page = 1;
flow();
distributionFlow()
}
const query = reactive({
@ -321,9 +315,16 @@ const state = reactive({
totalRecharge: 0,
});
const distributionFlowRes=ref({})
async function distributionFlow(){
const res=await distributionApi.distributionFlow();
distributionFlowRes.value=res
}
const isEnd = ref(false);
async function flow() {
const res = await distributionFlowApi.flow(query);
const res = await distributionApi.moneyRecoders(query);
if (query.page == 1) {
Object.assign(state, res);
} else {
@ -341,6 +342,7 @@ onReachBottom(() => {
});
async function init() {
const code = await wxlogin();
distributionFlow();
const res = await mchRecharge({
...options.value,
code,
@ -361,7 +363,7 @@ async function init() {
watch(
() => selChargeIndex.value,
(newval) => {
if (newval != -1 &&price.value*1!=chargeList.value[newval].price*1) {
if (newval != -1 && price.value * 1 != chargeList.value[newval].price * 1) {
price.value = chargeList.value[newval].price;
}
},
@ -372,22 +374,19 @@ watch(
</script>
<style scoped lang="scss">
.min-page {
background: #f5f5f5;
}
.box {
position: relative;
}
.top {
position: absolute;
left: 0;
right: 0;
top: 0;
z-index: -1;
.image {
width: 100%;
}
.container {
padding: 32rpx 24rpx;
border-radius: 16rpx;
background-color: #fff;
}
.chrage-box {
width: 750rpx;
border-radius: 74rpx;
background: #ffffff4d;
padding: 42rpx 28rpx;
@ -413,24 +412,20 @@ watch(
justify-content: space-between;
.item {
padding: 16rpx 36rpx;
border-radius: 22rpx;
background: linear-gradient(180deg, #f5f5f5 58.54%, #fff 104.47%);
border-radius: 8rpx;
background-color: #f8f8f8;
border: 6rpx solid transparent;
transition: all 0.3s ease-in-out;
margin-right: 30rpx;
margin-bottom: 62rpx;
margin-bottom: 36rpx;
position: relative;
width: 220rpx;
width: 172rpx;
display: flex;
justify-content: center;
&.active {
border: 6rpx solid #fe6c0e;
background: linear-gradient(180deg, #ffc29a -26.17%, #fff 64.06%);
box-shadow: 0 0 31.2rpx 2rpx #fe8b435e;
border: 6rpx solid $my-main-color;
.price {
.font-bold {
color: #ff6300;
}
color: $my-main-color;
}
}
.sel {
@ -445,7 +440,7 @@ watch(
display: flex;
align-items: baseline;
flex-wrap: nowrap;
color: #5f2e0f;
color: #333;
}
}
.item:nth-of-type(2n) {
@ -460,18 +455,7 @@ watch(
border-radius: 8rpx;
background: #f6f6f6;
}
.buy {
padding: 32rpx 32rpx;
background: linear-gradient(98deg, #fe6d1100 40.64%, #ffd1b4 105.2%),
linear-gradient(259deg, #fe6d11 50.14%, #ffd1b4 114.93%);
box-shadow: 0 14rpx 30.4rpx 0 #fe8b435e;
color: #ffffff;
font-size: 32rpx;
font-weight: 700;
border-radius: 40rpx;
text-align: center;
margin-top: 48rpx;
}
.recoders-list {
margin-top: 40rpx;
.item {
@ -482,8 +466,8 @@ watch(
.price {
line-height: 44rpx;
font-weight: 700;
color: #fe7e00;
font-size: 48rpx;
color: $my-main-color;
font-size: 44rpx;
.yuan {
font-weight: 400;
font-size: 28rpx;

BIN
static/iconImg/icon-sel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

53
store/market.js Normal file
View File

@ -0,0 +1,53 @@
// stores/counter.js
import { defineStore } from "pinia";
import * as distributionApi from "@/http/api/market/distribution.js";
export const upgradeTypes = [
{
value: "not_upgrade",
label: "不自动升级",
},
{
value: "invite",
label: "邀请有效人数",
},
{
value: "cost",
label: "消费金额(不含退款)",
},
];
// 分销
export const useDistributionStore = defineStore("distribution", {
state: () => {
return {
//分销配置
config: {
isEnable: 0,
openType: "pay",
inviteCount: 1,
inviteConsume: 0,
payAmount: 0,
rewardCount: 1,
settlementDay: 1,
upgradeType: "auto",
notActivatedPage: null,
levelConfigList: [],
},
//升级条件
upgradeTypes,
};
},
actions: {
async getConfig() {
const data = await distributionApi.getConfig();
this.config = data;
return this.config;
},
async editConfig(data) {
const res = await distributionApi.editConfig({ ...this.config, ...data });
this.getConfig();
return res;
},
},
unistorage: true, // 开启后对 state 的数据读写都将持久化
});