wip
This commit is contained in:
parent
383c5723fb
commit
1c1dbca6b7
|
|
@ -122,24 +122,22 @@ axios.defaults.baseURL = process.env.VUE_APP_BASE_URL; // axios.defaults.headers
|
|||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
// axios({method: method, url: url, data: QS.stringify(params)}).then((res) => {
|
||||
axios(_defineProperty({
|
||||
method: method,
|
||||
url: url
|
||||
}, method == 'get' ? 'params' : 'data', params)).then(function (res) {
|
||||
if (res) {
|
||||
resolve(res);
|
||||
resolve(res.data);
|
||||
} else {
|
||||
// 其他情况返回错误信息,根据需要处理
|
||||
reject(res);
|
||||
reject(res.data);
|
||||
if (!hmsg) return layer.msg(res.data.message, function () {});
|
||||
}
|
||||
})["catch"](function (res) {
|
||||
console.log(res);
|
||||
reject(res);
|
||||
|
||||
if (!hmsg && res.message) {
|
||||
layer.msg(res.message, function () {});
|
||||
layer.msg(res.response.data.message, function () {});
|
||||
}
|
||||
})["finally"](function () {
|
||||
layer.closeAll('loading');
|
||||
|
|
|
|||
|
|
@ -70,19 +70,17 @@ export default {
|
|||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// axios({method: method, url: url, data: QS.stringify(params)}).then((res) => {
|
||||
axios({method: method, url: url, [method == 'get' ? 'params' : 'data']: params}).then((res) => {
|
||||
if (res) {
|
||||
resolve(res);
|
||||
resolve(res.data);
|
||||
} else { // 其他情况返回错误信息,根据需要处理
|
||||
reject(res);
|
||||
reject(res.data);
|
||||
if (!hmsg) return layer.msg(res.data.message, ()=>{});
|
||||
}
|
||||
}).catch((res) => {
|
||||
console.log(res)
|
||||
reject(res);
|
||||
if (!hmsg && res.message) {
|
||||
layer.msg(res.message, ()=>{});
|
||||
layer.msg(res.response.data.message, ()=>{});
|
||||
}
|
||||
}).finally(function(){
|
||||
layer.closeAll('loading')
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
</td>
|
||||
<td>@{{ product.subtotal_format }}</td>
|
||||
<td class="text-end">
|
||||
<button type="button" class="btn btn-link btn-sm" @click="checkedBtnDelete(product.cart_id)">删除</button><br>
|
||||
<button type="button" class="btn btn-link btn-sm" @click.stop="checkedBtnDelete(product.cart_id)">删除</button><br>
|
||||
<button type="button" class="btn btn-link btn-sm">加入收藏</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -131,25 +131,16 @@
|
|||
|
||||
quantityChange(quantity, cart_id) {
|
||||
const self = this;
|
||||
$.ajax({
|
||||
url: `/carts/${cart_id}`,
|
||||
type: 'PUT',
|
||||
data: {quantity: quantity,},
|
||||
success: function(res) {
|
||||
self.setUpdateData(res);
|
||||
}
|
||||
$http.put(`/carts/${cart_id}`, {quantity: quantity}).then((res) => {
|
||||
this.setUpdateData(res);
|
||||
})
|
||||
},
|
||||
|
||||
checkedBtnDelete(cart_id) {
|
||||
const self = this;
|
||||
|
||||
$.ajax({
|
||||
url: `/carts/${cart_id}`,
|
||||
type: 'DELETE',
|
||||
success: function(res) {
|
||||
self.setUpdateData(res);
|
||||
}
|
||||
$http.delete(`/carts/${cart_id}`).then((res) => {
|
||||
this.setUpdateData(res);
|
||||
})
|
||||
},
|
||||
|
||||
|
|
@ -162,13 +153,8 @@
|
|||
const self = this;
|
||||
const cart_ids = this.products.filter(e => e.selected).map(x => x.cart_id)
|
||||
|
||||
$.ajax({
|
||||
url: `/carts/select`,
|
||||
type: 'POST',
|
||||
data: {cart_ids: cart_ids},
|
||||
success: function(res) {
|
||||
self.setUpdateData(res);
|
||||
}
|
||||
$http.post(`/carts/select`, {cart_ids: cart_ids}).then((res) => {
|
||||
this.setUpdateData(res);
|
||||
})
|
||||
},
|
||||
|
||||
|
|
@ -180,11 +166,6 @@
|
|||
},
|
||||
// 实例被挂载后调用
|
||||
mounted () {
|
||||
// if (this.products.length) {
|
||||
// this.products.forEach((e) => {
|
||||
// this.$set(e, 'selected', false)
|
||||
// })
|
||||
// }
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@
|
|||
}
|
||||
|
||||
const type = this.dialogAddress.form.id ? 'put' : 'post';
|
||||
const url = `/admin/customers/{{ $customer_id }}/addresses${type == 'put' ? '/' + this.dialogAddress.form.id : ''}`;
|
||||
const url = `/customers/{{ $customer_id }}/addresses${type == 'put' ? '/' + this.dialogAddress.form.id : ''}`;
|
||||
|
||||
$http[type](url, this.dialogAddress.form).then((res) => {
|
||||
if (type == 'post') {
|
||||
|
|
@ -269,22 +269,26 @@
|
|||
countryChange(e) {
|
||||
const self = this;
|
||||
|
||||
$http.get(`/admin/countries/${e}/zones`).then((res) => {
|
||||
this.source.zones = res.data.data.zones;
|
||||
$http.get(`/countries/${e}/zones`).then((res) => {
|
||||
this.source.zones = res.zones;
|
||||
})
|
||||
},
|
||||
|
||||
updateCheckout(id, key) {
|
||||
if (this.form[key] === id) {
|
||||
return
|
||||
}
|
||||
|
||||
this.form[key] = id
|
||||
|
||||
$http.put('/checkout', this.form).then((res) => {
|
||||
this.form = res.data.current
|
||||
this.form = res.current
|
||||
})
|
||||
},
|
||||
|
||||
checkedBtnCheckoutConfirm() {
|
||||
$http.post('/checkout/confirm', this.form).then((res) => {
|
||||
console.log(res)
|
||||
{{-- location = '{{ shop_route("orders.index", [1]) }}' --}}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue