| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import {
- searchHistory,
- deleteHistory,
- getIndexList
- } from '../../services/index.js'
- import {
- showToast
- } from '../../utils/tips.js'
- import {
- updataStorageData
- } from '../../utils/storage.js'
- Page({
- data: {
- historyList: [],
- searchVal: '',
- searchKey: [],
- },
- onLoad: function(options) {
- },
- onShow: function() {
- this.fetchData()
- },
- //获取历史记录
- fetchData() {
- var searchKey = wx.getStorageSync("searchKey");
- console.log("ll", searchKey);
- if (searchKey) {
- this.setData({
- searchKey: searchKey
- })
- }
- },
- //删除历史记录
- delHistory(e) {
- console.log(e)
- let id = e.currentTarget.dataset.id
- let title = "删除提示"
- let content = "";
- content = "是否清除历史记录"
- wx.showModal({
- title: title,
- content: content,
- success: (res) => {
- if (res.confirm) {
- wx.removeStorageSync("searchKey");
- showToast("删除成功");
- this.onShow();
- }
- }
- })
- },
- // 搜索框输入值
- bindKeyInput(e) {
- this.data.searchVal = e.detail.value;
- },
- // 点击搜索记录
- selectMsg(e) {
- this.data.searchVal = e.currentTarget.dataset.value
- this.toSearchPage(1);
- },
- //搜索
- toSearchPage(type) {
- if (!this.data.searchVal) {
- showToast("请输入搜索内容");
- return;
- }
- if (type == 1) {
- } else {
- var key = {};
- key.id = this.data.searchKey.length;
- key.searchVal = this.data.searchVal;
- let searchKey = this.data.searchKey
- searchKey.push(key);
- wx.setStorageSync("searchKey", searchKey);
- }
- wx.navigateTo({
- url: '../search-result/search-result?searchVal=' + this.data.searchVal,
- })
- },
- })
|