@@ -1,5 +1,5 @@ | |||
// components/listItem/listItem.js | |||
const app = getApp() | |||
const app = getApp(); | |||
Component({ | |||
/** | |||
* 组件的属性列表 | |||
@@ -17,23 +17,27 @@ Component({ | |||
// 是否收藏 | |||
isCollect: { | |||
type: Boolean, | |||
value:false, | |||
value: false, | |||
}, | |||
// 是否显示收藏 | |||
isShowCollect:{ | |||
isShowCollect: { | |||
type: Boolean, | |||
value:false, | |||
value: false, | |||
}, | |||
// 是否其他查看主页---用于是否显示聊一聊 | |||
isOther:{ | |||
isOther: { | |||
type: Boolean, | |||
value:true, | |||
value: true, | |||
}, | |||
// 类名 | |||
listClass: { | |||
type: String, | |||
value: "", | |||
}, | |||
customerId:{ | |||
type:Number, | |||
value:null, | |||
}, | |||
}, | |||
/** | |||
@@ -41,10 +45,14 @@ Component({ | |||
*/ | |||
data: { | |||
}, | |||
/** | |||
* 组件的方法列表 | |||
*/ | |||
methods: { | |||
getCustomerId() { | |||
return 123 | |||
}, | |||
// 进入详情 | |||
goDetails(e) { | |||
if (this.data.listClass == 'disabled-model-view') { | |||
@@ -77,10 +85,10 @@ Component({ | |||
console.log(`点击了聊一聊`) | |||
let item = e.currentTarget.dataset.item; | |||
wx.navigateTo({ | |||
url:"/pages/msgModule/wechat2/wechat2", | |||
url: "/pages/msgModule/wechat2/wechat2", | |||
success: function (res) { | |||
// 通过eventChannel向被打开页面传送数据 | |||
res.eventChannel.emit('customerid', { customerid:item.customerId,businessCommunicationDemandId:item.businessCommunicationDemandId,chatHeads:item.chatHeads }) | |||
res.eventChannel.emit('customerid', { customerid: item.customerId, businessCommunicationDemandId: item.businessCommunicationDemandId, chatHeads: item.chatHeads }) | |||
} | |||
}) | |||
}, |
@@ -51,7 +51,7 @@ | |||
<image class="collect-img" src="/images/home/not-collect.png" wx:else /> | |||
收藏 | |||
</view> | |||
<view class="fr list-foot-text-chat" wx:if="{{ pageStatus != 'myRelease' && isOther }}" bindtap="goToChat" data-item="{{ item }}"> | |||
<view class="fr list-foot-text-chat" wx:if="{{ pageStatus != 'myRelease' && isOther && customerId != item.customerId }}" bindtap="goToChat" data-item="{{ item }}"> | |||
<image class="chat-img" src="/images/home/chat-icon.png" /> | |||
聊一聊 | |||
</view> |
@@ -54,7 +54,7 @@ | |||
</view> | |||
<view wx:else> | |||
<view class="list-view" wx:for="{{ listData }}" wx:key="*this"> | |||
<listItem item="{{ item }}" bind:getItem="goDetails" pageStatus="homepage" isOther="{{ isOther }}"/> | |||
<listItem item="{{ item }}" bind:getItem="goDetails" pageStatus="homepage" isOther="{{ isOther }}" /> | |||
</view> | |||
<view class="text-center" wx:if="{{ itemLoading }}"> | |||
<van-loading size="24px">加载中...</van-loading> |
@@ -25,6 +25,8 @@ Page({ | |||
// 是否加载数据,true加载,false不加载 | |||
onRefresh: true, | |||
currentIndex: 0, | |||
// 当前登录器用户登录ID | |||
userCustomerId: null, | |||
}, | |||
/** | |||
@@ -33,6 +35,12 @@ Page({ | |||
onLoad(option) { | |||
}, | |||
onShow() { | |||
const businessCommunicationCustomer = wx.getStorageSync('businessCommunicationCustomer') || null; | |||
if (businessCommunicationCustomer) { | |||
this.setData({ | |||
userCustomerId:businessCommunicationCustomer.customerId | |||
}) | |||
} | |||
const listDetail = wx.getStorageSync('listDetail') || null; | |||
this.setData({ | |||
currentData: listDetail, |
@@ -5,12 +5,7 @@ | |||
</view> | |||
<view wx:else> | |||
<view class="list-view"> | |||
<listItem | |||
item="{{ currentData }}" | |||
pageStatus="detatil" | |||
isCollect="{{ isCollect }}" | |||
isShowCollect="{{ customerId != currentData.customerId }}" | |||
bind:changeCollect="changeCollect" /> | |||
<listItem item="{{ currentData }}" pageStatus="detatil" isCollect="{{ isCollect }}" isShowCollect="{{ customerId != currentData.customerId }}" bind:changeCollect="changeCollect" customerId="{{ userCustomerId }}" /> | |||
</view> | |||
<view class="view-interested">你可能感兴趣的需求</view> | |||
<view class="not-data" wx:if="{{ listData.length < 1 }}"> | |||
@@ -19,7 +14,7 @@ | |||
</view> | |||
<view wx:else> | |||
<view class="list-view" wx:for="{{ listData }}" wx:key="*this"> | |||
<listItem item="{{ item }}" bind:getItem="goDetails" /> | |||
<listItem item="{{ item }}" bind:getItem="goDetails" customerId="{{ userCustomerId }}" /> | |||
</view> | |||
<view class="text-center" wx:if="{{ itemLoading }}"> | |||
<van-loading size="24px">加载中...</van-loading> |
@@ -73,6 +73,7 @@ Page({ | |||
attentionTypeIds: "", | |||
// 用来判断关注显示按钮 | |||
paramIsInterest:0, | |||
customerId:null, | |||
}, | |||
onLoad() { | |||
}, | |||
@@ -82,7 +83,8 @@ Page({ | |||
const businessCommunicationCustomer = wx.getStorageSync('businessCommunicationCustomer') || null; | |||
if (businessCommunicationCustomer) { | |||
this.setData({ | |||
attentionTypeIds: businessCommunicationCustomer.attentionTypeIds.split(',') | |||
attentionTypeIds: businessCommunicationCustomer.attentionTypeIds.split(','), | |||
customerId:businessCommunicationCustomer.customerId | |||
}) | |||
} | |||
}, |
@@ -80,7 +80,7 @@ | |||
</view> | |||
<view class="view-interested" wx:if="{{ paramIsInterest == 1 }}">为您推荐以下内容</view> | |||
<view class="list-view" wx:for="{{ listData }}" wx:key="*this"> | |||
<listItem item="{{ item }}" bind:getItem="goDetails" /> | |||
<listItem item="{{ item }}" bind:getItem="goDetails" customerId="{{ customerId }}"/> | |||
</view> | |||
<view class="text-center" wx:if="{{ itemLoading }}"> | |||
<van-loading size="24px">加载中...</van-loading> |
@@ -21,7 +21,11 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad() { | |||
this.getMsgData(); | |||
}, | |||
onShow(){ | |||
// this.getMsgData(); | |||
this.initData(); | |||
}, | |||
closeTopShow() { | |||
this.setData({ | |||
@@ -40,6 +44,15 @@ Page({ | |||
} | |||
}) | |||
}, | |||
initData(){ | |||
this.setData({ | |||
pageLoading: true, | |||
page:1, | |||
size: 10, | |||
msgData: [], | |||
}) | |||
this.getMsgData(); | |||
}, | |||
getMsgData() { | |||
let { page, size } = this.data; | |||
$request.get('/businessCommunicationDemand/getChatRecordTable.action', { page, size }).then(res => { |
@@ -43,7 +43,7 @@ Page({ | |||
// 历史记录当前页 | |||
pageNo: 1, | |||
// 当前产品ID | |||
businessCommunicationDemandId:null, | |||
businessCommunicationDemandId: null, | |||
}, | |||
/** | |||
@@ -52,18 +52,18 @@ Page({ | |||
onLoad: function (options) { | |||
const eventChannel = this.getOpenerEventChannel() | |||
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | |||
eventChannel.on('customerid', data => { | |||
this.setData({ | |||
sendMemberId: data.customerid, | |||
businessCommunicationDemandId:data.businessCommunicationDemandId, | |||
receivebaseInfo:{ | |||
avatar:data.chatHeads | |||
businessCommunicationDemandId: data.businessCommunicationDemandId, | |||
receivebaseInfo: { | |||
avatar: data.chatHeads | |||
} | |||
}) | |||
// 获取历史记录 | |||
this.getHistory() | |||
this.getHistory(); | |||
}) | |||
let customerId = app.globalData.customerId; | |||
let sendAvatar = app.globalData.businessCommunicationCustomer.chatHeads; | |||
@@ -120,9 +120,9 @@ Page({ | |||
let _data = JSON.parse(res.data); | |||
_data.chatRecord = JSON.parse(_data.chatRecord); | |||
let msgData = {}; | |||
if(_data.chatRecord.sender != _this.data.receiveMemberId){ | |||
if (_data.chatRecord.sender != _this.data.receiveMemberId) { | |||
msgData.type = 1; | |||
}else{ | |||
} else { | |||
msgData.type = 0; | |||
} | |||
msgData.message = _data.chatRecord.content; | |||
@@ -143,17 +143,9 @@ Page({ | |||
// 获取历史记录 | |||
getHistory() { | |||
var { sendMemberId,businessCommunicationDemandId } = this.data; | |||
let url = ""; | |||
if(businessCommunicationDemandId){ | |||
url = '/businessCommunicationDemand/getChatRecordById/' + businessCommunicationDemandId + '/' + sendMemberId + '.action' | |||
}else{ | |||
url = '/businessCommunicationDemand/getChatRecordById/' + sendMemberId + '.action' | |||
} | |||
$request.get(url).then(res => { | |||
console.log(`------------聊一聊获取历史记录-----------------`) | |||
console.log(res); | |||
console.log(`------------聊一聊获取历史记录-----------------`) | |||
var { sendMemberId, businessCommunicationDemandId } = this.data; | |||
$request.get('/businessCommunicationDemand/getChatRecordById/' + sendMemberId + '.action').then(res => { | |||
if (res.status == 0) { | |||
var historyList = [...res.data.chatRecordList, ...this.data.historyList] | |||
if (historyList && historyList.length > 0) { | |||
@@ -170,6 +162,25 @@ Page({ | |||
}) | |||
console.log(this.data.historyList, '历史记录数据') | |||
} | |||
// 如果产品ID存在 | |||
console.log(businessCommunicationDemandId, '产品ID是否存在') | |||
if (businessCommunicationDemandId) { | |||
// this.data.historyList | |||
if(historyList.length > 0){ | |||
for (let index = historyList.length - 1; index >= 0; index--) { | |||
const element = historyList[index]; | |||
if (element.messageType == 1) { | |||
if (element.transactionId == businessCommunicationDemandId) { | |||
break; | |||
} else { | |||
this.sendmsgApi("", 1); | |||
} | |||
} | |||
} | |||
}else{ | |||
this.sendmsgApi("", 1); | |||
} | |||
} | |||
} | |||
}).catch(err => { | |||
console.log(err) | |||
@@ -269,50 +280,55 @@ Page({ | |||
send: function () { | |||
var _this = this; | |||
if (_this.data.input) { | |||
let { sendMemberId ,receiveMemberId ,businessCommunicationDemandId} = _this.data; | |||
let params = { | |||
sender: receiveMemberId, // 发件人Id | |||
addressee: sendMemberId, // 收件人Id | |||
transactionId: businessCommunicationDemandId, // 产品ID | |||
content: _this.data.input | |||
}; | |||
$request.post('/businessCommunicationDemand/addChatRecord.action',params).then(res => { | |||
console.log(`------------聊一聊保存记录-----------------`) | |||
console.log(res); | |||
console.log(`------------聊一聊保存记录-----------------`) | |||
}).catch(err => { | |||
console.log(err) | |||
}) | |||
// wx.sendSocketMessage({ | |||
// data: _this.data.input, | |||
// success: (res) => { | |||
// }, | |||
// fail: (err) => { | |||
// console.log('sendSocketMessage', '失败') | |||
// } | |||
// }) | |||
var list = []; | |||
list = this.data.newsList; | |||
var temp = { 'message': _this.data.input, 'date': utils.formatTime(new Date()), type: 0 }; | |||
list.push(temp); | |||
this.setData({ | |||
newsList: list, | |||
input: null | |||
}) | |||
this.scrollBottom() | |||
// 表情选择隐藏 | |||
this.setData({ | |||
emotionVisible: false, | |||
}) | |||
this.sendmsgApi(_this.data.input, 0); | |||
} | |||
}, | |||
sendmsgApi(content, msgType) { | |||
let { sendMemberId, receiveMemberId, businessCommunicationDemandId } = this.data; | |||
let transactionId = businessCommunicationDemandId; | |||
if (!businessCommunicationDemandId) { | |||
transactionId = this.data.historyList[this.data.historyList.length - 1].transactionId; | |||
} | |||
let params = { | |||
sender: receiveMemberId, // 发件人Id | |||
addressee: sendMemberId, // 收件人Id | |||
transactionId, // 产品ID | |||
content, | |||
messageType: msgType, | |||
}; | |||
$request.post('/businessCommunicationDemand/addChatRecord.action', params).then(res => { | |||
console.log(`------------聊一聊保存记录-----------------`) | |||
console.log(res); | |||
console.log(`------------聊一聊保存记录-----------------`) | |||
}).catch(err => { | |||
console.log(err) | |||
}) | |||
// wx.sendSocketMessage({ | |||
// data: _this.data.input, | |||
// success: (res) => { | |||
// }, | |||
// fail: (err) => { | |||
// console.log('sendSocketMessage', '失败') | |||
// } | |||
// }) | |||
var list = []; | |||
list = this.data.newsList; | |||
var temp = { 'message': this.data.input, 'date': utils.formatTime(new Date()), type: 0 }; | |||
list.push(temp); | |||
this.setData({ | |||
newsList: list, | |||
input: null | |||
}) | |||
// this.bottom() | |||
this.scrollBottom() | |||
// 表情选择隐藏 | |||
this.setData({ | |||
emotionVisible: false, | |||
}) | |||
const client = wx.getSystemInfoSync().windowHeight // 获取当前窗口的高度 | |||
console.log(client, 'shurugaodu') | |||
console.log(client, '当前消息高度') | |||
}, | |||
bindChange: function (res) { | |||
this.setData({ | |||
@@ -336,8 +352,8 @@ Page({ | |||
input = input + connectemoji[e.currentTarget.dataset.index]; | |||
} else { | |||
input = connectemoji[e.currentTarget.dataset.index] | |||
} | |||
} | |||
console.log(input, '输入框额值') | |||
this.setData({ | |||
input |
@@ -21,7 +21,7 @@ | |||
</view> | |||
<view wx:else> | |||
<view class="list-view " wx:for="{{ listData }}" wx:key="*this"> | |||
<listItem item="{{ item }}" pageStatus="myCollect" bind:getItem="goDetails" listClass="{{ item.isDeleted > 0 || item.state < 0 ? 'disabled-model-view' : '' }}" /> | |||
<listItem item="{{ item }}" pageStatus="myCollect" bind:getItem="goDetails" listClass="{{ item.isDeleted > 0 || item.state < 0 ? 'disabled-model-view' : '' }}" customerId="{{ customerId }}"/> | |||
<image class="disabled-model-img" src="/images/home/isDelete-icon.png" wx:if="{{ item.isDeleted > 0 }}"/> | |||
<image class="disabled-model-img" src="/images/home/isState-0-icon.png" wx:if="{{ item.isDeleted == 0 && item.state < 0}}"/> | |||
<view class="del-collect-view" bindtap="delCollect" data-id="{{ item.businessCommunicationDemandId }}"> |
@@ -64,9 +64,9 @@ Page({ | |||
if (code == 'my-release') { | |||
url = "/pages/myModule/components/myRelease/myRelease"; | |||
} | |||
// 前往发布的需求 | |||
if (code == 'my-release') { | |||
url = "/pages/myModule/components/myRelease/myRelease"; | |||
// 前往收藏的需求 | |||
if (code == 'my-collect') { | |||
url = "/pages/myModule/components/myCollect/myCollect"; | |||
} | |||
// 前往关注的类型 | |||
if (code == 'my-attention') { |