提交 f31c7dfa 编写于 作者: api工厂's avatar api工厂

增加历史搜索(删除)功能

上级 8fc0fc8e
......@@ -46,7 +46,8 @@
"pages/pwd-pay/reset",
"pages/pwd-pay/modify",
"pages/pwd-pay/set",
"pages/my/feedback"
"pages/my/feedback",
"pages/search/index"
],
"window": {
"backgroundTextStyle": "light",
......
module.exports = {
version: '9.12.0',
note: '购物车增加选择/取消选择功能', // 这个为版本描述,无需修改
version: '9.13.0',
note: '增加历史搜索(删除)功能', // 这个为版本描述,无需修改
subDomain: 'tz', // 此处改成你自己的专属域名。什么是专属域名?请看教程 https://www.it120.cc/help/qr6l4m.html
sdkAppID: 1400450467, // 腾讯实时音视频应用编号,请看教程 https://www.it120.cc/help/nxoqsl.html
}
\ No newline at end of file
......@@ -302,22 +302,9 @@ Page({
}
})
},
bindinput(e) {
this.setData({
inputVal: e.detail.value
})
},
bindconfirm(e) {
this.setData({
inputVal: e.detail.value
})
wx.navigateTo({
url: '/pages/goods/list?name=' + this.data.inputVal,
})
},
goSearch(){
wx.navigateTo({
url: '/pages/goods/list?name=' + this.data.inputVal,
url: '/pages/search/index'
})
}
})
\ No newline at end of file
......@@ -16,9 +16,9 @@
<image mode="aspectFill" bindtap="tapBanner" data-url="{{item.linkUrl}}" src="{{item.picUrl}}" />
</swiper-item>
</swiper>
<view class="search">
<input type="text" placeholder="输入搜索关键词" value="{{name}}" bindinput="bindinput" bindconfirm="bindconfirm"></input>
<image src="/images/icon/search.svg" bindtap="goSearch"></image>
<view class="search" bindtap="goSearch">
<input type="text" placeholder="输入搜索关键词" disabled></input>
<image src="/images/icon/search.svg"></image>
</view>
<view wx:if="{{goodsDynamic}}" class="goodsDynamic">
<swiper class="swiper2" autoplay circular vertical>
......
Page({
data: {
},
onLoad: function (options) {
this.setData({
list: wx.getStorageSync('searchHis')
})
},
onShow: function () {
},
search(e) {
this.setData({
inputVal: e.detail
})
if (e.detail) {
let searchHis = wx.getStorageSync('searchHis')
if (!searchHis) {
searchHis = [e.detail]
}
if (!searchHis.includes(e.detail)) {
searchHis.push(e.detail)
}
wx.setStorageSync('searchHis', searchHis)
this.setData({
list: searchHis
})
}
wx.redirectTo({
url: '/pages/goods/list?name=' + this.data.inputVal,
})
},
onClose(e) {
const idx = e.currentTarget.dataset.idx
const searchHis = this.data.list
searchHis.splice(idx, 1)
wx.setStorageSync('searchHis', searchHis)
this.setData({
list: searchHis
})
},
go(e) {
const idx = e.currentTarget.dataset.idx
const keywords = this.data.list[idx]
wx.redirectTo({
url: '/pages/goods/list?name=' + keywords,
})
}
})
\ No newline at end of file
{
"navigationBarTitleText": "搜索一下"
}
\ No newline at end of file
<van-search placeholder="请输入搜索关键词" focus bind:search="search" />
<van-empty wx:if="{{ !list || list.length == 0 }}" description="暂无历史搜索" />
<van-cell-group wx:if="{{ list && list.length > 0 }}" title="历史搜索">
<van-cell wx:for="{{list}}" wx:key="*this">
<view slot="title">
<view data-idx="{{ index }}" bindtap="go">{{ item }}</view>
</view>
<van-tag
closeable
size="medium"
type="primary"
id="primary"
data-idx="{{ index }}"
bind:close="onClose"
>
删除
</van-tag>
</van-cell>
</van-cell-group>
\ No newline at end of file
/* pages/search/index.wxss */
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册