Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
40081d1b
Commit
40081d1b
authored
Jul 19, 2018
by
Menethil
Browse files
添加小程序搜索支持商品名,修复搜索页面排序参数问题
parent
2f253cce
Changes
3
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java
View file @
40081d1b
...
@@ -76,6 +76,10 @@ public class LitemallGoodsService {
...
@@ -76,6 +76,10 @@ public class LitemallGoodsService {
}
}
if
(!
StringUtils
.
isEmpty
(
keyword
)){
if
(!
StringUtils
.
isEmpty
(
keyword
)){
criteria
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
criteria
.
andKeywordsLike
(
"%"
+
keyword
+
"%"
);
LitemallGoodsExample
.
Criteria
criteria2
=
example
.
createCriteria
();
criteria2
.
andNameLike
(
"%"
+
keyword
+
"%"
);
example
.
or
(
criteria2
);
}
}
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
...
...
litemall-wx/pages/search/search.js
View file @
40081d1b
...
@@ -10,6 +10,7 @@ Page({
...
@@ -10,6 +10,7 @@ Page({
helpKeyword
:
[],
helpKeyword
:
[],
historyKeyword
:
[],
historyKeyword
:
[],
categoryFilter
:
false
,
categoryFilter
:
false
,
currentSort
:
'
name
'
,
currentSortType
:
'
default
'
,
currentSortType
:
'
default
'
,
currentSortOrder
:
'
desc
'
,
currentSortOrder
:
'
desc
'
,
filterCategory
:
[],
filterCategory
:
[],
...
@@ -57,7 +58,9 @@ Page({
...
@@ -57,7 +58,9 @@ Page({
},
},
getHelpKeyword
:
function
()
{
getHelpKeyword
:
function
()
{
let
that
=
this
;
let
that
=
this
;
util
.
request
(
api
.
SearchHelper
,
{
keyword
:
that
.
data
.
keyword
}).
then
(
function
(
res
)
{
util
.
request
(
api
.
SearchHelper
,
{
keyword
:
that
.
data
.
keyword
}).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
that
.
setData
({
helpKeyword
:
res
.
data
helpKeyword
:
res
.
data
...
@@ -87,7 +90,14 @@ Page({
...
@@ -87,7 +90,14 @@ Page({
},
},
getGoodsList
:
function
()
{
getGoodsList
:
function
()
{
let
that
=
this
;
let
that
=
this
;
util
.
request
(
api
.
GoodsList
,
{
keyword
:
that
.
data
.
keyword
,
page
:
that
.
data
.
page
,
size
:
that
.
data
.
size
,
sort
:
that
.
data
.
currentSortType
,
order
:
that
.
data
.
currentSortOrder
,
categoryId
:
that
.
data
.
categoryId
}).
then
(
function
(
res
)
{
util
.
request
(
api
.
GoodsList
,
{
keyword
:
that
.
data
.
keyword
,
page
:
that
.
data
.
page
,
size
:
that
.
data
.
size
,
sort
:
that
.
data
.
currentSort
,
order
:
that
.
data
.
currentSortOrder
,
categoryId
:
that
.
data
.
categoryId
}).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
that
.
setData
({
searchStatus
:
true
,
searchStatus
:
true
,
...
@@ -107,7 +117,7 @@ Page({
...
@@ -107,7 +117,7 @@ Page({
},
},
getSearchResult
(
keyword
)
{
getSearchResult
(
keyword
)
{
if
(
keyword
===
''
){
if
(
keyword
===
''
)
{
keyword
=
this
.
data
.
defaultKeyword
.
keyword
;
keyword
=
this
.
data
.
defaultKeyword
.
keyword
;
}
}
this
.
setData
({
this
.
setData
({
...
@@ -119,13 +129,15 @@ Page({
...
@@ -119,13 +129,15 @@ Page({
this
.
getGoodsList
();
this
.
getGoodsList
();
},
},
openSortFilter
:
function
(
event
)
{
openSortFilter
:
function
(
event
)
{
let
currentId
=
event
.
currentTarget
.
id
;
let
currentId
=
event
.
currentTarget
.
id
;
switch
(
currentId
)
{
switch
(
currentId
)
{
case
'
categoryFilter
'
:
case
'
categoryFilter
'
:
this
.
setData
({
this
.
setData
({
categoryFilter
:
!
this
.
data
.
categoryFilter
,
categoryFilter
:
!
this
.
data
.
categoryFilter
,
currentSortOrder
:
'
asc
'
currentSortType
:
'
category
'
,
currentSort
:
'
add_time
'
,
currentSortOrder
:
'
desc
'
});
});
break
;
break
;
case
'
priceSort
'
:
case
'
priceSort
'
:
...
@@ -135,6 +147,7 @@ Page({
...
@@ -135,6 +147,7 @@ Page({
}
}
this
.
setData
({
this
.
setData
({
currentSortType
:
'
price
'
,
currentSortType
:
'
price
'
,
currentSort
:
'
retail_price
'
,
currentSortOrder
:
tmpSortOrder
,
currentSortOrder
:
tmpSortOrder
,
categoryFilter
:
false
categoryFilter
:
false
});
});
...
@@ -145,13 +158,15 @@ Page({
...
@@ -145,13 +158,15 @@ Page({
//综合排序
//综合排序
this
.
setData
({
this
.
setData
({
currentSortType
:
'
default
'
,
currentSortType
:
'
default
'
,
currentSort
:
'
name
'
,
currentSortOrder
:
'
desc
'
,
currentSortOrder
:
'
desc
'
,
categoryFilter
:
false
categoryFilter
:
false
,
categoryId
:
0
,
});
});
this
.
getGoodsList
();
this
.
getGoodsList
();
}
}
},
},
selectCategory
:
function
(
event
)
{
selectCategory
:
function
(
event
)
{
let
currentIndex
=
event
.
target
.
dataset
.
categoryIndex
;
let
currentIndex
=
event
.
target
.
dataset
.
categoryIndex
;
let
filterCategory
=
this
.
data
.
filterCategory
;
let
filterCategory
=
this
.
data
.
filterCategory
;
let
currentCategory
=
null
;
let
currentCategory
=
null
;
...
...
litemall-wx/pages/search/search.wxml
View file @
40081d1b
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
<view class="item by-price {{currentSortType == 'price' ? 'active' : ''}} {{currentSortOrder == 'asc' ? 'asc' : 'desc'}}" bindtap="openSortFilter" id="priceSort">
<view class="item by-price {{currentSortType == 'price' ? 'active' : ''}} {{currentSortOrder == 'asc' ? 'asc' : 'desc'}}" bindtap="openSortFilter" id="priceSort">
<text class="txt">价格</text>
<text class="txt">价格</text>
</view>
</view>
<view class="item {{currentSortType == 'category' ? 'active' : ''}}"
bindtap="openSortFilter"
id="categoryFilter">
<view class="item {{currentSortType == 'category' ? 'active' : ''}}" id="categoryFilter">
<text class="txt">分类</text>
<text class="txt">分类</text>
</view>
</view>
</view>
</view>
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
<view class="cate-item">
<view class="cate-item">
<view class="b">
<view class="b">
<navigator class="item {{(iindex + 1) % 2 == 0 ? 'item-b' : ''}}" url="/pages/goods/goods?id={{iitem.id}}" wx:for="{{goodsList}}" wx:key="id" wx:for-item="iitem" wx:for-index="iindex">
<navigator class="item {{(iindex + 1) % 2 == 0 ? 'item-b' : ''}}" url="/pages/goods/goods?id={{iitem.id}}" wx:for="{{goodsList}}" wx:key="id" wx:for-item="iitem" wx:for-index="iindex">
<image class="img" src="{{iitem.
listP
icUrl}}" background-size="cover"></image>
<image class="img" src="{{iitem.
p
icUrl}}" background-size="cover"></image>
<text class="name">{{iitem.name}}</text>
<text class="name">{{iitem.name}}</text>
<text class="price">¥{{iitem.retailPrice}}</text>
<text class="price">¥{{iitem.retailPrice}}</text>
</navigator>
</navigator>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment