Browse Source

立即购买,添加购物车按钮样式调整

yangc 8 years ago
parent
commit
38dba77ed0

+ 39 - 30
components/common/buyOrCar/buyComponent.vue

@@ -12,36 +12,47 @@
     props: ['item'],
     methods: {
       buyNow: function (isBuy) {
-        if (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}])
-            axios.post('trade/order/buyNow', [{uuid: this.item.uuid, batchCode: this.item.batchCode, number: this.item.minBuyQty}])
-              .then(response => {
-                window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
-              }, err => {
-                console.log(err)
-                this.$http.get('/login/page').then(response => {
-                  if (response.data) {
-                    this.$router.push('/auth/login')
-                  }
+        if (!this.$store.state.option.user.logged) {
+          this.$http.get('/login/page').then(response => {
+            if (response.data) {
+              this.$router.push('/auth/login')
+            }
+          })
+        } else {
+          if (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}])
+              axios.post('trade/order/buyNow', [{
+                uuid: this.item.uuid,
+                batchCode: this.item.batchCode,
+                number: this.item.minBuyQty
+              }])
+                .then(response => {
+                  window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
+                }, err => {
+                  console.log(err)
                 })
+            } else {
+              // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
+              axios.post('trade/cart/add', {
+                uuid: this.item.uuid,
+                batchCode: this.item.batchCode,
+                number: this.item.minBuyQty
               })
-          } else {
-            // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
-            axios.post('trade/cart/add', {uuid: this.item.uuid, batchCode: this.item.batchCode, number: this.item.minBuyQty})
-              .then(response => {
-                console.log(response.data)
-                if (response.data.success) {
-                  Message({
-                    message: '添加购物车成功',
-                    type: 'success'
-                  })
-                } else {
-                  Message.error(response.data.message)
-                  // console.log(response.data.message)
-                }
-              })
+                .then(response => {
+                  console.log(response.data)
+                  if (response.data.success) {
+                    Message({
+                      message: '添加购物车成功',
+                      type: 'success'
+                    })
+                  } else {
+                    Message.error(response.data.message)
+                    // console.log(response.data.message)
+                  }
+                })
+            }
           }
         }
         // window.location.href = 'user#/order/pay/' + this.enidfilter(this.buy_info.orderid)
@@ -126,7 +137,6 @@
     height: 30px;
     font-size: 12px;
     border: 1px solid #5078cb;
-    padding-top: 8px;
   }
 
   .btn-add-cart {
@@ -137,7 +147,6 @@
     font-size: 12px;
     background-color: #fff;
     border: 1px solid #e8e8e8;
-    padding-top: 8px;
   }
  .btn-buy-now:hover{
     background: #214797;

+ 36 - 28
components/store/CommodityInfo.vue

@@ -222,36 +222,44 @@ export default {
       getFragment(this.commodity, this.fragment)
     },
     buyNow: function (isBuy, item) {
-      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: this.fragment.num}])
-            .then(response => {
-              window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
-            }, err => {
-              console.log(err)
-              this.$http.get('/login/page').then(response => {
-                if (response.data) {
-                  this.$router.push('/auth/login')
+      if (!this.$store.state.option.user.logged) {
+        this.$http.get('/login/page').then(response => {
+          if (response.data) {
+            this.$router.push('/auth/login')
+          }
+        })
+      } 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: this.fragment.num}])
+              .then(response => {
+                window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
+              }, 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})
+            axios.post('trade/cart/add', {uuid: item.uuid, batchCode: item.batchCode, number: this.fragment.num})
+              .then(response => {
+                console.log(response.data)
+                if (response.data.success) {
+                  Message({
+                    message: '添加购物车成功',
+                    type: 'success'
+                  })
+                } else {
+                  Message.error(response.data.message)
+                  // console.log(response.data.message)
                 }
               })
-            })
-        } else {
-          // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
-          axios.post('trade/cart/add', {uuid: item.uuid, batchCode: item.batchCode, number: this.fragment.num})
-            .then(response => {
-              console.log(response.data)
-              if (response.data.success) {
-                Message({
-                  message: '添加购物车成功',
-                  type: 'success'
-                })
-              } else {
-                Message.error(response.data.message)
-                // console.log(response.data.message)
-              }
-            })
+          }
         }
       }
       // window.location.href = 'user#/order/pay/' + this.enidfilter(this.buy_info.orderid)

+ 36 - 28
components/store/RecommendProduct.vue

@@ -45,36 +45,44 @@
     },
     methods: {
       buyNow: function (isBuy, item) {
-        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}])
-              .then(response => {
-                window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
-              }, err => {
-                console.log(err)
-                this.$http.get('/login/page').then(response => {
-                  if (response.data) {
-                    this.$router.push('/auth/login')
+        if (!this.$store.state.option.user.logged) {
+          this.$http.get('/login/page').then(response => {
+            if (response.data) {
+              this.$router.push('/auth/login')
+            }
+          })
+        } 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}])
+                .then(response => {
+                  window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.orderid)
+                }, 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})
+              axios.post('trade/cart/add', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
+                .then(response => {
+                  console.log(response.data)
+                  if (response.data.success) {
+                    Message({
+                      message: '添加购物车成功',
+                      type: 'success'
+                    })
+                  } else {
+                    Message.error(response.data.message)
+                    // console.log(response.data.message)
                   }
                 })
-              })
-          } else {
-            // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
-            axios.post('trade/cart/add', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
-              .then(response => {
-                console.log(response.data)
-                if (response.data.success) {
-                  Message({
-                    message: '添加购物车成功',
-                    type: 'success'
-                  })
-                } else {
-                  Message.error(response.data.message)
-                  // console.log(response.data.message)
-                }
-              })
+            }
           }
         }
       },

+ 1 - 1
nuxt.config.js

@@ -109,5 +109,5 @@ module.exports = {
     ssr: false
   }],
   /* TODO 暂时代理到商城测试版,之后再做出调整 */
-  proxyTable: ['/api/**', '/search/**', '/user/**', '/login/**', '/logout/**', '/static/**', '/vendor**', '/user**', '/trade/**', '/recommendation/**', '/store-service/**', '/basic/**', '/logout**', '/operation/**', '/help**']
+  proxyTable: ['/api/**', '/search/**', '/user/**', '/login/**', '/logout/**', '/static/**', '/vendor**', '/user**', '/trade/**', '/recommendation/**', '/store-service/**', '/basic/**', '/logout**', '/operation/**', '/help**', '/product**', '/platform-b2c**']
 }

+ 0 - 0
pages/user/accountManager.vue


+ 0 - 0
pages/user/cart.vue


+ 0 - 0
pages/user/home/index.js


+ 0 - 0
pages/user/invoice.vue


+ 0 - 0
pages/user/order.vue


+ 0 - 0
pages/user/payCenter.vue