Browse Source

1 处理查看详情调接口顺序问题。

hotfix/210830_二组需求分支
王饶冀 3 years ago
parent
commit
f5c94a9007

+ 27
- 44
pages/index/components/listDetails/Details.js View File

data: { data: {
// 页面Loading // 页面Loading
pageLoading: true, pageLoading: true,
customerId: null,
// 路由接受的参数 // 路由接受的参数
currentData: {}, currentData: {},
// 感兴趣的需求---- // 感兴趣的需求----
onRefresh: true, onRefresh: true,
currentIndex: -1, currentIndex: -1,
// 当前登录器用户登录ID // 当前登录器用户登录ID
userCustomerId: null,
customerId: null,
businessCommunicationDemandId: "", businessCommunicationDemandId: "",
// 热门加载loading
hotLoading: false,
}, },


/** /**
const businessCommunicationCustomer = wx.getStorageSync('businessCommunicationCustomer') || null; const businessCommunicationCustomer = wx.getStorageSync('businessCommunicationCustomer') || null;
if (businessCommunicationCustomer) { if (businessCommunicationCustomer) {
this.setData({ this.setData({
userCustomerId: businessCommunicationCustomer.customerId
customerId: businessCommunicationCustomer.customerId
}) })
} }
// 获取当前数据 // 获取当前数据
this.getCurrentData(); this.getCurrentData();
if (app.globalData.customerId) {
this.setData({
customerId: app.globalData.customerId
})
// this.getIsCollect();
} else {
this.getListData();
}
// 设置当前访问量 // 设置当前访问量
this.setDemandCollect();
this.setDemandCollect();
}, },
setDemandCollect(){
setDemandCollect() {
let businessCommunicationDemandId = this.data.businessCommunicationDemandId; let businessCommunicationDemandId = this.data.businessCommunicationDemandId;
$request.post('/statisticsBusinessCommunicationDemand/saveDemandCollect.action', $request.post('/statisticsBusinessCommunicationDemand/saveDemandCollect.action',
{ businessCommunicationDemandId } { businessCommunicationDemandId }
).then(res => { }).catch(err => { console.log(err) }) ).then(res => { }).catch(err => { console.log(err) })
$request.post('/statisticsBusinessCommunicationDemand/demandPageView.action', $request.post('/statisticsBusinessCommunicationDemand/demandPageView.action',
{ businessCommunicationDemandId,customerId: app.globalData.customerId }
{ businessCommunicationDemandId, customerId: this.data.customerId }
).then(res => { }).catch(err => { console.log(err) }) ).then(res => { }).catch(err => { console.log(err) })
}, },
// 热门详情点击 // 热门详情点击
}); });
}, },
getCurrentData() { getCurrentData() {
let { businessCommunicationDemandId } = this.data;
let { businessCommunicationDemandId, customerId } = this.data;
let paramCustomerId = customerId ? customerId * 1 : null;
console.log(paramCustomerId, 'paramCustomerId')
$request.get('/businessCommunicationDemand/getDemandByDemandId.action', $request.get('/businessCommunicationDemand/getDemandByDemandId.action',
{ demandId: businessCommunicationDemandId }
{ demandId: businessCommunicationDemandId, customerId: paramCustomerId }
).then(res => { ).then(res => {
if (res.status == 0) { if (res.status == 0) {
let listDetail = res.data;
let listDetail = res.data.demandByDemandId;
listDetail.createdOn = $util.formatTime(new Date(listDetail.createdOn), true); listDetail.createdOn = $util.formatTime(new Date(listDetail.createdOn), true);
listDetail.createdOn = listDetail.createdOn.replaceAll('/', '-'); listDetail.createdOn = listDetail.createdOn.replaceAll('/', '-');
if (typeof listDetail.type == 'string') { if (typeof listDetail.type == 'string') {
this.setData({ this.setData({
currentData: listDetail, currentData: listDetail,
type: listDetail.type, type: listDetail.type,
})
this.getIsCollect();
}
}).catch(err => {
console.log(err, 'error appletLogin')
})
},
// 判断是否收藏
getIsCollect() {
let { currentData, customerId } = this.data;
$request.get('/businessCommunicationCollect/booleanIsCollect.action',
{ customerId, businessCommunicationDemandId: currentData.businessCommunicationDemandId }
).then(res => {
if (res.status == 0) {
this.setData({
isCollect: res.data == 0 ? false : true,
pageLoading: true,
})
}
if(this.data.currentData.customerId == this.data.userCustomerId){
this.setData({
pageLoading: false, pageLoading: false,
isCollect: res.data.booleanIsCollect == 0 ? false : true,
}) })
}else{
this.getListData();
if (this.data.currentData.customerId != this.data.userCustomerId) {
this.setData({
hotLoading: true,
})
this.getListData();
}
} }
}).catch(err => { }).catch(err => {
console.log(err, 'error appletLogin') console.log(err, 'error appletLogin')
// 获取list数据 // 获取list数据
getListData() { getListData() {
let { page, size, type, currentData } = this.data; let { page, size, type, currentData } = this.data;
if(typeof type == 'object'){
if (typeof type == 'object') {
type = type.join(','); type = type.join(',');
} }
$request.get('/businessCommunicationDemand/getDemandByKeywordOrType.action', $request.get('/businessCommunicationDemand/getDemandByKeywordOrType.action',
{ page, size, type, isInterest: 1, demandId: currentData.businessCommunicationDemandId } { page, size, type, isInterest: 1, demandId: currentData.businessCommunicationDemandId }
).then(res => { ).then(res => {
this.setData({
pageLoading: false,
})
let tempListData = this.data.listData; let tempListData = this.data.listData;
if (res.status == 0) { if (res.status == 0) {
let datas = res.data; let datas = res.data;
}) })
} }
} }
this.setData({
hotLoading: false,
})
}).catch(error => { }).catch(error => {
console.log(error, 'error appletLogin') console.log(error, 'error appletLogin')
this.setData({
hotLoading: false,
})
}) })
}, },
/* /*

+ 17
- 12
pages/index/components/listDetails/Details.wxml View File

<view class="list-view {{ customerId != currentData.customerId ? 'have-hot' : '' }}"> <view class="list-view {{ customerId != currentData.customerId ? 'have-hot' : '' }}">
<listItem item="{{ currentData }}" pageStatus="detatil" isCollect="{{ isCollect }}" isShowCollect="{{ customerId != currentData.customerId }}" bind:changeCollect="changeCollect" customerId="{{ userCustomerId }}" /> <listItem item="{{ currentData }}" pageStatus="detatil" isCollect="{{ isCollect }}" isShowCollect="{{ customerId != currentData.customerId }}" bind:changeCollect="changeCollect" customerId="{{ userCustomerId }}" />
</view> </view>
<view wx:if="{{ userCustomerId != currentData.customerId }}">
<view wx:if="{{ customerId != currentData.customerId }}">
<view class="view-interested">你可能感兴趣的需求</view> <view class="view-interested">你可能感兴趣的需求</view>
<view class="not-data" wx:if="{{ listData.length < 1 }}">
<image class="not-data-img" src="/images/home/not-data.png" />
<view class="not-info">没有更多感兴趣的需求</view>
<view class="list-loading text-center" wx:if="{{ hotLoading }}">
<van-loading size="24px">加载中...</van-loading>
</view> </view>
<view wx:else> <view wx:else>
<view class="list-view" wx:for="{{ listData }}" wx:key="index">
<listItem item="{{ item }}" bind:getItem="goDetails" customerId="{{ userCustomerId }}" />
<view class="not-data" wx:if="{{ listData.length < 1 }}">
<image class="not-data-img" src="/images/home/not-data.png" />
<view class="not-info">没有更多感兴趣的需求</view>
</view> </view>
<view class="text-center" wx:if="{{ itemLoading }}">
<van-loading size="24px">加载中...</van-loading>
</view>
<view class="list-finished text-center" wx:if="{{ isFinished }}">
<image class="finished-img" src="/images/home/finished-icon.png" />
没有更多啦~
<view wx:else>
<view class="list-view" wx:for="{{ listData }}" wx:key="index">
<listItem item="{{ item }}" bind:getItem="goDetails" customerId="{{ customerId }}" />
</view>
<view class="text-center" wx:if="{{ itemLoading }}">
<van-loading size="24px">加载中...</van-loading>
</view>
<view class="list-finished text-center" wx:if="{{ isFinished }}">
<image class="finished-img" src="/images/home/finished-icon.png" />
没有更多啦~
</view>
</view> </view>
</view> </view>
</view> </view>

Loading…
Cancel
Save