var pageNumber = 1, pagesize = 100;
var typeId = getParam("typeId");
mui.ready(function () {
var btnArray = ['否', '是'];
$.ajax(base_path + '/coupon/couponTypeList', {
data: {
"pageSize": pagesize,
"pageNO": pageNumber,
"typeId": typeId
},
dataType: 'json',
type: 'post',
timeout: 15000,
xhrFields: {
withCredentials: true
},
crossDomain: true,
success: function (dt) {
if (dt.isRedirect) {
location.href = dt.redirectURL;
} else {
console.log(dt);
if (dt.status) {
var coupontype_data = [];
coupontype_data = dt.data.typeList;
var table = document.body.querySelector('.my-yhq');
if (coupontype_data.length == 0) {
$(".no_yhq").show()
}
mui(coupontype_data).each(function (index) {
var li = document.createElement('li');
li.className = 'my-yhq-cell';
var ptrice;
if (this.couponType == 1) {
ptrice = accDiv(this.couponReduce, 100) + '元'
} else {
ptrice = "-" + (100 - this.couponReduce) + "%"
}
if (this.couponId != 1 && this.couponId != 2) {
li.innerHTML = '
有效期至' + this.couponEndDate + '
满' + accDiv(this.couponConsumeEnough, 100) + '元可使用
', '恭喜您成功领取一张', btnArray, function (e) {
if (e.index == 1) {
location.href = 'chanpin_list.html'
} else {
location.href = base_path + '/couponWechat/couponList'
}
})
} else {
var r = confirm(dt.message);
if (r == true) {
location.reload(true)
}
}
}
},
error: function (xhr, type, errorThrown) {
if (xhr.readyState == 4 && xhr.status == 200) {
} else {
location.href = domanUrl + base_path + "/couponWechat/coupon?dates=" + new Date().getTime()
}
}
});
});