Просмотр исходного кода

新加获取微信头像

release/210823_需求对对碰
王饶冀 4 лет назад
Родитель
Сommit
af3d1ac2b9
2 измененных файлов: 23 добавлений и 18 удалений
  1. 1
    1
      components/listItem/listItem.js
  2. 22
    17
      pages/msgModule/wechat2/wechat2.js

+ 1
- 1
components/listItem/listItem.js Просмотреть файл

url:"/pages/msgModule/wechat2/wechat2", url:"/pages/msgModule/wechat2/wechat2",
success: function (res) { success: function (res) {
// 通过eventChannel向被打开页面传送数据 // 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('customerid', { customerid:item.customerId,businessCommunicationDemandId:item.businessCommunicationDemandId })
res.eventChannel.emit('customerid', { customerid:item.customerId,businessCommunicationDemandId:item.businessCommunicationDemandId,chatHeads:item.chatHeads })
} }
}) })
}, },

+ 22
- 17
pages/msgModule/wechat2/wechat2.js Просмотреть файл

}, },
sendAvatar: 'http://wx.qlogo.cn/mmopen/ajNVdqHZLLAIliaZvz5B1ibTzTehYzXdfBZ9hXTL7yuhuCUQGyzbuHeYS2yr8rO5PkbUBbHuWb5h9SibpRQkj3GTw/0', sendAvatar: 'http://wx.qlogo.cn/mmopen/ajNVdqHZLLAIliaZvz5B1ibTzTehYzXdfBZ9hXTL7yuhuCUQGyzbuHeYS2yr8rO5PkbUBbHuWb5h9SibpRQkj3GTw/0',
newsList: [ newsList: [
// {
// date: "2020.10.19",
// message: '哈喽,好久不见',
// type: 0
// },
// {
// date: "2020.10.20",
// message: '是呀,好久不见',
// type: 1
// },
{
date: "2020.10.19",
message: '哈喽,好久不见',
type: 0
},
{
date: "2020.10.20",
message: '是呀,好久不见',
type: 1
},
],//消息列表 ],//消息列表
historyList: [], historyList: [],
input: null, input: null,
onLoad: function (options) { onLoad: function (options) {
const eventChannel = this.getOpenerEventChannel() const eventChannel = this.getOpenerEventChannel()
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
eventChannel.on('customerid', data => { eventChannel.on('customerid', data => {
this.setData({ this.setData({
sendMemberId: data.customerid, sendMemberId: data.customerid,
businessCommunicationDemandId:data.businessCommunicationDemandId, businessCommunicationDemandId:data.businessCommunicationDemandId,
receivebaseInfo:{
avatar:data.chatHeads
}
}) })
// 获取历史记录 // 获取历史记录
this.getHistory() this.getHistory()
}) })
var sendAvatar = app.globalData.sendAvatar
let customerId = app.globalData.customerId; let customerId = app.globalData.customerId;
let sendAvatar = app.globalData.businessCommunicationCustomer.chatHeads;
console.log(customerId, 'customerId'); console.log(customerId, 'customerId');
var _this = this; var _this = this;
_this.setData({ _this.setData({
receiveMemberId: customerId, receiveMemberId: customerId,
sendAvatar,
sendAvatar
}) })
console.log(app.globalData.sendAvatar, 'hahha')
console.log(this.data.sendAvatar, 'hahha')
// 获取内存中的数据 // 获取内存中的数据
this.getStorageBaseInfo() this.getStorageBaseInfo()
// 设置滚动区域的高度 // 设置滚动区域的高度
// console.log() // console.log()
//建立连接 //建立连接
wx.connectSocket({ wx.connectSocket({
url: `ws://192.168.18.138/webSocket/{"userno":${receiveMemberId},"messageModule":"008"}`,//本地
url: `ws://192.168.18.138/webSocket/{"userno":${receiveMemberId},"messageModule":"010"}`,//本地
success: function () { success: function () {
console.log('websocket连接成功~') console.log('websocket连接成功~')
}, },


// 获取历史记录 // 获取历史记录
getHistory() { getHistory() {
var { sendMemberId } = this.data;
$request.get('/businessCommunicationDemand/getChatRecordById/' + sendMemberId + '.action').then(res => {
var { sendMemberId,businessCommunicationDemandId } = this.data;
$request.get('/businessCommunicationDemand/getChatRecordById/' + businessCommunicationDemandId + '/' + sendMemberId + '.action').then(res => {
console.log(`------------聊一聊获取历史记录-----------------`) console.log(`------------聊一聊获取历史记录-----------------`)
console.log(res); console.log(res);
console.log(`------------聊一聊获取历史记录-----------------`) console.log(`------------聊一聊获取历史记录-----------------`)
// 设置滚动区域的高度 // 设置滚动区域的高度
setScrollHeight: function () { setScrollHeight: function () {
const client = wx.getSystemInfoSync().windowHeight // 获取当前窗口的高度 const client = wx.getSystemInfoSync().windowHeight // 获取当前窗口的高度
var scrollHeight = (client - 236) + 'px'
var scrollHeight = (client - 36) + 'px'
this.setData({ this.setData({
scrollHeight scrollHeight
}) })

Загрузка…
Отмена
Сохранить