|
@@ -151,7 +151,7 @@ export default {
|
|
|
//显示时间
|
|
//显示时间
|
|
|
renderMessageDate() {
|
|
renderMessageDate() {
|
|
|
return (message, index) => {
|
|
return (message, index) => {
|
|
|
- if (this.msgData.list[index + 1]?.timestamp - message.timestamp > 3 * 60 * 1000) {
|
|
|
|
|
|
|
+ if (message.timestamp - this.msgData.list[index + 1]?.timestamp > 3 * 60 * 1000) {
|
|
|
return formatDate(message.timestamp, 'timestamp');
|
|
return formatDate(message.timestamp, 'timestamp');
|
|
|
}
|
|
}
|
|
|
return '';
|
|
return '';
|
|
@@ -164,6 +164,9 @@ export default {
|
|
|
clearInterval(getSelectedTextRangeSetInterval);
|
|
clearInterval(getSelectedTextRangeSetInterval);
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ previewImg(data){
|
|
|
|
|
+ return openimg(1,[data])
|
|
|
|
|
+ },
|
|
|
async getServiceData(){
|
|
async getServiceData(){
|
|
|
var formData = {};
|
|
var formData = {};
|
|
|
const tokenPoi = uni.getStorageSync("contact");
|
|
const tokenPoi = uni.getStorageSync("contact");
|
|
@@ -213,8 +216,9 @@ export default {
|
|
|
});
|
|
});
|
|
|
var user_channel = this.pushData.obj.subscribe('user-' + this.chatData.userId);
|
|
var user_channel = this.pushData.obj.subscribe('user-' + this.chatData.userId);
|
|
|
user_channel.on('message', function (data) {
|
|
user_channel.on('message', function (data) {
|
|
|
- console.log(data);
|
|
|
|
|
- // _this.formatMsg(data);
|
|
|
|
|
|
|
+ const pushData = _this.formatMsg(data);
|
|
|
|
|
+ _this.msgData.list.unshift(pushData);
|
|
|
|
|
+ _this.scrollToBottom()
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
quickQs(data){
|
|
quickQs(data){
|
|
@@ -261,16 +265,13 @@ export default {
|
|
|
payload = item.content
|
|
payload = item.content
|
|
|
}
|
|
}
|
|
|
if (item.type == 'order') {
|
|
if (item.type == 'order') {
|
|
|
- var order = JSON.parse(item.content)
|
|
|
|
|
- payload = order
|
|
|
|
|
|
|
+ payload = JSON.parse(item.content)
|
|
|
}
|
|
}
|
|
|
if (item.type == 'pay') {
|
|
if (item.type == 'pay') {
|
|
|
- var order = JSON.parse(item.content)
|
|
|
|
|
- payload = order
|
|
|
|
|
|
|
+ payload = JSON.parse(item.content)
|
|
|
}
|
|
}
|
|
|
if (item.type == 'address') {
|
|
if (item.type == 'address') {
|
|
|
- var order = JSON.parse(item.content)
|
|
|
|
|
- payload = order
|
|
|
|
|
|
|
+ payload = JSON.parse(item.content)
|
|
|
}
|
|
}
|
|
|
if (item.type == 'image') {
|
|
if (item.type == 'image') {
|
|
|
payload = item.content
|
|
payload = item.content
|
|
@@ -308,9 +309,8 @@ export default {
|
|
|
},
|
|
},
|
|
|
sendingMore(data){
|
|
sendingMore(data){
|
|
|
switch (data.type) {
|
|
switch (data.type) {
|
|
|
- case 'img':
|
|
|
|
|
- show("暂未开通");
|
|
|
|
|
- // this.sendImageMessage();
|
|
|
|
|
|
|
+ case 'img':
|
|
|
|
|
+ this.sendImageMessage();
|
|
|
break;
|
|
break;
|
|
|
case 'video':
|
|
case 'video':
|
|
|
show("暂未开通");
|
|
show("暂未开通");
|
|
@@ -393,6 +393,37 @@ export default {
|
|
|
timestamp: Date.now(),
|
|
timestamp: Date.now(),
|
|
|
};
|
|
};
|
|
|
app.msgData.list.unshift(message);
|
|
app.msgData.list.unshift(message);
|
|
|
|
|
+ },
|
|
|
|
|
+ // 创建发送照片内容
|
|
|
|
|
+ sendImageMessage() {
|
|
|
|
|
+ uni.chooseImage({
|
|
|
|
|
+ count: 1,
|
|
|
|
|
+ sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
|
|
+ success: async (res) => {
|
|
|
|
|
+ res.tempFiles.forEach((file) => {
|
|
|
|
|
+ console.log(file);
|
|
|
|
|
+ this.createImageMessage(file);
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ fail(e) {
|
|
|
|
|
+ console.log("选择失败",e)
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ // 创建发送照片内容
|
|
|
|
|
+ async createImageMessage(file) {
|
|
|
|
|
+ var formData = {};
|
|
|
|
|
+ const tokenPoi = uni.getStorageSync("contact");
|
|
|
|
|
+ formData.groupId = tokenPoi.poi_id;
|
|
|
|
|
+ formData.type = "image";
|
|
|
|
|
+ var resp = await app.$api.chat.sendImage.post({'path':file.path,"param":formData});
|
|
|
|
|
+ var respData = JSON.parse(resp);
|
|
|
|
|
+ app.msgData.isSend = false;
|
|
|
|
|
+ if (respData.code !== 1) {
|
|
|
|
|
+ return show(respData.msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ app.sendMessage(respData.data.path,"image");
|
|
|
|
|
+ app.scrollToBottom()
|
|
|
},
|
|
},
|
|
|
getMessage(){
|
|
getMessage(){
|
|
|
let get = async ()=>{
|
|
let get = async ()=>{
|
|
@@ -402,35 +433,29 @@ export default {
|
|
|
formData.poi = tokenPoi.poi_id;
|
|
formData.poi = tokenPoi.poi_id;
|
|
|
formData.page = app.msgData.page;
|
|
formData.page = app.msgData.page;
|
|
|
formData.size = app.msgData.rows;
|
|
formData.size = app.msgData.rows;
|
|
|
- let data = await app.$api.chat.msg.get(formData);
|
|
|
|
|
- // var msgData = resp.data.msg.data;
|
|
|
|
|
- // var pushData = [];
|
|
|
|
|
- // if (msgData.length > 0) {
|
|
|
|
|
- // msgData.forEach(item => pushData.push(app.formatMsg(item)))
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // let data = await getHistoryMsg({
|
|
|
|
|
- // page:this.msgData.page,
|
|
|
|
|
- // rows: this.msgData.page == 3 ? 5 : this.msgData.rows
|
|
|
|
|
- // });
|
|
|
|
|
- // const selector = `msg-${data?.[0]?.messageId}`;;
|
|
|
|
|
- // this.msgData.list = this.msgData.list.concat(data);
|
|
|
|
|
- // // 数据挂载后执行,不懂的请自行阅读 Vue.js 文档对 Vue.nextTick 函数说明。
|
|
|
|
|
- // this.$nextTick(()=>{
|
|
|
|
|
- // // 设置当前滚动的位置
|
|
|
|
|
- // this.scrollIntoViewId = selector;
|
|
|
|
|
- // if(data.length < this.msgData.rows){
|
|
|
|
|
- // this.msgData.allLoaded = true;
|
|
|
|
|
- // this.msgData.flag = false;
|
|
|
|
|
- // // 当前消息数据条数小于请求要求条数时,则无更多消息,不再允许请求。
|
|
|
|
|
- // // 可在此处编写无更多消息数据时的逻辑
|
|
|
|
|
- // }else{
|
|
|
|
|
- // this.msgData.flag = true;
|
|
|
|
|
- // this.msgData.allLoaded = false;
|
|
|
|
|
- // this.msgData.page ++;
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // })
|
|
|
|
|
|
|
+ let resp = await app.$api.chat.msg.get(formData);
|
|
|
|
|
+ var msgData = resp.data.data.data;
|
|
|
|
|
+ var pushData = [];
|
|
|
|
|
+ if (msgData.length > 0) {
|
|
|
|
|
+ msgData.forEach(item => pushData.push(app.formatMsg(item)))
|
|
|
|
|
+ }
|
|
|
|
|
+ const selector = `msg-${msgData?.[0]?.messageId}`;;
|
|
|
|
|
+ this.msgData.list = this.msgData.list.concat(pushData);
|
|
|
|
|
+ // 数据挂载后执行,不懂的请自行阅读 Vue.js 文档对 Vue.nextTick 函数说明。
|
|
|
|
|
+ this.$nextTick(()=>{
|
|
|
|
|
+ // 设置当前滚动的位置
|
|
|
|
|
+ this.scrollIntoViewId = selector;
|
|
|
|
|
+ if(msgData.length < this.msgData.rows){
|
|
|
|
|
+ this.msgData.allLoaded = true;
|
|
|
|
|
+ this.msgData.flag = false;
|
|
|
|
|
+ // 当前消息数据条数小于请求要求条数时,则无更多消息,不再允许请求。
|
|
|
|
|
+ // 可在此处编写无更多消息数据时的逻辑
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.msgData.flag = true;
|
|
|
|
|
+ this.msgData.allLoaded = false;
|
|
|
|
|
+ this.msgData.page ++;
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
get();
|
|
get();
|
|
|
},
|
|
},
|
|
@@ -457,6 +482,11 @@ export default {
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
|
z-index: 98;
|
|
z-index: 98;
|
|
|
}
|
|
}
|
|
|
|
|
+.m-image {
|
|
|
|
|
+ image {
|
|
|
|
|
+ width: 140rpx;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
.m-address{
|
|
.m-address{
|
|
|
display: flex;align-items: center;gap: 20rpx;min-width: 70vw;
|
|
display: flex;align-items: center;gap: 20rpx;min-width: 70vw;
|
|
|
&.self{
|
|
&.self{
|