前端代码优化,及后端按钮状态优化
This commit is contained in:
@@ -18,19 +18,28 @@ Page({
|
||||
/**
|
||||
* 获取需求详情
|
||||
*/
|
||||
/**
|
||||
* 获取需求详情
|
||||
* @param {number|string} id
|
||||
* @returns {Promise} 详情渲染完成后 resolve
|
||||
*/
|
||||
loadDemandDetail(id) {
|
||||
fetchDemandDetail({ id: id }).then(
|
||||
(res) => {
|
||||
console.log(res);
|
||||
this.setData({
|
||||
demandInfo: res.data,
|
||||
actualAccount: parseFloat(res.data?.myBidding?.quoted_price || res.data?.demand_contracts?.total_amount || 0) * 0.9
|
||||
});
|
||||
},
|
||||
() => {
|
||||
//接口异常处理
|
||||
},
|
||||
);
|
||||
return new Promise((resolve) => {
|
||||
fetchDemandDetail({ id: id }).then(
|
||||
(res) => {
|
||||
console.log(res);
|
||||
const demandInfo = res.data;
|
||||
this.setData({
|
||||
demandInfo,
|
||||
actualAccount: parseFloat(demandInfo?.myBidding?.quoted_price || demandInfo?.demand_contracts?.total_amount || 0) * 0.9
|
||||
}, () => resolve()); // setData 回调:页面已重新渲染
|
||||
},
|
||||
() => {
|
||||
//接口异常处理
|
||||
resolve();
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
//文件预览
|
||||
fileView(e) {
|
||||
@@ -185,11 +194,12 @@ Page({
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
if (agree) {
|
||||
//刷新当前页面
|
||||
this.loadDemandDetail(this.data.id);
|
||||
wx.pageScrollTo({
|
||||
scrollTop: 0,
|
||||
duration: 300
|
||||
//刷新当前页面,等沟通群二维码渲染完成后再回到顶部,方便直接看到
|
||||
this.loadDemandDetail(this.data.id).then(() => {
|
||||
wx.pageScrollTo({
|
||||
scrollTop: 0,
|
||||
duration: 300
|
||||
});
|
||||
});
|
||||
} else {
|
||||
//返回上一页
|
||||
@@ -564,7 +574,11 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
// 从签约页等操作页返回时,backAndRefresh 会给本页打 freshPage 标记,此时刷新详情
|
||||
if (this.data.freshPage) {
|
||||
this.setData({ freshPage: false });
|
||||
this.loadDemandDetail(this.data.id);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
<t-button theme="light" size="large" data-status="0" bind:tap="signContractDev">放弃签约</t-button>
|
||||
<t-button theme="danger" size="large" data-status="1" bind:tap="signContractDev">合同签约</t-button>
|
||||
</view>
|
||||
<t-button wx:elif="{{_calc.isWaitingCustomerSign(demandInfo)}}" theme="light" size="large" disabled block>签约中(等待客户签约)</t-button>
|
||||
<view class="button-layout-flex" wx:elif="{{_calc.canCompleteWork(demandInfo)}}">
|
||||
<t-button theme="light" size="large" data-status="0" bind:tap="completeWork">完成失败</t-button>
|
||||
<t-button theme="danger" size="large" data-status="1" bind:tap="completeWork" block>工作完成</t-button>
|
||||
|
||||
@@ -14,6 +14,12 @@ var canConfirmOrder = function (demandInfo) {
|
||||
|
||||
var canSignContractDev = function (demandInfo) {
|
||||
if (!demandInfo) return false;
|
||||
// 开发者已签约(合同 status==2)、等待客户签约(status2==1)时,不再显示签约按钮
|
||||
if (demandInfo.demand_contracts &&
|
||||
demandInfo.demand_contracts.status == 2 &&
|
||||
demandInfo.demand_contracts.status2 == 1) {
|
||||
return false;
|
||||
}
|
||||
return demandInfo.status == 2 &&
|
||||
demandInfo.isMyWin &&
|
||||
demandInfo.winBidding &&
|
||||
@@ -21,6 +27,15 @@ var canSignContractDev = function (demandInfo) {
|
||||
demandInfo.winBidding.process_status == 2;
|
||||
}
|
||||
|
||||
// 开发者已签约、等待客户签约中
|
||||
var isWaitingCustomerSign = function (demandInfo) {
|
||||
if (!demandInfo) return false;
|
||||
return demandInfo.status == 2 &&
|
||||
demandInfo.demand_contracts &&
|
||||
demandInfo.demand_contracts.status == 2 &&
|
||||
demandInfo.demand_contracts.status2 == 1;
|
||||
}
|
||||
|
||||
var canSignContractCustomer = function (demandInfo) {
|
||||
if (!demandInfo) return false;
|
||||
return demandInfo.status == 2 &&
|
||||
@@ -61,6 +76,7 @@ module.exports = {
|
||||
canSubmitBidding: canSubmitBidding,
|
||||
canConfirmOrder: canConfirmOrder,
|
||||
canSignContractDev: canSignContractDev,
|
||||
isWaitingCustomerSign: isWaitingCustomerSign,
|
||||
canSignContractCustomer: canSignContractCustomer,
|
||||
canCompleteWork: canCompleteWork,
|
||||
canAcceptPassed: canAcceptPassed,
|
||||
|
||||
Reference in New Issue
Block a user