Browse Source

购买和购物车功能

yangc 8 years ago
parent
commit
24d9af36ab

+ 149 - 0
components/common/buyOrCar/BuyComponent.vue

@@ -0,0 +1,149 @@
+<template>
+  <div>
+    <button class="btn btn-primary btn-buy-now"  @click="buyNow(true)"><span class="watch">立即购买</span></button>
+    <button class="btn btn-add-cart"  @click="buyNow(false)"><span class="watch">加入购物车</span></button>
+  </div>
+</template>
+
+<script>
+  import axios from '~/plugins/axios'
+  import {Message} from 'element-ui'
+  export default {
+    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')
+                  }
+                })
+              })
+          } 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)
+                }
+              })
+          }
+        }
+        // window.location.href = 'user#/order/pay/' + this.enidfilter(this.buy_info.orderid)
+      },
+      enidfilter: function (str) {
+        if (str) {
+          let encryptStr = '' // 最终返回的加密后的字符串
+          // 产生三位随机数
+          let num = ''
+          for (let i = 0; i < 3; i++) {
+            num += Math.floor(Math.random() * 10)
+          }
+          encryptStr += num // 产生3位随机数
+
+          // 16位加密
+          let tempspit = ''
+          let strspit = str.toString().toLowerCase()
+          if (strspit.match(/^[-+]?\d*$/) === null) { // 非整数字符,对每一个字符都转换成16进制,然后拼接
+            /**
+             * Unicode汉字、英文字母、数字的unicode范围
+             *汉字:[0x4e00,0x9fa5](或十进制[19968,40869])
+             *数字:[0x30,0x39](或十进制[48, 57])
+             *小写字母:[0x61,0x7a](或十进制[97, 122])
+             *大写字母:[0x41,0x5a](或十进制[65, 90]
+             * 'a'的Unicode编码:'&#97;',charCodeAt()的值是97
+             * '码'的Unicode编码:'\u7801', new String('码').charCodeAt()的值是30721,30721的16进制表示是7801
+             */
+            let s = strspit.split('')
+            for (let i = 0; i < s.length; i++) {
+              s[i] = s[i].charCodeAt() // 先转换成Unicode编码
+              s[i] = s[i].toString(16)
+              // 因为在服务器是每两位当做一个字符进行解析的,所以这里每个字符的Unicode编码范围必须在0——255之间。数字和大小写满足该要求,特殊字符则不一定,如果后续有特殊字符的要求,需要重写编码器和解码器
+              if (s[i].length === 1) {
+                s[i] = '0' + s[i]
+              }
+              tempspit = tempspit + s[i]
+            }
+            tempspit = tempspit + '{' + 1 // 1代表字符
+          } else { // 数字直接转换成16进制
+            strspit = parseInt(strspit)
+              .toString(16)
+            tempspit = strspit + '{' + 0 // 0代表纯数字
+          }
+
+          let temp = tempspit.split('{') // 对要加密的字符转换成16进制
+          let numLength = temp[0].length // 转换后的字符长度
+          numLength = numLength.toString(16) // 字符长度换算成16进制
+          if (numLength.length === 1) { // 如果是1,补一个0
+            numLength = '0' + numLength
+          } else if (numLength.length > 3) { // 转换后的16进制字符长度如果大于2位数,则返回,不支持
+            return ''
+          }
+          encryptStr += numLength
+          if (temp[1] === '0') {
+            encryptStr += 0
+          } else if (temp[1] === '1') {
+            encryptStr += 1
+          }
+          encryptStr += temp[0]
+          if (encryptStr.length < 20) { // 如果小于20位,补上随机数
+            // 产生三位随机数
+            let numtwo = ''
+            for (let i = 0; i < 20 - encryptStr.length; i++) {
+              numtwo += Math.floor(Math.random() * 10)
+            }
+            let ran = numtwo // 产生3位随机数
+            encryptStr += ran
+          }
+          return encryptStr
+        }
+      }
+    }
+  }
+</script>
+
+<style scoped>
+  /* 物品列表按钮 */
+  .btn-buy-now {
+    background-color: #5078CB;
+    color: #fff;
+    width: 80px;
+    height: 30px;
+    font-size: 12px;
+    border: 1px solid #5078cb;
+    padding-top: 8px;
+  }
+
+  .btn-add-cart {
+    margin-top: 10px;
+    color: #214797;
+    width: 80px;
+    height: 30px;
+    font-size: 12px;
+    background-color: #fff;
+    border: 1px solid #e8e8e8;
+    padding-top: 8px;
+  }
+ .btn-buy-now:hover{
+    background: #214797;
+  }
+  .btn-add-cart:hover{
+    background-color: #5078CB;
+    color: #fff;
+  }
+</style>

+ 2 - 2
components/default/Header.vue

@@ -33,8 +33,8 @@
             <nuxt-link class="item" to="/vendor">卖家中心</nuxt-link>-->
             <!--<a class="item" :href="url + '/user'">买家中心</a>
             <a class="item" :href="url + '/vendor'">卖家中心</a>-->
-            <a class="item" href="user#/index">买家中心</a>
-            <a class="item" href="vendor#/index">卖家中心</a>
+            <a class="item" href="/user#/index">买家中心</a>
+            <a class="item" href="/vendor#/index">卖家中心</a>
           </template>
           <template v-else>
             <a class="item" @click="onLoginClick()">登录</a>

+ 5 - 6
components/product/ComponentGoods.vue

@@ -89,12 +89,7 @@
           <div v-if="!compGoods.reserve">
             <span>—</span>
           </div>
-          <div v-if="compGoods.reserve > 0">
-            <button class="btn btn-primary btn-buy-now" @click="addToCart(compGoods, true)"><span class="watch">立即购买</span></button>
-          </div>
-          <div v-if="compGoods.reserve > 0">
-            <button class="btn btn-add-cart" @click="addToCart(compGoods, false)"><span class="watch">加入购物车</span></button>
-          </div>
+          <buy :item="compGoods"></buy>
         </td>
       </tr>
       <tr v-if="componentGoods.totalElements == 0">
@@ -117,9 +112,13 @@
 </template>
 
 <script>
+  import Buy from '~components/common/buyOrCar/BuyComponent.vue'
   export default {
     layout: 'mian',
     props: ['brandid', 'propertyJSON'],
+    components: {
+      Buy
+    },
     data () {
       return {
         pageParams: {

+ 7 - 4
components/product/component/StoreInfo.vue

@@ -102,8 +102,7 @@
               </a>
             </td>
             <td>
-              <button class="btn btn-buyNow">立即购买</button>
-              <button class="btn btn-default">加入购物车</button>
+              <buy :item="list"></buy>
             </td>
           </tr>
           <tr v-if="!storeList.content || storeList.content.length == 0">
@@ -115,8 +114,12 @@
   </div>
 </template>
 <script>
+  import Buy from '~components/common/buyOrCar/BuyComponent.vue'
   export default {
     name: 'StoreInfo',
+    components: {
+      Buy
+    },
     filters: {
       currency: function (num) {
         if (typeof num === 'number') {
@@ -212,7 +215,7 @@
   .container .goodsList tbody tr td:hover a{
     color: #474443;
   }
-  .container .goodsList .btn{
+/*  .container .goodsList .btn{
     border-radius: 4px;
     width: 80px;
     height: 30px;
@@ -234,7 +237,7 @@
   .container .goodsList .btn-default{
     background-color: #fff;
     border-color: #ccc;
-  }
+  }*/
   .container .form-group input{
     vertical-align: sub;
   }

+ 12 - 7
components/search/GoodList.vue

@@ -122,10 +122,7 @@
                 <span>—</span>
               </div>
               <div v-if="item.reserve > 0">
-                <a href="/user#/order/pay/524241737332303137303830313030303030303036" class="btn btn-primary btn-buy-now" ><span class="watch">立即购买</span></a>
-              </div>
-              <div v-if="item.reserve > 0">
-                <a class="btn btn-add-cart"><span class="watch">加入购物车</span></a>
+              <buy :item="item" :isStoreStyle="false"></buy>
               </div>
             </td>
           </tr>
@@ -145,6 +142,7 @@
 
 <script>
   import Page from '~components/common/page/pageComponent.vue'
+  import Buy from '~components/common/buyOrCar/BuyComponent.vue'
   export default {
     data () {
       return {
@@ -160,7 +158,8 @@
       }
     },
     components: {
-      Page
+      Page,
+      Buy
     },
     props: ['crname_click_flag'],
     filters: {
@@ -182,6 +181,12 @@
       },
       total_count () {
         return Math.min(this.good_list.total, 100 * this.pageSize)
+      },
+      buy_info () {
+        return this.$store.state.user.buy.buyInfo.data
+      },
+      car_info () {
+        return this.$store.state.user.car.addCarInfo.data
       }
     },
     methods: {
@@ -415,7 +420,7 @@
   }
 
   /* 物品列表按钮 */
-  .product-list .btn-buy-now {
+ /* .product-list .btn-buy-now {
     background-color: #5078CB;
     color: #fff;
     width: 80px;
@@ -441,7 +446,7 @@
   .product-list .btn-add-cart:hover{
     background-color: #5078CB;
     color: #fff;
-  }
+  }*/
   .product-list .text-left{
     text-align: left;
   }

+ 106 - 4
components/store/CommodityInfo.vue

@@ -79,8 +79,8 @@
               </span>
             </div>
             <div class="button" ng-controller="GoodsPickUpCtrl">
-              <button class="btn btn-default btn-primary" ng-click="addToCart(commodity, false, fragment.num, fragment.currency)">加入购物车</button>
-              <button class="btn btn-default btn-now" ng-click="addToCart(commodity, true, fragment.num, fragment.currency)">立即购买</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>
             </div>
           </div>
           <div class="price-block">
@@ -114,7 +114,6 @@
   </div>
 </template>
 <script>
-
 function initFragment (commodity) {
   if (!commodity) {
     return {}
@@ -137,7 +136,8 @@ function initFragment (commodity) {
   }
   return fragment
 }
-
+import axios from '~/plugins/axios'
+import {Message} from 'element-ui'
 function getFragment (commodity, fragment) {
   // 判断是否小于第一分段的起订量
   if (commodity.prices[0].start > fragment.num) {
@@ -220,6 +220,108 @@ export default {
         this.fragment.num = this.commodity.reserve
       }
       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')
+                }
+              })
+            })
+        } 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)
+    },
+    enidfilter: function (str) {
+      if (str) {
+        let encryptStr = '' // 最终返回的加密后的字符串
+        // 产生三位随机数
+        let num = ''
+        for (let i = 0; i < 3; i++) {
+          num += Math.floor(Math.random() * 10)
+        }
+        encryptStr += num // 产生3位随机数
+
+        // 16位加密
+        let tempspit = ''
+        let strspit = str.toString().toLowerCase()
+        if (strspit.match(/^[-+]?\d*$/) === null) { // 非整数字符,对每一个字符都转换成16进制,然后拼接
+          /**
+           * Unicode汉字、英文字母、数字的unicode范围
+           *汉字:[0x4e00,0x9fa5](或十进制[19968,40869])
+           *数字:[0x30,0x39](或十进制[48, 57])
+           *小写字母:[0x61,0x7a](或十进制[97, 122])
+           *大写字母:[0x41,0x5a](或十进制[65, 90]
+           * 'a'的Unicode编码:'&#97;',charCodeAt()的值是97
+           * '码'的Unicode编码:'\u7801', new String('码').charCodeAt()的值是30721,30721的16进制表示是7801
+           */
+          let s = strspit.split('')
+          for (let i = 0; i < s.length; i++) {
+            s[i] = s[i].charCodeAt() // 先转换成Unicode编码
+            s[i] = s[i].toString(16)
+            // 因为在服务器是每两位当做一个字符进行解析的,所以这里每个字符的Unicode编码范围必须在0——255之间。数字和大小写满足该要求,特殊字符则不一定,如果后续有特殊字符的要求,需要重写编码器和解码器
+            if (s[i].length === 1) {
+              s[i] = '0' + s[i]
+            }
+            tempspit = tempspit + s[i]
+          }
+          tempspit = tempspit + '{' + 1 // 1代表字符
+        } else { // 数字直接转换成16进制
+          strspit = parseInt(strspit)
+            .toString(16)
+          tempspit = strspit + '{' + 0 // 0代表纯数字
+        }
+
+        let temp = tempspit.split('{') // 对要加密的字符转换成16进制
+        let numLength = temp[0].length // 转换后的字符长度
+        numLength = numLength.toString(16) // 字符长度换算成16进制
+        if (numLength.length === 1) { // 如果是1,补一个0
+          numLength = '0' + numLength
+        } else if (numLength.length > 3) { // 转换后的16进制字符长度如果大于2位数,则返回,不支持
+          return ''
+        }
+        encryptStr += numLength
+        if (temp[1] === '0') {
+          encryptStr += 0
+        } else if (temp[1] === '1') {
+          encryptStr += 1
+        }
+        encryptStr += temp[0]
+        if (encryptStr.length < 20) { // 如果小于20位,补上随机数
+          // 产生三位随机数
+          let numtwo = ''
+          for (let i = 0; i < 20 - encryptStr.length; i++) {
+            numtwo += Math.floor(Math.random() * 10)
+          }
+          let ran = numtwo // 产生3位随机数
+          encryptStr += ran
+        }
+        return encryptStr
+      }
     }
   }
 }

+ 5 - 8
components/store/CommodityList.vue

@@ -86,12 +86,7 @@
               <div v-if="commodity.b2cMinDelivery">交期:{{commodity.b2cMinDelivery || 0}}-{{commodity.b2cMaxDelivery || 0}}天</div>
             </td>
             <td>
-              <div>
-                <button class="btn btn-primary btn-buy-now" ng-click="addToCart(commodity, true, commodity.minBuyQty, commodity.currencyName)"><span class="watch">立即购买</span></button>
-              </div>
-              <div>
-                <button class="btn btn-add-cart" ng-click="addToCart(commodity, false, commodity.minBuyQty, commodity.currencyName)"><span class="watch">加入购物车</span></button>
-              </div>
+              <buy :item="commodity"></buy>
             </td>
           </tr>
           <tr v-if="!commodities.content || commodities.content.length == 0">
@@ -123,7 +118,6 @@
   </div>
 </template>
 <script>
-
 function getAllLeafIds (kind) {
   if (!kind) {
     return null
@@ -141,10 +135,13 @@ function getAllLeafIds (kind) {
     return ids.join('-')
   }
 }
-
+import Buy from '~components/common/buyOrCar/BuyComponent.vue'
 export default {
   name: 'commodity-list',
   props: ['kinds'],
+  components: {
+    Buy
+  },
   data () {
     return {
       defaultProps: {

+ 119 - 11
components/store/RecommendProduct.vue

@@ -18,8 +18,8 @@
               <div class="price" v-if="commodity.minPriceRMB">¥ {{commodity.minPriceRMB}}</div>
               <div class="price" v-if="!commodity.minPriceRMB">$ {{commodity.minPriceUSD || 0}}</div>
             </a>
-            <div class="by-cart"><button title="加入购物车" ng-click="addToCart(commodity, false, commodity.minBuyQty, commodity.currency)"><img src="/images/store/icon/cart-blue.png"/></button></div>
-            <div class="buy-now"><button title="立即购买" ng-click="addToCart(commodity, true, commodity.minBuyQty, commodity.currency)">立即购买</button></div>
+            <div class="by-cart"><button title="加入购物车" @click="buy(false, commodity)"><img src="/images/store/icon/cart-blue.png"/></button></div>
+            <div class="buy-now"><button title="立即购买" @click="buy(true, commodity)">立即购买</button></div>
           </div>
         </li>
       </ul>
@@ -27,18 +27,126 @@
   </div>
 </template>
 <script>
-
-export default {
-  name: 'recommend-product',
-  computed: {
-    commodities () {
-      return this.$store.state.shop.recommend.products.data
+  import Buy from '~components/common/buyOrCar/BuyComponent.vue'
+  import axios from '~/plugins/axios'
+  import {Message} from 'element-ui'
+  export default {
+    name: 'recommend-product',
+    components: {
+      Buy
+    },
+    computed: {
+      commodities () {
+        return this.$store.state.shop.recommend.products.data
+      },
+      storeInfo () {
+        return this.$store.state.shop.storeInfo.store.data
+      }
     },
-    storeInfo () {
-      return this.$store.state.shop.storeInfo.store.data
+    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')
+                  }
+                })
+              })
+          } 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)
+                }
+              })
+          }
+        }
+      },
+      enidfilter: function (str) {
+        if (str) {
+          let encryptStr = '' // 最终返回的加密后的字符串
+          // 产生三位随机数
+          let num = ''
+          for (let i = 0; i < 3; i++) {
+            num += Math.floor(Math.random() * 10)
+          }
+          encryptStr += num // 产生3位随机数
+
+          // 16位加密
+          let tempspit = ''
+          let strspit = str.toString().toLowerCase()
+          if (strspit.match(/^[-+]?\d*$/) === null) { // 非整数字符,对每一个字符都转换成16进制,然后拼接
+            /**
+             * Unicode汉字、英文字母、数字的unicode范围
+             *汉字:[0x4e00,0x9fa5](或十进制[19968,40869])
+             *数字:[0x30,0x39](或十进制[48, 57])
+             *小写字母:[0x61,0x7a](或十进制[97, 122])
+             *大写字母:[0x41,0x5a](或十进制[65, 90]
+             * 'a'的Unicode编码:'&#97;',charCodeAt()的值是97
+             * '码'的Unicode编码:'\u7801', new String('码').charCodeAt()的值是30721,30721的16进制表示是7801
+             */
+            let s = strspit.split('')
+            for (let i = 0; i < s.length; i++) {
+              s[i] = s[i].charCodeAt() // 先转换成Unicode编码
+              s[i] = s[i].toString(16)
+              // 因为在服务器是每两位当做一个字符进行解析的,所以这里每个字符的Unicode编码范围必须在0——255之间。数字和大小写满足该要求,特殊字符则不一定,如果后续有特殊字符的要求,需要重写编码器和解码器
+              if (s[i].length === 1) {
+                s[i] = '0' + s[i]
+              }
+              tempspit = tempspit + s[i]
+            }
+            tempspit = tempspit + '{' + 1 // 1代表字符
+          } else { // 数字直接转换成16进制
+            strspit = parseInt(strspit)
+              .toString(16)
+            tempspit = strspit + '{' + 0 // 0代表纯数字
+          }
+
+          let temp = tempspit.split('{') // 对要加密的字符转换成16进制
+          let numLength = temp[0].length // 转换后的字符长度
+          numLength = numLength.toString(16) // 字符长度换算成16进制
+          if (numLength.length === 1) { // 如果是1,补一个0
+            numLength = '0' + numLength
+          } else if (numLength.length > 3) { // 转换后的16进制字符长度如果大于2位数,则返回,不支持
+            return ''
+          }
+          encryptStr += numLength
+          if (temp[1] === '0') {
+            encryptStr += 0
+          } else if (temp[1] === '1') {
+            encryptStr += 1
+          }
+          encryptStr += temp[0]
+          if (encryptStr.length < 20) { // 如果小于20位,补上随机数
+            // 产生三位随机数
+            let numtwo = ''
+            for (let i = 0; i < 20 - encryptStr.length; i++) {
+              numtwo += Math.floor(Math.random() * 10)
+            }
+            let ran = numtwo // 产生3位随机数
+            encryptStr += ran
+          }
+          return encryptStr
+        }
+      }
     }
   }
-}
 </script>
 <style scoped>
   #recommend-fragment{

+ 20 - 0
store/user.js

@@ -30,5 +30,25 @@ export const actions = {
       }, err => {
         commit('history/GET_CARTCOUNT_FAILURE', err)
       })
+  },
+  // 获取购买信息
+  getBuyInfo ({ commit }, params) {
+    commit('buy/REQUEST_BUY')
+    return axios.post(`/trade/order/buyNow`, params)
+      .then(response => {
+        commit('buy/GET_BUY_SUCCESS', response.data)
+      }, err => {
+        commit('buy/GET_BUY_FAILURE', err)
+      })
+  },
+  // 加入购物车
+  addCar ({ commit }, params) {
+    commit('car/REQUEST_CAR')
+    return axios.post(`/trade/cart/add`, params)
+      .then(response => {
+        commit('car/GET_CAR_SUCCESS', response.data)
+      }, err => {
+        commit('car/GET_CAR_FAILURE', err)
+      })
   }
 }

+ 19 - 0
store/user/buy.js

@@ -0,0 +1,19 @@
+export const state = () => ({
+  buyInfo: {
+    fetching: false,
+    data: []
+  }
+})
+
+export const mutations = {
+  REQUEST_BUY (state) {
+    state.buyInfo.fetching = true
+  },
+  GET_BUY_FAILURE (state) {
+    state.buyInfo.fetching = false
+  },
+  GET_BUY_SUCCESS (state, result) {
+    state.buyInfo.fetching = false
+    state.buyInfo.data = result
+  }
+}

+ 19 - 0
store/user/car.js

@@ -0,0 +1,19 @@
+export const state = () => ({
+  addCarInfo: {
+    fetching: false,
+    data: []
+  }
+})
+
+export const mutations = {
+  REQUEST_CAR (state) {
+    state.addCarInfo.fetching = true
+  },
+  GET_CAR_FAILURE (state) {
+    state.addCarInfo.fetching = false
+  },
+  GET_CAR_SUCCESS (state, result) {
+    state.addCarInfo.fetching = false
+    state.addCarInfo.data = result
+  }
+}