|
|
@@ -6,6 +6,7 @@
|
|
|
:class="{'disabled': disabledFlag}"
|
|
|
@click="buyNow(true, $event)">
|
|
|
<span class="watch">立即购买</span>
|
|
|
+
|
|
|
</button>
|
|
|
<button style="z-index: 1000;"
|
|
|
ref="addCartBtn"
|
|
|
@@ -17,6 +18,7 @@
|
|
|
@click="buyNow(false, $event)">
|
|
|
<span class="watch">加入购物车</span>
|
|
|
</button>
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -24,88 +26,104 @@
|
|
|
export default {
|
|
|
props: ['item', 'disabledFlag', 'btnColor'],
|
|
|
methods: {
|
|
|
+ drop(el) {
|
|
|
+ this.$store.commit('option/SET_BALLSLIST_SUCCESS', el)
|
|
|
+ },
|
|
|
buyNow: function (isBuy, event) {
|
|
|
+ this.drop(event.target)
|
|
|
+ // let $el = this.$refs.ballCard
|
|
|
+ // let transform = whichTransitionEvent()
|
|
|
+ // let _shopCar = document.getElementById('shopCar')
|
|
|
+ // let _eltop = event.currentTarget.getBoundingClientRect().top - 22
|
|
|
+ // let _elleft = event.currentTarget.getBoundingClientRect().left - 278
|
|
|
+ // // $el.style = `left: ${_elleft}px;top:${_eltop}px`
|
|
|
+ // $el.style[transform] = `translate3d(${_elleft}px,${_eltop}px,0)`
|
|
|
+ // $el.style.transition = 'all 0.5s'
|
|
|
+ // let _shopCarTop = _shopCar.getBoundingClientRect().top
|
|
|
+ // let _shopCarLeft = _shopCar.getBoundingClientRect().left
|
|
|
+ // $el.style[transform] = `translate3d(${_shopCarLeft}px,${_shopCarTop}px,0)`
|
|
|
event.stopPropagation()
|
|
|
- if (!this.$store.state.option.user.logged) {
|
|
|
- this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
|
|
|
- if (response.data) {
|
|
|
- window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- if (this.item && !this.disabledFlag) {
|
|
|
- if (isBuy) {
|
|
|
- this.$http.post('/trade/order/buyNow', [{
|
|
|
- uuid: this.item.uuid,
|
|
|
- batchCode: this.item.batchCode,
|
|
|
- number: this.item.minBuyQty,
|
|
|
- storeid: this.item.storeid ? this.item.storeid : this.item.storeId,
|
|
|
- storeUuid: this.item.storeid ? this.item.storeid : 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,
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- window.setTimeout(function () {
|
|
|
- window.location.href = '/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid)
|
|
|
- }, 1000)
|
|
|
- } else {
|
|
|
- window.location.href = '/user#/order/pay/' + this.baseUtils.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)
|
|
|
- if (this.item.minBuyQty > this.item.reserve) {
|
|
|
- this.$message.error('商品' + this.item.code + '的库存已经不满足最小起订量')
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$http.post('/trade/cart/add', {
|
|
|
- uuid: this.item.uuid,
|
|
|
- batchCode: this.item.batchCode,
|
|
|
- number: this.item.minBuyQty,
|
|
|
- storeid: this.item.storeid ? this.item.storeid : this.item.storeId,
|
|
|
- storeUuid: this.item.storeid ? this.item.storeid : this.item.storeId,
|
|
|
- currencyName: this.item.currencyName,
|
|
|
- minPackQty: this.item.minPackQty
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- if (response.data.success) {
|
|
|
- if (response.data.message) {
|
|
|
- this.$message({
|
|
|
- message: '添加购物车成功,但商品信息有更新',
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- message: '添加购物车成功',
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (response.data.code === 2) {
|
|
|
- this.$message.error('库存已不满足最小起订量')
|
|
|
- } else if (response.data.message === '该产品已失效') {
|
|
|
- this.$message.error(response.data.message + ',请刷新页面')
|
|
|
- } else {
|
|
|
- this.$message.error(response.data.message)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ return
|
|
|
+ // if (!this.$store.state.option.user.logged) {
|
|
|
+ // this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
|
|
|
+ // if (response.data) {
|
|
|
+ // window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // if (this.item && !this.disabledFlag) {
|
|
|
+ // if (isBuy) {
|
|
|
+ // this.$http.post('/trade/order/buyNow', [{
|
|
|
+ // uuid: this.item.uuid,
|
|
|
+ // batchCode: this.item.batchCode,
|
|
|
+ // number: this.item.minBuyQty,
|
|
|
+ // storeid: this.item.storeid ? this.item.storeid : this.item.storeId,
|
|
|
+ // storeUuid: this.item.storeid ? this.item.storeid : 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,
|
|
|
+ // type: 'success'
|
|
|
+ // })
|
|
|
+ // window.setTimeout(function () {
|
|
|
+ // window.location.href = '/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid)
|
|
|
+ // }, 1000)
|
|
|
+ // } else {
|
|
|
+ // window.location.href = '/user#/order/pay/' + this.baseUtils.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)
|
|
|
+ // if (this.item.minBuyQty > this.item.reserve) {
|
|
|
+ // this.$message.error('商品' + this.item.code + '的库存已经不满足最小起订量')
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // this.$http.post('/trade/cart/add', {
|
|
|
+ // uuid: this.item.uuid,
|
|
|
+ // batchCode: this.item.batchCode,
|
|
|
+ // number: this.item.minBuyQty,
|
|
|
+ // storeid: this.item.storeid ? this.item.storeid : this.item.storeId,
|
|
|
+ // storeUuid: this.item.storeid ? this.item.storeid : this.item.storeId,
|
|
|
+ // currencyName: this.item.currencyName,
|
|
|
+ // minPackQty: this.item.minPackQty
|
|
|
+ // })
|
|
|
+ // .then(response => {
|
|
|
+ // if (response.data.success) {
|
|
|
+ // if (response.data.message) {
|
|
|
+ // this.$message({
|
|
|
+ // message: '添加购物车成功,但商品信息有更新',
|
|
|
+ // type: 'success'
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // this.$message({
|
|
|
+ // message: '添加购物车成功',
|
|
|
+ // type: 'success'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // if (response.data.code === 2) {
|
|
|
+ // this.$message.error('库存已不满足最小起订量')
|
|
|
+ // } else if (response.data.message === '该产品已失效') {
|
|
|
+ // this.$message.error(response.data.message + ',请刷新页面')
|
|
|
+ // } else {
|
|
|
+ // this.$message.error(response.data.message)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
},
|
|
|
setHoverStyle: function (isShow) {
|
|
|
if (this.btnColor) {
|
|
|
@@ -126,8 +144,8 @@
|
|
|
height: 30px;
|
|
|
font-size: 12px;
|
|
|
border: 1px solid #5078cb;
|
|
|
+ position: relative;
|
|
|
}
|
|
|
-
|
|
|
.btn-add-cart {
|
|
|
margin-top: 10px;
|
|
|
color: #214797;
|