diff --git a/pages/plugins/video/search/search-record.vue b/pages/plugins/video/search/search-record.vue index 6c884ab8..5c0cdb8d 100644 --- a/pages/plugins/video/search/search-record.vue +++ b/pages/plugins/video/search/search-record.vue @@ -147,7 +147,7 @@ export default { menu_button_info: menu_button_info }); // 搜索历史记录 - this.search_history = uni.getStorageSync('search_history_key') || []; + this.search_history = uni.getStorageSync('cache_plugins_video_search_history_key') || []; if (this.search_history.length > 0) { this.show_search_history = this.search_history.filter((item, index) => index < 5); } else { @@ -193,7 +193,7 @@ export default { // 保存搜索历史记录 if (!isEmpty(e) && !this.search_history.includes(e)) { this.search_history.push(e); - uni.setStorageSync('search_history_key', this.search_history); + uni.setStorageSync('cache_plugins_video_search_history_key', this.search_history); } this.search_query = e; // 跳转到搜索页 @@ -212,7 +212,7 @@ export default { this.search_history.splice(newIndex, 1); } this.show_search_history.splice(index, 1); - uni.setStorageSync('search_history_key', this.search_history); + uni.setStorageSync('cache_plugins_video_search_history_key', this.search_history); }, perform_url(e) { const url = e?.currentTarget?.dataset?.url || ''; @@ -235,7 +235,7 @@ export default { }); }, clear_history() { - uni.setStorageSync('search_history_key', []); + uni.setStorageSync('cache_plugins_video_search_history_key', []); this.setData({ search_history: [], show_search_history: [], diff --git a/pages/plugins/video/search/search.vue b/pages/plugins/video/search/search.vue index 26f44485..fb3e1e0b 100644 --- a/pages/plugins/video/search/search.vue +++ b/pages/plugins/video/search/search.vue @@ -154,7 +154,8 @@ export default { data_tabs_loding_status: 1, data_tabs_loding_msg: '', data_list_loding_status: 1, - data_list_loding_msg: '' + data_list_loding_msg: '', + search_history: [], }; }, onLoad(params) { @@ -207,6 +208,8 @@ export default { }) .exec(); // 执行查询 }, 500); + this.search_history = uni.getStorageSync('cache_plugins_video_search_history_key') || []; + // 初始化搜索页数据 this.init_data(); }, @@ -263,6 +266,10 @@ export default { data_list_loding_status: 1, recommend_videos: [] }) + if (!isEmpty(e) && !this.search_history.includes(e)) { + this.search_history.push(e); + uni.setStorageSync('cache_plugins_video_search_history_key', this.search_history); + } // 更新数据信息 this.load_recommend_videos(); },