commission--yt-commit
This commit is contained in:
parent
d58e024f23
commit
175c052e97
|
@ -8,10 +8,15 @@ Page({
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
projectList: [], // 项目列表
|
projectList: [], // 项目列表
|
||||||
items_1: [null, null, null],
|
projectId: 0, // 项目ID
|
||||||
items: [null, null],
|
maxCommissionRate: 0, // 最大抽佣比率
|
||||||
showPopup: false, // 控制弹窗显隐
|
showPopup: false, // 控制弹窗显隐
|
||||||
|
LodingHidden: true, // 控制加载框取消
|
||||||
showCommissionRatePop: false,
|
showCommissionRatePop: false,
|
||||||
|
nowMyUnitPrice: 0, // 现在的‘我的单价’,用于传给弹窗
|
||||||
|
nowCommissionRate: 0, // 现在的'抽成比例', 用于传给弹窗
|
||||||
|
nowAgentUnitPrice: 0, // 现在的‘代理单价’,用于传给弹窗
|
||||||
|
nowProjectDetailName: '', // 现在的‘项目详细名称’,用于传给弹窗
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取项目列表
|
// 获取项目列表
|
||||||
|
@ -76,7 +81,17 @@ Page({
|
||||||
},
|
},
|
||||||
|
|
||||||
// 点击“设价”按钮,显示弹窗
|
// 点击“设价”按钮,显示弹窗
|
||||||
showCommissionRatePop() {
|
showCommissionRatePop(e) {
|
||||||
|
console.log('弹窗传值----->',e);
|
||||||
|
this.setData({
|
||||||
|
nowCommissionRate: e.currentTarget.dataset.currentcommissionrate,
|
||||||
|
nowMyUnitPrice: e.currentTarget.dataset.nowmyunitprice,
|
||||||
|
nowAgentUnitPrice: e.currentTarget.dataset.agentunitprice,
|
||||||
|
nowProjectDetailName: e.currentTarget.dataset.projectdetailname,
|
||||||
|
projectId: e.currentTarget.dataset.detailid,
|
||||||
|
maxCommissionRate: e.currentTarget.dataset.maxcommissionrate,
|
||||||
|
})
|
||||||
|
|
||||||
this.setData({ showCommissionRatePop: true });
|
this.setData({ showCommissionRatePop: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -87,8 +102,7 @@ Page({
|
||||||
|
|
||||||
// 确认按钮回调
|
// 确认按钮回调
|
||||||
handleCommissionRateConfirm(e) {
|
handleCommissionRateConfirm(e) {
|
||||||
const { agentPrice, commissionRate, pricingMethod } = e.detail;
|
this.getProjectList()
|
||||||
console.log('设置数据:', agentPrice, commissionRate, pricingMethod);
|
|
||||||
this.closeCommissionRatePop();
|
this.closeCommissionRatePop();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
>
|
>
|
||||||
<text class="font_6 text_6 pos">{{ CommissionList.projectDetailName }}</text>
|
<text class="font_6 text_6 pos">{{ CommissionList.projectDetailName }}</text>
|
||||||
<text class="font_7 text_9">{{ CommissionList.myUnitPrice }}/{{ CommissionList.agentUnitPrice }}/{{ CommissionList.currentCommissionRate }}%</text>
|
<text class="font_7 text_9">{{ CommissionList.myUnitPrice }}/{{ CommissionList.agentUnitPrice }}/{{ CommissionList.currentCommissionRate }}%</text>
|
||||||
<view class="flex-row group_5 pos_2" bindtap="showCommissionRatePop">
|
<view class="flex-row group_5 pos_2" bindtap="showCommissionRatePop" data-nowMyUnitPrice="{{ CommissionList.myUnitPrice }} " data-currentCommissionRate="{{ CommissionList.currentCommissionRate }}" data-agentUnitPrice="{{ CommissionList.agentUnitPrice }}" data-projectDetailName="{{ CommissionList.projectDetailName }}" data-detailid="{{ CommissionList.id }}" data-maxCommissionRate="{{ CommissionList.maxCommissionRate }}">
|
||||||
<image
|
<image
|
||||||
class="image_4 image_6"
|
class="image_4 image_6"
|
||||||
src="./images/yjt3.png"
|
src="./images/yjt3.png"
|
||||||
|
@ -70,9 +70,16 @@
|
||||||
<!-- 弹窗组件 -->
|
<!-- 弹窗组件 -->
|
||||||
<commissionPop show="{{showPopup}}" bind:close="closePopup" bind:submit="handleCommissionSubmit" />
|
<commissionPop show="{{showPopup}}" bind:close="closePopup" bind:submit="handleCommissionSubmit" />
|
||||||
<!-- 弹窗组件 -->
|
<!-- 弹窗组件 -->
|
||||||
|
<!-- 四个变量 -->
|
||||||
<commissionRatePop
|
<commissionRatePop
|
||||||
show="{{showCommissionRatePop}}"
|
show="{{showCommissionRatePop}}"
|
||||||
bind:cancel="closeCommissionRatePop"
|
bind:cancel="closeCommissionRatePop"
|
||||||
bind:close="closeCommissionRatePop"
|
bind:close="closeCommissionRatePop"
|
||||||
bind:confirm="handleCommissionRateConfirm"
|
bind:confirm="handleCommissionRateConfirm"
|
||||||
|
pgencyPrice="{{ nowAgentUnitPrice }}"
|
||||||
|
commissionRate="{{ nowCommissionRate }}"
|
||||||
|
myUnitPrice="{{ nowMyUnitPrice }}"
|
||||||
|
projectDetailName="{{ nowProjectDetailName }}"
|
||||||
|
detailId="{{ projectId }}"
|
||||||
|
maxCommissionRate="{{ maxCommissionRate }}"
|
||||||
/>
|
/>
|
|
@ -1,4 +1,11 @@
|
||||||
|
import { baseUrl } from "../../../../request";
|
||||||
Component({
|
Component({
|
||||||
|
|
||||||
|
data: {
|
||||||
|
pgencyPriceAble: true, // 代理单价input启用/禁用
|
||||||
|
commissionRateAble: true, // 抽成比例input启用/禁用
|
||||||
|
LodingHidden: false, // 遮罩禁用启用
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 组件的属性列表
|
* 组件的属性列表
|
||||||
*/
|
*/
|
||||||
|
@ -7,8 +14,111 @@ Component({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false
|
value: false
|
||||||
},
|
},
|
||||||
pgencyPrice: 0, // 代理价
|
pgencyPrice: { // 代理单价
|
||||||
commissionRate: 0, // 抽成比例
|
type: String,
|
||||||
|
value: 0
|
||||||
|
},
|
||||||
|
commissionRate: { // 抽成比例
|
||||||
|
type: String,
|
||||||
|
value: 0
|
||||||
|
},
|
||||||
|
myUnitPrice: { // 我的单价
|
||||||
|
type: Number,
|
||||||
|
value: 0
|
||||||
|
},
|
||||||
|
projectDetailName: { // 项目详细名称
|
||||||
|
type: String,
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
detailId: { // 下级项目明细id
|
||||||
|
type: Number,
|
||||||
|
value: 0
|
||||||
|
},
|
||||||
|
maxCommissionRate: { // 最大抽佣比例
|
||||||
|
type: Number,
|
||||||
|
value: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的方法列表
|
||||||
|
*/
|
||||||
|
methods: {
|
||||||
|
close() {
|
||||||
|
this.resetStatus();
|
||||||
|
this.triggerEvent('close');
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
this.resetStatus();
|
||||||
|
this.triggerEvent('cancel');
|
||||||
|
},
|
||||||
|
confirm() {
|
||||||
|
// 触发confirm事件带数据
|
||||||
|
const id = this.data.detailId;
|
||||||
|
const Rate = this.data.commissionRate;
|
||||||
|
const maxRate = this.data.maxCommissionRate;
|
||||||
|
// console.log('maxRate---->', maxRate);
|
||||||
|
if (Rate > maxRate || Rate < 0) {
|
||||||
|
wx.showModal({
|
||||||
|
title: '抽佣比率错误',
|
||||||
|
content: '抽佣比率大于最大抽成',
|
||||||
|
showCancel: false
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wx.showLoading({
|
||||||
|
title: '加载中',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
// 发送请求
|
||||||
|
wx.request({
|
||||||
|
url: baseUrl + '/projectCommission/update/rate',
|
||||||
|
method: 'POST',
|
||||||
|
header: {
|
||||||
|
Authorization: wx.getStorageSync('token'),
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
id: id,
|
||||||
|
currentCommissionRate: Rate
|
||||||
|
},
|
||||||
|
success: res => {
|
||||||
|
console.log('后端结果---->',res.data);
|
||||||
|
if (res.data.code === 1) {
|
||||||
|
wx.hideLoading() // 加载框关闭
|
||||||
|
this.triggerEvent('confirm', {});
|
||||||
|
} else {
|
||||||
|
wx.showToast({
|
||||||
|
title: '服务异常',
|
||||||
|
icon: 'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.resetStatus();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 单选框选择方法
|
||||||
|
radioChange(e) {
|
||||||
|
const selected = e.detail.value;
|
||||||
|
if (selected === '代理价') {
|
||||||
|
this.setData({
|
||||||
|
pgencyPriceAble: false,
|
||||||
|
commissionRateAble: true,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.setData({
|
||||||
|
pgencyPriceAble: true,
|
||||||
|
commissionRateAble: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 重置input状态
|
||||||
|
resetStatus() {
|
||||||
|
this.setData({
|
||||||
|
pgencyPriceAble: true,
|
||||||
|
commissionRateAble: true,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,20 +131,30 @@ Component({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
// 计算单价——当输入抽成比率失焦时自动计算
|
||||||
* 组件的方法列表
|
calculateUnitPrice() {
|
||||||
*/
|
const tempCommissionRate = this.data.commissionRate/100; // 暂存抽成比率
|
||||||
methods: {
|
const tempMyUnitPrice = this.data.myUnitPrice; // 暂存我的单价
|
||||||
close() {
|
let res = parseFloat( (tempMyUnitPrice * (1- tempCommissionRate)).toPrecision(2) ) ;
|
||||||
this.triggerEvent('close');
|
// 计算单价 (避免精度丢失问题)
|
||||||
},
|
this.setData({
|
||||||
cancel() {
|
pgencyPrice : res
|
||||||
this.triggerEvent('cancel');
|
})
|
||||||
},
|
|
||||||
confirm() {
|
|
||||||
// 触发confirm事件带数据
|
|
||||||
this.triggerEvent('confirm', {/*数据*/});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 计算比率——当输入代理单价失焦时自动计算
|
||||||
|
calculateRatio() {
|
||||||
|
const tempPgencyPrice = this.data.pgencyPrice; // 暂存代理单价
|
||||||
|
const tempMyUnitPrice = this.data.myUnitPrice; // 暂存我的单价
|
||||||
|
if (tempPgencyPrice == tempMyUnitPrice) {
|
||||||
|
this.setData({ commissionRate: 100 })
|
||||||
|
} else {
|
||||||
|
let res = (tempMyUnitPrice - tempPgencyPrice) / tempMyUnitPrice;
|
||||||
|
this.setData({
|
||||||
|
commissionRate: parseFloat((res*100).toPrecision(2))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log('抽佣比率------>',this.data.commissionRate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -4,34 +4,53 @@
|
||||||
<text class="self-center font text">代理价设置</text>
|
<text class="self-center font text">代理价设置</text>
|
||||||
<view class="flex-col self-stretch mt-24">
|
<view class="flex-col self-stretch mt-24">
|
||||||
<view class="flex-col">
|
<view class="flex-col">
|
||||||
<text class="self-start font_2 text_2">我的价格0.30,我的抽成0.17元</text>
|
<text class="self-start font_2 text_2">我的价格{{ myUnitPrice }},我的抽成{{ (myUnitPrice*100 - pgencyPrice*100)/100 }}元</text>
|
||||||
<view class="flex-col self-stretch section_2 mt-13">
|
<view class="flex-col self-stretch section_2 mt-13">
|
||||||
<view class="flex-row justify-between items-center">
|
<view class="flex-row justify-between items-center">
|
||||||
<text class="font_2 text_4">结算标准</text>
|
<text class="font_2 text_4">结算标准</text>
|
||||||
<text class="font_2 text_3">3.6元购买30元券包3.6元购买</text>
|
<text class="font_2 text_3">{{ projectDetailName }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-row justify-between items-center group">
|
<view class="flex-row justify-between items-center group">
|
||||||
<text class="font_2 text_5">代理价</text>
|
<text class="font_2 text_5">代理价</text>
|
||||||
<view class="flex-col justify-start items-start text-wrapper">
|
<view class="flex-col justify-start items-start text-wrapper">
|
||||||
<input class="text_6 font" placeholder="0.30" />
|
<input
|
||||||
|
class="text_8 font"
|
||||||
|
type="digit"
|
||||||
|
placeholder="请输入代理单价"
|
||||||
|
data-field="pgencyPrice"
|
||||||
|
value="{{ pgencyPrice }}"
|
||||||
|
disabled="{{ pgencyPriceAble }}"
|
||||||
|
bindblur="calculateRatio"
|
||||||
|
bindinput="handleInputChange"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-row justify-between items-center group_2">
|
<view class="flex-row justify-between items-center group_2">
|
||||||
<text class="font_2 text_7">抽成比例</text>
|
<text class="font_2 text_7">抽成比例</text>
|
||||||
<view class="flex-col justify-start items-start text-wrapper">
|
<view class="flex-col justify-start items-start text-wrapper input-container">
|
||||||
<input class="text_8 font" placeholder="0.30" />
|
<image class="input-icon" src="./images/baifenbi.png"></image>
|
||||||
|
<input
|
||||||
|
class="text_8 font"
|
||||||
|
placeholder="请输入抽成比例"
|
||||||
|
type="digit"
|
||||||
|
data-field="commissionRate"
|
||||||
|
value="{{ commissionRate }}"
|
||||||
|
disabled="{{ commissionRateAble }}"
|
||||||
|
bindblur="calculateUnitPrice"
|
||||||
|
bindinput="handleInputChange"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="flex-row justify-between items-center group_3">
|
<view class="flex-row justify-between items-center group_3">
|
||||||
<text class="font_2 text_10">设价方式</text>
|
<text class="font_2 text_10">设价方式</text>
|
||||||
<radio-group class="flex-col group_4">
|
<radio-group class="flex-col group_4" bindchange="radioChange">
|
||||||
<view class="flex-row items-center">
|
<view class="flex-row items-center">
|
||||||
<radio class="radio" color="#FF8D1A"></radio>
|
<radio class="radio" color="#FF8D1A" value="代理价"></radio>
|
||||||
<text class="font_2 text_9 ml-7">代理价</text>
|
<text class="font_2 text_9 ml-7">代理价</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-row items-center mt-14">
|
<view class="flex-row items-center mt-14">
|
||||||
<radio class="radio_1" color="#FF8D1A"></radio>
|
<radio class="radio_1" color="#FF8D1A" value="抽成比例"></radio>
|
||||||
<text class="font_2 text_11 ml-7">抽成比例</text>
|
<text class="font_2 text_11 ml-7">抽成比例</text>
|
||||||
</view>
|
</view>
|
||||||
</radio-group>
|
</radio-group>
|
||||||
|
|
|
@ -121,6 +121,19 @@ radio {
|
||||||
transform: scale(0.8); /* 调整为你需要的缩放比例 */
|
transform: scale(0.8); /* 调整为你需要的缩放比例 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 在.wxss文件中 */
|
||||||
|
.input-container {
|
||||||
|
position: relative; /* 容器使用相对定位 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-icon {
|
||||||
|
position: absolute; /* 图标使用绝对定位 */
|
||||||
|
left: 82px; /* 设置图标距离左边的距离 */
|
||||||
|
top: 9px; /* 设置图标距离顶部的距离 */
|
||||||
|
width: 15px; /* 图标宽度 */
|
||||||
|
height: 15px; /* 图标高度 */
|
||||||
|
}
|
||||||
|
|
||||||
/* 弹窗外围容器,覆盖全屏并居中 */
|
/* 弹窗外围容器,覆盖全屏并居中 */
|
||||||
.popup-wrapper {
|
.popup-wrapper {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
Loading…
Reference in New Issue
Block a user