前端代码优化,及后端按钮状态优化
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);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user