2025-06-05 14:27:57 +00:00
|
|
|
|
|
|
|
import { baseUrl } from "../../../../request";Component({
|
2025-05-29 00:56:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 组件的属性列表
|
|
|
|
*/
|
|
|
|
properties: {
|
2025-06-01 02:43:37 +00:00
|
|
|
show: {
|
|
|
|
type: Boolean,
|
|
|
|
value: false,
|
|
|
|
},
|
2025-05-29 00:56:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组件的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
2025-06-03 16:18:25 +00:00
|
|
|
commissionRate: 0, // 用户输入的抽佣比例
|
2025-05-29 00:56:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组件的方法列表
|
|
|
|
*/
|
|
|
|
methods: {
|
2025-06-01 02:43:37 +00:00
|
|
|
// 获取用户输入的比例
|
|
|
|
handleInput(e) {
|
|
|
|
this.setData({
|
|
|
|
commissionRate: e.detail.value,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// 提交设置
|
|
|
|
submit() {
|
|
|
|
const rate = parseFloat(this.data.commissionRate);
|
|
|
|
if (isNaN(rate) || rate <= 0 || rate > 5) {
|
|
|
|
wx.showToast({
|
|
|
|
title: `请输入有效的比例,最大为 5%`,
|
|
|
|
icon: 'none',
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2025-06-05 14:27:57 +00:00
|
|
|
wx.showLoading({
|
|
|
|
title: '加载中',
|
|
|
|
mask: true
|
|
|
|
})
|
2025-06-01 02:43:37 +00:00
|
|
|
|
2025-06-05 14:27:57 +00:00
|
|
|
// 一键设置抽佣
|
|
|
|
wx.request({
|
|
|
|
url: baseUrl + '/projectCommission/update/unite/rate',
|
|
|
|
method: 'POST',
|
|
|
|
header: {
|
|
|
|
Authorization: wx.getStorageSync('token'),
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
uniteCommissionRate: rate
|
|
|
|
},
|
|
|
|
success: res => {
|
|
|
|
console.log('一键设置下级抽成比例结果---->',res.data);
|
|
|
|
if (res.data.code === 1) {
|
|
|
|
wx.hideLoading()
|
|
|
|
wx.showToast({
|
|
|
|
title: '设置成功',
|
|
|
|
icon: 'success',
|
|
|
|
duration: 1500
|
|
|
|
})
|
|
|
|
// 触发父组件的事件,将设置的比例传递出去
|
|
|
|
this.triggerEvent('submit', {});
|
|
|
|
// 关闭弹窗
|
|
|
|
this.triggerEvent('close');
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
title: '服务错误',
|
|
|
|
icon: 'error'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2025-06-01 02:43:37 +00:00
|
|
|
},
|
2025-05-29 00:56:35 +00:00
|
|
|
|
2025-06-01 02:43:37 +00:00
|
|
|
// 关闭弹窗
|
|
|
|
close() {
|
|
|
|
this.triggerEvent('close');
|
|
|
|
}
|
|
|
|
}
|
2025-05-29 00:56:35 +00:00
|
|
|
})
|