index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // nova-werun/components/circle-card/index.js
  2. const Parse = getApp().Parse;
  3. const company = getApp().globalData.company;
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. objectId: '',
  10. type: ''
  11. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. //图片
  17. images: [],
  18. imageclass: '',
  19. //是否展示点赞评论按钮
  20. isgood: false,
  21. isclick: false,
  22. //朋友圈
  23. cicleList: []
  24. },
  25. lifetimes: {
  26. detached: function () {
  27. // 在组件实例被从页面节点树移除时执行
  28. },
  29. attached: async function () {
  30. // 在组件实例进入页面节点树时执行
  31. this.getcircle()
  32. },
  33. },
  34. /**
  35. * 组件的方法列表
  36. */
  37. methods: {
  38. onImageLoad: function (e) {
  39. const {
  40. width,
  41. height
  42. } = e.detail; // 获取图片的宽高
  43. console.log('11', e.detail);
  44. const imageClass = width > height ? 'image-landscape' : 'image-portrait'; // 判断横竖屏
  45. this.setData({
  46. imageclass: imageClass // 动态设置图片的类名
  47. });
  48. },
  49. previewImage: function (e) {
  50. const index = e.currentTarget.dataset.index; // 获取当前点击图片的索引
  51. const images = this.data.images; // 获取所有图片的链接
  52. wx.previewImage({
  53. current: images[index], // 当前显示图片的链接
  54. urls: images // 需要预览的图片链接列表
  55. });
  56. },
  57. gourl(e) {
  58. const url = e.currentTarget.dataset.url
  59. const objectId = e.currentTarget.dataset.id
  60. wx.navigateTo({
  61. url: `${url}?id=` + objectId // 目标页面的路径
  62. });
  63. },
  64. showgood() {
  65. this.setData({
  66. isgood: !this.data.isgood
  67. })
  68. console.log(this.data.isgood);
  69. },
  70. isclick() {
  71. this.setData({
  72. isclick: !this.data.isclick
  73. })
  74. setTimeout(() => {
  75. this.showgood()
  76. }, 400)
  77. console.log(this.data.isclick);
  78. },
  79. async getcircle() {
  80. console.log('数据',this.data.objectId,this.data.type);
  81. let AIMomentquery = new Parse.Query('AIMoment');
  82. AIMomentquery.equalTo('company', company);
  83. AIMomentquery.equalTo('objectId', this.data.objectId);
  84. AIMomentquery.equalTo('isVisible', true);
  85. AIMomentquery.include('profile.user');
  86. AIMomentquery.include('profile');
  87. AIMomentquery.notEqualTo('isDeleted', true)
  88. let P = await AIMomentquery.find();
  89. let AIMoment1List = P.map(item => item.toJSON());
  90. this.setData({
  91. cicleList: AIMoment1List,
  92. })
  93. this.setData({
  94. images: this.data.cicleList[0].images
  95. })
  96. console.log('动态', this.data.cicleList);
  97. console.log('动态', this.data.type);
  98. }
  99. }
  100. })