/** * Created by mac on 17/6/7. */ (function () { var func = { //页面初始化执行函数 initPage: function () { func.getMyParkCardInfo(); }, //获取信息ajax请求函数 getMyParkCardInfo: function () { $.ajax({ url: mUrl.myParkCardList, dataType: 'json', success: func.myParkCardInfoSuccess }); }, //信息获取成功处理函数 myParkCardInfoSuccess: function (res) { var html = ''; if (res.code == '8888') { //未失效卡片 var available = res.data.available; //已失效卡片 var unavailable = res.data.unavailable; html = func.parseAvailableData(available, html); html = func.parseUnavailableData(unavailable, html); if (html.length < 2) { //没有渲染数据,展示没有记录 $("#dataNullInfo").show(); } else { $("body").append(html); } } else { $.toptip('获取数据失败,请重试!', 2000, 'error'); } }, //解析未失效卡片 parseAvailableData: function (data, html) { if (typeof(data) != "undefined" && null != data) { $.each(data, function (index, val) { html += '
' + '
' + '
' + '
' + '

' + val.cardName + '

' + '

' + val.cardNum + '

' + '
续费
' + '
' + '
' + '
' + '
' + val.parkName + '
' + '
' + val.expDateStr + '
' + '
' + '
' + '
' }); } return html; }, //解析已失效卡片 parseUnavailableData: function (data, html) { if (typeof(data) != "undefined" && null != data) { $.each(data, function (index, val) { console.log(val); html += '
' + '
' + '
' + '
' + '

' + val.cardName + '

' + '

' + val.cardNum + '

' + '
' + '
' + '
' + '
' + '
' + val.parkName + '
' + '
' + val.expDateStr + '
' + '
' + '
' + '
' }); } return html; } } func.initPage(); })(); $(document).on('click', '.month-renew', function () { //var cardType = this.data('cardType'); var custCardId = $(this).data('custcardid'); var parkName = $(this).data('parkname'); window.location.href = mUrl.renewView + '&custCardId=' + custCardId + '&parkName=' + parkName; }); //月卡 $('.month-renew').on('click', function () { //月卡跳转url localStorage.setItem("name", "j99999"); window.location.href = "monthrenew.html"; }); //年卡 $('.year-renew').on('click', function () { //年卡 跳转url localStorage.setItem("name", "j99999"); window.location.href = "yearrenew.html"; }); //渲染列表的时候如果date 为空 $('#datanull').show(); $('#datanull').on('click', function () { window.location.href = mUrl.toParkInfoListView; });