Browse Source

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

plf 5 năm trước cách đây
mục cha
commit
e92299ff89

+ 14 - 2
src/main/java/com/caimei/www/controller/RedirectController.java

@@ -31,8 +31,8 @@ public class RedirectController {
 	 * 供应商商品页【旧】
 	 */
 	@GetMapping("/supplier/productlist-{id}.html")
-	public String toSupplierProduct(@PathVariable("id") Integer supplierId, @RequestParam("brandID") Integer brandId) {
-		return "redirect:/supplier/product.html?id=" + supplierId +"&brandId=" + brandId;
+	public String toSupplierProduct(@PathVariable("id") Integer supplierId) {
+		return "redirect:/supplier/index.html?id=" + supplierId;
 	}
 	/**
 	 * 二级页面(找产品/找仪器/找项目/正品联盟)【旧】
@@ -108,5 +108,17 @@ public class RedirectController {
         return "redirect:/flea-market/form.html";
     }
 
+    /**
+     * 商品搜索列表
+     */
+    @GetMapping("/product/search/list/0-0-0-1-0.html")
+    public String toSearchProduct(@RequestParam("wd") String keyword) {
+        return "redirect:/product/list.html?keyword=" + keyword;
+    }
+    @GetMapping("/product/search.shtml")
+    public String toSearchProduct2(@RequestParam("keyword") String keyword) {
+        return "redirect:/product/list.html?keyword=" + keyword;
+    }
+
 
 }

+ 0 - 11
src/main/java/com/caimei/www/controller/unlimited/SupplierController.java

@@ -25,7 +25,6 @@ public class SupplierController extends BaseController {
 
 	private static final String SUPPLIER_LIST_PATH = "supplier/list";
 	private static final String SUPPLIER_INDEX_PATH = "supplier/index";
-	private static final String SUPPLIER_PRODUCT_PATH = "supplier/product";
 
     private SupplierService supplierService;
     @Autowired
@@ -51,16 +50,6 @@ public class SupplierController extends BaseController {
         return SUPPLIER_INDEX_PATH;
     }
 
-    /**
-     * 供应商商品页
-     */
-    @GetMapping("/supplier/product.html")
-    public String product(final Model model, @RequestParam("id") Integer supplierId, @RequestParam("brandID") Integer brandId) {
-        SupplierDetail detail = supplierService.getSupplierById(supplierId);
-        model.addAttribute("supplier", detail);
-        return SUPPLIER_PRODUCT_PATH;
-    }
-
     /**
      * 供应商-轮播图片
      * @return

+ 1 - 1
src/main/resources/static/css/product/detail.pc.css

@@ -17,7 +17,7 @@ li{list-style:none;}
 .productBox .zoomImage{display:none;overflow:hidden;position:absolute;right:-466px;top:0;width:452px;height:452px;border:1px solid #e4e4e4;z-index:9999;background:#FFF}
 .productBox .zoomImage img{width:950px;height:950px;margin-right:10px;display:block}
 
-.productBox .detailBox .crumbs{height:28px;line-height:28px;font-size:14px;overflow:hidden;color:#93979F}
+.productBox .detailBox .crumbs{height:28px;line-height:28px;font-size:14px;overflow:hidden;color:#93979F;padding:0;}
 .productBox .detailBox .crumbs a{color:#93979F}
 .productBox .detailBox .crumbs a:hover{color:#E15616}
 .productBox .detailBox .title{font-size:18px;font-weight:bold;line-height:24px;padding:5px 0;color:#4A4F58}

+ 2 - 0
src/main/resources/static/js/article/detail.js

@@ -0,0 +1,2 @@
+// 获取相关阅读
+// "/article/related",{id:文章Id, labels: 文章标签,用,号隔开}

+ 87 - 13
src/main/resources/static/js/supplier/index.js

@@ -1,19 +1,35 @@
 var supplierHome = new Vue({
     el: "#supplierHome",
     data: {
+        requestFlag: true,
         userId: 0,
-        supplierId: 0,
+        supplierInfo:{},
         supplierBanner: [],
         mainProducts:[],
+        params: {
+            size: 12,
+            num: 1,
+            id: 0,
+            keyword: ''
+        },
+        listRecord:0,
         productLists:[]
     },
     computed: {
 
     },
     methods: {
+        getShopInfo: function(){
+            var _self = this;
+            $.getJSON(spiServer + "/supplier/home/detail",{supplierId: this.params.id}).done(function (r) {
+                if (r.code === 0 && r.data) {
+                    _self.supplierInfo = r.data;
+                }
+            });
+        },
         getBanners: function(){
             var _self = this;
-            $.getJSON("/supplier/images",{supplierId: this.supplierId}).done(function (r) {
+            $.getJSON(spiServer + "/supplier/home/images",{supplierId: this.params.id}).done(function (r) {
                 if (r.code === 0 && r.data) {
                     _self.supplierBanner = r.data;
                     setTimeout(function(){
@@ -52,7 +68,7 @@ var supplierHome = new Vue({
         },
         getMainProducts: function(){
             var _self = this;
-            $.getJSON("/supplier/products",{supplierId: this.supplierId}).done(function (r) {
+            $.getJSON(spiServer + "/supplier/home/products",{supplierId: this.params.id}).done(function (r) {
                 if (r.code === 0 && r.data) {
                     if(_self.userId && _self.userId>0){
                         var productIdArr = [];
@@ -70,35 +86,93 @@ var supplierHome = new Vue({
         },
         getProductLists: function(){
             var _self = this;
-            $.getJSON(spiServer+"/search/query/product/supplier",{
-                id: this.supplierId,
-                pageSize: 12,
-                pageNum: 1
-            }, function (r) {
+            $.getJSON(spiServer + "/search/query/product/supplier",this.params, function (r) {
                 if (r.code === 0 && r.data) {
                     var result = JSON.parse(r.data);
                     _self.listRecord = result.total;
-                    var resultData = setSearchProductList(result.items, _self.userId);
+                    var resultData = setSearchProductList(result.items, _self.userId,2);
                     _self.productLists = _self.productLists.concat(resultData);
                 }
+                _self.requestFlag = true;
             })
+        },
+        keyupSearch: function(event) {
+            // 搜索输入框 按回车键搜索
+            var keyCode = event.keyCode || event.which;
+            if(keyCode === 13){
+                this.supplierSearch();
+            }
+        },
+        supplierSearch: function(){
+            if (this.params.keyword.length < 2) {
+                $.confirm({
+                    useBootstrap: false,
+                    boxWidth: (isPC?'300px':'70%'),
+                    title:'提示',
+                    content:'请至少输入两个关键字!',
+                    closeIcon: true,
+                    animation: 'opacity',
+                    closeAnimation: 'opacity',
+                    animateFromElement: false,
+                    buttons: {
+                        close: {
+                            text: '确定',
+                            btnClass: 'btn-confirm'
+                        }
+                    }
+                });
+                return false;
+            }
+            this.productLists = [];
+            this.getProductLists();
+            var floorScroll = $('#supProduct').offset().top;
+            $('html,body').animate({scrollTop: floorScroll},600);
+        },
+        upgrade: function () {
+            location.href='/upgrade.html';
         }
     },
     created: function () {
-        this.supplierId = getUrlParam("id") ? getUrlParam("id") * 1 : 0;
-        if(this.supplierId !== 0) {
+        this.params.id = getUrlParam("id") ? getUrlParam("id") * 1 : 0;
+        if(this.params.id !== 0) {
+            this.getShopInfo();
             this.getBanners();
-            this.getMainProducts();
-            this.getProductLists();
         }
     },
     mounted: function () {
+        if(this.params.id !== 0) {
+            this.getMainProducts();
+            this.getProductLists();
+        }
+         var userInfo = localStorage.getItem('userInfo');
+            if(userInfo){
+                this.userId = JSON.parse(userInfo).userID;
+            }
         var _self = this;
         $('.supplierInfo').slide({
             mainCell:".tabCon"
             ,titCell:".tabTit span"
             ,trigger: "click"
         });
+        //上垃加载更多
+        $(window).on('scroll', function(){
+            var scrollTop = $(this).scrollTop();
+            var scrollHeight = $(document).height();
+            var windowHeight = window.innerHeight+$(".new-footer").height();
+            if (scrollTop + windowHeight >= scrollHeight) {
+                //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
+                var totalPage = Math.ceil(_self.listRecord / _self.params.size)?Math.ceil(_self.listRecord / _self.params.size):1;
+                var next = _self.params.num+1;
+                if(next <= totalPage){
+                    if (_self.requestFlag){
+                        _self.params.num = next;
+                        // 获取列表数据
+                        _self.getProductLists();
+                    }
+                    _self.requestFlag = false;
+                }
+            }
+        });
         $('body').on("click", '.showSearch', function(){
             $('.supplierTit .search').show();
         })

+ 0 - 25
src/main/resources/static/js/supplier/product.js

@@ -1,25 +0,0 @@
-var supplierHome = new Vue({
-    el: "#supplierHome",
-    data: {
-        userId: 0,
-        supplierId: 0,
-        brandId: 0,
-
-    },
-    computed: {
-
-    },
-    methods: {
-
-    },
-    created: function () {
-        this.supplierId = getUrlParam("id") ? getUrlParam("id") * 1 : 0;
-        this.brandId = getUrlParam("brandId") ? getUrlParam("brandId") * 1 : 0;
-    },
-    mounted: function () {
-        var _self = this;
-        $('body').on("click", '.showSearch', function(){
-            $('.supplierTit .search').show();
-        })
-    }
-});

+ 3 - 3
src/main/resources/templates/supplier/index.html

@@ -30,8 +30,8 @@
             <a href="javascript:void(0);"><i class="icon mIcon shop"><em class="tips">点击查看授权牌照</em></i></a>
         </div>
         <div class="search">
-            <input class="keyword" type="text" placeholder="请输入商品名称(商铺内商品)">
-            <a class="searchBtn icon mIcon" href="javascript:void(0);"></a>
+            <input class="keyword" v-model.trim="params.keyword" type="text" placeholder="请输入商品名称(商铺内商品)">
+            <a class="searchBtn icon mIcon" href="javascript:void(0);" @click="supplierSearch()" @keyup="keyupSearch()"></a>
         </div>
     </div>
 
@@ -81,7 +81,7 @@
                     </ul>
                 </div>
                 <div class="part">
-                    <div class="title">供应商产品</div>
+                    <div class="title" id="supProduct">供应商产品</div>
                     <!--主推商品列表-->
                     <ul class="productList clear mfw">
                         <li class="productItem mfc" v-for="p in productLists">

+ 0 - 39
src/main/resources/templates/supplier/product.html

@@ -1,39 +0,0 @@
-<!DOCTYPE html>
-<html lang="zh-CN" xmlns:th="https://www.thymeleaf.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      xsi:schemaLocation="https://www.thymeleaf.org ">
-<head>
-    <title th:text="'采美365网-'+${supplier.name}">采美365网-供应商首页</title>
-    <template th:replace="components/head-link"></template>
-    <link th:href="@{/css/supplier/index.css(v=${version})}" rel="stylesheet" type="text/css">
-</head>
-<body>
-<!-- 引用头部 -->
-<template th:replace="components/header"></template>
-
-<!-- 供应商首页 -->
-<div id="supplierProduct">
-    <div class="supplierTit">
-        <div class="title">
-            <img th:src="${supplier.logo}">
-            <h1 th:text="${supplier.name}"></h1>
-            <a href="javascript:void(0);"><i class="icon mIcon shop"><em class="tips">点击查看授权牌照</em></i></a>
-        </div>
-        <div class="search">
-            <input class="keyword" type="text" placeholder="请输入商品名称(商铺内商品)">
-            <a class="searchBtn icon mIcon" href="javascript:void(0);"></a>
-        </div>
-    </div>
-
-    <!--主体内容-->
-    <div>
-
-    </div>
-
-</div>
-
-<!-- 引入底部 -->
-<template th:replace="components/footer"></template>
-<template th:replace="components/foot-link"></template>
-<script charset="utf-8" type="text/javascript" th:src="@{/js/supplier/product.js(v=${version})}"></script>
-</body>
-</html>