|
|
@@ -1,6 +1,6 @@ |
|
|
|
var utils = require("../../../utils/util.js") |
|
|
|
const app = getApp() |
|
|
|
const api = require('../../../utils/request.js'); //相对路径 |
|
|
|
const $request = require('../../../utils/request.js'); |
|
|
|
Page({ |
|
|
|
|
|
|
|
/** |
|
|
@@ -8,7 +8,7 @@ Page({ |
|
|
|
*/ |
|
|
|
data: { |
|
|
|
receivebaseInfo: { |
|
|
|
avatar:"http://wx.qlogo.cn/mmopen/ajNVdqHZLLAIliaZvz5B1ibTzTehYzXdfBZ9hXTL7yuhuCUQGyzbuHeYS2yr8rO5PkbUBbHuWb5h9SibpRQkj3GTw/0", |
|
|
|
avatar: "http://wx.qlogo.cn/mmopen/ajNVdqHZLLAIliaZvz5B1ibTzTehYzXdfBZ9hXTL7yuhuCUQGyzbuHeYS2yr8rO5PkbUBbHuWb5h9SibpRQkj3GTw/0", |
|
|
|
}, |
|
|
|
sendAvatar: 'http://wx.qlogo.cn/mmopen/ajNVdqHZLLAIliaZvz5B1ibTzTehYzXdfBZ9hXTL7yuhuCUQGyzbuHeYS2yr8rO5PkbUBbHuWb5h9SibpRQkj3GTw/0', |
|
|
|
newsList: [ |
|
|
@@ -47,7 +47,9 @@ Page({ |
|
|
|
inputShowed: false, |
|
|
|
scrollTop: 0, |
|
|
|
inputBottom: '0px', |
|
|
|
// 当前登录用户的ID |
|
|
|
receiveMemberId: null, |
|
|
|
// 对方的聊天ID |
|
|
|
sendMemberId: null, |
|
|
|
scrollid: 'scrollid', |
|
|
|
scrollHeight: '300px', |
|
|
@@ -55,32 +57,34 @@ Page({ |
|
|
|
triggered: true, |
|
|
|
// 历史记录当前页 |
|
|
|
pageNo: 1, |
|
|
|
customerId:null, |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function (options) { |
|
|
|
var receiveMemberId = options.receiveMemberId |
|
|
|
var sendMemberId = app.globalData.open_id |
|
|
|
const eventChannel = this.getOpenerEventChannel() |
|
|
|
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 |
|
|
|
eventChannel.on('customerid', data => { |
|
|
|
this.setData({ |
|
|
|
sendMemberId: data.customerid, |
|
|
|
}) |
|
|
|
// 获取历史记录 |
|
|
|
this.getHistory() |
|
|
|
}) |
|
|
|
var sendAvatar = app.globalData.sendAvatar |
|
|
|
let customerId = app.globalData.customerId; |
|
|
|
console.log(customerId,'customerId'); |
|
|
|
console.log(customerId, 'customerId'); |
|
|
|
var _this = this; |
|
|
|
_this.setData({ |
|
|
|
receiveMemberId, |
|
|
|
sendMemberId, |
|
|
|
receiveMemberId: customerId, |
|
|
|
sendAvatar, |
|
|
|
customerId |
|
|
|
}) |
|
|
|
console.log(app.globalData.sendAvatar, 'hahha') |
|
|
|
// 获取内存中的数据 |
|
|
|
this.getStorageBaseInfo() |
|
|
|
// 设置滚动区域的高度 |
|
|
|
this.setScrollHeight() |
|
|
|
// 获取历史记录 |
|
|
|
this.getHistory() |
|
|
|
// 初始化websocket |
|
|
|
this.initWebSocket() |
|
|
|
// 页面进入滚动到底部 |
|
|
@@ -141,18 +145,14 @@ Page({ |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取历史记录 |
|
|
|
getHistory: function () { |
|
|
|
var { receiveMemberId, sendMemberId, pageNo } = this.data |
|
|
|
var params = { |
|
|
|
receiveMemberId, |
|
|
|
sendMemberId, |
|
|
|
pageNo, |
|
|
|
pageSize: 5, |
|
|
|
} |
|
|
|
api.get("/zxxt/chat/msg/list", params, (res) => { |
|
|
|
if (res.code == 'success') { |
|
|
|
// var historyList = res.data.data |
|
|
|
var historyList = [...res.data.data, ...this.data.historyList] |
|
|
|
getHistory() { |
|
|
|
var { sendMemberId } = this.data; |
|
|
|
$request.get('/businessCommunicationDemand/getChatRecordById/' + sendMemberId + '.action').then(res => { |
|
|
|
console.log(`------------聊一聊获取历史记录-----------------`) |
|
|
|
console.log(res); |
|
|
|
console.log(`------------聊一聊获取历史记录-----------------`) |
|
|
|
if (res.status == 0) { |
|
|
|
var historyList = [...res.data.chatRecordList, ...this.data.historyList] |
|
|
|
if (historyList && historyList.length > 0) { |
|
|
|
historyList.forEach(item => { |
|
|
|
if (item.send_member_id == sendMemberId) { |
|
|
@@ -165,34 +165,61 @@ Page({ |
|
|
|
historyList |
|
|
|
}) |
|
|
|
console.log(this.data.historyList, '历史记录数据') |
|
|
|
} else { |
|
|
|
// 判断是否是第一次进入查看历史记录:是(不显示弹框,不是则显示弹框) |
|
|
|
if (this.data.pageNo > 1) { |
|
|
|
wx.showToast({ |
|
|
|
title: "没有更多历史记录了", |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (res.message) { |
|
|
|
wx.showToast({ |
|
|
|
title: res.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}, (res) => { |
|
|
|
if (res.message) { |
|
|
|
wx.showToast({ |
|
|
|
title: res.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
console.log(err) |
|
|
|
}) |
|
|
|
// var params = { |
|
|
|
// receiveMemberId, |
|
|
|
// sendMemberId, |
|
|
|
// pageNo, |
|
|
|
// pageSize: 5, |
|
|
|
// } |
|
|
|
// api.get("/zxxt/chat/msg/list", params, (res) => { |
|
|
|
// if (res.code == 'success') { |
|
|
|
// // var historyList = res.data.data |
|
|
|
// var historyList = [...res.data.data, ...this.data.historyList] |
|
|
|
// if (historyList && historyList.length > 0) { |
|
|
|
// historyList.forEach(item => { |
|
|
|
// if (item.send_member_id == sendMemberId) { |
|
|
|
// item.type = 0 |
|
|
|
// } else { |
|
|
|
// item.type = 1 |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// this.setData({ |
|
|
|
// historyList |
|
|
|
// }) |
|
|
|
// console.log(this.data.historyList, '历史记录数据') |
|
|
|
// } else { |
|
|
|
// // 判断是否是第一次进入查看历史记录:是(不显示弹框,不是则显示弹框) |
|
|
|
// if (this.data.pageNo > 1) { |
|
|
|
// wx.showToast({ |
|
|
|
// title: "没有更多历史记录了", |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// if (res.message) { |
|
|
|
// wx.showToast({ |
|
|
|
// title: res.message, |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }, (res) => { |
|
|
|
// if (res.message) { |
|
|
|
// wx.showToast({ |
|
|
|
// title: res.message, |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
}, |
|
|
|
|
|
|
|
// 滚动到底部 |