<script type="text/javascript">
//复选框选中和不选中切换
$(".checkbox").click(function(){
var state = $(this).attr('checked');
$(this).attr('checked',!state);
});
var productId = sessionStorage.productId;
console.log(productId);
var orderId = sessionStorage.orderId;
$(".mr20 a").text(orderId);
var userId = sessionStorage.userId;
console.log(userId);
$("#comment_submit").click(function(){
// 商品满意度
var product_satisfaction = $("#select_tag option:selected").text();
console.log(product_satisfaction);
// 买家印象
var Buyers_impression = "";
$(".checkbox:checked").each(function(){
var check_val = $(this).val();
Buyers_impression += check_val + ","
})
console.log(Buyers_impression);
// 评价
var comment = $("#product_comment").val();
console.log(comment);
$.ajax({
url : "http://192.168.0.231:8099/comment",
type : "POST",
data : {
"productSatisfaction" : product_satisfaction,
"BuyersImpression" : Buyers_impression,
"comment" : comment,
"productId" : productId,
"orderId" : orderId,
"userId" : userId
},
success : function(data){
alert("评价完成!");
},
error : function(data){
alert("评价完成!");
}
})
});
$("#comment_check").click(function(){
location.href = "http://www.atguigu.com/showComment.html?productId=" + productId +"&userId="+userId;
});
// 查询商品并遍历的ajax
$.ajax({
url : "http://manager.atguigu.com/restful/api/productTwo/" + productId,
dataType : "jsonp",
type : "GET",
success : function(data){
$(".p-img").html('<img src="/assess/14.jpg">');
$(".p-name").text("图文无关");
$(".p-price strong").text("$"+(data.price/100));
$(".p-attr").text(data.title);
},
error : function(data){
alert("查询失败!");
}
});
var create_time = sessionStorage.createTime;
$(".create_time").text(create_time);
</script>