Browse Source

Merge remote-tracking branch 'origin/master'

ouxq 8 years ago
parent
commit
31c47cc413

+ 3 - 0
components/common/buyOrCar/buyComponent.vue

@@ -52,6 +52,9 @@
                   }
                   }
                 }, err => {
                 }, err => {
                   console.log(err)
                   console.log(err)
+                  if (this.item.minBuyQty > this.item.reserve) {
+                    this.$message.error('商品' + this.item.code + '的库存已经不满足起订量')
+                  }
                 })
                 })
             } else {
             } else {
               // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
               // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})

+ 13 - 5
components/main/count/Box.vue

@@ -23,8 +23,8 @@
           autoplay: 5000,
           autoplay: 5000,
           speed: 500,
           speed: 500,
           direction: 'vertical',
           direction: 'vertical',
-          slidesPerView: 2,
-          slidesPerGroup: 2
+          slidesPerView: 1,
+          slidesPerGroup: 1
         }
         }
       }
       }
     },
     },
@@ -52,11 +52,19 @@
 <style lang="scss" scoped>
 <style lang="scss" scoped>
   .count-box {
   .count-box {
     position: relative;
     position: relative;
-    top: 15px;
+    top: 21px;
     float: right;
     float: right;
-    width: 300px;
-    height: 60px;
+    width: 210px;
+    height: 40px;
+    margin-right: 60px;
     overflow: hidden;
     overflow: hidden;
+    border-radius: 3px;
+    background: #83c5f8;
+  .swiper-slide{
+    width: 100%;
+    /*background: #83c5f8;*/
+    border-radius: 3px;
+  }
 
 
   .swiper-container {
   .swiper-container {
     height: 100%;
     height: 100%;

+ 64 - 11
components/main/count/Item.vue

@@ -1,7 +1,12 @@
 <template>
 <template>
   <div class="count-item">
   <div class="count-item">
     <span class="title">{{ title }}</span>
     <span class="title">{{ title }}</span>
-    <span v-for="num in nums" :class="num == ',' ? 'separator' : 'num'">{{ num }}</span>
+    <div class="count-content">
+      <span v-for="num in nums" :class="num == ',' ? 'separator' : num == 0 ? 'zero num' : 'num'">{{ num }}</span>
+     <!-- <span v-if="nums.length < 7">个</span>
+      <span v-if="nums.length > 7">万</span>-->
+      <span v-text="isMore?'万':'个'"></span>
+    </div>
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
@@ -16,14 +21,30 @@
         type: String
         type: String
       }
       }
     },
     },
+    data () {
+      return {
+        isMore: false
+      }
+    },
     methods: {
     methods: {
       formatNumber (num) {
       formatNumber (num) {
+        console.log(num)
         let re = /(\d+)(\d{3})/
         let re = /(\d+)(\d{3})/
-        num = (Array(10 - String(num).length).join(0) + num)
+        if (num > 9999) {
+          this.isMore = true
+          let str = num.toString()
+          num = Math.floor(num / 10000)
+          if (parseInt(str.charAt(str.length - 4)) > 4) {
+            num = num + 1
+          }
+        }
+        num = (Array(7 - String(num).length).join(0) + num)
         while (re.test(num)) {
         while (re.test(num)) {
-          num = num.replace(re, '$1,$2')
+          num = num.replace(re, '$1$2')
         }
         }
-        return num.split('')
+        num = num.split('')
+//        console.log(num)
+        return num
       }
       }
     },
     },
     computed: {
     computed: {
@@ -42,26 +63,58 @@
 
 
     .title {
     .title {
       display: inline-block;
       display: inline-block;
-      width: 60px;
+      width: 58px;
       float: left;
       float: left;
       font-weight: bold;
       font-weight: bold;
+      line-height: 40px;
+      color: #fff;
+      font-size: 14px;
     }
     }
     .separator, .num {
     .separator, .num {
       display: inline-block;
       display: inline-block;
     }
     }
     .separator {
     .separator {
       font-size: 12px;
       font-size: 12px;
-      color: $primary;
-      margin: 0 5px 0 -2px;
+      color: #6cb7f3;
+      line-height: 38px !important;
+      margin: 0 5px 0 -5px;
+      width: 3px;
+    }
+    .count-content{
+      width: 145px;
+      background: #fff;
+      float: right;
+      height: 30px;
+      margin-top: 5px;
+      margin-right: 5px;
+      span{
+        float: left;
+        line-height: 24px;
+        font-weight: bold;
+      }
+      span.zero{
+        color: #bbdffb;
+      }
+      span:first-child{
+        margin-left: 3px;
+      }
+      span:last-child{
+        line-height: 30px;
+        color: #6cb7f3;
+        margin-left: 2px;
+      }
     }
     }
     .num {
     .num {
-      background: $primary;
-      width: 15px;
-      height: 20px;
-      margin-right: 10px;
+      background: #9dd0f9;
+      width: 18px;
+      height: 24px;
+      margin-right: 2px;
+      line-height: 24px;
       text-align: center;
       text-align: center;
       color: $white;
       color: $white;
       font-weight: bold;
       font-weight: bold;
+      border-radius: 2px;
+      margin-top: 3px;
     }
     }
   }
   }
 </style>
 </style>

+ 9 - 4
components/store/CommodityInfo.vue

@@ -88,7 +88,7 @@
                  <span>{{(calculate || 0)}}</span>
                  <span>{{(calculate || 0)}}</span>
               </span>
               </span>
             </div>
             </div>
-            <div class="button" ng-controller="GoodsPickUpCtrl">
+            <div class="button">
               <button class="btn btn-default btn-primary" @click="buyNow(false, commodity)">加入购物车</button>
               <button class="btn btn-default btn-primary" @click="buyNow(false, commodity)">加入购物车</button>
               <button class="btn btn-default btn-now" @click="buyNow(true, commodity)">立即购买</button>
               <button class="btn btn-default btn-now" @click="buyNow(true, commodity)">立即购买</button>
             </div>
             </div>
@@ -214,7 +214,7 @@ export default {
       }
       }
     },
     },
     changeNum: function (newNum) {
     changeNum: function (newNum) {
-      let pack = this.commodity.minPackQty
+      let pack = this.commodity.perQty || this.commodity.minPackQty
       let buy = this.commodity.minBuyQty
       let buy = this.commodity.minBuyQty
       let reserve = this.commodity.reserve
       let reserve = this.commodity.reserve
       if (newNum < buy) {
       if (newNum < buy) {
@@ -258,12 +258,14 @@ export default {
       }
       }
     },
     },
     subNum () {
     subNum () {
-      let newNum = this.fragment.num - this.commodity.minPackQty
+      let pack = this.commodity.perQty || this.commodity.minPackQty
+      let newNum = this.fragment.num - pack
       this.changeNum(newNum)
       this.changeNum(newNum)
       getFragment(this.commodity, this.fragment)
       getFragment(this.commodity, this.fragment)
     },
     },
     addNum () {
     addNum () {
-      let newNum = this.fragment.num + this.commodity.minPackQty
+      let pack = this.commodity.perQty || this.commodity.minPackQty
+      let newNum = this.fragment.num + pack
       this.changeNum(newNum)
       this.changeNum(newNum)
       getFragment(this.commodity, this.fragment)
       getFragment(this.commodity, this.fragment)
     },
     },
@@ -319,6 +321,9 @@ export default {
                 }
                 }
               }, err => {
               }, err => {
                 console.log(err)
                 console.log(err)
+                if (item.minBuyQty > item.reserve) {
+                  this.$message.error('商品' + item.code + '的库存已经不满足起订量')
+                }
               })
               })
           } else {
           } else {
             // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
             // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})

+ 3 - 1
components/store/RecommendProduct.vue

@@ -43,7 +43,6 @@
     },
     },
     methods: {
     methods: {
       buyNow: function (isBuy, item) {
       buyNow: function (isBuy, item) {
-        console.log(item)
         if (!this.$store.state.option.user.logged) {
         if (!this.$store.state.option.user.logged) {
           this.$http.get('/login/page').then(response => {
           this.$http.get('/login/page').then(response => {
             if (response.data) {
             if (response.data) {
@@ -86,6 +85,9 @@
                   }
                   }
                 }, err => {
                 }, err => {
                   console.log(err)
                   console.log(err)
+                  if (item.minBuyQty > item.reserve) {
+                    this.$message.error('商品' + item.code + '的库存已经不满足起订量')
+                  }
                 })
                 })
             } else {
             } else {
               // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
               // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})

+ 1 - 1
plugins/axios.js

@@ -4,7 +4,7 @@ import store from '~store'
 
 
 const service = axios.create({
 const service = axios.create({
   withCredentials: true,
   withCredentials: true,
-  baseURL: '/'
+  baseURL: process.env.proxyUrl || process.env.baseUrl
 })
 })
 
 
 service.interceptors.request.use(config => {
 service.interceptors.request.use(config => {

+ 14 - 8
server.js

@@ -57,14 +57,20 @@ const nuxt = new Nuxt(config)
 app.use(nuxt.render)
 app.use(nuxt.render)
 
 
 // Build only in dev mode
 // Build only in dev mode
-if (config.dev) {
-  nuxt.build()
-    .catch((error) => {
-      // eslint-disable-line no-console
-      console.error(error)
-      process.exit(1)
-    })
-}
+// if (config.dev) {
+//   nuxt.build()
+//     .catch((error) => {
+//       // eslint-disable-line no-console
+//       console.error(error)
+//       process.exit(1)
+//     })
+// }
+nuxt.build()
+  .catch((error) => {
+    // eslint-disable-line no-console
+    console.error(error)
+    process.exit(1)
+  })
 
 
 // Listen the server
 // Listen the server
 app.listen(port)
 app.listen(port)