Browse Source

器件詳情頁面加入货币格式化

hangb 8 years ago
parent
commit
1792c21b25
2 changed files with 23 additions and 3 deletions
  1. 13 3
      components/product/component/StoreInfo.vue
  2. 10 0
      store/index.js

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

+ 10 - 0
store/index.js

@@ -236,6 +236,16 @@ export const actions = {
         commit('brandComponent/GET_COMPONENT_FAILURE', err)
         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 = {}) {
   loadHelpSnapsho ({ commit }, params = {}) {
     commit('help/REQUEST_SNAPSHO')
     commit('help/REQUEST_SNAPSHO')