Browse Source

Merge branch 'master' of ssh://10.10.101.21/source/mall-web-ssr into HEAD

# Conflicts:
#	components/product/CategoryProperty.vue
yangc 8 years ago
parent
commit
98fac02811

+ 37 - 11
components/product/CategoryProperty.vue

@@ -21,7 +21,7 @@
           <tr>
             <td class="td-width dropdown">
               <span  class="dropdown-toggle dropdown-back" data-toggle="dropdown">品牌<span class="fa fa-angle-down td-icon"></span></span>
-              <ul class="dropdown-menu parameter-selection-ul" role="menu" aria-labelledby="dropdownMenu1">
+              <ul class="dropdown-menu parameter-selection-ul" role="menu" aria-labelledby="dropdownMenu1" style="top: 38px;">
                 <!--orderBy:'nameCn'-->
                 <li v-for="b in brands"><a @click="selectBrand(b)"><span>{{b.nameCn}}</span></a></li>
               </ul>
@@ -56,8 +56,8 @@
           <tbody>
           <tr v-if="hasProperties" class="tr-properties">
             <td v-for="pro in properties" class="td-properties" style="vertical-align:middle;" >
- 								<span class="sl-selected" v-if="pro.selected" @click="selectProperty(pro)">
- 									<a class="text-num">{{pro.selected.value}}</a>
+ 								<span class="sl-selected" @click="selectProperty(pro.propertyId)" v-if="selectedProduct['a' + pro.propertyId] != ''">
+ 									<a class="text-num" v-text="selectedProduct['a' + pro.propertyId].value" style="color: #5078CB"></a>
 									<span><i class="fa fa-close"></i></span>
  								</span>
             </td>
@@ -71,7 +71,7 @@
         </table>
       </div>
           <ul v-show="list_exp_flag" @mouseenter="show_exp_list()" @mouseleave="hide_exp_list()" class="parameter-selection-ul drop-down-list" role="menu" aria-labelledby="dropdownMenu1">
-            <li v-for="v in selectedProperties.values"><a @click="selectPropertyValue(selectedProperties, v)" class="a-color"><span>{{v.value}}</span></a></li>
+            <li v-for="item in selectedProperties.values"><a @click="selectPropertyValue(item, selectedProperties.propertyId)" class="a-color"><span>{{item.value}}</span></a></li>
           </ul>
     </div>
   </div>
@@ -87,9 +87,19 @@
           nameCn: null
         },
         selectedProperties: {},
-        list_exp_flag: false
+        list_exp_flag: false,
+        selectedProduct: {},
+        JSONObj: {}
       }
     },
+    mounted () {
+//      var list = document.getElementsByClassName('list-menu')
+//      var container = document.getElementsByClassName('div-table')
+//      list.onmouseover = function () {
+//        var id = list[0].getAttribute['split-dropdown-trigger']
+//        console.log(id)
+//      }
+    },
     computed: {
       kind () {
         return this.$store.state.product.kind.kindsParentWithBother.data[this.$store.state.product.kind.kindsParentWithBother.data.length - 1]
@@ -98,7 +108,11 @@
         return this.$store.state.product.kind.children.data
       },
       properties () {
-        return this.$store.state.product.kind.kindProperty.data
+        let arr = this.$store.state.product.kind.kindProperty.data
+        for (let i = 0; i < arr.length; i++) {
+          this.selectedProduct[ 'a' + arr[i].propertyId ] = ''
+        }
+        return arr
       },
       brands () {
         return this.$store.state.product.kind.brands.data
@@ -124,11 +138,24 @@
         this.selectedBrand = {}
         this.$emit('loadCmpGoodsByBrandEvent', null)
       },
-      selectProperty (item) {
-        return null
+      selectProperty (propertyId) {
+        this.selectedProduct['a' + propertyId] = ''
+        this.hasProperties = this.isempty(this.selectedProduct)
+        this.$emit('loadCmpGoodsByTypeEvent', null)
+      },
+      isempty (obj) {
+        for (let attr in obj) {
+          if (obj[attr] !== '') {
+            return true
+          }
+        }
+        return false
       },
-      selectPropertyValue (item, value) {
-        return null
+      selectPropertyValue (item, propertyId) {
+        this.hasProperties = true
+        this.selectedProduct['a' + propertyId] = item
+        this.JSONObj[propertyId] = item.value
+        this.$emit('loadCmpGoodsByTypeEvent', JSON.stringify(this.JSONObj))
       },
       use_exp_list: function (pro, index) {
         this.selectedProperties = pro
@@ -162,7 +189,6 @@
   .breadcrumbs ul.list-unstyled.list-inline {
     margin-left: 0px;
   }
-
   .breadcrumbs ul.list-inline.list-unstyled li.crumb-item {
     position: relative;
     padding-left: 0px;

+ 13 - 3
components/product/component/StoreInfo.vue

@@ -42,7 +42,7 @@
             <th class="text-center" width="100">香港交货<span style="font-size: 12px;">($)</span></th>
             <th class="text-center" width="130">大陆交货<span style="font-size: 12px;">(¥)</span></th>
             <th class="text-center" width="120">交期</span></th>
-            <th class="text-center" width="150">操作</th>
+            <th class="text-center" width="140">操作</th>
           </tr>
         </thead>
         <tbody class="text-center">
@@ -79,7 +79,7 @@
                   <span>—</span>
                 </div>
                 <div v-for="price in list.prices">
-                  <span>{{price.uSDPrice}}</span>
+                  <span>{{price.uSDPrice | currency}}</span>
                 </div>
               </a>
             </td>
@@ -89,7 +89,7 @@
                   <span>—</span>
                 </div>
                 <div v-for="price in list.prices">
-                  <span>{{price.rMBPrice}}</span>
+                  <span>{{price.rMBPrice | currency}}</span>
                 </div>
               </a>
             </td>
@@ -117,6 +117,16 @@
 <script>
   export default {
     name: 'StoreInfo',
+    filters: {
+      currency: function (num) {
+        if (typeof num === 'number') {
+          if (num.toString().indexOf('.') === -1) {
+            num += '.00'
+          }
+        }
+        return num
+      }
+    },
     computed: {
       stores () {
         return this.$store.state.componentStore.store

+ 3 - 3
components/store/CommodityInfo.vue

@@ -75,7 +75,7 @@
               <span class="money">
                  <span v-if="fragment.currency == 'RMB'">¥</span>
                  <span v-if="fragment.currency == 'USD'">$</span>
-                 <span v-text="calculate || 0"></span>
+                 <span>{{(calculate || 0) | currency('', 2)}}</span>
               </span>
             </div>
             <div class="button" ng-controller="GoodsPickUpCtrl">
@@ -98,7 +98,7 @@
                       <span v-text="price.start"></span>+
                     </div>
                     <div class="price">
-                      <span v-if="price.rMBPrice" v-text="price.rMBPrice ||0"></span>
+                      <span v-if="price.rMBPrice" v-text="price.rMBPrice || 0"></span>
                     </div>
                     <div class="price">
                       <span v-if="price.uSDPrice" v-text="price.uSDPrice || 0"></span>
@@ -174,7 +174,7 @@ export default {
     },
     calculate () {
       this.fragment.total = this.fragment.price * this.fragment.num
-      return this.fragment.total
+      return Math.ceil(this.fragment.total * Math.pow(10, 2)) / Math.pow(10, 2)
     }
   },
   methods: {

+ 3 - 0
nuxt.config.js

@@ -95,6 +95,9 @@ module.exports = {
     ssr: false
   }, {
     src: '~plugins/element-ui.js'
+  }, {
+    src: '~plugins/filters.js',
+    ssr: false
   }],
   proxyTable: ['/api/**', '/search/**', '/user/**', '/login/**', '/logout/**']
 }

+ 2 - 1
package.json

@@ -15,7 +15,8 @@
     "http-proxy-middleware": "^0.17.4",
     "iview": "^2.0.0-rc.19",
     "nuxt": "0.10.6",
-    "vue-awesome-swiper": "^2.5.4"
+    "vue-awesome-swiper": "^2.5.4",
+    "vue2-filters": "^0.1.9"
   },
   "scripts": {
     "dev": "nodemon --exec node server.js",

+ 8 - 1
pages/product/kind/_id.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="container">
     <categroy-nav></categroy-nav>
-    <category-property  @loadCmpGoodsByBrandEvent="listemBrandFilter"></category-property>
+    <category-property  @loadCmpGoodsByBrandEvent="listemBrandFilter" @loadCmpGoodsByTypeEvent="listemProTypeFilter"></category-property>
     <component-goods></component-goods>
   </div>
 </template>
@@ -33,6 +33,13 @@
         } else {
           this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id})
         }
+      },
+      listemProTypeFilter (propertyJSON) {
+        if (propertyJSON !== {}) {
+          this.$store.dispatch('product/pageComGoods', propertyJSON == null ? {kindid: this.$route.params.id} : {kindid: this.$route.params.id, properties: propertyJSON})
+        } else {
+          this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id})
+        }
       }
     }
   }

+ 4 - 0
plugins/filters.js

@@ -0,0 +1,4 @@
+import Vue from 'vue'
+import Vue2Filters from 'vue2-filters'
+
+Vue.use(Vue2Filters)

+ 10 - 0
store/index.js

@@ -236,6 +236,16 @@ export const actions = {
         commit('brandComponent/GET_COMPONENT_FAILURE', err)
       })
   },
+  // 获取品牌详情分页信息
+  loadBrandPages ({commit}, params = {}) {
+    commit('brandPages/REQUEST_PAGES', params)
+    return axios.get('/api/product/PAGES/list', { params })
+      .then(response => {
+        commit('brandPages/GET__SUCCESS', response.data)
+      }, err => {
+        commit('brandPages/GET_COMPONENT_FAILURE', err)
+      })
+  },
   // 获取帮助中心信息
   loadHelpSnapsho ({ commit }, params = {}) {
     commit('help/REQUEST_SNAPSHO')

+ 1 - 1
store/product.js

@@ -86,7 +86,7 @@ export const actions = {
   },
   pageComGoods ({ commit }, kindid = '', brandid = '', pageParams = { page: 1, count: 10 }) {
     let params = {}
-    let filter = {kindid: kindid.kindid, brandid: kindid.brandid}
+    let filter = {kindid: kindid.kindid, brandid: kindid.brandid, properties: kindid.properties}
     params.filter = filter
     params.page = pageParams.page
     params.count = pageParams.count

+ 4 - 0
yarn.lock

@@ -4965,6 +4965,10 @@ vue-template-es2015-compiler@^1.2.2:
   version "1.5.3"
   resolved "http://registry.npm.taobao.org/vue-template-es2015-compiler/download/vue-template-es2015-compiler-1.5.3.tgz#22787de4e37ebd9339b74223bc467d1adee30545"
 
+vue2-filters@^0.1.9:
+  version "0.1.9"
+  resolved "http://registry.npm.taobao.org/vue2-filters/download/vue2-filters-0.1.9.tgz#3fc9e78e5744efff03223cff0e395907bb6b41ed"
+
 vue@^2.2.6:
   version "2.4.1"
   resolved "http://registry.npm.taobao.org/vue/download/vue-2.4.1.tgz#76e0b8eee614613532216b7bfe784e0b5695b160"