Parcourir la source

商品详情无userid接口静态化

zhijiezhao il y a 3 ans
Parent
commit
ff44eee915

+ 5 - 0
src/main/java/com/caimei/www/controller/unlimited/ProductController.java

@@ -3,6 +3,7 @@ package com.caimei.www.controller.unlimited;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei.www.controller.BaseController;
+import com.caimei.www.pojo.page.Parameter;
 import com.caimei.www.pojo.page.ProductDetail;
 import com.caimei.www.service.page.ProductService;
 import com.caimei.www.service.page.SinglePageService;
@@ -105,6 +106,10 @@ public class ProductController extends BaseController {
         if (detail == null || detail.getValidFlag() == 0 || detail.getValidFlag() == 9) {
             return super.errorPath();
         }
+        List<String> images=productService.getImages(productId);
+        List<Parameter> params=productService.getParams(productId);
+        model.addAttribute("params",params);
+        model.addAttribute("images",images);
         model.addAttribute("productId", productId);
         model.addAttribute("product", detail);
         return PRODUCT_DETAIL_PATH;

+ 6 - 0
src/main/java/com/caimei/www/service/page/ProductService.java

@@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.baike.BaikeProduct;
 import com.caimei.www.pojo.baike.BaikeType;
+import com.caimei.www.pojo.page.Parameter;
 import com.caimei.www.pojo.page.ProductDetail;
 
+import java.util.List;
 import java.util.Map;
 
 
@@ -93,4 +95,8 @@ public interface ProductService {
      * @return
      */
     BaikeType getBaikeType(Integer typeId);
+
+    List<String> getImages(Integer productId);
+
+    List<Parameter> getParams(Integer productId);
 }

+ 18 - 0
src/main/java/com/caimei/www/service/page/impl/ProductServiceImpl.java

@@ -7,6 +7,7 @@ import com.caimei.www.mapper.BaikeDao;
 import com.caimei.www.mapper.ProductDao;
 import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.baike.*;
+import com.caimei.www.pojo.page.Parameter;
 import com.caimei.www.pojo.page.ProductDetail;
 import com.caimei.www.service.page.ProductService;
 import com.caimei.www.utils.ImageUtil;
@@ -211,6 +212,23 @@ public class ProductServiceImpl implements ProductService {
         return baikeDao.getBaikeType(typeId);
     }
 
+    @Override
+    public List<String> getImages(Integer productId) {
+        List<String> productDetailImages = productDao.getProductDetailImages(productId);
+        List<String> strings = new ArrayList<>();
+        if(null!=productDetailImages&&productDetailImages.size()>0){
+            productDetailImages.forEach(p->{
+                strings.add(ImageUtil.getImageURL("product",p,0,domain));
+            });
+        }
+        return strings;
+    }
+
+    @Override
+    public List<Parameter> getParams(Integer productId) {
+        return  productDao.getProductParameters(productId);
+    }
+
     @Override
     public BaikeProduct getBaikeProductDetail(Integer productId) {
         BaikeProduct baikeProduct = baikeDao.getBaikeProductDetail(productId);

+ 24 - 24
src/main/resources/static/js/common/serviceapi/product.service.js

@@ -28,18 +28,18 @@ var ProductApi = {
                 callback(res);
             });
         },
-        GetProductDdtailsImages: function (params, callback) {//获取商品图片
-            Http.AjaxService({
-                url:'/commodity/product/detail/images',
-                type:'get',
-                data:params,
-                json:true,
-                isHost:true
-            })
-            .then(function(res){
-                callback(res);
-            });
-        },
+        // GetProductDdtailsImages: function (params, callback) {//获取商品图片
+        //     Http.AjaxService({
+        //         url:'/commodity/product/detail/images',
+        //         type:'get',
+        //         data:params,
+        //         json:true,
+        //         isHost:true
+        //     })
+        //     .then(function(res){
+        //         callback(res);
+        //     });
+        // },
         GetProductDdtailsPrice: function (params, callback) {//获取商品价格
             Http.AjaxService({
                 url:'/commodity/price/detail',
@@ -64,18 +64,18 @@ var ProductApi = {
                 callback(res);
             });
         },
-        GetProductDdtailsParameter: function (params, callback) {//获取商品参数
-            Http.AjaxService({
-                url:'/commodity/detail/params',
-                type:'get',
-                data:params,
-                json:true,
-                isHost:true
-            })
-            .then(function(res){
-                callback(res);
-            });
-        },
+        // GetProductDdtailsParameter: function (params, callback) {//获取商品参数
+        //     Http.AjaxService({
+        //         url:'/commodity/detail/params',
+        //         type:'get',
+        //         data:params,
+        //         json:true,
+        //         isHost:true
+        //     })
+        //     .then(function(res){
+        //         callback(res);
+        //     });
+        // },
         GetProductDdtailsRecommend: function (params, callback) {//获取商品推荐
             Http.AjaxService({
                 url:'/commodity/detail/recommend',

+ 1 - 1
src/main/resources/static/js/document/beauty-archive.js

@@ -140,7 +140,7 @@ var beautyArchive = new Vue({
                 window.location.href = '/404.html'
             }
             if (product.redirectType === 1) {
-                url = '/product-' + product.productId + '.html?open=caimei365';
+                url = '/product-' + product.productId +'-'+globalUserData.userId+ '.html?open=caimei365';
             } else if (product.redirectType === 2) {
                 url = '/document/archive-detail.html' + '?id=' + product.archiveId;
             } else {

+ 49 - 49
src/main/resources/static/js/product/detail.js

@@ -135,41 +135,41 @@ var productDetail = new Vue({
                 }
             });
         },
-        getImages: function () {
-            var _self = this;
-            if (!this.productId) {
-                return;
-            }
-            ProductApi.GetProductDdtailsImages({productId: _self.productId}, function (response) {
-                if (response.code === 0 && response.data) {
-                    _self.images = response.data;
-                    setTimeout(function () {
-                        if (isPC) {
-                            var magnifier = new ImageMagnifier(
-                                '#imgShown .smallImage li',
-                                '#imgShown .bigImage',
-                                '#imgShown .zoomImage',
-                                '#imgShown .mask',
-                                '#imgShown .zoom',
-                                "on"
-                            ).init();
-                        } else {
-                            var swiper = new Swiper('#swiperImage', {
-                                loop: true,
-                                autoplay: {
-                                    delay: 2000,
-                                    disableOnInteraction: false
-                                },
-                                pagination: {
-                                    el: '.swiper-pagination',
-                                    type: 'fraction'
-                                }
-                            });
-                        }
-                    }, 500);
-                }
-            });
-        },
+        // getImages: function () {
+        //     var _self = this;
+        //     if (!this.productId) {
+        //         return;
+        //     }
+        //     ProductApi.GetProductDdtailsImages({productId: _self.productId}, function (response) {
+        //         if (response.code === 0 && response.data) {
+        //             _self.images = response.data;
+        //             setTimeout(function () {
+        //                 if (isPC) {
+        //                     var magnifier = new ImageMagnifier(
+        //                         '#imgShown .smallImage li',
+        //                         '#imgShown .bigImage',
+        //                         '#imgShown .zoomImage',
+        //                         '#imgShown .mask',
+        //                         '#imgShown .zoom',
+        //                         "on"
+        //                     ).init();
+        //                 } else {
+        //                     var swiper = new Swiper('#swiperImage', {
+        //                         loop: true,
+        //                         autoplay: {
+        //                             delay: 2000,
+        //                             disableOnInteraction: false
+        //                         },
+        //                         pagination: {
+        //                             el: '.swiper-pagination',
+        //                             type: 'fraction'
+        //                         }
+        //                     });
+        //                 }
+        //             }, 500);
+        //         }
+        //     });
+        // },
         getProductDetails: function () {
             var _self = this;
             ProductApi.GetProductDdtails({userId: GLOBAL_USER_ID, productId: _self.productId}, function (response) {
@@ -317,18 +317,18 @@ var productDetail = new Vue({
                 }
             });
         },
-        getParameters: function () {//获取商品参数
-            var _self = this;
-            if (!this.productId) {
-                return;
-            }
-            ProductApi.GetProductDdtailsParameter({productId: _self.productId}, function (response) {
-                if (response.code === 0 && response.data) {
-                    _self.parameters = response.data;
-                    console.log(_self.parameters)
-                }
-            });
-        },
+        // getParameters: function () {//获取商品参数
+        //     var _self = this;
+        //     if (!this.productId) {
+        //         return;
+        //     }
+        //     ProductApi.GetProductDdtailsParameter({productId: _self.productId}, function (response) {
+        //         if (response.code === 0 && response.data) {
+        //             _self.parameters = response.data;
+        //             console.log(_self.parameters)
+        //         }
+        //     });
+        // },
         toggleThisLadder: function (event) {
             var el = event.currentTarget;
             if ($(el).hasClass("on")) {
@@ -804,7 +804,7 @@ var productDetail = new Vue({
         this.productId = this.couponParam.productId = this.listQuery.productId = $("#productId").val();
         this.userId = this.couponParam.userId = this.listQuery.userId = GLOBAL_USER_ID;
         this.productStock = $("#productStock").val();
-        this.getImages();
+        // this.getImages();
         // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
         // visibility:3:所有人可见,2:普通机构可见,1:会员机构可见 4:仅医美机构可见
         var visible = $("#productVisibility").val() * 1;
@@ -821,7 +821,7 @@ var productDetail = new Vue({
         this.userId = this.couponParam.userId = GLOBAL_USER_ID;
         this.getProductDetails();
         this.getProductPrice();
-        this.getParameters();
+        // this.getParameters();
         this.queryProductDetilsCoupons();
         this.getCommodityCombinationList();
         console.log('GLOBAL_CLUB_TYPE',GLOBAL_CLUB_TYPE)

+ 8 - 8
src/main/resources/templates/product/detail.html

@@ -27,14 +27,14 @@
                 <div class="cm-product-cover-tag"  v-if="pcActType === 1"></div>
                 <div class="page_main_type" th:if="*{productType}==2">医疗器械</div>
                 <div v-if="isPC" class="bigImage">
-                    <img :src="images[0]">
+                    <img th:src="${images[0]}">
                     <span class="mask"></span>
 <!--                    <span class="cm-product-cover-tag" v-if="isPC && pcActType === 1">云上美博会</span>-->
                 </div>
                 <div id="swiperImage" class="smallImage swiper-container">
                     <ul class="swiper-wrapper clear">
-                        <li class="swiper-slide mfc" v-for="img in images">
-                            <img :src="img">
+                        <li class="swiper-slide mfc" th:each="img : ${images}">
+                            <img th:src="${img}">
 <!--                            <span class="cm-product-cover-tag" v-if="!isPC && pcActType === 1">云上美博会</span>-->
 <!--                            <span class="cm-product-cover-tag" v-if="!isPC && pcActType === 1"></span>-->
                         </li>
@@ -43,7 +43,7 @@
                 </div>
                 <div v-if="isPC" class="zoomImage">
                     <div class="zoom">
-                        <img :src="images[0]">
+                        <img th:src="${images[0]}">
                     </div>
                 </div>
             </div>
@@ -454,7 +454,7 @@
         <div class="productInfo">
             <div class="tabTit">
                 <span :class="tabsIndex == 0 ? 'on' : ''" @click="detailsClicktab(0)">商品详情</span>
-                <span :class="tabsIndex == 1 ? 'on' : ''" v-if="parameters.length>0 && !isNoneDisabled" @click="detailsClicktab(1)">相关参数</span>
+                <span :class="tabsIndex == 1 ? 'on' : ''" th:if="${null!=params && params.size()>0}" v-if="!isNoneDisabled" @click="detailsClicktab(1)">相关参数</span>
                 <span :class="tabsIndex == 2 ? 'on' : ''" v-if="isServiceInfo && !isNoneDisabled" @click="detailsClicktab(2)">服务项目</span>
                 <span :class="tabsIndex == 3 ? 'on' : ''" v-if="isTrainingMethod" @click="detailsClicktab(3)">培训方案</span>
                 <span v-if="archiveId !== 0" :class="tabsIndex == 4 ? 'on' : ''" @click="detailsClicktab(4)">相关资料</span>
@@ -482,9 +482,9 @@
                 </div>
                 <div class="item" v-if="tabsIndex == 1">
                     <table>
-                        <tr v-for="pa in parameters">
-                            <td v-text="pa.paramsName"></td>
-                            <td v-text="pa.paramsContent"></td>
+                        <tr th:each="pa : ${params}">
+                            <td th:text="${pa.name}"></td>
+                            <td th:text="${pa.content}"></td>
                         </tr>
                     </table>
                 </div>