Browse Source

产品详情页价格问题

yangc 7 years ago
parent
commit
a05497161d
1 changed files with 3 additions and 3 deletions
  1. 3 3
      components/store/CommodityInfo.vue

+ 3 - 3
components/store/CommodityInfo.vue

@@ -199,7 +199,7 @@
               let inputStr = num.toString()
               let arr = inputStr.split('.')
               let floatNum = arr[1]
-              if (floatNum) {
+              if (floatNum && arr[0]) {
                 if (floatNum.length > 2) {
                   num = inputStr.substring(0, arr[0].length + 3)
                   if (Number(floatNum.charAt(2)) >= 1) {
@@ -210,7 +210,7 @@
                     if (num.toString().indexOf('.') === -1) {
                       num += '.00'
                     }
-                    if (floatNum1.length === 1) {
+                    if (floatNum1 && floatNum1.length === 1) {
                       num = num + '0'
                     }
                   }
@@ -234,7 +234,7 @@
               let inputStr = num.toString()
               let arr = inputStr.split('.')
               let floatNum = arr[1]
-              if (floatNum) {
+              if (floatNum && arr[0]) {
                 if (floatNum.length > 6) {
                   num = inputStr.substring(0, arr[0].length + 7)
                   if (Number(floatNum.charAt(6)) > 4) {