Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
chen-xin-zhi 2025-06-05 11:17:54 +08:00
commit 23bbb1bf7d
7 changed files with 204 additions and 31 deletions

View File

@ -8,10 +8,15 @@ Page({
*/
data: {
projectList: [], // 项目列表
items_1: [null, null, null],
items: [null, null],
projectId: 0, // 项目ID
maxCommissionRate: 0, // 最大抽佣比率
showPopup: false, // 控制弹窗显隐
LodingHidden: true, // 控制加载框取消
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 });
},
@ -87,8 +102,7 @@ Page({
// 确认按钮回调
handleCommissionRateConfirm(e) {
const { agentPrice, commissionRate, pricingMethod } = e.detail;
console.log('设置数据:', agentPrice, commissionRate, pricingMethod);
this.getProjectList()
this.closeCommissionRatePop();
},

View File

@ -54,7 +54,7 @@
>
<text class="font_6 text_6 pos">{{ CommissionList.projectDetailName }}</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
class="image_4 image_6"
src="./images/yjt3.png"
@ -70,9 +70,16 @@
<!-- 弹窗组件 -->
<commissionPop show="{{showPopup}}" bind:close="closePopup" bind:submit="handleCommissionSubmit" />
<!-- 弹窗组件 -->
<!-- 四个变量 -->
<commissionRatePop
show="{{showCommissionRatePop}}"
bind:cancel="closeCommissionRatePop"
bind:close="closeCommissionRatePop"
bind:confirm="handleCommissionRateConfirm"
/>
pgencyPrice="{{ nowAgentUnitPrice }}"
commissionRate="{{ nowCommissionRate }}"
myUnitPrice="{{ nowMyUnitPrice }}"
projectDetailName="{{ nowProjectDetailName }}"
detailId="{{ projectId }}"
maxCommissionRate="{{ maxCommissionRate }}"
/>

View File

@ -172,4 +172,4 @@
}
.text_8 {
margin-left: -75.75rpx;
}
}

View File

@ -1,4 +1,11 @@
import { baseUrl } from "../../../../request";
Component({
data: {
pgencyPriceAble: true, // 代理单价input启用/禁用
commissionRateAble: true, // 抽成比例input启用/禁用
LodingHidden: false, // 遮罩禁用启用
},
/**
* 组件的属性列表
*/
@ -7,18 +14,30 @@ Component({
type: Boolean,
value: false
},
pgencyPrice: 0, // 代理价
commissionRate: 0, // 抽成比例
},
/**
* 处理输入框的变化
*/
handleInputChange(e) {
const { field } = e.target.dataset; // 获取字段名
this.setData({
[field]: e.detail.value, // 动态更新输入框数据
});
pgencyPrice: { // 代理单价
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
}
},
/**
@ -26,15 +45,116 @@ Component({
*/
methods: {
close() {
this.resetStatus();
this.triggerEvent('close');
},
cancel() {
this.resetStatus();
this.triggerEvent('cancel');
},
confirm() {
// 触发confirm事件带数据
this.triggerEvent('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,
})
},
/**
* 处理输入框的变化
*/
handleInputChange(e) {
const { field } = e.target.dataset; // 获取字段名
this.setData({
[field]: e.detail.value, // 动态更新输入框数据
});
},
// 计算单价——当输入抽成比率失焦时自动计算
calculateUnitPrice() {
const tempCommissionRate = this.data.commissionRate/100; // 暂存抽成比率
const tempMyUnitPrice = this.data.myUnitPrice; // 暂存我的单价
let res = parseFloat( (tempMyUnitPrice * (1- tempCommissionRate)).toPrecision(2) ) ;
// 计算单价 (避免精度丢失问题)
this.setData({
pgencyPrice : res
})
},
// 计算比率——当输入代理单价失焦时自动计算
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);
}
}
})

View File

@ -4,34 +4,53 @@
<text class="self-center font text">代理价设置</text>
<view class="flex-col self-stretch mt-24">
<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-row justify-between items-center">
<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 class="flex-row justify-between items-center group">
<text class="font_2 text_5">代理价</text>
<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 class="flex-row justify-between items-center group_2">
<text class="font_2 text_7">抽成比例</text>
<view class="flex-col justify-start items-start text-wrapper">
<input class="text_8 font" placeholder="0.30" />
<view class="flex-col justify-start items-start text-wrapper input-container">
<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 class="flex-row justify-between items-center group_3">
<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">
<radio class="radio" color="#FF8D1A"></radio>
<radio class="radio" color="#FF8D1A" value="代理价"></radio>
<text class="font_2 text_9 ml-7">代理价</text>
</view>
<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>
</view>
</radio-group>

View File

@ -121,6 +121,19 @@ radio {
transform: scale(0.8); /* 调整为你需要的缩放比例 */
}
/* 在.wxss文件中 */
.input-container {
position: relative; /* 容器使用相对定位 */
}
.input-icon {
position: absolute; /* 图标使用绝对定位 */
left: 82px; /* 设置图标距离左边的距离 */
top: 9px; /* 设置图标距离顶部的距离 */
width: 15px; /* 图标宽度 */
height: 15px; /* 图标高度 */
}
/* 弹窗外围容器,覆盖全屏并居中 */
.popup-wrapper {
position: fixed;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB