zxl
2025-05-23 5d5b0f7ab0f34019e11901ddcd59cd8b51ea9ff9
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<template>
  <div class="lum-dialog-mask">
    <el-container class="lum-dialog-box" v-outside="closeBox">
      <el-header class="no-padding header" height="50px">
        <p>系统表情</p>
        <p class="tools">
          <i class="el-icon-close" @click="closeBox" />
        </p>
      </el-header>
 
      <el-main class="no-padding mian lum-scrollbar">
        <ul>
          <li v-for="(item, i) in items" :key="item.id" class="no-select">
            <div class="pkg-avatar">
              <el-image :src="item.icon" fit="cover" :lazy="true" />
            </div>
            <div class="pkg-info" v-text="item.name"></div>
            <div class="pkg-status">
              <button
                :class="{
                  'add-emoji': item.status == 0,
                  'remove-emoji': item.status != 0,
                }"
                @click="setEmoticon(i, item, item.status == 0 ? 1 : 2)"
              >
                {{ item.status == 0 ? '添加' : '移除' }}
              </button>
            </div>
          </li>
        </ul>
      </el-main>
 
      <el-footer class="footer" height="50px">
        <el-button type="primary" size="medium" class="btn" @click="closeBox">
          关闭窗口
        </el-button>
      </el-footer>
    </el-container>
  </div>
</template>
 
<script>
import { ServeFindSysEmoticon, ServeSetUserEmoticon } from '@/api/emoticon'
 
export default {
  name: 'MeEditorSystemEmoticon',
  data() {
    return {
      items: [],
    }
  },
  created() {
    this.loadSysEmoticon()
  },
  methods: {
    closeBox() {
      this.$emit('close')
    },
 
    // 获取系统表情包列表
    loadSysEmoticon() {
      ServeFindSysEmoticon().then(res => {
        if (res.code == 200) {
          this.items = res.data
        }
      })
    },
 
    setEmoticon(index, item, type) {
      ServeSetUserEmoticon({
        emoticon_id: item.id,
        type: type,
      }).then(res => {
        if (res.code == 200) {
          if (type == 1) {
            this.items[index].status = 1
            this.$store.commit('APPEND_SYS_EMOTICON', res.data)
          } else {
            this.items[index].status = 0
            this.$store.commit('REMOVE_SYS_EMOTICON', {
              emoticon_id: item.id,
            })
          }
        }
      })
    },
  },
}
</script>
<style lang="less" scoped>
.lum-dialog-box {
  width: 350px;
  max-width: 350px;
  height: 500px;
 
  .mian {
    height: 480px;
    overflow-y: auto;
 
    li {
      display: flex;
      cursor: pointer;
      height: 68px;
      align-items: center;
      border-bottom: 3px solid #fbf2fb;
      padding-left: 5px;
 
      .pkg-avatar {
        flex-shrink: 0;
 
        .el-image {
          width: 50px;
          height: 50px;
          border-radius: 3px;
        }
      }
 
      .pkg-info {
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin-left: 14px;
        margin-right: 14px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        width: 200px;
        color: #615d5d;
        font-size: 13px;
      }
 
      .pkg-status {
        flex-shrink: 0;
 
        button {
          font-size: 12px;
          text-align: center;
          line-height: 28px;
          border-radius: 20px;
          width: 50px;
          cursor: pointer;
          color: white;
        }
 
        .add-emoji {
          background-color: #38adff;
        }
 
        .remove-emoji {
          background-color: #ff5722;
        }
      }
    }
  }
 
  .footer {
    height: 50px;
    background: rgba(247, 245, 245, 0.66);
    text-align: center;
    line-height: 50px;
 
    .btn {
      width: 150px;
      border-radius: 2px;
    }
  }
}
</style>