concern.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. const util = require('../../static/utils/util.js');
  2. const config = require('../../static/config.js');
  3. var app = getApp(); //获取应用实例
  4. import requestConfig from '../../static/lib/requestConfig';
  5. export default {
  6. data(){
  7. return {
  8. showConcernTips:false,
  9. haveAlreadyCollectThisProject: false,
  10. }
  11. },
  12. watch:{
  13. },
  14. methods:{
  15. catchTouchMove: function() {
  16. return false;
  17. },
  18. /**
  19. * 查询项目的状态
  20. */
  21. async collectProjectStatus(successBack, failBack) {
  22. let requestData = {
  23. customerId: app.globalData.single && app.globalData.single.id,
  24. houseId: this.houseId,
  25. };
  26. let checkCollectRes = await requestConfig('collectionStatus', requestData, true);
  27. if (checkCollectRes && checkCollectRes.success) {
  28. if (successBack) {
  29. successBack();
  30. }
  31. this.haveAlreadyCollectThisProject = true;
  32. } else {
  33. this.haveAlreadyCollectThisProject = false;
  34. if (failBack) {
  35. failBack();
  36. }
  37. }
  38. },
  39. /**
  40. * 收藏项目
  41. */
  42. async collectProject() {
  43. let requestData = {
  44. customerId: app.globalData.single && app.globalData.single.id,
  45. houseId: this.houseId,
  46. };
  47. let res = await requestConfig('houseCollection', requestData, true);
  48. if (res.success) {
  49. this.haveAlreadyCollectThisProject = true;
  50. this.updateShowConcernTips()
  51. }
  52. },
  53. updateShowConcernTips(){
  54. this.showConcernTips = true;
  55. setTimeout(() => {
  56. this.showConcernTips=false
  57. }, 2500);
  58. },
  59. /**
  60. * 关注项目
  61. */
  62. attendProject(e) {
  63. let type = e.currentTarget.dataset.jumptype;
  64. if (type == -1) {
  65. let param = {
  66. type: 'CLK', //埋点类型
  67. clkName: 'follow', //点击前往的页面名称
  68. clkId: 'clk_2cmina_241', //点击ID
  69. clkParams: {
  70. "houseId": this.houseId,
  71. }
  72. };
  73. util.trackRequest(param, app);
  74. this.collectProjectStatus(() => {
  75. let projectName = app.globalData.houseProject.projectName || '';
  76. let msg = "您已成功关注" + projectName + "项目";
  77. uni.showToast({
  78. title: msg,
  79. icon: "none",
  80. duration: 2000
  81. });
  82. }, () => {
  83. this.collectProject();
  84. });
  85. } else if (type == -2) {
  86. this.navigateFuc(e)
  87. }
  88. },
  89. }
  90. }