serviceDetails.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * @author:liting
  3. * @update:2018/06/20
  4. *
  5. */
  6. import 'css/bootstrap.less';
  7. import 'bootstrap/dist/js/bootstrap.js';
  8. import 'css/newMenu/public.css';
  9. import 'css/newMenu/header.css'
  10. import 'css/newMenu/serviceDetails.css';
  11. import 'js/public.js';
  12. "use strict";
  13. $(function () {
  14. init();
  15. function init(){
  16. heightF();
  17. }
  18. $('.collection p').eq(0).click(function () {
  19. let heart = $('.heart');
  20. if (heart.hasClass('active')) {
  21. collectionApi(0) //取消收藏
  22. } else {
  23. collectionApi(1) //收藏
  24. }
  25. })
  26. function collectionApi(index) {
  27. $.ajax({
  28. method: "get",
  29. dataType: "json",
  30. //url: globalConfig.context + "/portal/search/achievementList",
  31. url: "https://www.apiopen.top/satinApi",
  32. data: {
  33. name:index
  34. },
  35. success: function (data) {
  36. if (data.error && data.error.length) {
  37. $('#msg').val(data.error);
  38. msg();
  39. }else{
  40. if(!index){
  41. $('.heart').removeClass('active');
  42. }else{
  43. $('.heart').addClass('active');
  44. }
  45. $('#msg').val(index?'收藏成功,请至个人中心查看.':'撤销收藏');
  46. msg();
  47. }
  48. }
  49. })
  50. }
  51. //价值
  52. function heightF(){
  53. let het = $('.serviceDetailsList .value div').height();
  54. console.log(het);
  55. $('.serviceDetailsList .value h4').css({
  56. height:(het+20)+'px',
  57. lineHeight:(het+20)+'px'
  58. })
  59. }
  60. //提示框渐隐函数
  61. function msg() {
  62. if($('.smg').hasClass('active')){
  63. return ;
  64. }
  65. $('.smg').addClass('active')
  66. var lit = $('#msg').val();
  67. setTimeout(function () {
  68. $('.smg').removeClass('active')
  69. $('#msg').val('');
  70. }, 2000)
  71. }
  72. })