From 5ee272fbdbee18161362d68499673def0ccb2968 Mon Sep 17 00:00:00 2001 From: Cxpller Date: Mon, 16 Oct 2023 23:21:14 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods/search/index.js | 57 ++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/pages/goods/search/index.js b/pages/goods/search/index.js index b5f34ee..5b4fbe6 100644 --- a/pages/goods/search/index.js +++ b/pages/goods/search/index.js @@ -1,7 +1,15 @@ -import { getHistorySearchList } from '~/services/home/getHistorySearchList'; -import { getHotSearchList } from '~/services/home/getHotSearchList'; -import { addHistorySearch } from '~/services/home/addHistorySearch'; -import { deleteHistorySearch } from '~/services/home/deleteHistorySearch'; +import { + getHistorySearchList +} from '~/services/home/getHistorySearchList'; +import { + getHotSearchList +} from '~/services/home/getHotSearchList'; +import { + addHistorySearch +} from '~/services/home/addHistorySearch'; +import { + deleteHistorySearch +} from '~/services/home/deleteHistorySearch'; Page({ data: { @@ -56,8 +64,13 @@ Page({ }, confirm() { - const { historyWords } = this.data; - const { deleteType, deleteIndex } = this; + const { + historyWords + } = this.data; + const { + deleteType, + deleteIndex + } = this; // console.log('deleteType', deleteType, 'deleteIndex', deleteIndex); // console.log(historyWords); if (deleteType === 0) { @@ -83,7 +96,9 @@ Page({ }, handleClearHistory() { - const { dialog } = this.data; + const { + dialog + } = this.data; this.deleteType = 1; this.setData({ dialog: { @@ -95,8 +110,12 @@ Page({ }, deleteCurr(e) { - const { index } = e.currentTarget.dataset; - const { dialog } = this.data; + const { + index + } = e.currentTarget.dataset; + const { + dialog + } = this.data; this.deleteIndex = index; this.setData({ dialog: { @@ -109,9 +128,13 @@ Page({ }, handleHistoryTap(e) { - const { historyWords } = this.data; - const { dataset } = e.currentTarget; - const _searchValue = historyWords[dataset.index || 0] || ''; + const { + historyWords + } = this.data; + const { + dataset + } = e.currentTarget; + const _searchValue = historyWords[dataset.index || 0].historySearchContent || ''; if (_searchValue) { wx.navigateTo({ url: `/pages/goods/result/index?searchValue=${_searchValue}`, @@ -121,10 +144,12 @@ Page({ // TODO:提交搜索 handleSubmit(e) { - const { value } = e.detail.value; - if (value?.length === 0) return; + const { + value + } = e.detail; + if (value?.length === 0 || value == undefined) return; const data = { - HistorySearchContent: e.detail.value, + HistorySearchContent: value, }; addHistorySearch(data).then((res) => { this.queryHistory(); @@ -133,4 +158,4 @@ Page({ url: `/pages/goods/result/index?searchValue=${value}`, }); }, -}); +}); \ No newline at end of file