MVC退单


@{
ViewBag.Title = "SaleIndex";
}

<h2>SaleIndex</h2>
<script>
var UId = 0;
var OId = 0;
var GId = 0;
$(function () {
//判断是否从详情页面过来的
if (this.location.search.split("?") == null) {
this.location.href = '/Sale/LoginIndex';
}
else {
UId = location.search.split("?")[1].split("&")[0].split("=")[1];
OId = location.search.split("?")[1].split("&")[1].split("=")[1];
}
DataBound();
})
function DataBound() {
$.ajax({
url: "http://localhost:57190/api/Sale/GetOrdersInfos",
data: { UId: UId, OId: OId },
type: "get",
dataType: "json",
success: function (d) {
$(d).each(function (i, n) {
$("#OId").text(n.OId);
})

}
})
}
function SaleReturn() {
var formData = new FormData();
var file = document.getElementById("SImg").files[0];
formData.append("fileInfo", file);
$.ajax({
url: "http://localhost:57190/api/Sale/UpLoad",
type: "POST",
data: formData,
contentType: false,//必须false才会自动加上正确的Content-Type
processData: false,//必须false才会避开jQuery对 formdata 的默认处理,XMLHttpRequest会对 formdata 进行正确的处理
success: function (data) {
if (data.Code < 0)
alert(data.Msg)
else {
var obj = {
UId: UId,
OId: OId,
SaleCase: $("#SaleCase").val(),
SImg: data.Url
}
$.ajax({
url: "http://localhost:57190/api/Sale/SaleReturn",
contentType: 'application/json',
data: obj,
type: "get",
dataType: "json",
success: function (d) {
if (d > 0) {
alert('退单成功');
}
else {
alert('退单失败');
}
}
})
}
},
error: function (data) {
alert("上传失败!");
}
});


}
</script>
<table class="table">
<thead>
<tr>
<td>订单编号:</td>
<td><label id="OId"></label></td>
</tr>
<tr>
<td>退回原因:</td>
<td><input id="SaleCase" type="text" /></td>
</tr>
<tr>
<td>退货照片</td>
<td><input id="SImg" type="file" /></td>
</tr>
<tr>
<td colspan="2"><input id="Button1" type="button" value="退单" onclick="SaleReturn()" /></td>

</tr>
</thead>
</table>

posted @ 2020-07-09 18:58  N_o  阅读(28)  评论(0编辑  收藏  举报