修复商品排序问题

This commit is contained in:
Junling Bu
2018-07-08 15:06:59 +08:00
parent d2a561f33b
commit 3abfeea8de
45 changed files with 142 additions and 184 deletions

View File

@@ -111,7 +111,8 @@ export default {
limit: 20,
userId: undefined,
valueId: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,
@@ -119,8 +120,7 @@ export default {
valueId: undefined,
content: undefined,
hasPicture: false,
picUrls: [],
addTime: undefined
picUrls: []
},
dialogFormVisible: false,
dialogStatus: '',
@@ -170,8 +170,7 @@ export default {
userId: undefined,
valueId: undefined,
content: undefined,
picUrls: [],
addTime: undefined
picUrls: []
}
},
handleCreate() {

View File

@@ -139,7 +139,8 @@ export default {
limit: 20,
goodsSn: undefined,
name: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -120,7 +120,8 @@ export default {
limit: 20,
id: undefined,
name: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -156,7 +156,8 @@ export default {
limit: 20,
id: undefined,
name: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
catL1: {},
dataForm: {

View File

@@ -70,7 +70,8 @@ export default {
page: 1,
limit: 20,
question: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -102,7 +102,8 @@ export default {
limit: 20,
keyword: undefined,
url: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -116,7 +116,8 @@ export default {
limit: 20,
id: undefined,
name: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
shipForm: {
orderId: undefined,

View File

@@ -58,8 +58,7 @@ export default {
page: 1,
limit: 20,
name: undefined,
code: undefined,
sort: '+id'
code: undefined
},
downloadLoading: false
}

View File

@@ -128,7 +128,8 @@ export default {
limit: 20,
name: undefined,
content: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -131,7 +131,8 @@ export default {
limit: 20,
title: undefined,
subtitle: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -99,7 +99,8 @@ export default {
page: 1,
limit: 20,
username: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -85,7 +85,8 @@ export default {
limit: 20,
key: undefined,
name: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
createDialogVisible: false,
dataForm: {

View File

@@ -117,7 +117,8 @@ export default {
limit: 20,
name: undefined,
userId: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
provinces: {},
cities: {},

View File

@@ -80,7 +80,8 @@ export default {
limit: 20,
userId: undefined,
valueId: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -80,7 +80,8 @@ export default {
limit: 20,
userId: undefined,
goodsId: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -79,7 +79,8 @@ export default {
limit: 20,
userId: undefined,
keyword: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -148,7 +148,8 @@ export default {
limit: 20,
username: undefined,
mobile: undefined,
sort: '+id'
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,

View File

@@ -33,6 +33,10 @@ public class LitemallAdService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, limit);
return adMapper.selectByExample(example);
}

View File

@@ -63,6 +63,10 @@ public class LitemallAddressService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, limit);
return addressMapper.selectByExample(example);
}

View File

@@ -32,6 +32,10 @@ public class LitemallAdminService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, limit);
return adminMapper.selectByExampleSelective(example, result);
}

View File

@@ -44,6 +44,10 @@ public class LitemallBrandService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return brandMapper.selectByExample(example);
}

View File

@@ -5,6 +5,7 @@ import org.linlinjava.litemall.db.dao.LitemallCartMapper;
import org.linlinjava.litemall.db.domain.LitemallCart;
import org.linlinjava.litemall.db.domain.LitemallCartExample;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.List;
@@ -77,14 +78,18 @@ public class LitemallCartService {
LitemallCartExample example = new LitemallCartExample();
LitemallCartExample.Criteria criteria = example.createCriteria();
if(userId != null){
if(!StringUtils.isEmpty(userId)){
criteria.andUserIdEqualTo(userId);
}
if(goodsId != null){
if(!StringUtils.isEmpty(goodsId)){
criteria.andGoodsIdEqualTo(goodsId);
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, limit);
return cartMapper.selectByExample(example);
}

View File

@@ -63,6 +63,10 @@ public class LitemallCategoryService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return categoryMapper.selectByExample(example);
}

View File

@@ -61,6 +61,10 @@ public class LitemallCollectService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return collectMapper.selectByExample(example);
}

View File

@@ -83,6 +83,10 @@ public class LitemallCommentService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return commentMapper.selectByExample(example);
}

View File

@@ -1,7 +0,0 @@
package org.linlinjava.litemall.db.service;
import org.springframework.stereotype.Service;
@Service
public class LitemallCouponService {
}

View File

@@ -53,6 +53,10 @@ public class LitemallFootprintService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return footprintMapper.selectByExample(example);
}

View File

@@ -20,31 +20,6 @@ public class LitemallGoodsAttributeService {
return goodsAttributeMapper.selectByExample(example);
}
public List<LitemallGoodsAttribute> querySelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
LitemallGoodsAttributeExample example = new LitemallGoodsAttributeExample();
LitemallGoodsAttributeExample.Criteria criteria = example.createCriteria();
if(goodsId != null){
criteria.andGoodsIdEqualTo(goodsId);
}
criteria.andDeletedEqualTo(false);
PageHelper.startPage(page, size);
return goodsAttributeMapper.selectByExample(example);
}
public int countSelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
LitemallGoodsAttributeExample example = new LitemallGoodsAttributeExample();
LitemallGoodsAttributeExample.Criteria criteria = example.createCriteria();
if(goodsId != null){
criteria.andGoodsIdEqualTo(goodsId);
}
criteria.andDeletedEqualTo(false);
return (int)goodsAttributeMapper.countByExample(example);
}
public void updateById(LitemallGoodsAttribute goodsAttribute) {
goodsAttributeMapper.updateByPrimaryKeySelective(goodsAttribute);
}

View File

@@ -58,31 +58,32 @@ public class LitemallGoodsService {
return (int)goodsMapper.countByExample(example);
}
public List<LitemallGoods> querySelective(Integer catId, Integer brandId, String keyword, Integer isHot, Integer isNew, Integer offset, Integer limit, String sort) {
public List<LitemallGoods> querySelective(Integer catId, Integer brandId, String keyword, Boolean isHot, Boolean isNew, Integer offset, Integer limit, String sort, String order) {
LitemallGoodsExample example = new LitemallGoodsExample();
LitemallGoodsExample.Criteria criteria = example.createCriteria();
if(catId != null && catId != 0){
if(!StringUtils.isEmpty(catId) && catId != 0){
criteria.andCategoryIdEqualTo(catId);
}
if(brandId != null){
if(!StringUtils.isEmpty(brandId)){
criteria.andBrandIdEqualTo(brandId);
}
if(isNew != null){
criteria.andIsNewEqualTo(isNew.intValue() == 1);
if(!StringUtils.isEmpty(isNew)){
criteria.andIsNewEqualTo(isNew);
}
if(isHot != null){
criteria.andIsHotEqualTo(isHot.intValue() == 1);
if(!StringUtils.isEmpty(isHot)){
criteria.andIsHotEqualTo(isHot);
}
if(keyword != null){
if(!StringUtils.isEmpty(keyword)){
criteria.andKeywordsLike("%" + keyword + "%");
}
criteria.andDeletedEqualTo(false);
if(sort != null){
example.setOrderByClause(sort);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
if(limit != null && offset != null) {
if(!StringUtils.isEmpty(limit) && !StringUtils.isEmpty(offset)) {
PageHelper.startPage(offset, limit);
}
@@ -90,7 +91,7 @@ public class LitemallGoodsService {
return goodsMapper.selectByExampleSelective(example ,columns);
}
public int countSelective(Integer catId, Integer brandId, String keyword, Integer isHot, Integer isNew, Integer offset, Integer limit, String sort) {
public int countSelective(Integer catId, Integer brandId, String keyword, Boolean isHot, Boolean isNew, Integer offset, Integer limit, String sort, String order) {
LitemallGoodsExample example = new LitemallGoodsExample();
LitemallGoodsExample.Criteria criteria = example.createCriteria();
@@ -101,10 +102,10 @@ public class LitemallGoodsService {
criteria.andBrandIdEqualTo(brandId);
}
if(isNew != null){
criteria.andIsNewEqualTo(isNew.intValue() == 1);
criteria.andIsNewEqualTo(isNew);
}
if(isHot != null){
criteria.andIsHotEqualTo(isHot.intValue() == 1);
criteria.andIsHotEqualTo(isHot);
}
if(keyword != null){
criteria.andKeywordsLike("%" + keyword + "%");
@@ -182,7 +183,7 @@ public class LitemallGoodsService {
return (int)goodsMapper.countByExample(example);
}
public List<Integer> getCatIds(Integer brandId, String keyword, Integer isHot, Integer isNew) {
public List<Integer> getCatIds(Integer brandId, String keyword, Boolean isHot, Boolean isNew) {
LitemallGoodsExample example = new LitemallGoodsExample();
LitemallGoodsExample.Criteria criteria = example.createCriteria();
@@ -190,10 +191,10 @@ public class LitemallGoodsService {
criteria.andBrandIdEqualTo(brandId);
}
if(isNew != null){
criteria.andIsNewEqualTo(isNew.intValue() == 1);
criteria.andIsNewEqualTo(isNew);
}
if(isHot != null){
criteria.andIsHotEqualTo(isHot.intValue() == 1);
criteria.andIsHotEqualTo(isHot);
}
if(keyword != null){
criteria.andKeywordsLike("%" + keyword + "%");

View File

@@ -27,31 +27,6 @@ public class LitemallGoodsSpecificationService {
return goodsSpecificationMapper.selectByPrimaryKey(id);
}
public List<LitemallGoodsSpecification> querySelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
LitemallGoodsSpecificationExample example = new LitemallGoodsSpecificationExample();
LitemallGoodsSpecificationExample.Criteria criteria = example.createCriteria();
if(goodsId != null){
criteria.andGoodsIdEqualTo(goodsId);
}
criteria.andDeletedEqualTo(false);
PageHelper.startPage(page, size);
return goodsSpecificationMapper.selectByExample(example);
}
public int countSelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
LitemallGoodsSpecificationExample example = new LitemallGoodsSpecificationExample();
LitemallGoodsSpecificationExample.Criteria criteria = example.createCriteria();
if(goodsId != null){
criteria.andGoodsIdEqualTo(goodsId);
}
criteria.andDeletedEqualTo(false);
return (int)goodsSpecificationMapper.countByExample(example);
}
public void updateById(LitemallGoodsSpecification goodsSpecification) {
goodsSpecificationMapper.updateByPrimaryKeySelective(goodsSpecification);
}
@@ -70,15 +45,6 @@ public class LitemallGoodsSpecificationService {
goodsSpecificationMapper.insertSelective(goodsSpecification);
}
public Integer[] queryIdsByGid(Integer goodsId) {
List<LitemallGoodsSpecification> goodsSpecificationList = queryByGid(goodsId);
Integer[] ids = new Integer[goodsSpecificationList.size()];
for(int i = 0; i < ids.length; i++){
ids[i] = goodsSpecificationList.get(i).getId();
}
return ids;
}
private class VO {
private String name;
private List<LitemallGoodsSpecification> valueList;

View File

@@ -38,6 +38,10 @@ public class LitemallIssueService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return issueMapper.selectByExample(example);
}

View File

@@ -53,6 +53,10 @@ public class LitemallKeywordService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, limit);
return keywordsMapper.selectByExample(example);
}

View File

@@ -75,7 +75,7 @@ public class LitemallOrderService {
public List<LitemallOrder> queryByOrderStatus(Integer userId, List<Short> orderStatus) {
LitemallOrderExample example = new LitemallOrderExample();
example.orderBy(LitemallOrder.Column.addTime.desc());
example.setOrderByClause(LitemallOrder.Column.addTime.desc());
LitemallOrderExample.Criteria criteria = example.or();
criteria.andUserIdEqualTo(userId);
if(orderStatus != null) {
@@ -112,6 +112,10 @@ public class LitemallOrderService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return orderMapper.selectByExample(example);
}

View File

@@ -24,31 +24,6 @@ public class LitemallProductService {
return productMapper.selectByPrimaryKey(id);
}
public List<LitemallProduct> querySelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
LitemallProductExample example = new LitemallProductExample();
LitemallProductExample.Criteria criteria = example.createCriteria();
if(goodsId != null){
criteria.andGoodsIdEqualTo(goodsId);
}
criteria.andDeletedEqualTo(false);
PageHelper.startPage(page, size);
return productMapper.selectByExample(example);
}
public int countSelective(Integer goodsId, Integer page, Integer size, String sort, String order) {
LitemallProductExample example = new LitemallProductExample();
LitemallProductExample.Criteria criteria = example.createCriteria();
if(goodsId != null){
criteria.andGoodsIdEqualTo(goodsId);
}
criteria.andDeletedEqualTo(false);
return (int)productMapper.countByExample(example);
}
public void updateById(LitemallProduct product) {
productMapper.updateByPrimaryKeySelective(product);
}

View File

@@ -32,9 +32,14 @@ public class LitemallRegionService {
if(!StringUtils.isEmpty(name)){
criteria.andNameLike("%" + name + "%");
}
if(code != null){
if(!StringUtils.isEmpty(code)){
criteria.andCodeEqualTo(code);
}
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return regionMapper.selectByExample(example);
}

View File

@@ -57,6 +57,10 @@ public class LitemallSearchHistoryService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return searchHistoryMapper.selectByExample(example);
}

View File

@@ -58,6 +58,10 @@ public class LitemallStorageService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, limit);
return storageMapper.selectByExample(example);
}

View File

@@ -66,6 +66,10 @@ public class LitemallTopicService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, limit);
return topicMapper.selectByExampleWithBLOBs(example);
}

View File

@@ -44,6 +44,10 @@ public class LitemallUserService {
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, size);
return userMapper.selectByExample(example);
}

View File

@@ -1,33 +0,0 @@
package org.linlinjava.litemall.db.util;
public class SortUtil {
public static final String goodsSort(String sort, String order){
if(sort == null){
return null;
}
String sortWithOrder = "";
if(sort.equalsIgnoreCase("price")){
sortWithOrder = "retail_price";
}
else if(sort.equalsIgnoreCase("default") || sort.equalsIgnoreCase("category")){
return null;
}
else{
return null;
}
if(order == null) {
return sortWithOrder;
}
if(order.equalsIgnoreCase("asc")){
sortWithOrder += " ASC";
}
else if(order.equalsIgnoreCase("DESC")){
sortWithOrder += " DESC";
}
return sortWithOrder;
}
}

View File

@@ -32,8 +32,6 @@ public class WxCartController {
private LitemallGoodsSpecificationService goodsSpecificationService;
@Autowired
private LitemallAddressService addressService;
@Autowired
private LitemallCouponService apiCouponService;
/**
* 购物车

View File

@@ -3,7 +3,6 @@ package org.linlinjava.litemall.wx.web;
import org.apache.commons.lang3.ObjectUtils;
import org.linlinjava.litemall.db.domain.LitemallComment;
import org.linlinjava.litemall.db.service.LitemallCommentService;
import org.linlinjava.litemall.db.service.LitemallCouponService;
import org.linlinjava.litemall.db.service.LitemallUserService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.wx.annotation.LoginUser;
@@ -26,8 +25,6 @@ public class WxCommentController {
@Autowired
private LitemallUserService userService;
@Autowired
private LitemallCouponService couponService;
@Autowired
private UserInfoService userInfoService;
/**

View File

@@ -5,7 +5,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.db.util.SortUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
@@ -48,8 +47,6 @@ public class WxGoodsController {
@Autowired
private LitemallSearchHistoryService searchHistoryService;
@Autowired
private LitemallCouponService apiCouponService;
@Autowired
private LitemallCartService cartService;
@Autowired
private LitemallGoodsSpecificationService goodsSpecificationService;
@@ -229,14 +226,12 @@ public class WxGoodsController {
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping("list")
public Object list(Integer categoryId, Integer brandId, String keyword, Integer isNew, Integer isHot,
public Object list(Integer categoryId, Integer brandId, String keyword, Boolean isNew, Boolean isHot,
@LoginUser Integer userId,
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "size", defaultValue = "10") Integer size,
String sort, String order) {
String sortWithOrder = SortUtil.goodsSort(sort, order);
//添加到搜索历史
if (userId != null && !StringUtils.isNullOrEmpty(keyword)) {
LitemallSearchHistory searchHistoryVo = new LitemallSearchHistory();
@@ -248,8 +243,8 @@ public class WxGoodsController {
}
//查询列表数据
List<LitemallGoods> goodsList = goodsService.querySelective(categoryId, brandId, keyword, isHot, isNew, page, size, sortWithOrder);
int total = goodsService.countSelective(categoryId, brandId, keyword, isHot, isNew, page, size, sortWithOrder);
List<LitemallGoods> goodsList = goodsService.querySelective(categoryId, brandId, keyword, isHot, isNew, page, size, sort, order);
int total = goodsService.countSelective(categoryId, brandId, keyword, isHot, isNew, page, size, sort, order);
// 查询商品所属类目列表。
List<Integer> goodsCatIds = goodsService.getCatIds(brandId, keyword, isHot, isNew);

View File

@@ -13,6 +13,7 @@ Page({
goodsList: [],
categoryId: 0,
currentSortType: 'default',
currentSort: 'add_time',
currentSortOrder: 'desc',
page: 1,
size: 100
@@ -42,7 +43,7 @@ Page({
getGoodsList: function (){
var that = this;
util.request(api.GoodsList, { isHot: 1, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSortType, categoryId: that.data.categoryId})
util.request(api.GoodsList, { isHot: true, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSort, categoryId: that.data.categoryId})
.then(function (res) {
if (res.errno === 0) {
that.setData({
@@ -80,7 +81,8 @@ Page({
this.setData({
categoryFilter: !this.data.categoryFilter,
currentSortType: 'category',
currentSortOrder: 'asc'
currentSort: 'add_time',
currentSortOrder: 'desc'
});
break;
case 'priceSort':
@@ -90,6 +92,7 @@ Page({
}
this.setData({
currentSortType: 'price',
currentSort: 'retail_price',
currentSortOrder: tmpSortOrder,
categoryFilter: false
});
@@ -100,6 +103,7 @@ Page({
//综合排序
this.setData({
currentSortType: 'default',
currentSort: 'add_time',
currentSortOrder: 'desc',
categoryFilter: false,
categoryId: 0,

View File

@@ -13,6 +13,7 @@ Page({
goodsList: [],
categoryId: 0,
currentSortType: 'default',
currentSort: 'add_time',
currentSortOrder: 'desc',
page: 1,
size: 100
@@ -30,7 +31,7 @@ Page({
getGoodsList: function() {
var that = this;
util.request(api.GoodsList, { isNew: 1, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSortType, categoryId: that.data.categoryId })
util.request(api.GoodsList, { isNew: true, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSort, categoryId: that.data.categoryId })
.then(function (res) {
if (res.errno === 0) {
that.setData({
@@ -67,7 +68,8 @@ Page({
this.setData({
categoryFilter: !this.data.categoryFilter,
currentSortType: 'category',
currentSortOrder: 'asc'
currentSort: 'add_time',
currentSortOrder: 'desc'
});
break;
case 'priceSort':
@@ -77,6 +79,7 @@ Page({
}
this.setData({
currentSortType: 'price',
currentSort: 'retail_price',
currentSortOrder: tmpSortOrder,
categoryFilter: false
});
@@ -87,6 +90,7 @@ Page({
//综合排序
this.setData({
currentSortType: 'default',
currentSort: 'add_time',
currentSortOrder: 'desc',
categoryFilter: false,
categoryId: 0