|
|
@@ -23,11 +23,12 @@ Page({
|
|
|
unreadCount: 0, //对方发送未读信息
|
|
|
joinHands: false, //是否显示合作按钮
|
|
|
ownerid: 0, //供需id
|
|
|
- fimdialogtype: '话题', //对话框类型
|
|
|
+ fimdialogtype: '', //对话框类型
|
|
|
fimuserid: 0, //创建者id
|
|
|
timsubjectid: 0, //话题id
|
|
|
+ timdialogid: 0, //对话框id
|
|
|
+ gambitList: [], //话题列表
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
@@ -55,6 +56,7 @@ Page({
|
|
|
let title = res.data[0].fimdialogname.split('-'),
|
|
|
headerTitle = (title[0] == res.data[0].fname) ? title[1] : title[0],
|
|
|
joinHands = false;
|
|
|
+ //供需类型对话框,判断对话框ID是否为当前账号,当前账号更改供需状态,非当前账号显示合作按钮
|
|
|
if (res.data[0].fimdialogtype == '供需') {
|
|
|
if (res.data[0].fimuserid == this.data.userid) {
|
|
|
_Http.basic({
|
|
|
@@ -73,17 +75,43 @@ Page({
|
|
|
joinHands = true
|
|
|
}
|
|
|
}
|
|
|
+ //返回数据
|
|
|
this.setData({
|
|
|
headerTitle,
|
|
|
ownerid: res.data[0].ownerid,
|
|
|
initiator: res.data[0].fimuserid,
|
|
|
joinHands,
|
|
|
- fimdialogtype: res.data[0].fimdialogtype,
|
|
|
- fimuserid: res.data[0].fimuserid
|
|
|
+ fimuserid: res.data[0].fimuserid,
|
|
|
+ fimdialogtype: res.data[0].fimdialogtype
|
|
|
})
|
|
|
+ //判断是否为话题类型对话框
|
|
|
+ if (res.data[0].fimdialogtype == '话题') {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "system.im.imdialog.imdialog",
|
|
|
+ "method": "queryDialogUncloseSubject",
|
|
|
+ "content": {
|
|
|
+ "timdialogid": res.data[0].timdialogid
|
|
|
+ }
|
|
|
+ }, false).then(s => {
|
|
|
+ if (s.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ if (s.data != '成功') {
|
|
|
+ this.setData({
|
|
|
+ timsubjectid: s.data[0].timsubjectid
|
|
|
+ })
|
|
|
+ this.endGambit(true) //存在未关闭话题,调用关闭话题,并在关闭后重新获取历史话题
|
|
|
+ } else {
|
|
|
+ this.query_imdialogMessage(); //不存在未关闭话题,直接获取历史话题
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.query_imdialogMessage(); //非话题类型对话框,直接获取历史记录
|
|
|
+ }
|
|
|
})
|
|
|
- //群历史信息
|
|
|
- this.query_imdialogMessage();
|
|
|
+ //判断是否存在安全距离
|
|
|
let iosX = (getApp().globalData.safeAreaBottom == 0) ? false : true;
|
|
|
this.setData({
|
|
|
iosX
|
|
|
@@ -91,12 +119,11 @@ Page({
|
|
|
//获取表情包
|
|
|
this.getMeme()
|
|
|
},
|
|
|
- /* 创建话题 */
|
|
|
+ /* 创建话题,回复话题 */
|
|
|
createGambit(e) {
|
|
|
const {
|
|
|
type
|
|
|
} = e.currentTarget.dataset;
|
|
|
- console.log(type)
|
|
|
if (type == '发起会话') {
|
|
|
_Http.basic({
|
|
|
"accesstoken": wx.getStorageSync('userData').token,
|
|
|
@@ -113,8 +140,24 @@ Page({
|
|
|
title: res.data,
|
|
|
icon: "none"
|
|
|
})
|
|
|
+ let gambitList = this.data.gambitList;
|
|
|
+ gambitList.push(res.data[0]);
|
|
|
this.setData({
|
|
|
- timsubjectid: res.data[0].timsubjectid
|
|
|
+ timsubjectid: res.data[0].timsubjectid,
|
|
|
+ gambitList
|
|
|
+ })
|
|
|
+ app.globalData.SocketTask.send({
|
|
|
+ data: JSON.stringify({
|
|
|
+ "classname": "message.message",
|
|
|
+ "method": "sendDataMessage",
|
|
|
+ "content": {
|
|
|
+ "timdialogid": this.data.timdialogid,
|
|
|
+ "ownertable": "timsubject",
|
|
|
+ "ownerid": this.data.timsubjectid,
|
|
|
+ "ftype": "话题",
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ success(res) {}
|
|
|
})
|
|
|
})
|
|
|
} else {
|
|
|
@@ -144,36 +187,121 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- /* 确认合作 */
|
|
|
- confirmTheCooperation() {
|
|
|
+ /* 结束话题 */
|
|
|
+ endGambit(isGetList) {
|
|
|
_Http.basic({
|
|
|
"accesstoken": wx.getStorageSync('userData').token,
|
|
|
- "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
- "method": "updatesupplyanddemandstatus",
|
|
|
+ "classname": "system.im.imdialog.imdialog",
|
|
|
+ "method": "closeSubject",
|
|
|
"content": {
|
|
|
- "tsupplyanddemandid": this.data.ownerid,
|
|
|
- "fstatus": "已解决",
|
|
|
- "tenterprise_userid": this.data.initiator,
|
|
|
+ "timsubjectid": this.data.timsubjectid,
|
|
|
"timdialogid": this.data.timdialogid
|
|
|
}
|
|
|
}).then(res => {
|
|
|
- console.log("确认合作", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ timsubjectid: 0
|
|
|
+ })
|
|
|
+ if (isGetList) this.query_imdialogMessage();
|
|
|
})
|
|
|
},
|
|
|
- /* 拒绝合作 */
|
|
|
- refuseToCooperate() {
|
|
|
- _Http.basic({
|
|
|
- "accesstoken": wx.getStorageSync('userData').token,
|
|
|
- "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
- "method": "updatesupplyanddemandstatus",
|
|
|
- "content": {
|
|
|
- "tsupplyanddemandid": this.data.ownerid,
|
|
|
- "fstatus": "待对接",
|
|
|
- "timdialogid": this.data.timdialogid
|
|
|
+ /* 发送信息 */
|
|
|
+ sendMsg(type, data) {
|
|
|
+ const content = this.data.sendText.trim(),
|
|
|
+ that = this;
|
|
|
+ if (this.data.fimdialogtype == '话题') {
|
|
|
+ if (type === 'file') {
|
|
|
+ console.log("附件类型", data)
|
|
|
+ let list = this.data.gambitList[this.data.gambitList.length - 1].imsubjectcontent;
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "changeFilesData",
|
|
|
+ "content": {
|
|
|
+ "files": [{
|
|
|
+ "tattachmentid": data[0].tattachmentid,
|
|
|
+ "fdocument": data[0].fdocument,
|
|
|
+ "ownertable": "timsubjectcontent",
|
|
|
+ "ownerid": list[list.length - 1].timsubjectcontenid,
|
|
|
+ "ftype": data[0].ftype
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ }).then(async s => {
|
|
|
+ console.log("附件位置修改", s)
|
|
|
+
|
|
|
+ let id = [{
|
|
|
+ message: {
|
|
|
+ data: {
|
|
|
+ ownerid: this.data.timsubjectid
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ item = await this.querySubject(id)
|
|
|
+ list = this.data.gambitList;
|
|
|
+ list[list.length - 1] = {};
|
|
|
+ this.setData({
|
|
|
+ gambitList: list
|
|
|
+ })
|
|
|
+ list[list.length - 1] = item[0];
|
|
|
+ console.log(item[0])
|
|
|
+ this.setData({
|
|
|
+ gambitList: list
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "system.im.imdialog.imdialog",
|
|
|
+ "method": "createSubject",
|
|
|
+ "content": {
|
|
|
+ "timdialogid": this.data.timdialogid,
|
|
|
+ "timsubjectid": this.data.timsubjectid,
|
|
|
+ "fcontent": content
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ let list = this.data.gambitList;
|
|
|
+ list[list.length - 1] = res.data[0];
|
|
|
+ console.log(res.data[0])
|
|
|
+ this.setData({
|
|
|
+ gambitList: list
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
- }).then(res => {
|
|
|
- console.log("拒绝合作", res)
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ if (type === 'file') {
|
|
|
+ app.globalData.SocketTask.send({
|
|
|
+ data: JSON.stringify({
|
|
|
+ "classname": "message.message",
|
|
|
+ "method": "sendFileMessage",
|
|
|
+ "content": {
|
|
|
+ "timdialogid": this.data.timdialogid,
|
|
|
+ "tattachmentid": data[0].tattachmentid
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ success(res) {}
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (content == '') return;
|
|
|
+ app.globalData.SocketTask.send({
|
|
|
+ data: JSON.stringify({
|
|
|
+ "classname": "message.message",
|
|
|
+ "method": "sendTextMessage",
|
|
|
+ "content": {
|
|
|
+ "timdialogid": that.data.timdialogid,
|
|
|
+ "fmessage": content
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ success(res) {
|
|
|
+ that.setData({
|
|
|
+ sendText: ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
//历史信息查询
|
|
|
query_imdialogMessage() {
|
|
|
@@ -186,37 +314,85 @@ Page({
|
|
|
"pageSize": 20,
|
|
|
"timdialogid": this.data.timdialogid
|
|
|
}
|
|
|
- }, false).then(res => {
|
|
|
+ }, false).then(async res => {
|
|
|
+ console.log("聊天记录", res)
|
|
|
if (res.msg != '成功') return wx.showToast({
|
|
|
title: res.data,
|
|
|
icon: "none"
|
|
|
- })
|
|
|
+ });
|
|
|
+ let list = res.data;
|
|
|
+ list = list.reverse();
|
|
|
if (res.pageNumber != 1) {
|
|
|
- let list = res.data;
|
|
|
- list = list.reverse();
|
|
|
- list = list.concat(this.data.socketMsgQueue);
|
|
|
- this.setData({
|
|
|
- socketMsgQueue: list,
|
|
|
- toView: `item${res.data.length - 1}`,
|
|
|
- triggered: false
|
|
|
- })
|
|
|
+ if (this.data.fimdialogtype != '话题') {
|
|
|
+ list = list.concat(this.data.socketMsgQueue);
|
|
|
+ this.setData({
|
|
|
+ socketMsgQueue: list,
|
|
|
+ toView: `item${res.data.length - 1}`,
|
|
|
+ triggered: false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let gambitList = await this.querySubject(list);
|
|
|
+ list = gambitList.concat(this.data.gambitList);
|
|
|
+ this.setData({
|
|
|
+ gambitList: list,
|
|
|
+ toView: `item${res.data.length - 1}`,
|
|
|
+ triggered: false
|
|
|
+ })
|
|
|
+ }
|
|
|
} else {
|
|
|
- let list = res.data;
|
|
|
- list = list.reverse();
|
|
|
- this.setData({
|
|
|
- socketMsgQueue: list,
|
|
|
- toView: `item${res.data.length - 1}`,
|
|
|
- pageTotal: res.pageTotal
|
|
|
- })
|
|
|
+ if (this.data.fimdialogtype != '话题') {
|
|
|
+ this.setData({
|
|
|
+ socketMsgQueue: list,
|
|
|
+ toView: `item${res.data.length - 1}`,
|
|
|
+ pageTotal: res.pageTotal
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let gambitList = await this.querySubject(list);
|
|
|
+ this.setData({
|
|
|
+ gambitList,
|
|
|
+ toView: `item${res.data.length - 1}`,
|
|
|
+ pageTotal: res.pageTotal
|
|
|
+ })
|
|
|
+ }
|
|
|
setTimeout(() => {
|
|
|
this.setData({
|
|
|
toView: 'bottom'
|
|
|
})
|
|
|
}, 500)
|
|
|
}
|
|
|
-
|
|
|
})
|
|
|
},
|
|
|
+ /* 根据话题ID查询详情 */
|
|
|
+ async querySubject(array) {
|
|
|
+ let list = [];
|
|
|
+ for (let index = 0; index < array.length; index++) {
|
|
|
+ await _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "system.im.imdialog.imdialog",
|
|
|
+ "method": "querySubject",
|
|
|
+ "content": {
|
|
|
+ "timsubjectid": array[index].message.data.ownerid
|
|
|
+ }
|
|
|
+ }, false).then(res => {
|
|
|
+ if (res.data[0].imsubjectcontent.length != 0) {
|
|
|
+ res.data[0].sendfrom = array[index].message.sendfrom;
|
|
|
+ res.data[0].timdialogid = array[index].message.timdialogid;
|
|
|
+ if (res.data[0].closedate != null) {
|
|
|
+ let time = res.data[0].closedate.split('.');
|
|
|
+ res.data[0].closedate = time[0];
|
|
|
+ list.push(res.data[0]);
|
|
|
+ } else {
|
|
|
+ let time = res.data[0].createdate.split('.');
|
|
|
+ res.data[0].createdate = time[0];
|
|
|
+ list.push(res.data[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log("群聊话题详情", list);
|
|
|
+ return list;
|
|
|
+ },
|
|
|
+ /* 加载分页 */
|
|
|
scrolltoupper() {
|
|
|
if (this.data.pageNumber < this.data.pageTotal) {
|
|
|
this.setData({
|
|
|
@@ -240,80 +416,58 @@ Page({
|
|
|
keyboardHeight: height
|
|
|
})
|
|
|
},
|
|
|
+ /* 确认合作 */
|
|
|
+ confirmTheCooperation() {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
+ "method": "updatesupplyanddemandstatus",
|
|
|
+ "content": {
|
|
|
+ "tsupplyanddemandid": this.data.ownerid,
|
|
|
+ "fstatus": "已解决",
|
|
|
+ "tenterprise_userid": this.data.initiator,
|
|
|
+ "timdialogid": this.data.timdialogid
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("确认合作", res)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 拒绝合作 */
|
|
|
+ refuseToCooperate() {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
+ "method": "updatesupplyanddemandstatus",
|
|
|
+ "content": {
|
|
|
+ "tsupplyanddemandid": this.data.ownerid,
|
|
|
+ "fstatus": "待对接",
|
|
|
+ "timdialogid": this.data.timdialogid
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("拒绝合作", res)
|
|
|
+ })
|
|
|
+ },
|
|
|
/* 输入框数据绑定 */
|
|
|
sendInput(e) {
|
|
|
this.setData({
|
|
|
sendText: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
- /* 发送信息 */
|
|
|
- sendMsg(type, data) {
|
|
|
- const content = this.data.sendText.trim(),
|
|
|
- that = this;
|
|
|
- if (type === 'file') {
|
|
|
- if (this.data.fimdialogtype != '话题') {
|
|
|
- app.globalData.SocketTask.send({
|
|
|
- data: JSON.stringify({
|
|
|
- "classname": "message.message",
|
|
|
- "method": "sendFileMessage",
|
|
|
- "content": {
|
|
|
- "timdialogid": this.data.timdialogid,
|
|
|
- "tattachmentid": data[0].tattachmentid
|
|
|
- }
|
|
|
- }),
|
|
|
- success(res) {}
|
|
|
- })
|
|
|
- } else {
|
|
|
- app.globalData.SocketTask.send({
|
|
|
- data: JSON.stringify({
|
|
|
- "classname": "message.message",
|
|
|
- "method": "sendDataMessage",
|
|
|
- "content": {
|
|
|
- "timdialogid": this.data.timdialogid,
|
|
|
- "ownertable": "timsubject",
|
|
|
- "ownerid": this.data.timsubjectid,
|
|
|
- "ftype": "话题"
|
|
|
- }
|
|
|
- }),
|
|
|
- success(res) {}
|
|
|
- })
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (content == '') return;
|
|
|
- if (this.data.fimdialogtype != '话题') {
|
|
|
- app.globalData.SocketTask.send({
|
|
|
- data: JSON.stringify({
|
|
|
- "classname": "message.message",
|
|
|
- "method": "sendTextMessage",
|
|
|
- "content": {
|
|
|
- "timdialogid": that.data.timdialogid,
|
|
|
- "fmessage": content
|
|
|
- }
|
|
|
- }),
|
|
|
- success(res) {
|
|
|
- that.setData({
|
|
|
- sendText: ''
|
|
|
- })
|
|
|
- }
|
|
|
+ /* 发送表情 */
|
|
|
+ sendMeme(e) {
|
|
|
+ if (this.data.fimdialogtype == '话题') {
|
|
|
+ if (this.data.timsubjectid == 0 || this.data.userid != this.data.fimuserid) {
|
|
|
+ return wx.showToast({
|
|
|
+ title: '当前状态不可发送',
|
|
|
+ icon: "none"
|
|
|
})
|
|
|
} else {
|
|
|
- app.globalData.SocketTask.send({
|
|
|
- data: JSON.stringify({
|
|
|
- "classname": "message.message",
|
|
|
- "method": "sendDataMessage",
|
|
|
- "content": {
|
|
|
- "timdialogid": this.data.timdialogid,
|
|
|
- "ownertable": "timsubject",
|
|
|
- "ownerid": this.data.timsubjectid,
|
|
|
- "ftype": "话题"
|
|
|
- }
|
|
|
- }),
|
|
|
- success(res) {}
|
|
|
+ if (this.data.gambitList[this.data.gambitList.length - 1].imsubjectcontent.length < 1) return wx.showToast({
|
|
|
+ title: '当前状态不可发送',
|
|
|
+ icon: "none"
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
- sendMeme(e) {
|
|
|
const {
|
|
|
item
|
|
|
} = e.currentTarget.dataset;
|
|
|
@@ -409,6 +563,19 @@ Page({
|
|
|
afterRead({
|
|
|
file
|
|
|
}) {
|
|
|
+ if (this.data.fimdialogtype == '话题') {
|
|
|
+ if (this.data.timsubjectid == 0 || this.data.userid != this.data.fimuserid) {
|
|
|
+ return wx.showToast({
|
|
|
+ title: '当前状态不可发送',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (this.data.gambitList[this.data.gambitList.length - 1].imsubjectcontent.length < 1) return wx.showToast({
|
|
|
+ title: '当前状态不可发送',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
var that = this
|
|
|
var index = file.lastIndexOf(".");
|
|
|
var ext = file.substr(index + 1);
|