话不多说直接上代码
<script type="text/javascript">
$(function(){
$(".dingdan").click(function(){
var id = {$user['id']};
//访问PHP后台请求参数 注意返回json格式
$.post("/admin.php/index/index/weizhifu",{id:id},function(e){
//json转数组
var jsons = JSON.parse(e);
var sum = jsons.length;
var html ='';
for(var i=0; sum>i;i++){
if(jsons[i]['order_status'] == 1){
var o ='已支付';
}else{
var o ='待支付';
}
var time = timestampToTime(jsons[i]['addtime']);
html += '<tr>\
<td>'+jsons[i]['order']+'</td>\
<td>'+jsons[i]['title']+'</td>\
<td>'+jsons[i]['price']+'</td>\
<td>'+o+'</td>\
<td>'+time+'</td>\
</tr>';
//console.log(html);
}
//给id 为aaa 重新赋值 HTML
$("#aaa").html(html);
});
//隐藏显示
document.getElementById("add_menber_style").style.display = "block";
//$("#add_menber_style").
})
// 这个方法是 时间戳转换时间
function timestampToTime(timestamp){
var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = (date.getMinutes() < 10 ? '0'+(date.getMinutes()) : date.getMinutes()) + ':';
s = (date.getSeconds() < 10 ? '0'+(date.getSeconds()) : date.getSeconds());
return Y+M+D+h+m+s;
}
})
</script>
溜了==!