语音消息发送成功,播放暂时不支持带token的路径

This commit is contained in:
2022-01-30 17:46:36 +08:00
parent 3ae6ab881b
commit 83061d7c8e
4 changed files with 585 additions and 476 deletions

View File

@@ -4,7 +4,7 @@
* 碌碌无为枉半生,一朝惊醒万事空。
* moduleName: 聊聊
*/
import store from '@/store'
import {
request
} from '../index'
@@ -84,9 +84,9 @@ const pedingFriend = (recipient) => {
url: 'im/friends/' + recipient
})
}
/**
* 好友申请数量
/**
* 好友申请数量
*/
const getPendingCount = () => {
return request({
@@ -94,6 +94,49 @@ const getPendingCount = () => {
})
}
/**
* 上传聊天附件
* 图片
* 语音
* 视频
*/
// 基础配置
const config = {
apiUrl: 'http://api.zh.shangkelian.cn/api/', // 正式环境
timeout: 60000
}
const uploadMessageFile = (file, type) => {
config.header = {
'Accept': 'application/json',
'Authorization': store.getters.getToken || ''
}
return new Promise((resolve, reject) => {
uni.uploadFile({
url: config.apiUrl + 'im/upload',
filePath: file,
name: 'upload',
formData: {
type
},
header: config.header || {},
success: (res) => {
if (res.statusCode === 200) {
let updData = JSON.parse(res.data)
if (updData.status_code === 200) {
resolve(updData.data)
} else {
reject(updData)
}
}
},
fail: (err) => {
console.log('ERR', err);
}
})
})
}
export {
getImToken,
deleteFriend,
@@ -105,5 +148,6 @@ export {
rejectFriend,
searchFriend,
pedingFriend,
getPendingCount
getPendingCount,
uploadMessageFile
}