...
|
...
|
@@ -44,6 +44,9 @@ |
|
|
<p>Your do not have an order <br>for the time being</p>
|
|
|
<a href="">去购物</a>
|
|
|
</div>
|
|
|
<select id="cancel-reason" class="cancel-reason" v-on:change="reasonChange" v-model="selected">
|
|
|
<option v-for="option in options" v-bind:value="{id:option.id}">{{option.reason}}</option>
|
|
|
</select>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
...
|
...
|
@@ -63,12 +66,16 @@ |
|
|
type: this.$parent.$data.type,
|
|
|
orderList: [],
|
|
|
busy: false,
|
|
|
emptybox: 'hide'
|
|
|
emptybox: 'hide',
|
|
|
selected: null,
|
|
|
options: [],
|
|
|
currentCode: ''
|
|
|
};
|
|
|
},
|
|
|
|
|
|
ready() {
|
|
|
this.getOrderData();
|
|
|
this.getCancelReason();
|
|
|
},
|
|
|
|
|
|
methods: {
|
...
|
...
|
@@ -102,11 +109,39 @@ |
|
|
tip('网络错误');
|
|
|
});
|
|
|
},
|
|
|
reasonChange(){
|
|
|
console.log(this.currentCode)
|
|
|
this.order().cancel({
|
|
|
orderCode: this.currentCode,
|
|
|
reasonId: this.selected.id
|
|
|
}, (result) => {
|
|
|
if (result.code === 200) {
|
|
|
location.href = '/home/orders?type=2';
|
|
|
} else {
|
|
|
tip(result.message);
|
|
|
}
|
|
|
}, () => {
|
|
|
tip('操作失败');
|
|
|
});
|
|
|
},
|
|
|
getCancelReason() {
|
|
|
let that = this;
|
|
|
|
|
|
$.ajax({
|
|
|
url: '/home/order/cancel-reason',
|
|
|
}).then(result => {
|
|
|
if (result.data.length > 0) {
|
|
|
that.options = result.data;
|
|
|
}
|
|
|
}).fail(() => {
|
|
|
tip('操作失败');
|
|
|
});
|
|
|
},
|
|
|
autoCancel(code) {
|
|
|
let _that = this;
|
|
|
|
|
|
return () => {
|
|
|
_that.order().cancel(code, (result) => {
|
|
|
_that.order().cancel({orderCode: code}, (result) => {
|
|
|
if (result.code === 200) {
|
|
|
location.reload();
|
|
|
}
|
...
|
...
|
@@ -115,13 +150,11 @@ |
|
|
},
|
|
|
order() {
|
|
|
return {
|
|
|
cancel(code, success, fail) {
|
|
|
cancel(param, success, fail) {
|
|
|
$.ajax({
|
|
|
url: '/home/cancel-order',
|
|
|
type: 'post',
|
|
|
data: {
|
|
|
orderCode: code
|
|
|
}
|
|
|
data: param
|
|
|
}).then(success).fail(fail);
|
|
|
}
|
|
|
};
|
...
|
...
|
@@ -130,21 +163,16 @@ |
|
|
let _that = this;
|
|
|
|
|
|
Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() {
|
|
|
_that.order().cancel(code, (result) => {
|
|
|
if (result.code === 200) {
|
|
|
location.reload();
|
|
|
} else {
|
|
|
tip(result.message);
|
|
|
}
|
|
|
}, () => {
|
|
|
tip('操作失敗');
|
|
|
});
|
|
|
this.hide();
|
|
|
_that.currentCode = code;
|
|
|
_that.dropDown('cancel-reason');
|
|
|
});
|
|
|
},
|
|
|
deleteOrder(order, index) {
|
|
|
let that = this;
|
|
|
|
|
|
Modal.confirm('确认删除订单?', '', function() {
|
|
|
this.hide();
|
|
|
$.ajax({
|
|
|
url: '/home/delete-order',
|
|
|
type: 'post',
|
...
|
...
|
@@ -153,12 +181,12 @@ |
|
|
}
|
|
|
}).then(result => {
|
|
|
if (result.code === 200) {
|
|
|
that.$el.querySelectorAll('.order-item')[index].remove();
|
|
|
that.orderList.splice(index, 1);
|
|
|
} else {
|
|
|
tip(result.message);
|
|
|
}
|
|
|
}).fail(() => {
|
|
|
tip('操作失敗');
|
|
|
tip('操作失败');
|
|
|
});
|
|
|
});
|
|
|
},
|
...
|
...
|
@@ -176,7 +204,7 @@ |
|
|
tip(result.message);
|
|
|
}
|
|
|
}).fail(() => {
|
|
|
tip('操作失敗');
|
|
|
tip('操作失败');
|
|
|
});
|
|
|
},
|
|
|
goBuy(code) {
|
...
|
...
|
@@ -184,6 +212,22 @@ |
|
|
},
|
|
|
seeExpress(code) {
|
|
|
location.href = '/home/logistic?order_code='+code;
|
|
|
},
|
|
|
dropDown(elementId){
|
|
|
let dropdown = document.getElementById(elementId);
|
|
|
try {
|
|
|
this.showDropdown(dropdown);
|
|
|
} catch(e) {
|
|
|
console.log(e)
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
|
|
|
showDropdown(element) {
|
|
|
let event;
|
|
|
event = document.createEvent('MouseEvents');
|
|
|
event.initMouseEvent('mousedown', true, true, window);
|
|
|
element.dispatchEvent(event);
|
|
|
}
|
|
|
}
|
|
|
};
|
...
|
...
|
|