Ver Fonte

Merge remote-tracking branch 'origin/developerB' into developerB

zhengjinyi há 3 anos atrás
pai
commit
35bebf5234

+ 2 - 0
README.md

@@ -7,3 +7,5 @@
   3. [Thymeleaf](https://www.thymeleaf.org/)
   4. [Vue 2.6.11](https://cn.vuejs.org/)
   5. [Jquery 3.5.1](https://jquery.com/)
+
+test2.

+ 29 - 24
src/main/java/com/caimei/www/controller/unlimited/ProductController.java

@@ -36,7 +36,9 @@ public class ProductController extends BaseController {
     private static final String ACTIVITY_TOP_PATH = "activity/activityTopic";
     private static final String CLOUD_BEAUTY_PATH = "activity/beautyTopic";
     private static final String ACTIVITY_COUPON_EXP = "activity/couponExp";
-    /** 优惠券活动商品列表 */
+    /**
+     * 优惠券活动商品列表
+     */
     private static final String PRODUCT_COUPON = "product/product-coupon";
     /**
      * 美博会专题页
@@ -69,7 +71,9 @@ public class ProductController extends BaseController {
      * 优惠券活动商品列表
      */
     @GetMapping("/product/product-coupon.html")
-    public String productCoupon() { return PRODUCT_COUPON; }
+    public String productCoupon() {
+        return PRODUCT_COUPON;
+    }
 
     /**
      * 促销活动商品列表
@@ -120,28 +124,28 @@ public class ProductController extends BaseController {
      * 商品分类列表页面
      */
     @GetMapping("/product/classify-{ids}.html")
-    public String instruelist(final Model model, @PathVariable("ids") String ids) {
+    public String instruelist(final Model model, @PathVariable("ids") String ids, String bpn, Integer pro, Integer newg) {
         String[] split = ids.split("-");
         // 分类类型:1产品,2仪器,0全部
-        Integer typeSort =  split.length>=1 ? Integer.valueOf(split[0]) : 0;
+        Integer typeSort = split.length >= 1 ? Integer.valueOf(split[0]) : 0;
         model.addAttribute("typeSort", typeSort);
         // 一级分类Id
-        Integer bigTypeId = split.length>=2 ? Integer.valueOf(split[1]) : 0;
+        Integer bigTypeId = split.length >= 2 ? Integer.valueOf(split[1]) : 0;
         model.addAttribute("bigTypeId", bigTypeId);
         // 二级分类Id
-        Integer smallTypeId = split.length>=3 ? Integer.valueOf(split[2]) : 0;
+        Integer smallTypeId = split.length >= 3 ? Integer.valueOf(split[2]) : 0;
         model.addAttribute("smallTypeId", smallTypeId);
         // 三级级分类Id
-        Integer tinyTypeId = split.length>=4 ? Integer.valueOf(split[3]) : 0;
+        Integer tinyTypeId = split.length >= 4 ? Integer.valueOf(split[3]) : 0;
         model.addAttribute("tinyTypeId", tinyTypeId);
         // 页码
-        Integer pageNum = split.length>=5 ? Integer.valueOf(split[4]) : 1;
+        Integer pageNum = split.length >= 5 ? Integer.valueOf(split[4]) : 1;
         // 每页数量
-        Integer pageSize = split.length>=6 ? Integer.valueOf(split[5]) : 24;
+        Integer pageSize = split.length >= 6 ? Integer.valueOf(split[5]) : 24;
         // 排序字段:价格price,销量sales,人气favorite
-        String sortField = split.length>=7 ? split[6] : "";
+        String sortField = split.length >= 7 ? split[6] : "";
         // 排序规则:1降序,其他升序
-        Integer sortType = split.length>=8 ? Integer.valueOf(split[7]) : 1;
+        Integer sortType = split.length >= 8 ? Integer.valueOf(split[7]) : 1;
         /*
          * 获取一级分类
          */
@@ -192,45 +196,45 @@ public class ProductController extends BaseController {
         } else {
             productParams.append("?id=").append(bigTypeId).append("&idType=1");
         }
-        productParams.append("&pageNum=").append(pageNum).append("&pageSize=").append(pageSize).append("&sortField=").append(sortField).append("&sortType=").append(sortType);
+        productParams.append("&pageNum=").append(pageNum).append("&pageSize=").append(pageSize).append("&sortField=").append(sortField).append("&sortType=").append(sortType).append("&newFlag=").append(newg).append("&promotionFlag=").append(pro).append("&brandIds=").append(bpn);
         JSONObject productObj = productService.getProductListJson(productParams.toString());
         Integer totalCount = productObj.getInteger("total");
         JSONArray productList = (JSONArray) productObj.get("items");
         model.addAttribute("productCount", totalCount);
         model.addAttribute("productListJson", productList);
 
-        int totalPage = (int) Math.ceil((double) totalCount/pageSize);
+        int totalPage = (int) Math.ceil((double) totalCount / pageSize);
         totalPage = totalPage > 0 ? totalPage : 1;
         int[] arr = null;
         if (totalPage <= 6) {
             int[] tmp = new int[]{1, 2, 3, 4, 5, 6};
             arr = Arrays.copyOf(tmp, totalPage);
-        }else if (pageNum <= 3) {
+        } else if (pageNum <= 3) {
             arr = new int[]{1, 2, 3, 4, 5, 0, totalPage};
-        }else if (pageNum >= totalPage - 2) {
+        } else if (pageNum >= totalPage - 2) {
             arr = new int[]{1, 0, totalPage - 4, totalPage - 3, totalPage - 2, totalPage - 1, totalPage};
-        }else{
+        } else {
             arr = new int[]{1, 0, pageNum - 2, pageNum - 1, pageNum, pageNum + 1, pageNum + 2, 0, totalPage};
         }
 
-        List<Map<String,Object>> arrPath = new ArrayList<>();
+        List<Map<String, Object>> arrPath = new ArrayList<>();
 
         final String basePath = "/product/classify-" + typeSort + "-" + bigTypeId + "-" + smallTypeId + "-" + tinyTypeId;
         if (pageNum > 1) {
             StringBuilder prevPath = new StringBuilder(basePath);
-            prevPath.append("-").append(pageNum-1).append("-").append(pageSize);
+            prevPath.append("-").append(pageNum - 1).append("-").append(pageSize);
             if (!StringUtils.isEmpty(sortField)) {
                 prevPath.append("-").append(sortField).append("-").append(sortType).append(".html");
             } else {
                 prevPath.append(".html");
             }
-            Map<String,Object> tempPath = new HashMap<>();
+            Map<String, Object> tempPath = new HashMap<>();
             tempPath.put("btn", -1);
             tempPath.put("path", prevPath);
             arrPath.add(tempPath);
         }
         for (int j : arr) {
-            Map<String,Object> tempPath = new HashMap<>();
+            Map<String, Object> tempPath = new HashMap<>();
             tempPath.put("btn", j);
             if (j > 0) {
                 StringBuilder btnPath = new StringBuilder(basePath);
@@ -248,13 +252,13 @@ public class ProductController extends BaseController {
         }
         if (pageNum < totalPage) {
             StringBuilder nextPath = new StringBuilder(basePath);
-            nextPath.append("-").append(pageNum+1).append("-").append(pageSize);
+            nextPath.append("-").append(pageNum + 1).append("-").append(pageSize);
             if (!StringUtils.isEmpty(sortField)) {
                 nextPath.append("-").append(sortField).append("-").append(sortType).append(".html");
             } else {
                 nextPath.append(".html");
             }
-            Map<String,Object> tempPath = new HashMap<>();
+            Map<String, Object> tempPath = new HashMap<>();
             tempPath.put("btn", -2);
             tempPath.put("path", nextPath);
             arrPath.add(tempPath);
@@ -323,14 +327,15 @@ public class ProductController extends BaseController {
      * 优惠券说明页
      */
     @GetMapping("/product/couponExp.html")
-    public String getCouponExpPath(){
+    public String getCouponExpPath() {
         return ACTIVITY_COUPON_EXP;
     }
+
     /**
      * H5配套商品页
      */
     @GetMapping("/product/product-supporting.html")
-    public String getProductSupporting(){
+    public String getProductSupporting() {
         return PRODUCT_SUPPORTING_PATH;
     }
 }