diff --git a/public/favicon1.ico b/public/favicon1.ico deleted file mode 100644 index e263760..0000000 Binary files a/public/favicon1.ico and /dev/null differ diff --git a/src/api/home/home.js b/src/api/home/home.js index b0517c6..57b118a 100644 --- a/src/api/home/home.js +++ b/src/api/home/home.js @@ -1,5 +1,12 @@ import request from '@/utils/request'; +// 首页获取所有轮播 +export function getRotationList(params) { + return request({ + url: '/mobile/list', + params + }); +} // 首页获取政策列表 export function getPolicy(params) { return request({ diff --git a/src/assets/logo/logo3.png b/src/assets/logo/logo3.png deleted file mode 100644 index e263760..0000000 Binary files a/src/assets/logo/logo3.png and /dev/null differ diff --git a/src/utils/auth.js b/src/utils/auth.js index 08a43d6..1fc39af 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,15 +1,15 @@ -import Cookies from 'js-cookie' +import Cookies from 'js-cookie'; -const TokenKey = 'Admin-Token' +const TokenKey = 'Web-Token'; export function getToken() { - return Cookies.get(TokenKey) + return Cookies.get(TokenKey); } export function setToken(token) { - return Cookies.set(TokenKey, token) + return Cookies.set(TokenKey, token); } export function removeToken() { - return Cookies.remove(TokenKey) + return Cookies.remove(TokenKey); } diff --git a/src/views/customerService.vue b/src/views/customerService.vue index 22d4aaa..7858498 100644 --- a/src/views/customerService.vue +++ b/src/views/customerService.vue @@ -70,14 +70,14 @@ export default { queryParams: { userId: '1385154178159804416', pageNum: 1, - pageSize: 10, + pageSize: 10 }, msgTotal: 0, // 待发送信息 message: '', // 聊天记录 chats: [], - isLoading: 0, //是否正在加载中,0否1是 + isLoading: 0 //是否正在加载中,0否1是 }; }, created() {}, @@ -85,7 +85,7 @@ export default { this.init(); }, methods: { - init: function () { + init: function() { if (typeof WebSocket === 'undefined') { alert('您的浏览器不支持socket'); } else { @@ -104,7 +104,7 @@ export default { console.log('socket连接成功'); this.getMsgList(true); }, - error: function () { + error: function() { if (!this.$store.state.user.userId) { this.msgError('请先登录'); } else { @@ -114,12 +114,50 @@ export default { getMessage(msg) { console.log(JSON.parse(msg.data)); const msgInfo = JSON.parse(msg.data); + let that = this; + if (!('Notification' in window)) { + console.log('浏览器不支持消息通知'); + return; + } + Notification.requestPermission(function(permission) { + //如果不是当前页面,标题栏闪动+消息提示 + if (document.hidden) { + var options = { + body: '您有新的未读消息,请及时处理', + silent: true + }; + var notification = new Notification('消息通知', options); + notification.onclick = function() { + window.open(`/customerService`, '_blank'); + }; + //标题栏闪动 + var defaultTitle = document.title; + if (that.isReceive) { + return; + } else { + that.isReceive = true; + } + that.timer = setInterval(function() { + var title = document.title; + if (document.hidden && that.isReceive) { + if (/你有新消息/.test(title) == false) { + document.title = '【你有新消息】'; + } else { + document.title = defaultTitle; + } + } else { + that.isReceive = false; + document.title = defaultTitle; + } + }, 500); + } + }); this.chats.push(msgInfo); }, - send: function (params) { + send: function(params) { this.socket.send(params); }, - close: function () { + close: function() { console.log('socket已经关闭'); }, scroll(e) { @@ -138,11 +176,11 @@ export default { getMsgList(flag) { this.isLoading = 1; getChatRecords(this.queryParams).then(({ data }) => { - data.list.map((item) => { + data.list.map(item => { item.sendTime = new Date(item.sendTime).getTime(); }); // 时间戳排序 - data.list.sort(function (a, b) { + data.list.sort(function(a, b) { return a.sendTime > b.sendTime ? 1 : -1; }); this.chats = [...data.list, ...this.chats]; @@ -208,7 +246,7 @@ export default { this.chats.push({ type: 'leftinfo', sendText: this.message, - msgTime: this.getTodayTime(), + msgTime: this.getTodayTime() }); this.chatWindowActive(); let message = this.message; @@ -217,18 +255,18 @@ export default { sendMsg({ sendText: message, receiverUserId: '1385154178159804416', - type: 'leftinfo', - }).then((res) => { + type: 'leftinfo' + }).then(res => { console.log(res); this.isLoading = 0; }); - }, + } }, destroyed() { console.log('out'); // 销毁监听 this.socket.onclose = this.close; - }, + } }; @@ -268,6 +306,8 @@ export default { -ms-user-select: none; user-select: none; img { + background-color: #ffffff; + border-radius: 50%; width: 42px; height: 42px; display: block; @@ -337,9 +377,10 @@ export default { width: 45px; height: 45px; border-radius: 50%; - // background-color: #ffffff; + background-color: #ffffff; background-image: url('~@/assets/logo/logo.png'); - background-size: cover; + // background-size: cover; + background-size: 50% 50%; background-position: center; background-repeat: no-repeat; margin-right: 10px; diff --git a/src/views/home/achievements.vue b/src/views/home/achievements.vue index 3e55027..2018a87 100644 --- a/src/views/home/achievements.vue +++ b/src/views/home/achievements.vue @@ -268,7 +268,8 @@ export default { padding: 15px; margin-top: 30px; .screen_item_l { - width: 225px; + width: 300px; + height: 160px; img { width: 100%; height: 100%; @@ -282,6 +283,7 @@ export default { font-weight: bold; color: #ffa32c; padding: 10px 0; + text-align: left; } .text { font-size: 14px; diff --git a/src/views/home/home.vue b/src/views/home/home.vue index 619525b..d20abdc 100644 --- a/src/views/home/home.vue +++ b/src/views/home/home.vue @@ -5,8 +5,15 @@