Selaa lähdekoodia

获取历史记录接口

release/210823_需求对对碰
王饶冀 3 vuotta sitten
vanhempi
commit
bdf6fa24ad

+ 1
- 1
app.js Näytä tiedosto

@@ -100,7 +100,7 @@ App({
})
},
// mangerUrl: 'http://test2.hhrchina.com',
mangerUrl: "http://192.168.18.156",
mangerUrl: "http://192.168.18.138",
// mangerUrl: "https://www.hhrchina.com",
// mangerUrlPath: "https://www.hhrchina.com",
})

+ 6
- 5
components/listItem/listItem.js Näytä tiedosto

@@ -69,18 +69,19 @@ Component({
this.triggerEvent('changeCollect');
},
// 聊一聊
goToChat() {
goToChat(e) {
if (!app.globalData.customerId) {
app.goLogin();
return
}
console.log(`点击了聊一聊`)
let customerid = e.currentTarget.dataset.customerid;
wx.navigateTo({
url:"/pages/msgModule/wechat2/wechat2",
// success: function (res) {
// // 通过eventChannel向被打开页面传送数据
// res.eventChannel.emit('customerid', { customerid:app.globalData.customerId })
// }
success: function (res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('customerid', { customerid })
}
})
},
}

+ 1
- 1
components/listItem/listItem.wxml Näytä tiedosto

@@ -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">
<view class="fr list-foot-text-chat" wx:if="{{ pageStatus != 'myRelease' && isOther }}" bindtap="goToChat" data-customerid="{{ item.customerId }}">
<image class="chat-img" src="/images/home/chat-icon.png" />
聊一聊
</view>

+ 0
- 1
pages/index/index.js Näytä tiedosto

@@ -247,7 +247,6 @@ Page({
if(this.data.attentionTypeIds.length > 0 && res.data.total == 0){
this.getListData(1);
}
console.log(paramIsInterest,'isInterest')
}).catch(error => {
console.log(error, 'error appletLogin')
})

+ 75
- 48
pages/msgModule/wechat2/wechat2.js Näytä tiedosto

@@ -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
// })
// }
// })
},

// 滚动到底部

Loading…
Peruuta
Tallenna