index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <el-dialog
  3. title="投诉提醒"
  4. :visible.sync="visible"
  5. width="480px"
  6. :close-on-click-modal="false"
  7. :show-close="true"
  8. custom-class="complaint-msg-dialog"
  9. @close="handleClose"
  10. center
  11. >
  12. <div class="msg-content">
  13. <div class="msg-icon">
  14. <i class="el-icon-warning-outline"></i>
  15. </div>
  16. <div class="msg-text">
  17. <h3>{{ msgData.title }}</h3>
  18. <p>{{ msgData.content }}</p>
  19. <div class="msg-stats">
  20. <div class="stat-item">
  21. <span class="stat-label">未处理消息</span>
  22. <span class="stat-value">{{ unreadCount }}条</span>
  23. </div>
  24. <div class="stat-item">
  25. <span class="stat-label">未处理率</span>
  26. <span class="stat-value percent">{{ unreadPercent }}%</span>
  27. </div>
  28. </div>
  29. <div class="msg-time" v-if="msgData.createTime">
  30. <i class="el-icon-time"></i>
  31. {{ msgData.createTime }}
  32. </div>
  33. </div>
  34. </div>
  35. <span slot="footer" class="dialog-footer">
  36. <el-button @click="handleKnow" size="medium">
  37. <i class="el-icon-check"></i> 知道了
  38. </el-button>
  39. <el-button type="primary" @click="handleGoProcess" size="medium">
  40. <i class="el-icon-right"></i> 去处理
  41. </el-button>
  42. </span>
  43. </el-dialog>
  44. </template>
  45. <script>
  46. import { getLatestUnreadMsg, markAsRead } from '@/api/crm/complaintMsg'
  47. export default {
  48. name: 'ComplaintMsgDialog',
  49. data() {
  50. return {
  51. visible: false,
  52. msgData: {
  53. msgId: null,
  54. title: '',
  55. content: '',
  56. actionUrl: '',
  57. createTime: ''
  58. },
  59. unreadCount: 0,
  60. totalCount: 0
  61. }
  62. },
  63. computed: {
  64. unreadPercent() {
  65. if (this.totalCount === 0) return 0
  66. return Math.round((this.unreadCount / this.totalCount) * 100)
  67. }
  68. },
  69. methods: {
  70. checkNewMsg() {
  71. getLatestUnreadMsg().then(res => {
  72. if (res.code === 200 && res.data) {
  73. if (res.data.msg) {
  74. this.msgData = res.data.msg
  75. this.unreadCount = res.data.unreadCount || 0
  76. this.totalCount = res.data.totalCount || 0
  77. this.visible = true
  78. }
  79. }
  80. }).catch(err => {
  81. console.error('获取投诉消息失败:', err)
  82. })
  83. },
  84. handleKnow() {
  85. this.visible = false
  86. },
  87. handleGoProcess() {
  88. if (this.msgData.msgId) {
  89. markAsRead(this.msgData.msgId).then(() => {
  90. this.visible = false
  91. this.$emit('msg-read')
  92. this.navigateToUrl('/course/userCourseComplaintRecord')
  93. setTimeout(() => {
  94. this.checkNewMsg()
  95. }, 500)
  96. })
  97. } else {
  98. this.visible = false
  99. this.navigateToUrl('/course/userCourseComplaintRecord')
  100. }
  101. },
  102. navigateToUrl(url) {
  103. if (url.endsWith('/index')) {
  104. url = url.slice(0, -6)
  105. }
  106. if (!url.startsWith('/')) {
  107. url = '/' + url
  108. }
  109. this.$router.push(url).catch(err => {
  110. console.error('路由跳转失败:', err)
  111. })
  112. },
  113. handleClose() {
  114. this.visible = false
  115. },
  116. show() {
  117. this.checkNewMsg()
  118. }
  119. }
  120. }
  121. </script>
  122. <style scoped>
  123. .complaint-msg-dialog {
  124. border-radius: 12px;
  125. overflow: hidden;
  126. }
  127. .msg-content {
  128. display: flex;
  129. align-items: flex-start;
  130. padding: 24px 16px;
  131. }
  132. .msg-icon {
  133. flex-shrink: 0;
  134. width: 56px;
  135. height: 56px;
  136. border-radius: 50%;
  137. background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. margin-right: 20px;
  142. box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
  143. }
  144. .msg-icon i {
  145. font-size: 28px;
  146. color: #fff;
  147. animation: shake 0.5s ease-in-out infinite;
  148. }
  149. @keyframes shake {
  150. 0%, 100% {
  151. transform: translateX(0);
  152. }
  153. 25% {
  154. transform: translateX(-3px);
  155. }
  156. 75% {
  157. transform: translateX(3px);
  158. }
  159. }
  160. .msg-text {
  161. flex: 1;
  162. }
  163. .msg-text h3 {
  164. margin: 0 0 12px 0;
  165. font-size: 18px;
  166. font-weight: 600;
  167. color: #303133;
  168. }
  169. .msg-text p {
  170. margin: 0 0 12px 0;
  171. font-size: 14px;
  172. color: #606266;
  173. line-height: 1.6;
  174. }
  175. .msg-stats {
  176. display: flex;
  177. gap: 20px;
  178. margin-bottom: 12px;
  179. padding: 12px;
  180. background: #fef0f0;
  181. border-radius: 8px;
  182. }
  183. .stat-item {
  184. display: flex;
  185. flex-direction: column;
  186. align-items: center;
  187. }
  188. .stat-label {
  189. font-size: 12px;
  190. color: #909399;
  191. margin-bottom: 4px;
  192. }
  193. .stat-value {
  194. font-size: 20px;
  195. font-weight: 600;
  196. color: #f56c6c;
  197. }
  198. .stat-value.percent {
  199. color: #e6a23c;
  200. }
  201. .msg-time {
  202. font-size: 12px;
  203. color: #909399;
  204. display: flex;
  205. align-items: center;
  206. }
  207. .msg-time i {
  208. margin-right: 4px;
  209. }
  210. .dialog-footer {
  211. text-align: center;
  212. padding: 10px 20px 20px;
  213. }
  214. .dialog-footer .el-button {
  215. min-width: 100px;
  216. }
  217. .dialog-footer .el-button i {
  218. margin-right: 4px;
  219. }
  220. </style>
  221. <style>
  222. .complaint-msg-dialog .el-dialog__header {
  223. background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
  224. padding: 16px 20px;
  225. }
  226. .complaint-msg-dialog .el-dialog__title {
  227. color: #fff;
  228. font-size: 16px;
  229. font-weight: 600;
  230. }
  231. .complaint-msg-dialog .el-dialog__headerbtn .el-dialog__close {
  232. color: #fff;
  233. font-size: 18px;
  234. }
  235. .complaint-msg-dialog .el-dialog__body {
  236. padding: 0;
  237. }
  238. </style>