1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
| import { ServeFindUserEmoticon, ServeUploadEmoticon } from "@/api/emoticon";
|
| import { ServeCollectEmoticon } from "@/api/chat";
|
| import { Notification } from "element-ui";
|
| export default {
| state: {
| items: [
| ],
| },
| mutations: {
| // 加载用户表情包
| LOAD_USER_EMOTICON(state) {
| // TODO 隐藏
| return;
| ServeFindUserEmoticon().then((res) => {
| if (res.code == 200) {
| const { collect_emoticon, sys_emoticon } = res.data;
|
| state.items = state.items.slice(0, 2);
|
| // 用户收藏的系统表情包
| state.items[1].list = collect_emoticon;
|
| // 用户添加的系统表情包
| state.items.push(...sys_emoticon);
| }
| });
| },
|
| // 收藏用户表情包
| SAVE_USER_EMOTICON(state, resoure) {
| ServeCollectEmoticon({
| record_id: resoure.record_id,
| })
| .then((res) => {
| if (res.code == 200) {
| Notification({
| title: "收藏提示",
| message: "表情包收藏成功...",
| type: "success",
| });
|
| this.commit("LOAD_USER_EMOTICON");
| }
| })
| .catch(() => {
| Notification({
| title: "收藏提示",
| message: "表情包收藏失败...",
| type: "warning",
| });
| });
| },
|
| // 自定义上传用户表情包
| UPLOAD_USER_EMOTICON(state, resoure) {
| let fileData = new FormData();
| fileData.append("emoticon", resoure.file);
| ServeUploadEmoticon(fileData)
| .then((res) => {
| if (res.code == 200) {
| state.items[1].list.push(res.data);
| }
| })
| .catch(() => {
| Notification({
| message: "网络异常请稍后再试...",
| type: "error",
| duration: 3000,
| });
| });
| },
|
| // 添加系统表情包
| APPEND_SYS_EMOTICON(state, resoure) {
| state.items.push(resoure);
| },
|
| // 移除系统表情包
| REMOVE_SYS_EMOTICON(state, resoure) {
| for (let i in state.items) {
| if (state.items[i].emoticon_id === resoure.emoticon_id) {
| state.items.splice(i, 1);
| break;
| }
| }
| },
| },
| };
|
|