up
This commit is contained in:
@ -34,3 +34,11 @@ export function getPolicyMatch(params) {
|
||||
params
|
||||
});
|
||||
}
|
||||
// 中转图片
|
||||
export function handlePic(data) {
|
||||
return request({
|
||||
url: '/mobile/handlePic',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
10
src/api/service.js
Normal file
10
src/api/service.js
Normal file
@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 给某人发送信息
|
||||
export function send(data) {
|
||||
return request({
|
||||
url: '/chat/send',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
@ -12,26 +12,19 @@ export function formatRichText(url, id) {
|
||||
for (let i = 0; i < src.length; i++) {
|
||||
const string = src[i].getAttribute('src');
|
||||
endUrl.push(string);
|
||||
const flag = string.includes('http://');
|
||||
// 域名存在
|
||||
if (status) {
|
||||
if (i == src.length - 1) {
|
||||
const data = {
|
||||
startUrl: url,
|
||||
policyId: id,
|
||||
endUrl
|
||||
};
|
||||
handlePic(data).then(({ data: res }) => {
|
||||
console.log(res);
|
||||
for (let i = 0; i < src.length; i++) {
|
||||
src[i].setAttribute('src', res[i].name);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (endUrl.length) {
|
||||
const data = {
|
||||
startUrl: url,
|
||||
policyId: id,
|
||||
endUrl
|
||||
};
|
||||
handlePic(data).then(({ data: res }) => {
|
||||
console.log(res);
|
||||
for (let i = 0; i < src.length; i++) {
|
||||
src[i].setAttribute('src', res[i].name);
|
||||
}
|
||||
} else {
|
||||
// 域名不存在并且不包含http
|
||||
if (!flag) src[i].setAttribute('src', url + string);
|
||||
}
|
||||
});
|
||||
}
|
||||
// let src2 = document.querySelectorAll('#text .ql-editor a');
|
||||
let src2 = document.querySelectorAll('#text a');
|
||||
|
@ -87,36 +87,18 @@
|
||||
<div class="sendBtn" @click="send">发送</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 辅助工具 -->
|
||||
<!-- <div class="tools">
|
||||
<div class="toolsBox" v-if="tool_show == -1">
|
||||
<img
|
||||
v-for="(item, index) in tools"
|
||||
:key="index"
|
||||
:src="item.img"
|
||||
:alt="item.name"
|
||||
@click="getTool(index)"
|
||||
/>
|
||||
</div>
|
||||
<legislation v-else-if="tool_show == 0"></legislation>
|
||||
<lawcase v-else-if="tool_show == 1"></lawcase>
|
||||
<dispute v-else-if="tool_show == 2"></dispute>
|
||||
<aidedtools v-else-if="tool_show == 3"></aidedtools>
|
||||
<replayDetail
|
||||
:detail="replyDetail"
|
||||
v-else-if="tool_show == -2"
|
||||
></replayDetail>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { send } from '@/api/service';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
path: 'ws://192.168.0.125:1919/webStock/1425648094011330560',
|
||||
socket: '',
|
||||
userid: '23941',
|
||||
// 待发送信息
|
||||
message: '',
|
||||
@ -152,13 +134,44 @@ export default {
|
||||
this.getIsShowTime();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['avatar'])
|
||||
},
|
||||
mounted() {
|
||||
this.chatWindowActive();
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init: function() {
|
||||
if (typeof WebSocket === 'undefined') {
|
||||
alert('您的浏览器不支持socket');
|
||||
} else {
|
||||
// 实例化socket
|
||||
this.socket = new WebSocket(this.path);
|
||||
console.log(this.socket);
|
||||
// 监听socket连接
|
||||
this.socket.onopen = this.open;
|
||||
// 监听socket错误信息
|
||||
this.socket.onerror = this.error;
|
||||
// 监听socket消息
|
||||
this.socket.onmessage = this.getMessage;
|
||||
}
|
||||
},
|
||||
open: function() {
|
||||
console.log('socket连接成功');
|
||||
},
|
||||
error: function() {
|
||||
console.log('连接错误');
|
||||
},
|
||||
getMessage(msg) {
|
||||
console.log(msg.data);
|
||||
console.log(JSON.parse(msg.data));
|
||||
this.a = JSON.parse(msg.data);
|
||||
// sendUserId
|
||||
},
|
||||
send: function(params) {
|
||||
this.socket.send(params);
|
||||
},
|
||||
close: function() {
|
||||
console.log('socket已经关闭');
|
||||
},
|
||||
// 原回车键失去回车功能
|
||||
stopEnter(event) {
|
||||
if (event.keyCode === 13) {
|
||||
@ -274,68 +287,64 @@ export default {
|
||||
let message = this.message;
|
||||
this.message = '';
|
||||
this.isLoading = 1; //加载中
|
||||
this.$axios({
|
||||
url: 'http://rpai.365lawhelp.com/api/Reply/getReply',
|
||||
method: 'post',
|
||||
data: {
|
||||
message,
|
||||
appuid: '23941' //测试使用id
|
||||
}
|
||||
}).then(res => {
|
||||
var that = this;
|
||||
if (
|
||||
res.data.replayType == 'NEEDCONTRACTUSER' ||
|
||||
res.data.replayType == 'MSG' ||
|
||||
res.data.replayType == 'UNKNOWN'
|
||||
) {
|
||||
setTimeout(function() {
|
||||
that.chats.push({
|
||||
sender: 0,
|
||||
send_con: res.data.msgInfos,
|
||||
send_timestamp: that.getTime(),
|
||||
type: res.data.replayType
|
||||
});
|
||||
that.isLoading = 0;
|
||||
that.getIsShowTime();
|
||||
that.chatWindowActive();
|
||||
that.updateHistory(that.chats.length);
|
||||
}, 1000);
|
||||
} else {
|
||||
let all;
|
||||
if (res.data.replayType == 'QA') {
|
||||
//输入"你能做些什么"测试,右侧进入问答页面
|
||||
all = res.data.replyQADatas;
|
||||
} else if (res.data.replayType == 'CONTRACT') {
|
||||
//输入"劳动合同"测试,跳转下载链接
|
||||
all = res.data.replyContractDatas;
|
||||
} else if (res.data.replayType == 'LAW') {
|
||||
//输入"宪法"测试,右侧进入法律页面
|
||||
all = res.data.replyLawDatas;
|
||||
} else if (res.data.replayType == 'CASE') {
|
||||
//输入"强奸案案例"测试,右侧进入案例页面
|
||||
all = res.data.replyCaseDatas;
|
||||
}
|
||||
let list = [];
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (all[i]) {
|
||||
list.push(all[i]);
|
||||
send({ sendText: message, sendUserId: '1422032951604023296' }).then(
|
||||
res => {
|
||||
console.log(res);
|
||||
var that = this;
|
||||
if (
|
||||
res.data.replayType == 'NEEDCONTRACTUSER' ||
|
||||
res.data.replayType == 'MSG' ||
|
||||
res.data.replayType == 'UNKNOWN'
|
||||
) {
|
||||
setTimeout(function() {
|
||||
that.chats.push({
|
||||
sender: 0,
|
||||
send_con: res.data.msgInfos,
|
||||
send_timestamp: that.getTime(),
|
||||
type: res.data.replayType
|
||||
});
|
||||
that.isLoading = 0;
|
||||
that.getIsShowTime();
|
||||
that.chatWindowActive();
|
||||
that.updateHistory(that.chats.length);
|
||||
}, 1000);
|
||||
} else {
|
||||
let all;
|
||||
if (res.data.replayType == 'QA') {
|
||||
//输入"你能做些什么"测试,右侧进入问答页面
|
||||
all = res.data.replyQADatas;
|
||||
} else if (res.data.replayType == 'CONTRACT') {
|
||||
//输入"劳动合同"测试,跳转下载链接
|
||||
all = res.data.replyContractDatas;
|
||||
} else if (res.data.replayType == 'LAW') {
|
||||
//输入"宪法"测试,右侧进入法律页面
|
||||
all = res.data.replyLawDatas;
|
||||
} else if (res.data.replayType == 'CASE') {
|
||||
//输入"强奸案案例"测试,右侧进入案例页面
|
||||
all = res.data.replyCaseDatas;
|
||||
}
|
||||
let list = [];
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (all[i]) {
|
||||
list.push(all[i]);
|
||||
}
|
||||
}
|
||||
setTimeout(function() {
|
||||
that.chats.push({
|
||||
sender: 0,
|
||||
send_con: res.data.msgInfos,
|
||||
send_timestamp: that.getTime(),
|
||||
type: res.data.replayType,
|
||||
list
|
||||
});
|
||||
that.isLoading = 0;
|
||||
that.getIsShowTime();
|
||||
that.chatWindowActive();
|
||||
that.updateHistory(that.chats.length);
|
||||
}, 1000);
|
||||
}
|
||||
setTimeout(function() {
|
||||
that.chats.push({
|
||||
sender: 0,
|
||||
send_con: res.data.msgInfos,
|
||||
send_timestamp: that.getTime(),
|
||||
type: res.data.replayType,
|
||||
list
|
||||
});
|
||||
that.isLoading = 0;
|
||||
that.getIsShowTime();
|
||||
that.chatWindowActive();
|
||||
that.updateHistory(that.chats.length);
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
);
|
||||
},
|
||||
// 更新聊天记录
|
||||
updateHistory(len) {
|
||||
@ -353,6 +362,10 @@ export default {
|
||||
getTool(index) {
|
||||
this.tool_show = index;
|
||||
}
|
||||
},
|
||||
destroyed() {
|
||||
// 销毁监听
|
||||
this.socket.onclose = this.close;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -191,7 +191,7 @@ export default {
|
||||
formData: {
|
||||
handler: function() {
|
||||
this.$nextTick(() => {
|
||||
this.formatRichText(this.formData.downloadUrl);
|
||||
this.formatRichText(this.formData.downloadUrl, this.formData.id);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user