This commit is contained in:
pengxiaolong
2025-07-21 22:10:59 +08:00
parent 31527ba8a6
commit 7116e57fc3
157 changed files with 2793 additions and 405 deletions

View File

@@ -0,0 +1,32 @@
// let COS = require('cos-wx-sdk-v5')
import COS from 'cos-wx-sdk-v5'
// const COS = require('./lib/cos-wx-sdk-v5.min.js'); // 上线时使用压缩包
const cos = new COS({
SecretId: "AKID4KPIyQgjjnkWJzSnwtfHj281tcBZo28v", // 推荐使用环境变量获取;用户的 SecretId建议使用子账号密钥授权遵循最小权限指引降低使用风险。子账号密钥获取可参考https://cloud.tencent.com/document/product/598/37140
SecretKey: "kQvMjuscBWgfSCqeHiGfx3vc7PUP7ctx", // 推荐使用环境变量获取;用户的 SecretKey建议使用子账号密钥授权遵循最小权限指引降低使用风险。子账号密钥获取可参考https://cloud.tencent.com/document/product/598/37140
});
const audioMessages = function(file) {
return new Promise((resolve, reject) => {
cos.uploadFile({
Bucket: 'vv-1317974657', // 填入您自己的存储桶,必须字段
Region: 'ap-shanghai', // 存储桶所在地域,例如 ap-beijing必须字段
Key: "audios/" + file.name, // 存储在桶里的对象键例如1.jpga/b/test.txt必须字段文件名
FilePath: file.path, // 必须
FileSize: "", // v1.4.3之前的版本必须v1.4.3及以后的版本非必须
SliceSize: 1024 * 1024 * 2, // 触发分块上传的阈值超过2MB使用分块上传非必须按需调整最小支持1MB
// 支持自定义 headers 非必须
Headers: {
'x-cos-meta-test': 123
},
}, function(err, data) {
if (err) {
reject(err);
} else {
resolve(data.Location);
}
});
});
}
export default audioMessages

View File

@@ -1,65 +1,65 @@
import GoEasy from 'goeasy'
//IM登录
export function goEasylogin(goeasy,id,avatar,nickname) {
console.log("`````````````````goEasylogin`````````````````",id,avatar,nickname);
export function goEasylogin(goeasy, id, avatar, nickname) {
console.log("`````````````````goEasylogin`````````````````", id, avatar, nickname);
goeasy.connect({
id:id, //im必填最大长度60字符
data:{"avatar":avatar,"nickname":nickname}, //必须是一个对象im必填最大长度300字符显示在会话列表中
id: id, //im必填最大长度60字符
data: { "avatar": avatar, "nickname": nickname }, //必须是一个对象im必填最大长度300字符显示在会话列表中
onSuccess: function () { //连接成功
console.log("IM连接成功") //连接成功
},
onFailed: function (error) { //连接失败
console.log("IM连接失败, code:"+error.code+ ",error:"+error.content);
console.log("IM连接失败, code:" + error.code + ",error:" + error.content);
},
onProgress:function(attempts) { //连接或自动重连中
onProgress: function (attempts) { //连接或自动重连中
console.log("IM连接或自动重连中", attempts);
}
});
});
}
//退出登录
export function goEasylogout(goeasy) {
goeasy.disconnect({
onSuccess: function(){
console.log("IM断开成功")
onSuccess: function () {
console.log("IM断开成功")
},
onFailed: function(error){
console.log("IM断开失败, code:"+error.code+ ",error:"+error.content);
onFailed: function (error) {
console.log("IM断开失败, code:" + error.code + ",error:" + error.content);
}
});
});
}
//获取会话列表
export function getConversationList(goeasy) {
return new Promise((resolve, reject) => {
var im = goeasy.im;
im.latestConversations({
onSuccess: function (result) {
var im = goeasy.im;
im.latestConversations({
onSuccess: function (result) {
console.log("获取会话列表成功", result);
resolve(result.content);
},
onFailed: function (error) { //获取失败
console.log("获取会话列表失败, code:" + error.code + " content:" + error.content);
console.log("获取会话列表失败, code:" + error.code + " content:" + error.content);
},
});
});
});
}
//获取指定会话的消息列表
export function getConversationMessages(goeasy,userid,imestamp) {
export function getConversationMessages(goeasy, userid, imestamp) {
return new Promise((resolve, reject) => {
var im = goeasy.im;
im.history({
id: userid, //用户id或者群id
type: GoEasy.IM_SCENE.PRIVATE, //群聊GoEasy.IM_SCENE.GROUP, 客服GoEasy.IM_SCENE.CS,
lastTimestamp:imestamp, //上次查询结果里最后一条消息的时间戳首次查询传入null即可
lastTimestamp: imestamp, //上次查询结果里最后一条消息的时间戳首次查询传入null即可
limit: 30, //可选项返回的消息条数默认为10条最多30条
onSuccess: function (result) {
console.log("获取消息列表成功", result);
resolve(result.content);
}, //查询成功
onFailed: function (error) {
onFailed: function (error) {
console.log("获取消息列表失败, code:" + error.code + " content:" + error.content);
}, //查询失败
});
@@ -67,36 +67,36 @@ export function getConversationMessages(goeasy,userid,imestamp) {
}
//发送消息
export function sendMessage(goeasy,userid,message,avatar,nickname) {
export function sendMessage(goeasy, userid, message, avatar, nickname) {
return new Promise((resolve, reject) => {
var im = goeasy.im;
//创建消息, 内容最长不超过3K可以发送字符串对象和json格式字符串
let textMessage = im.createTextMessage({
text: message, //消息内容
to: {
type: GoEasy.IM_SCENE.PRIVATE, //私聊还是群聊群聊为GoEasy.IM_SCENE.GROUP
id: userid, //接收方用户id
data: {"avatar": avatar, "nickname":nickname} //接收方用户扩展数据, 任意格式的字符串或者对象用于更新会话列表conversation.data
}
text: message, //消息内容
to: {
type: GoEasy.IM_SCENE.PRIVATE, //私聊还是群聊群聊为GoEasy.IM_SCENE.GROUP
id: userid, //接收方用户id
data: { "avatar": avatar, "nickname": nickname } //接收方用户扩展数据, 任意格式的字符串或者对象用于更新会话列表conversation.data
}
});
//发送消息
im.sendMessage({
message: textMessage,
onSuccess: function () { //发送成功
resolve(textMessage);
},
onFailed: function (error) { //发送失败
console.log('发送消息失败code:' + error.code + ' ,error ' + error.content);
reject(error);
}
message: textMessage,
onSuccess: function () { //发送成功
resolve(textMessage);
},
onFailed: function (error) { //发送失败
console.log('发送消息失败code:' + error.code + ' ,error ' + error.content);
reject(error);
}
});
});
}
//消息已读
export function messageRead(goeasy,userid) {
export function messageRead(goeasy, userid) {
return new Promise((resolve, reject) => {
var im = goeasy.im;
im.markMessageAsRead({
@@ -106,8 +106,68 @@ export function messageRead(goeasy,userid) {
resolve()
},
onFailed: function (error) {
console.log('标记私聊已读失败', error);
console.log('标记私聊已读失败', error);
},
});
});
}
//发送自定义消息
export function sendCustomMessage(goeasy, type, userid, order, avatar, nickname) {
return new Promise((resolve, reject) => {
var im = goeasy.im;
// 创建自定义消息
var customMessage = im.createCustomMessage({
type: type, //字符串,可以任意自定义类型
payload: order,
to: {
type: GoEasy.IM_SCENE.PRIVATE, //私聊还是群聊群聊为GoEasy.IM_SCENE.GROUP
id: userid, //接收方用户id
data: { "avatar": avatar, "nickname": nickname } //好友扩展数据, 任意格式的字符串或者对象用于更新会话列表conversation.data
}
})
// 发自定义消息
im.sendMessage({
message: customMessage,
onSuccess: function () { //发送成功
resolve(customMessage);
},
onFailed: function (error) { //发送失败
console.log('Failed to send messagecode:' + error.code + ',error' + error.content);
}
});
});
}
//置顶会话
export function conversationTop(goeasy, conversation, top) {
return new Promise((resolve, reject) => {
var im = goeasy.im;
im.topConversation({
conversation: conversation,
top:top ,//或者 false
onSuccess: function () {
resolve('成功');
},
onFailed: function (error) {
console.log( '失败:', error);
},
});
});
}
//删除会话
export function conversationDelete(goeasy, conversation) {
return new Promise((resolve, reject) => {
var im = goeasy.im;
im.removeConversation({
conversation: conversation,
onSuccess: function () {
resolve('删除会话成功');
},
onFailed: function (error) {
console.log(error);
},
});
});
}

View File

@@ -0,0 +1,32 @@
// let COS = require('cos-wx-sdk-v5')
import COS from 'cos-wx-sdk-v5'
// const COS = require('./lib/cos-wx-sdk-v5.min.js'); // 上线时使用压缩包
const cos = new COS({
SecretId: "AKID4KPIyQgjjnkWJzSnwtfHj281tcBZo28v", // 推荐使用环境变量获取;用户的 SecretId建议使用子账号密钥授权遵循最小权限指引降低使用风险。子账号密钥获取可参考https://cloud.tencent.com/document/product/598/37140
SecretKey: "kQvMjuscBWgfSCqeHiGfx3vc7PUP7ctx", // 推荐使用环境变量获取;用户的 SecretKey建议使用子账号密钥授权遵循最小权限指引降低使用风险。子账号密钥获取可参考https://cloud.tencent.com/document/product/598/37140
});
const picturesVideosMessages = function(file) {
return new Promise((resolve, reject) => {
cos.uploadFile({
Bucket: 'vv-1317974657', // 填入您自己的存储桶,必须字段
Region: 'ap-shanghai', // 存储桶所在地域,例如 ap-beijing必须字段
Key: "sources/" + file.name, // 存储在桶里的对象键例如1.jpga/b/test.txt必须字段文件名
FilePath: file.path, // 必须
FileSize: "", // v1.4.3之前的版本必须v1.4.3及以后的版本非必须
SliceSize: 1024 * 1024 * 2, // 触发分块上传的阈值超过2MB使用分块上传非必须按需调整最小支持1MB
// 支持自定义 headers 非必须
Headers: {
'x-cos-meta-test': 123
},
}, function(err, data) {
if (err) {
reject(err);
} else {
resolve(data.Location);
}
});
});
}
export default picturesVideosMessages

View File

@@ -2,8 +2,8 @@ import addPrefixToHeaderIcon from './addPrefixToHeaderIcon.js'
export default function request(urldata) {
const { url, data, method, header, userInfo } = urldata;
// const baseUrl = "http://49.235.115.212:8086/"+ url;
// const baseUrl = "https://pk.zhukeping.com/"+ url;
const baseUrl = "http://120.26.251.180:8086/"+ url;
const baseUrl = "https://pk.zhukeping.com/"+ url;
// const baseUrl = "http://120.26.251.180:8086/"+ url;
// const baseUrl = "http://192.168.1.218:8086/"+ url;
if (userInfo) {
return new Promise((resolve, reject) => {