需求列表状态刷新优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// pages/demand/detail.js
|
||||
import { fetchDemandDetail, joinDemandBidding, demandOperate } from '../../../services/demand/fetchDemand';
|
||||
import { fetchPlatformCommissionRatio, calcActualAccount } from '../../../services/home/home';
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -11,6 +12,8 @@ Page({
|
||||
needDays: '',
|
||||
remark: '',
|
||||
actualAccount: 0,
|
||||
commissionRatio: 0.1, // 平台服务费比例,来自 common/getMiniConfig
|
||||
commissionPercent: 10, // 平台服务费百分比,用于提示文案
|
||||
activeValues: [0, 1, 2, 3, 4],
|
||||
demandInfo: null,
|
||||
freshPage: false, // 返回本页时是否需要重新拉取详情(签约/发货/支付后置为 true)
|
||||
@@ -33,7 +36,7 @@ Page({
|
||||
const demandInfo = res.data;
|
||||
this.setData({
|
||||
demandInfo,
|
||||
actualAccount: parseFloat(demandInfo?.myBidding?.quoted_price || demandInfo?.demand_contracts?.total_amount || 0) * 0.9
|
||||
actualAccount: calcActualAccount(this.getQuoteAmount(demandInfo), this.data.commissionRatio)
|
||||
}, () => resolve()); // setData 回调:页面已重新渲染
|
||||
},
|
||||
() => {
|
||||
@@ -43,6 +46,19 @@ Page({
|
||||
);
|
||||
});
|
||||
},
|
||||
// 报价金额:优先已投标报价,其次合同总费用,最后为当前输入
|
||||
getQuoteAmount(demandInfo) {
|
||||
return demandInfo?.myBidding?.quoted_price || demandInfo?.demand_contracts?.total_amount || this.data.quotedPrice || 0;
|
||||
},
|
||||
// 拉取平台服务费比例,并按新比例重算预计到手金额
|
||||
async loadCommissionRatio() {
|
||||
const ratio = await fetchPlatformCommissionRatio();
|
||||
this.setData({
|
||||
commissionRatio: ratio,
|
||||
commissionPercent: Math.round(ratio * 10000) / 100,
|
||||
actualAccount: calcActualAccount(this.getQuoteAmount(this.data.demandInfo), ratio)
|
||||
});
|
||||
},
|
||||
// 取文件扩展名对应的 openDocument 类型(默认 pdf)
|
||||
getFileType(url) {
|
||||
const ext = String(url || '').split('?')[0].split('#')[0].split('.').pop().toLowerCase();
|
||||
@@ -178,8 +194,7 @@ Page({
|
||||
const field = e.currentTarget.dataset.field;
|
||||
const value = e.detail.value;
|
||||
if (field == 'quotedPrice') {
|
||||
let actualAccount = parseInt(value * 0.9);
|
||||
this.setData({ actualAccount });
|
||||
this.setData({ actualAccount: calcActualAccount(value, this.data.commissionRatio) });
|
||||
}
|
||||
this.setData({
|
||||
[`${field}`]: value
|
||||
@@ -682,6 +697,7 @@ Page({
|
||||
opType
|
||||
});
|
||||
this.loadDemandDetail(id);
|
||||
this.loadCommissionRatio();
|
||||
wx.$util.checkSubscriptionsSetting();
|
||||
//从列表「前去验收」进入时,提示先到沟通群查看/体验交付成果再验收
|
||||
if (options.fromAccept == '1') {
|
||||
|
||||
Reference in New Issue
Block a user