thinkerDetail.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import '../../css/bootstrap.less';
  2. import 'bootstrap/dist/js/bootstrap.js';
  3. import 'css/newMenu/public.css';
  4. import 'css/newMenu/header.css';
  5. import '../../js/public.js';
  6. import '../../css/thinkTank/thinkerDetail.css';
  7. import {
  8. message
  9. } from '../tools.js';
  10. var addConsultorder = function () {
  11. let userId = $('#userId').val();
  12. $.ajax({
  13. method: "post",
  14. dataType: "json",
  15. crossDomain: false,
  16. url: globalConfig.context + '/api/user/consultorder/add',
  17. data: {
  18. toUserId: userId
  19. },
  20. success: function (data) {
  21. if (data.error && data.error.length) {
  22. message(data.error[0].message);
  23. } else {
  24. message('提交会员服务订单成功!');
  25. setTimeout("window.location.href = globalConfig.context + '/user/account/index.html#consultList'", 3000);
  26. };
  27. }.bind(this)
  28. });
  29. };
  30. var consultClick = function () {
  31. $.ajax({
  32. method: "get",
  33. dataType: "json",
  34. url: globalConfig.context + "/api/user/consultorder/price"
  35. }).done(function (data) {
  36. if (data.error && data.error.length) {
  37. message(data.error[0].message);
  38. } else {
  39. $('#modal-content').empty();
  40. $('#modal-content').append("预约该专家的线下咨询需要支付 " + data.data + " 元的咨询费,是否确认提交预约订单?");
  41. $('#myModal').modal('show');
  42. }
  43. });
  44. };
  45. $(function () {
  46. //收藏
  47. $('.collection p').eq(0).click(function () {
  48. let heart = $('.heart');
  49. if (heart.hasClass('active')) {
  50. collectionApi(0) //取消收藏
  51. } else {
  52. collectionApi(1) //收藏
  53. }
  54. })
  55. let hash = window.location.search,
  56. hashArr =hash.split('&'),
  57. idArr = hashArr[0].split('='),
  58. ids =idArr[1];
  59. function collectionApi(index) {
  60. let url = index?'/api/user/portal/expertInterest':'/api/user/portal/expertCancelInterest'
  61. $.ajax({
  62. method: "post",
  63. dataType: "json",
  64. url: globalConfig.context + url,
  65. data: {
  66. id:ids
  67. },
  68. success: function (data) {
  69. if (data.error && data.error.length) {
  70. $('#msg').val(data.error[0].message);
  71. msg();
  72. }else{
  73. if(!index){
  74. $('.heart').removeClass('active');
  75. }else{
  76. $('.heart').addClass('active');
  77. }
  78. $('#msg').val(index?'收藏成功,请至个人中心查看.':'撤销收藏');
  79. msg();
  80. }
  81. }
  82. })
  83. }
  84. $('#submitOrder').click(function () {
  85. addConsultorder()
  86. });
  87. $("#consultBtn").click(function(){
  88. var isLogin=$("#isLogin").attr("islogin");
  89. if(isLogin=="true"){
  90. $(".head_login").click();
  91. }else{
  92. var theId = $(".right_btn").attr('val');
  93. $.ajax({
  94. method: "post",
  95. dataType: "json",
  96. url: globalConfig.context + "/api/user/consultorder/add",
  97. data: {
  98. toUserId:theId
  99. },
  100. success: function (data) {
  101. if (data.error && data.error.length) {
  102. msg(data.error[0].message);
  103. }else if(data.error==""){
  104. window.open(globalConfig.context+ '/user/account/index.html#consultList');
  105. }else{
  106. return;
  107. }
  108. }
  109. });
  110. }
  111. });
  112. $(".achieve_cont>a>div>span").click(function(){
  113. var biaozhi=$(this).attr("val");
  114. if(!biaozhi){
  115. var p_width=$(this).siblings("p").height();
  116. $(this).addClass("active").attr("val","yes").parent().animate({"height":p_width},500);
  117. }else if(biaozhi=="yes"){
  118. $(this).removeClass("active").attr("val","").parent().animate({"height":45},500);
  119. }
  120. });
  121. //提示框渐隐函数
  122. function msg() {
  123. if($('.smg').hasClass('active')){
  124. return ;
  125. }
  126. $('.smg').addClass('active')
  127. setTimeout(function () {
  128. $('.smg').removeClass('active')
  129. $('#msg').val('');
  130. }, 2000)
  131. }
  132. })