聊天 评论不能为空

This commit is contained in:
Mr.jiang 2024-08-05 10:50:50 +08:00
parent 702905f27f
commit ef3f229c02
3 changed files with 61 additions and 81 deletions

View File

@ -190,6 +190,9 @@
},
// "serviceHost" : "http://192.168.2.222:8187/_AMapService"
// "serviceHost" : "http://120.46.52.165/_AMapService"
"template" : "index.html"
"template" : "index.html",
"unipush" : {
"enable" : false
}
}
}

View File

@ -140,6 +140,8 @@
],
//
onlineEmoji:{"100.gif":"AbNQgA.gif","101.gif":"AbN3ut.gif","102.gif":"AbNM3d.gif","103.gif":"AbN8DP.gif","104.gif":"AbNljI.gif","105.gif":"AbNtUS.gif","106.gif":"AbNGHf.gif","107.gif":"AbNYE8.gif","108.gif":"AbNaCQ.gif","109.gif":"AbNN4g.gif","110.gif":"AbN0vn.gif","111.gif":"AbNd3j.gif","112.gif":"AbNsbV.gif","113.gif":"AbNwgs.gif","114.gif":"AbNrD0.gif","115.gif":"AbNDuq.gif","116.gif":"AbNg5F.gif","117.gif":"AbN6ET.gif","118.gif":"AbNcUU.gif","119.gif":"AbNRC4.gif","120.gif":"AbNhvR.gif","121.gif":"AbNf29.gif","122.gif":"AbNW8J.gif","123.gif":"AbNob6.gif","124.gif":"AbN5K1.gif","125.gif":"AbNHUO.gif","126.gif":"AbNIDx.gif","127.gif":"AbN7VK.gif","128.gif":"AbNb5D.gif","129.gif":"AbNX2d.gif","130.gif":"AbNLPe.gif","131.gif":"AbNjxA.gif","132.gif":"AbNO8H.gif","133.gif":"AbNxKI.gif","134.gif":"AbNzrt.gif","135.gif":"AbU9Vf.gif","136.gif":"AbUSqP.gif","137.gif":"AbUCa8.gif","138.gif":"AbUkGQ.gif","139.gif":"AbUFPg.gif","140.gif":"AbUPIS.gif","141.gif":"AbUZMn.gif","142.gif":"AbUExs.gif","143.gif":"AbUA2j.gif","144.gif":"AbUMIU.gif","145.gif":"AbUerq.gif","146.gif":"AbUKaT.gif","147.gif":"AbUmq0.gif","148.gif":"AbUuZV.gif","149.gif":"AbUliF.gif","150.gif":"AbU1G4.gif","151.gif":"AbU8z9.gif","152.gif":"AbU3RJ.gif","153.gif":"AbUYs1.gif","154.gif":"AbUJMR.gif","155.gif":"AbUadK.gif","156.gif":"AbUtqx.gif","157.gif":"AbUUZ6.gif","158.gif":"AbUBJe.gif","159.gif":"AbUdIO.gif","160.gif":"AbU0iD.gif","161.gif":"AbUrzd.gif","162.gif":"AbUDRH.gif","163.gif":"AbUyQA.gif","164.gif":"AbUWo8.gif","165.gif":"AbU6sI.gif","166.gif":"AbU2eP.gif","167.gif":"AbUcLt.gif","168.gif":"AbU4Jg.gif","169.gif":"AbURdf.gif","170.gif":"AbUhFS.gif","171.gif":"AbU5WQ.gif","172.gif":"AbULwV.gif","173.gif":"AbUIzj.gif","174.gif":"AbUTQs.gif","175.gif":"AbU7yn.gif","176.gif":"AbUqe0.gif","177.gif":"AbUHLq.gif","178.gif":"AbUOoT.gif","179.gif":"AbUvYF.gif","180.gif":"AbUjFU.gif","181.gif":"AbaSSJ.gif","182.gif":"AbUxW4.gif","183.gif":"AbaCO1.gif","184.gif":"Abapl9.gif","185.gif":"Aba9yR.gif","186.gif":"AbaFw6.gif","187.gif":"Abaiex.gif","188.gif":"AbakTK.gif","189.gif":"AbaZfe.png","190.gif":"AbaEFO.gif","191.gif":"AbaVYD.gif","192.gif":"AbamSH.gif","193.gif":"AbaKOI.gif","194.gif":"Abanld.gif","195.gif":"Abau6A.gif","196.gif":"AbaQmt.gif","197.gif":"Abal0P.gif","198.gif":"AbatpQ.gif","199.gif":"Aba1Tf.gif","200.png":"Aba8k8.png","201.png":"AbaGtS.png","202.png":"AbaJfg.png","203.png":"AbaNlj.png","204.png":"Abawmq.png","205.png":"AbaU6s.png","206.png":"AbaaXn.png","207.png":"Aba000.png","208.png":"AbarkT.png","209.png":"AbastU.png","210.png":"AbaB7V.png","211.png":"Abafn1.png","212.png":"Abacp4.png","213.png":"AbayhF.png","214.png":"Abag1J.png","215.png":"Aba2c9.png","216.png":"AbaRXR.png","217.png":"Aba476.png","218.png":"Abah0x.png","219.png":"Abdg58.png"},
webSocketTask:null,
timer: null,
};
},
onLoad(d) {
@ -162,9 +164,28 @@
}
}
},
onShow(){
// websocket
this.webSocketTask.onMessage((res) => {
let data = JSON.parse(res.data);
console.log("消息及处理",data)
});
},
mounted() {
this.timer = setInterval(() => {
this.getTimeOrListItem1()
}, 3000);
},
onUnload() {
uni.closeSocket({
success: () => {
console.info("退出成功")
},
})
// uni.closeSocket()
uni.hideLoading()
uni.hideLoading();
clearInterval(this.timer);
this.timer = null;
},
methods:{
guanbi(){
@ -247,7 +268,7 @@
})
// wss://sausers.blxinchuang.com/wss/chatSocket/
// websocketUtils.getWsBaseUrl()
uni.connectSocket({
this.webSocketTask = uni.connectSocket({
url: websocketUtils.getWsBaseUrl() + userId,
data() {
return {
@ -268,63 +289,13 @@
console.log("--------------"+JSON.stringify(err))
}
});
uni.onSocketOpen((res) => {
that.connecting = false
that.connected = true
uni.hideLoading()
// uni.showToast({
// icon: 'none',
// title: ''
// })
console.log('onOpen', res);
// WebSocket
this.webSocketTask.onOpen((res) => {
console.info("监听WebSocket连接打开事件", res)
});
uni.onSocketError((err) => {
that.connecting = false
that.connected = false
uni.hideLoading()
console.log('onError', err);
uni.showModal({
content: '网络较差,请稍后再试',
showCancel: false
})
});
uni.onSocketMessage(function (res) {
console.log('收到服务器内容:' + JSON.stringify(res));
setTimeout(() => {
that.getTimeOrListItem1();
}, 50);
});
uni.onSocketClose((res) => {
that.connected = false
that.startRecive = false
that.msg = false
console.log('onClose', res)
uni.showLoading({
title: '连接中...'
})
uni.connectSocket({
url: websocketUtils.getWsBaseUrl() + userId,
data() {
return {
msg: 'Hello'
}
},
header: {
'content-type': 'application/json'
},
method: 'GET',
success(res) {
uni.hideLoading();
that.getTimeOrListItem1();
//
},
fail(err) {
//
console.log("--------------"+JSON.stringify(err))
}
});
// WebSocket
uni.onSocketError((res) => {
console.info("监听WebSocket错误" + res)
});
},
close() {
@ -333,6 +304,7 @@
//
getTimeOrListItem1() {
console.log("接受数据测试");
this.$Request.get('/app/chat/selectChatContent?page=1&limit=1000&chatConversationId=' + this.chatConversationId).then(
res => {
this.ListItem = [];
@ -547,7 +519,6 @@
//
replaceEmoji(str){
let replacedStr = str.replace(/\[([^(\]|\[)]*)\]/g,(item, index)=>{
console.log("item: " + item);
for(let i=0;i<this.emojiList.length;i++){
let row = this.emojiList[i];
for(let j=0;j<row.length;j++){

View File

@ -354,27 +354,33 @@
},
replyFun(params, callback) {
// console.log("replyFun", params);
var data={
createBy:uni.getStorageSync('userId'),
content:params.params.user_content,
shipinquanId:this.videoID,
}
this.$Request.post("/app/shipinquan/addContent",data).then(res => {
if (res.code == 0) {
setTimeout(() => this.getPingL(this.videoID), 500);
this.showPopup==true;
uni.hideLoading();
// callback(this.videoID);
} else {
uni.hideLoading();
uni.showToast({
title: res.msg,
icon: 'none'
})
}
});
// const res = { id: Math.random() }; // ! id! !
// setTimeout(() => callback(res), 500); // , callback
if(params.params.user_content==''){
uni.hideLoading();
uni.showToast({
icon:'error',
title:'请填写发布评论'
})
}else{
var data={
createBy:uni.getStorageSync('userId'),
content:params.params.user_content,
shipinquanId:this.videoID,
}
this.$Request.post("/app/shipinquan/addContent",data).then(res => {
if (res.code == 0) {
setTimeout(() => this.getPingL(this.videoID), 500);
this.showPopup==true;
uni.hideLoading();
// callback(this.videoID);
} else {
uni.hideLoading();
uni.showToast({
title: res.msg,
icon: 'none'
})
}
});
}
},
deleteFun({ params, mode }, callback) {