将搜索条件存储为cookie

This commit is contained in:
junleea 2024-07-03 16:45:28 +08:00
parent 5d111c8642
commit 639bcd4848
3 changed files with 15 additions and 31 deletions

View File

@ -95,21 +95,6 @@ export default {
if (typeof WebSocket == "undefined") { if (typeof WebSocket == "undefined") {
console.log("您的浏览器不支持WebSocket"); console.log("您的浏览器不支持WebSocket");
} else { } 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); var aesEnc = await this.aesEncrypt(this.text, this.imKey, this.imKey);
let data = let data =
'{"type":"msg","data":"' + '{"type":"msg","data":"' +

View File

@ -2,12 +2,14 @@
import axios from "axios"; import axios from "axios";
import { SearchUserService } from "@/api/user.js"; import { SearchUserService } from "@/api/user.js";
import router from "@/router/index.js"; import router from "@/router/index.js";
import Cookies from "js-cookie";
export default { export default {
data() { data() {
return { return {
ip: "", ip: "",
tableData: [], tableData: [],
search_id: 2002,
keyword: "",
tokenData: { tokenData: {
token: localStorage.getItem("token"), token: localStorage.getItem("token"),
ip: localStorage.getItem("ip"), ip: localStorage.getItem("ip"),
@ -25,17 +27,15 @@ export default {
async getUserList() { async getUserList() {
let result = {}; let result = {};
try { 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); result = await SearchUserService(this.tokenData);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
let data = result.data; 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; this.tableData = data;
}, },
onSubmit() { onSubmit() {
@ -91,6 +91,8 @@ export default {
if (localStorage.getItem("token") === null) { if (localStorage.getItem("token") === null) {
router.push("/login"); router.push("/login");
} }
this.search_id = Cookies.get("search_id")?cookies.get("search_id"):2002;
this.keyword = Cookies.get("keyword")?cookies.get("keyword"):"";
}, },
}; };
</script> </script>
@ -125,14 +127,14 @@ export default {
<!-- 搜索与添加区域 --> <!-- 搜索与添加区域 -->
<el-input <el-input
placeholder="请输入ID" placeholder="请输入ID"
v-model="tokenData.id" v-model="search_id"
clearable clearable
@clear="getUserList" @clear="getUserList"
> >
</el-input> </el-input>
<el-input <el-input
placeholder="请输入关键字" placeholder="请输入关键字"
v-model="tokenData.keyword" v-model="keyword"
clearable clearable
@clear="getUserList" @clear="getUserList"
> >

View File

@ -5,13 +5,6 @@ import { delayVideoService } from "@/api/video.js";
import router from "@/router/index.js"; import router from "@/router/index.js";
export default { export default {
// data()
// `this`
// setup: function() {
// const globalData = inject("globalData");
// const token = globalData.token;
// return { token };
// },
data() { data() {
return { return {
ip: "", ip: "",
@ -38,6 +31,9 @@ export default {
async getVideoList() { async getVideoList() {
let result = {}; let result = {};
try { try {
if(this.tokenData.entrydate.length > 0) {
Cookies.set("entrydate", this.tokenData.entrydate);
}
result = await getVideoListService(this.tokenData); result = await getVideoListService(this.tokenData);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
@ -212,6 +208,7 @@ export default {
} }
// console.log("mounted"); // console.log("mounted");
await this.getIpClient(); await this.getIpClient();
this.tokenData.entrydate = Cookies.get("entrydate")? Cookies.get("entrydate"): [];
this.getVideoList(); this.getVideoList();
}, },
}; };