/* * @author:liting * @update:2018/06/20 * */ import 'css/bootstrap.less'; import 'bootstrap/dist/js/bootstrap.js'; import 'css/newMenu/public.css'; import 'css/newMenu/header.css' import 'css/newMenu/serviceDetails.css'; import 'js/public.js'; import 'css/newMenu/quill.bubble.css' "use strict"; $(function () { init(); function init(){ heightF(); pages(); add(); } $('.collection p').eq(0).click(function () { let heart = $('.heart'); if (heart.hasClass('active')) { collectionApi(0) //取消收藏 } else { collectionApi(1) //收藏 } }) //数量加减; var nub=0; function add(){ $('.up').click(function(){ nub = $(this).siblings('#number').val(); nub++; if(nub>99){ nub=99 } $(this).siblings('#number').val(nub); }) $('.down').click(function(){ nub = $(this).siblings('#number').val(); nub--; if(nub<1){ nub=1 } $(this).siblings('#number').val(nub); }) $('#number').keyup(function(){ let val = $(this).val(); if(isNaN(val)){ $(this).val(1) }; if(val>99){ $(this).val(99) }; if(val<1){ $(this).val(1) }; }) } let hash = window.location.search, hashArr =hash.split('='), ids =hashArr[1]; function collectionApi(index) { let url = index?'/api/user/portal/projectInterest':'/api/user/portal/projectCancelInterest' $.ajax({ method: "post", dataType: "json", url: globalConfig.context + url, data: { id:ids }, success: function (data) { if (data.error && data.error.length) { msg(data.error[0].message); }else{ if(!index){ $('.heart').removeClass('active'); }else{ $('.heart').addClass('active'); } msg(index?'收藏成功,请至个人中心查看.':'撤销收藏'); } } }) } //价值 function heightF(){ let het = $('.serviceDetailsList .value div').height(); $('.serviceDetailsList .value h4').css({ height:(het+20)+'px', lineHeight:(het+20)+'px' }); }; /*评论 切换*/ $('.tabEvaluate li').click(function(){ let index= $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.tabList>div').eq(index).show().siblings().hide(); }); //评论列表 loadDate(); var thePageNo = 1, thePageLength = 1, pageSize = 4; function loadDate(pageNo) { $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/open/unlanded/comment/list", data: { pageNo: pageNo || 1, pageSize:4, commodityId:ids }, success: function (data) { var theArrs = []; if(data&&data.error.length){ msg(data.error[0].message) }; if(data.data.totalCommentCount>0){ let good = (((data.data.positiveCommentCount)/(data.data.totalCommentCount))*100).toFixed(1), middle = (((data.data.ordinaryCommentCount)/(data.data.totalCommentCount))*100).toFixed(1), bad = (100-good-middle).toFixed(1); $('.commentDetails').html(` 评价 :好评(${good+'%'})中评(${middle+'%'})差评(${bad+'%'}) `) }else{ $('.commentDetails').html(` 评价 :好评(100%)中评(0%)差评(0%) `) } if (data.data && data.data.comments.list.length) { let nub = data.data.comments.list.length; for (let i = 0; i < nub; i++) { let thisdata = data.data.comments.list[i],name; let times =thisdata.createTime?new Date(thisdata.createTime).toLocaleString():'', star=thisdata.star; if(thisdata.uname.indexOf('游客')>-1){ name='匿名' }else{ name=thisdata.uname }; theArrs.push(`
用户名 :${name}
${thisdata.content}