Эх сурвалжийг харах

Merge branch 'master' into release-20170915

yangc 8 жил өмнө
parent
commit
ca387383a3

+ 23 - 5
components/common/page/pageComponent.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="page-wrap" v-if="total/1.0/pageSize>1">
     <el-pagination
-      :current-page.sync="nowPage"
+      :current-page.sync="currentPage"
       :page-size="pageSize"
       layout="prev, pager, next"
       :total="total"
@@ -10,7 +10,7 @@
     </el-pagination>
     <ul class="pagination" style="float:right;margin-left:20px;">
       <li>
-        <input type="text" class="page-number" v-model="nowPage">
+        <input type="number" class="page-number" @keyup.13="changePage" v-model="nowPage">
       </li>
       <li>
         <a class="page-a" @click="changePage">GO</a>
@@ -23,20 +23,30 @@
   export default {
     data () {
       return {
-        nowPage: 1
+        nowPage: 1,
+        currentPage: 1
       }
     },
     watch: {
       current: function () {
-        this.nowPage = this.current
+        this.nowPage = Number(this.current)
+        this.currentPage = this.nowPage
       }
     },
     props: ['current', 'total', 'pageSize'],
     methods: {
       handleCurrentChange: function (changedPage) {
-        this.$emit('childEvent', changedPage)
+        if (this.nowPage !== this.currentPage) {
+          this.$emit('childEvent', changedPage)
+        }
       },
       changePage: function () {
+        let totalPage = Math.ceil(this.total / this.pageSize)
+        if (this.nowPage > totalPage) {
+          this.nowPage = totalPage
+        } else if (this.nowPage < 1) {
+          this.nowPage = 1
+        }
         this.$emit('childEvent', this.nowPage)
       }
     }
@@ -150,4 +160,12 @@
     display: inline-block;
     margin: 0;
   }
+  input.page-number {
+    -moz-appearance:textfield;
+  }
+  input.page-number::-webkit-inner-spin-button,
+  input.page-number::-webkit-outer-spin-button {
+    -webkit-appearance: none;
+    margin: 0;
+  }
 </style>

+ 27 - 2
components/product/ComponentGoods.vue

@@ -70,7 +70,7 @@
           </div>
           <div v-for="price in compGoods.prices">
             <!--| formateNumber : 6-->
-            <span>{{price.uSDPrice}}</span>
+            <span>{{price.uSDPrice | currency}}</span>
           </div>
         </td>
         <td>
@@ -79,7 +79,7 @@
           </div>
           <div v-for="price in compGoods.prices">
             <!--formateNumber : 6-->
-            <span>{{price.rMBPrice}}</span>
+            <span>{{price.rMBPrice | currency}}</span>
           </div>
         </td>
         <td>
@@ -143,6 +143,31 @@
         return goodsPage
       }
     },
+    filters: {
+      currency: function (num) {
+        if (typeof num === 'number') {
+          if (num <= 0.000001) {
+            num = 0.000001
+          } else {
+            if (num.toString().indexOf('.') === -1) {
+              num += '.00'
+            } else {
+              let inputStr = num.toString()
+              let floatNum = inputStr.split('.')[1]
+              if (floatNum.length > 6) {
+                num = inputStr.substring(0, inputStr.length - 1)
+                if (Number(floatNum.charAt(6)) > 4) {
+                  num = Number(num) + 0.000001
+                }
+              } else if (floatNum.length === 1) {
+                num = num + '0'
+              }
+            }
+          }
+        }
+        return num
+      }
+    },
     methods: {
       addToCart: function (goods, buyNow) {
         return null

+ 17 - 2
components/product/component/StoreInfo.vue

@@ -159,8 +159,23 @@
     filters: {
       currency: function (num) {
         if (typeof num === 'number') {
-          if (num.toString().indexOf('.') === -1) {
-            num += '.00'
+          if (num <= 0.000001) {
+            num = 0.000001
+          } else {
+            if (num.toString().indexOf('.') === -1) {
+              num += '.00'
+            } else {
+              let inputStr = num.toString()
+              let floatNum = inputStr.split('.')[1]
+              if (floatNum.length > 6) {
+                num = inputStr.substring(0, inputStr.length - 1)
+                if (Number(floatNum.charAt(6)) > 4) {
+                  num = Number(num) + 0.000001
+                }
+              } else if (floatNum.length === 1) {
+                num = num + '0'
+              }
+            }
           }
         }
         return num

+ 17 - 2
components/search/GoodList.vue

@@ -175,8 +175,23 @@
     filters: {
       currency: function (input) {
         if (typeof input === 'number') {
-          if (input.toString().indexOf('.') === -1) {
-            input = input + '.00'
+          if (input <= 0.000001) {
+            input = 0.000001
+          } else {
+            if (input.toString().indexOf('.') === -1) {
+              input = input + '.00'
+            } else {
+              let inputStr = input.toString()
+              let floatNum = inputStr.split('.')[1]
+              if (floatNum.length > 6) {
+                input = inputStr.substring(0, inputStr.length - 1)
+                if (Number(floatNum.charAt(6)) > 4) {
+                  input = Number(input) + 0.000001
+                }
+              } else if (floatNum.length === 1) {
+                input = input + '0'
+              }
+            }
           }
         }
         return input

+ 27 - 2
components/store/CommodityInfo.vue

@@ -109,10 +109,10 @@
                       <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">{{price.rMBPrice || 0 | currency}}</span>
                     </div>
                     <div class="price">
-                      <span v-if="price.uSDPrice" v-text="price.uSDPrice || 0"></span>
+                      <span v-if="price.uSDPrice">{{price.uSDPrice || 0 | currency}}</span>
                     </div>
                   </li>
                 </ul>
@@ -176,6 +176,31 @@ export default {
         canSub: true}
     }
   },
+  filters: {
+    currency: function (num) {
+      if (typeof num === 'number') {
+        if (num <= 0.000001) {
+          num = 0.000001
+        } else {
+          if (num.toString().indexOf('.') === -1) {
+            num += '.00'
+          } else {
+            let inputStr = num.toString()
+            let floatNum = inputStr.split('.')[1]
+            if (floatNum.length > 6) {
+              num = inputStr.substring(0, inputStr.length - 1)
+              if (Number(floatNum.charAt(6)) > 4) {
+                num = Number(num) + 0.000001
+              }
+            } else if (floatNum.length === 1) {
+              num = num + '0'
+            }
+          }
+        }
+      }
+      return num
+    }
+  },
   computed: {
     storeInfo () {
       return this.$store.state.shop.storeInfo.store.data

+ 27 - 2
components/store/CommodityList.vue

@@ -79,13 +79,13 @@
               <div v-show="commodity.currencyName.indexOf('USD')==-1 || !commodity.prices">
                 <span>—</span>
               </div>
-              <div v-for="price in commodity.prices" v-text="price.uSDPrice"></div>
+              <div v-for="price in commodity.prices">{{price.uSDPrice | currency}}</div>
             </td>
             <td>
               <div v-show="commodity.currencyName.indexOf('RMB')==-1 || !commodity.prices">
                 <span>—</span>
               </div>
-              <div v-for="price in commodity.prices" v-text="price.rMBPrice"></div>
+              <div v-for="price in commodity.prices" >{{price.rMBPrice | currency}}</div>
             </td>
             <td>
               <div v-if="commodity.b2cMinDelivery">交期:
@@ -164,6 +164,31 @@ export default {
       ids: null
     }
   },
+  filters: {
+    currency: function (num) {
+      if (typeof num === 'number') {
+        if (num <= 0.000001) {
+          num = 0.000001
+        } else {
+          if (num.toString().indexOf('.') === -1) {
+            num += '.00'
+          } else {
+            let inputStr = num.toString()
+            let floatNum = inputStr.split('.')[1]
+            if (floatNum.length > 6) {
+              num = inputStr.substring(0, inputStr.length - 1)
+              if (Number(floatNum.charAt(6)) > 4) {
+                num = Number(num) + 0.000001
+              }
+            } else if (floatNum.length === 1) {
+              num = num + '0'
+            }
+          }
+        }
+      }
+      return num
+    }
+  },
   computed: {
     commodities () {
       return this.$store.state.shop.storeInfo.storeCommodity.data