|
|
@@ -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)
|