From 639bcd484829cd6065f7d3911aff82a2a8ae50c5 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Wed, 3 Jul 2024 16:45:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E4=B8=BAcookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Im.vue | 15 --------------- src/views/UserList.vue | 20 +++++++++++--------- src/views/VideoList.vue | 11 ++++------- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/views/Im.vue b/src/views/Im.vue index dc43739..087b9d3 100644 --- a/src/views/Im.vue +++ b/src/views/Im.vue @@ -95,21 +95,6 @@ export default { if (typeof WebSocket == "undefined") { console.log("您的浏览器不支持WebSocket"); } else { - // 组装待发送的消息 json - // {"type":"msg","data":"hello","to_user_id":1,"from_user_id":2002,"session":"11917957"} - // let message = { - // type: "msg", - // data: "hello", - // to_user_id: this.to_user_id, - // from_user_id: this.tokenData.userId, - // session: this.session, - // }; - // let json=JSON.stringify(message) - // var aesEnc = await this.aesEncrypt( - // this.text, - // this.imKey, - // this.session - // ); var aesEnc = await this.aesEncrypt(this.text, this.imKey, this.imKey); let data = '{"type":"msg","data":"' + diff --git a/src/views/UserList.vue b/src/views/UserList.vue index e87e431..adaa46c 100644 --- a/src/views/UserList.vue +++ b/src/views/UserList.vue @@ -2,12 +2,14 @@ import axios from "axios"; import { SearchUserService } from "@/api/user.js"; import router from "@/router/index.js"; - +import Cookies from "js-cookie"; export default { data() { return { ip: "", tableData: [], + search_id: 2002, + keyword: "", tokenData: { token: localStorage.getItem("token"), ip: localStorage.getItem("ip"), @@ -25,17 +27,15 @@ export default { async getUserList() { let result = {}; try { + this.tokenData.id = this.search_id; + this.tokenData.keyword = this.keyword; + Cookies.set("search_id", this.search_id); + Cookies.set("keyword", this.keyword); result = await SearchUserService(this.tokenData); } catch (e) { console.log(e); } let data = result.data; - - // for(let d in data){ - // let res = JSON.parse(d); - // console.log("res=",res); - // this.tableData.push(res); - // } this.tableData = data; }, onSubmit() { @@ -91,6 +91,8 @@ export default { if (localStorage.getItem("token") === null) { router.push("/login"); } + this.search_id = Cookies.get("search_id")?cookies.get("search_id"):2002; + this.keyword = Cookies.get("keyword")?cookies.get("keyword"):""; }, }; @@ -125,14 +127,14 @@ export default { diff --git a/src/views/VideoList.vue b/src/views/VideoList.vue index 443459b..dd785c1 100644 --- a/src/views/VideoList.vue +++ b/src/views/VideoList.vue @@ -5,13 +5,6 @@ import { delayVideoService } from "@/api/video.js"; import router from "@/router/index.js"; export default { - // data() 返回的属性将会成为响应式的状态 - // 并且暴露在 `this` 上 - // setup: function() { - // const globalData = inject("globalData"); - // const token = globalData.token; - // return { token }; - // }, data() { return { ip: "", @@ -38,6 +31,9 @@ export default { async getVideoList() { let result = {}; try { + if(this.tokenData.entrydate.length > 0) { + Cookies.set("entrydate", this.tokenData.entrydate); + } result = await getVideoListService(this.tokenData); } catch (e) { console.log(e); @@ -212,6 +208,7 @@ export default { } // console.log("mounted"); await this.getIpClient(); + this.tokenData.entrydate = Cookies.get("entrydate")? Cookies.get("entrydate"): []; this.getVideoList(); }, };