12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import axios from '../http'
- import { cryptoMsg } from '@/util/util.js'
- import Message from '@/store/db/Message.js'
- export default {
- /**
- * 用户最新消息
- * @param {Object} data
- * @param {String} data.group_id
- * @param {String} data.client_hash // 客户端最新消息hash
- */
- async getNewMsg (params) {
- let res = await axios.request({
- url: 'person/newMsg',
- method: 'get',
- needLogin: true,
- params
- })
- const objMessage = new Message()
- // 如果不同步执行,第一次初始化数据库会出现很奇怪的问题...
- await objMessage.saveMsg(params['session_id'], res.data.data)
- return res
- },
- /**
- * 用户历史消息
- * @param {Object} data
- * @param {String} data.group_id
- * @param {String} data.client_hash // 客户端最旧消息hash
- */
- getHistoryMsg (params) {
- return axios.request({
- url: 'person/historyMsg',
- method: 'get',
- needLogin: true,
- params
- })
- },
- /**
- * 发送私聊信息
- * @param {Object} data
- * @param {Number} data.session_id 会话id
- * @param {Number} data.msg_type 消息类型:0:文本,1:图片,2:视频
- * @param {String} data.msg 内容
- */
- sendMsg (data) {
- data.msg = cryptoMsg(data.msg)
- return axios.request({
- url: 'person/sendMsg',
- method: 'post',
- needLogin: true,
- data
- })
- },
- /**
- * 发送私聊信息
- * @param {Object} data
- * @param {String} data.session_id 会话id
- * @param {String} data.hash 会话hash
- */
- repealPersonMsg (data) {
- return axios.request({
- url: 'person/repealMsg',
- method: 'post',
- needLogin: true,
- data
- })
- }
- }
|