chao 4 年之前
父节点
当前提交
3d202db869
共有 2 个文件被更改,包括 6 次插入5 次删除
  1. 5 5
      src/main/resources/static/js/product/detail.js
  2. 1 0
      src/main/resources/templates/product/detail.html

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

@@ -34,7 +34,7 @@ var productDetail = new Vue({
     methods: {
         getImages: function(){
             var _self = this;
-            if(this.productId ===0){return;}
+            if(!this.productId){return;}
             $.getJSON(spiServer + "/product/detail/images",{productId: this.productId}).done(function (r) {
                 if (r.code === 0 && r.data) {
                     _self.images = r.data;
@@ -208,7 +208,7 @@ var productDetail = new Vue({
 			},
         getRecommends: function(){
             var _self = this;
-            if(this.productId ===0){return;}
+            if(!this.productId){return;}
             $.getJSON(spiServer + "/product/detail/recommend",{
                 productId: this.productId,
                 recommendType: this.recommendType
@@ -233,7 +233,7 @@ var productDetail = new Vue({
         },
         ladderPrice:function(){
             var _self = this;
-            if(this.productId ===0){return;}
+            if(!this.productId){return;}
             $.getJSON(spiServer + "/product/ladderPrice",{
                 productId: this.productId
             }).done(function (r) {
@@ -255,7 +255,7 @@ var productDetail = new Vue({
         },
         getParameters: function(){
             var _self = this;
-            if(this.productId ===0){return;}
+            if(!this.productId){return;}
             $.getJSON(spiServer + "/product/detail/parameter",{
                 productId: this.productId
             }).done(function (r) {
@@ -286,7 +286,7 @@ var productDetail = new Vue({
         }
     },
     created: function () {
-        this.productId = getUrlParam("id") ? getUrlParam("id")*1 : 0;
+        this.productId = $("#productId").val();
         var userInfo = localStorage.getItem('userInfo');
         if(userInfo){
             this.userId = JSON.parse(userInfo).userId*1;

+ 1 - 0
src/main/resources/templates/product/detail.html

@@ -13,6 +13,7 @@
 
 <!-- 商品详情 -->
 <div id="productDetail">
+    <input type="hidden" th:value="${product.id}" id="productId">
     <div class="wrap">
         <div class="productBox clear">
             <div class="imageBox" id="imgShown">