|
|
@@ -7,7 +7,7 @@ const NULL_ARR = ['空', '没', '无', '-', '—', 'null', '#N/A']
|
|
|
* $this: 当前对象
|
|
|
* item: 操作对象
|
|
|
* */
|
|
|
-const _buyOrCar = function (isBuy, event, $this, item) {
|
|
|
+const _buyOrCar = function (isBuy, event, $this, item, url = '/user#/order/pay/') {
|
|
|
if (event) event.stopPropagation()
|
|
|
if (!$this.$store.state.option.user.logged) {
|
|
|
$this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
|
|
|
@@ -36,22 +36,22 @@ const _buyOrCar = function (isBuy, event, $this, item) {
|
|
|
type: 'success'
|
|
|
})
|
|
|
window.setTimeout(function () {
|
|
|
- window.location.href = '/user#/order/pay/' + _enidfilter(response.data.data.orderid)
|
|
|
+ window.location.href = url + _enidfilter(response.data.data.orderid)
|
|
|
}, 1000)
|
|
|
} else {
|
|
|
- window.location.href = '/user#/order/pay/' + _enidfilter(response.data.data.orderid)
|
|
|
+ window.location.href = url + _enidfilter(response.data.data.orderid)
|
|
|
}
|
|
|
} else {
|
|
|
if (response.data.data && response.data.data.unvailable === 1) {
|
|
|
- $this.$message.error('产品信息已失效,请刷新页面')
|
|
|
+ _setMessage($this, '产品信息已失效,请刷新页面', $this.isMobile, false)
|
|
|
} else {
|
|
|
- $this.$message.error(response.data.message)
|
|
|
+ _setMessage($this, response.data.message, $this.isMobile, false)
|
|
|
}
|
|
|
}
|
|
|
}, err => {
|
|
|
console.log(err)
|
|
|
if (item.minBuyQty > item.reserve) {
|
|
|
- $this.$message.error('商品' + item.code + '的库存已经不满足起订量')
|
|
|
+ _setMessage($this, '商品' + item.code + '的库存已经不满足起订量', $this.isMobile, false)
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
@@ -68,24 +68,18 @@ const _buyOrCar = function (isBuy, event, $this, item) {
|
|
|
.then(response => {
|
|
|
if (response.data.success) {
|
|
|
if (response.data.message) {
|
|
|
- $this.$message({
|
|
|
- message: '添加购物车成功,但商品信息有更新',
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
+ _setMessage($this, '添加购物车成功,但商品信息有更新', $this.isMobile, true)
|
|
|
} else {
|
|
|
- $this.$message({
|
|
|
- message: '添加购物车成功',
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
+ _setMessage($this, '添加购物车成功', $this.isMobile, true)
|
|
|
}
|
|
|
} else {
|
|
|
// if (response.data.code === 2) {
|
|
|
// $this.$message.error('库存已不满足起订量')
|
|
|
// } else
|
|
|
if (response.data.message === '该产品已失效') {
|
|
|
- $this.$message.error(response.data.message + ',请刷新页面')
|
|
|
+ _setMessage($this, response.data.message + ',请刷新页面', $this.isMobile, false)
|
|
|
} else {
|
|
|
- $this.$message.error(response.data.message)
|
|
|
+ _setMessage($this, response.data.message, $this.isMobile, false)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -352,11 +346,15 @@ const _filterStringEllipsis = (str, len) => {
|
|
|
* @str 提示信息
|
|
|
* @isMobile 是否移动端
|
|
|
* */
|
|
|
-const _setMessage = ($this, str = '系统错误', isMobile) => {
|
|
|
+const _setMessage = ($this, str = '系统错误', isMobile, isSuccess = false) => {
|
|
|
if (isMobile) {
|
|
|
$this.setRemindText(str)
|
|
|
} else {
|
|
|
- $this.$message.error(str)
|
|
|
+ if (isSuccess) {
|
|
|
+ $this.$message.success(str)
|
|
|
+ } else {
|
|
|
+ $this.$message.error(str)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|