Browse Source

立即购买和购物车问题解决。

yangc 8 years ago
parent
commit
56e23499f2

+ 25 - 10
components/common/buyOrCar/buyComponent.vue

@@ -18,23 +18,37 @@
           })
         } else {
           if (this.item) {
-            console.log(this.item)
-            // this.$emit('buyAction', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])
             if (isBuy) {
-              // this.$store.dispatch('user/getBuyInfo', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])
               this.$http.post('trade/order/buyNow', [{
                 uuid: this.item.uuid,
                 batchCode: this.item.batchCode,
                 number: this.item.minBuyQty,
                 storeid: this.item.storeid,
-                currencyName: this.item.currencyName
+                storeUuid: this.item.storeid,
+                currencyName: this.item.currencyName,
+                minPackQty: this.item.minPackQty
               }])
                 .then(response => {
           //        window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
-                  if (response.data.message) {
-                    this.$message.error(response.data.message)
+                  if (response.data.success) {
+                    if (response.data.message) {
+                      this.$message({
+                        message: response.data.message,
+                        type: 'success'
+                      })
+                      let _self = this
+                      window.setTimeout(function () {
+                        window.location.href = '/user#/order/pay/' + _self.enidfilter(response.data.data.orderid)
+                      }, 1000)
+                    } else {
+                      window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.data.orderid)
+                    }
                   } else {
-                    window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.data.orderid)
+                    if (response.data.data && response.data.data.unvailable === 1) {
+                      this.$message.error('产品信息已失效')
+                    } else {
+                      this.$message.error(response.data.message)
+                    }
                   }
                 }, err => {
                   console.log(err)
@@ -46,13 +60,15 @@
                 batchCode: this.item.batchCode,
                 number: this.item.minBuyQty,
                 storeid: this.item.storeid,
-                currencyName: this.item.currencyName
+                storeUuid: this.item.storeid,
+                currencyName: this.item.currencyName,
+                minPackQty: this.item.minPackQty
               })
                 .then(response => {
                   if (response.data.success) {
                     if (response.data.message) {
                       this.$message({
-                        message: response.data.message,
+                        message: '添加购物车成功,但商品信息有更新',
                         type: 'success'
                       })
                     } else {
@@ -63,7 +79,6 @@
                     }
                   } else {
                     this.$message.error(response.data.message)
-                    // console.log(response.data.message)
                   }
                 })
             }

+ 50 - 16
components/store/CommodityInfo.vue

@@ -280,33 +280,67 @@ export default {
         })
       } else {
         if (item) {
-          // this.$emit('buyAction', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])
           if (isBuy) {
-            // this.$store.dispatch('user/getBuyInfo', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])
-            this.$http.post('trade/order/buyNow', [{uuid: item.uuid, batchCode: item.batchCode, number: this.fragment.num}])
+            this.$http.post('trade/order/buyNow', [{
+              uuid: item.uuid,
+              batchCode: item.batchCode,
+              number: this.fragment.num,
+              storeid: item.storeid,
+              storeUuid: item.storeid,
+              currencyName: item.currencyName,
+              minPackQty: item.minPackQty
+            }])
               .then(response => {
-                window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
+                //        window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
+                if (response.data.success) {
+                  if (response.data.message) {
+                    this.$message({
+                      message: response.data.message,
+                      type: 'success'
+                    })
+                    let _self = this
+                    window.setTimeout(function () {
+                      window.location.href = '/user#/order/pay/' + _self.enidfilter(response.data.data.orderid)
+                    }, 1000)
+                  } else {
+                    window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.data.orderid)
+                  }
+                } else {
+                  if (response.data.data && response.data.data.unvailable === 1) {
+                    this.$message.error('产品信息已失效')
+                  } else {
+                    this.$message.error(response.data.message)
+                  }
+                }
               }, err => {
                 console.log(err)
-                this.$http.get('/login/page').then(response => {
-                  if (response.data) {
-                    this.$router.push('/auth/login')
-                  }
-                })
               })
           } else {
             // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
-            this.$http.post('trade/cart/add', {uuid: item.uuid, batchCode: item.batchCode, number: this.fragment.num})
+            this.$http.post('trade/cart/add', {
+              uuid: item.uuid,
+              batchCode: item.batchCode,
+              number: this.fragment.num,
+              storeid: item.storeid,
+              storeUuid: item.storeid,
+              currencyName: item.currencyName,
+              minPackQty: item.minPackQty
+            })
               .then(response => {
-                console.log(response.data)
                 if (response.data.success) {
-                  this.$message({
-                    message: '添加购物车成功',
-                    type: 'success'
-                  })
+                  if (response.data.message) {
+                    this.$message({
+                      message: '添加购物车成功,但商品信息有更新',
+                      type: 'success'
+                    })
+                  } else {
+                    this.$message({
+                      message: '添加购物车成功',
+                      type: 'success'
+                    })
+                  }
                 } else {
                   this.$message.error(response.data.message)
-                  // console.log(response.data.message)
                 }
               })
           }

+ 50 - 13
components/store/RecommendProduct.vue

@@ -28,7 +28,6 @@
 </template>
 <script>
   import Buy from '~components/common/buyOrCar/buyComponent.vue'
-  import axios from '~/plugins/axios'
   export default {
     name: 'recommend-product',
     components: {
@@ -52,29 +51,67 @@
           })
         } else {
           if (item) {
-            // this.$emit('buyAction', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])
             if (isBuy) {
-              // this.$store.dispatch('user/getBuyInfo', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])
-              axios.post('trade/order/buyNow', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])
+              this.$http.post('trade/order/buyNow', [{
+                uuid: item.comUuid,
+                batchCode: item.batchCode,
+                number: item.minBuyQty,
+                storeid: item.storeId,
+                storeUuid: item.storeUuid,
+                currencyName: item.currency,
+                minPackQty: item.minPackQty
+              }])
                 .then(response => {
-                  window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
+                  //        window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
+                  if (response.data.success) {
+                    if (response.data.message) {
+                      this.$message({
+                        message: response.data.message,
+                        type: 'success'
+                      })
+                      let _self = this
+                      window.setTimeout(function () {
+                        window.location.href = '/user#/order/pay/' + _self.enidfilter(response.data.data.orderid)
+                      }, 1000)
+                    } else {
+                      window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.data.orderid)
+                    }
+                  } else {
+                    if (response.data.data && response.data.data.unvailable === 1) {
+                      this.$message.error('产品信息已失效')
+                    } else {
+                      this.$message.error(response.data.message)
+                    }
+                  }
                 }, err => {
-                  this.$message.error('以下器件null对应的商品不存在,请您重新选择')
                   console.log(err)
                 })
             } else {
-              console.log(item)
               // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
-              axios.post('trade/cart/add', {uuid: item.comUuid, batchCode: item.batchCode, number: item.minBuyQty, currencyName: item.currency})
+              this.$http.post('trade/cart/add', {
+                uuid: item.comUuid,
+                batchCode: item.batchCode,
+                number: item.minBuyQty,
+                storeid: item.storeId,
+                storeUuid: item.storeUuid,
+                currencyName: item.currency,
+                minPackQty: item.minPackQty
+              })
                 .then(response => {
                   if (response.data.success) {
-                    this.$message({
-                      message: '添加购物车成功',
-                      type: 'success'
-                    })
+                    if (response.data.message) {
+                      this.$message({
+                        message: '添加购物车成功,但商品信息有更新',
+                        type: 'success'
+                      })
+                    } else {
+                      this.$message({
+                        message: '添加购物车成功',
+                        type: 'success'
+                      })
+                    }
                   } else {
                     this.$message.error(response.data.message)
-                    // console.log(response.data.message)
                   }
                 })
             }

+ 1 - 1
nuxt.config.js

@@ -1,6 +1,6 @@
 const path = require('path')
 const isProdMode = Object.is(process.env.NODE_ENV, 'production')
-const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://www.usoftmall.com/' : 'http://192.168.253.60:9090/platform-b2c/')
+const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://www.usoftmall.com/' : 'http://192.168.253.123:8080/')
 
 module.exports = {
   router: {