| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import {
- showToast
- } from '../../utils/tips.js'
- import {
- imgServerUrl
- } from '../../config/config.js'
- Page({
- data: {
- historyList: [],
- searchVal: '',
- searchKey: [],
- imgServerUrl: imgServerUrl,
- hotSearch: [
- {
- id: 0,
- searchVal: '返费'
- },
- {
- id: 1,
- searchVal: '工资日结'
- }
- ]
- },
- onLoad: function () {
- },
- onShow: function () {
- let cityName = wx.getStorageSync('city') || '无锡';
- let cityCode = wx.getStorageSync('cityCode') || '320200';
- this.setData({
- cityName: cityName,
- cityCode: cityCode
- })
- this.fetchData()
- },
- // 返回上级页面
- back() {
- wx.navigateBack({
- delta: 1,
- })
- },
- //获取历史记录
- fetchData() {
- var searchKey = wx.getStorageSync("searchKey");
- if (searchKey) {
- this.setData({
- searchKey: searchKey
- })
- }
- },
- //删除历史记录
- delHistory(e) {
- let title = "删除提示"
- let content = "";
- content = "是否清除历史记录"
- wx.showModal({
- title: title,
- content: content,
- success: (res) => {
- if (res.confirm) {
- wx.removeStorageSync("searchKey");
- showToast("删除成功");
- this.setData({
- searchKey: []
- })
- }
- }
- })
- },
- // 搜索框输入值
- 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
- if (!searchKey.map(value => value.searchVal).includes(this.data.searchVal)) {
- searchKey.push(key);
- wx.setStorageSync("searchKey", searchKey);
- }
- }
- wx.navigateTo({
- url: '../search-result/search-result?searchVal=' + this.data.searchVal,
- success: () => {
- this.setData({
- searchVal: ''
- })
- }
- })
- },
- })
|