优化
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
// 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.jpg,a/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
|
||||
@@ -41,6 +41,10 @@ export function getConversationList(goeasy) {
|
||||
},
|
||||
onFailed: function (error) { //获取失败
|
||||
console.log("获取会话列表失败, code:" + error.code + " content:" + error.content);
|
||||
uni.showToast({
|
||||
title: "获取会话列表失败",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -61,6 +65,10 @@ export function getConversationMessages(goeasy, userid, imestamp) {
|
||||
}, //查询成功
|
||||
onFailed: function (error) {
|
||||
console.log("获取消息列表失败, code:" + error.code + " content:" + error.content);
|
||||
uni.showToast({
|
||||
title: "获取消息列表失败",
|
||||
icon: "none",
|
||||
});
|
||||
}, //查询失败
|
||||
});
|
||||
});
|
||||
@@ -88,6 +96,10 @@ export function sendMessage(goeasy, userid, message, avatar, nickname) {
|
||||
},
|
||||
onFailed: function (error) { //发送失败
|
||||
console.log('发送消息失败,code:' + error.code + ' ,error ' + error.content);
|
||||
uni.showToast({
|
||||
title: "发送消息失败",
|
||||
icon: "none",
|
||||
});
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
@@ -107,6 +119,10 @@ export function messageRead(goeasy, userid) {
|
||||
},
|
||||
onFailed: function (error) {
|
||||
console.log('标记私聊已读失败', error);
|
||||
uni.showToast({
|
||||
title: "标记私聊已读失败",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -135,6 +151,10 @@ export function sendCustomMessage(goeasy, type, userid, order, avatar, nickname)
|
||||
},
|
||||
onFailed: function (error) { //发送失败
|
||||
console.log('Failed to send message,code:' + error.code + ',error' + error.content);
|
||||
uni.showToast({
|
||||
title: "发送自定义消息失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -146,14 +166,18 @@ export function conversationTop(goeasy, conversation, top) {
|
||||
var im = goeasy.im;
|
||||
im.topConversation({
|
||||
conversation: conversation,
|
||||
top:top ,//或者 false
|
||||
top: top,//或者 false
|
||||
onSuccess: function () {
|
||||
resolve('成功');
|
||||
},
|
||||
onFailed: function (error) {
|
||||
console.log( '失败:', error);
|
||||
console.log('失败:', error);
|
||||
uni.showToast({
|
||||
title: "置顶会话失败",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
//删除会话
|
||||
@@ -166,8 +190,32 @@ export function conversationDelete(goeasy, conversation) {
|
||||
resolve('删除会话成功');
|
||||
},
|
||||
onFailed: function (error) {
|
||||
console.log(error);
|
||||
console.log(error);
|
||||
uni.showToast({
|
||||
title: "删除会话失败",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//发送消息
|
||||
export function sendGroupMessage(goeasy, message) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var im = goeasy.im;
|
||||
//发送消息
|
||||
im.sendMessage({
|
||||
message: message,
|
||||
onSuccess: () => {
|
||||
resolve(message);
|
||||
},
|
||||
onFailed: function (error) {
|
||||
uni.showToast({
|
||||
title: "发送消息失败",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
// 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.jpg,a/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
|
||||
Reference in New Issue
Block a user