@@ -48,13 +48,6 @@ Component({ | |||
*/ | |||
methods: { | |||
tabChange(e) { | |||
wx.closeSocket(); | |||
if (e.detail.item.text == "发布需求" || e.detail.item.text == "消息") { | |||
if (!app.globalData.customerId) { | |||
app.goLogin(); | |||
return | |||
} | |||
} | |||
const url = e.detail.item.pagePath; | |||
wx.redirectTo({ url }); | |||
} |
@@ -54,6 +54,25 @@ Page({ | |||
// 底部按钮点击 | |||
footBtnClick(){ | |||
console.log(`点击了底部按钮`) | |||
console.log(this.data.isOther) | |||
// 前往聊一聊 | |||
if(this.data.isOther){ | |||
console.log(this.data.customer) | |||
let customer = this.data.customer; | |||
wx.navigateTo({ | |||
url: "/pages/msgModule/wechat2/wechat2", | |||
success: function (res) { | |||
// 通过eventChannel向被打开页面传送数据 | |||
res.eventChannel.emit('customerid', { customerid: customer.customerId, chatHeads: customer.chatHeads }) | |||
} | |||
}) | |||
} | |||
// 前往发布需求 | |||
else{ | |||
wx.navigateTo({ | |||
url: '/pages/releaseModule/index', | |||
}) | |||
} | |||
}, | |||
getListData() { | |||
let { page, size, customerId } = this.data; |
@@ -6,9 +6,9 @@ | |||
padding: 26rpx 42rpx; | |||
padding-bottom: 0; | |||
position: relative; | |||
position: sticky; | |||
/* position: sticky; | |||
top: 0; | |||
z-index: 999; | |||
z-index: 999; */ | |||
} | |||
.header-view .user-view{ | |||
height: 104rpx; |
@@ -21,8 +21,10 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad() { | |||
if (!app.globalData.customerId) { | |||
app.goLogin(); | |||
return | |||
} | |||
}, | |||
onShow() { | |||
const businessCommunicationCustomer = wx.getStorageSync('businessCommunicationCustomer') || null; | |||
@@ -60,14 +62,14 @@ Page({ | |||
// 接收服务器的消息事件 | |||
wx.onSocketMessage(function (res) { | |||
// 接收到的消息{date,message,type} type类型为 1 是对方的消息 为 0 是自己的消息 | |||
console.log(res,'消息页----收到新消息') | |||
console.log(res, '消息页----收到新消息') | |||
// _this.initData(); | |||
let _data = JSON.parse(res.data); | |||
_data.chatRecord = JSON.parse(_data.chatRecord); | |||
let msgData = _this.data.msgData; | |||
msgData.forEach(el=>{ | |||
msgData.forEach(el => { | |||
// 如果当前消息的 customerId = 发送人的ID | |||
if(el.businessCommunicationCustomerVO.customerId == _data.chatRecord.sender){ | |||
if (el.businessCommunicationCustomerVO.customerId == _data.chatRecord.sender) { | |||
el.lastContent = _data.chatRecord.content; | |||
el.lastContentDate = $util.formatTime(new Date(_data.chatRecord.sendTime)); | |||
el.lastContentDate = el.lastContentDate.replaceAll('/', '-'); | |||
@@ -170,18 +172,18 @@ Page({ | |||
} | |||
}, | |||
// 去关注 | |||
followApplets(){ | |||
followApplets() { | |||
wx.navigateTo({ | |||
url: "/pages/outLink/outLink?followApplets=true", //跳转页面的路径,可带参数 ?隔开,不同参数用 & 分隔;相对路径,不需要.wxml后缀 | |||
success: function () {}, //成功后的回调; | |||
fail: function () {}, //失败后的回调; | |||
complete: function () {} //结束后的回调(成功,失败都会执行) | |||
success: function () { }, //成功后的回调; | |||
fail: function () { }, //失败后的回调; | |||
complete: function () { } //结束后的回调(成功,失败都会执行) | |||
}) | |||
}, | |||
/** | |||
* 生命周期函数--监听页面隐藏 | |||
*/ | |||
onHide: function () { | |||
onHide: function () { | |||
wx.closeSocket(); | |||
}, | |||
@@ -28,7 +28,7 @@ Page({ | |||
input: null, | |||
openid: null, | |||
// 表情 | |||
connectemoji:[], | |||
connectemoji: [], | |||
emoji_list: ['emoji1i1', 'emoji2i2', 'emoji3i3', 'emoji4i4', 'emoji5i5'], | |||
emotionVisible: false, | |||
inputShowed: false, | |||
@@ -49,7 +49,7 @@ Page({ | |||
// 当前产品详情 | |||
productInfo: null, | |||
// 发送框是否获取焦点 | |||
inputShowed:false, | |||
inputShowed: false, | |||
}, | |||
/** | |||
@@ -82,7 +82,7 @@ Page({ | |||
this.setData({ | |||
receiveMemberId: customerId, | |||
sendAvatar, | |||
connectemoji:$faces.getfaces(), | |||
connectemoji: $faces.getfaces(), | |||
}) | |||
// 获取内存中的数据 | |||
this.getStorageBaseInfo() | |||
@@ -177,18 +177,27 @@ Page({ | |||
console.log(businessCommunicationDemandId, '产品ID是否存在') | |||
if (businessCommunicationDemandId) { | |||
if (historyList.length > 0) { | |||
let tempArr = []; | |||
for (let index = historyList.length - 1; index >= 0; index--) { | |||
const element = historyList[index]; | |||
if (element.messageType == 1) { | |||
tempArr.push(element); | |||
if (element.transactionId == businessCommunicationDemandId) { | |||
break; | |||
} else { | |||
this.sendmsgApi("", 1); | |||
console.log(`走这里1`) | |||
} | |||
} | |||
} | |||
// 说明没有一条是messageType == 1 的 | |||
if(tempArr.length < 1){ | |||
this.sendmsgApi("", 1); | |||
console.log(`走这里3`) | |||
} | |||
} else { | |||
this.sendmsgApi("", 1); | |||
console.log(`走这里2`) | |||
} | |||
} | |||
} | |||
@@ -267,14 +276,14 @@ Page({ | |||
* 生命周期函数--监听页面隐藏 | |||
*/ | |||
onHide: function () { | |||
wx.closeSocket(); | |||
// wx.closeSocket(); | |||
}, | |||
/** | |||
* 生命周期函数--监听页面卸载 | |||
*/ | |||
onUnload: function () { | |||
wx.closeSocket(); | |||
// wx.closeSocket(); | |||
}, | |||
/** | |||
@@ -307,7 +316,12 @@ Page({ | |||
let { sendMemberId, receiveMemberId, businessCommunicationDemandId } = this.data; | |||
let transactionId = businessCommunicationDemandId; | |||
if (!businessCommunicationDemandId) { | |||
transactionId = this.data.historyList[this.data.historyList.length - 1].transactionId; | |||
if(this.data.historyList.length > 0){ | |||
transactionId = this.data.historyList[this.data.historyList.length - 1].transactionId; | |||
} | |||
} | |||
if(!transactionId){ | |||
transactionId = ""; | |||
} | |||
let params = { | |||
sender: receiveMemberId, // 发件人Id | |||
@@ -379,13 +393,32 @@ Page({ | |||
console.log(input, '输入框额值') | |||
this.setData({ | |||
input, | |||
emotionVisible:false, | |||
inputShowed:true, | |||
emotionVisible: false, | |||
inputShowed: true, | |||
}) | |||
}, | |||
closeEmotionVisible(){ | |||
closeEmotionVisible() { | |||
this.setData({ | |||
emotionVisible:false, | |||
emotionVisible: false, | |||
}) | |||
}, | |||
// 发送图片 | |||
upImg() { | |||
wx.chooseImage({ | |||
count: 1, | |||
success: (res) => { | |||
console.log(res); | |||
console.log(res.tempFilePaths[0], '拿到的URL'); | |||
wx.uploadFile({ | |||
filePath: res.tempFilePaths[0], | |||
name: "file", | |||
url: "/file/uploading.action?fileType=TinymceImg", | |||
success: (res2) => { | |||
console.log(`上传之后的res2`,res2) | |||
} | |||
}) | |||
// /file/uploading.action?fileType=TinymceImg | |||
} | |||
}) | |||
}, | |||
// 公共聚焦方法,方法比较笨,但是过度效果平滑流畅 |
@@ -26,6 +26,10 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad() { | |||
if (!app.globalData.customerId) { | |||
app.goLogin(); | |||
return | |||
} | |||
const eventChannel = this.getOpenerEventChannel() | |||
if (eventChannel.on) { | |||
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | |||
@@ -112,7 +116,12 @@ Page({ | |||
success(res1) { | |||
if (res1.confirm) { | |||
that.clearData(); | |||
console.log('用户点击确定') | |||
wx.navigateTo({ | |||
url: "/pages/outLink/outLink?followApplets=true", //跳转页面的路径,可带参数 ?隔开,不同参数用 & 分隔;相对路径,不需要.wxml后缀 | |||
success: function () { }, //成功后的回调; | |||
fail: function () { }, //失败后的回调; | |||
complete: function () { } //结束后的回调(成功,失败都会执行) | |||
}) | |||
} else if (res1.cancel) { | |||
let listDetail = res.data; | |||
that.clearData(); |