science-card.ts 1.0 KB

123456789101112131415161718192021222324252627282930
  1. // module/article/components/science-card/science-card.ts
  2. import { HOST } from "../../../../app.config";
  3. Component({
  4. properties: {
  5. item: { type: Object, value: {} },
  6. index: { type: Number, value: 0 },
  7. replace: { type: Boolean, value: false },
  8. },
  9. data: {},
  10. methods: {
  11. toInfoPage(event: WechatMiniprogram.TouchEvent) {
  12. const id = event.currentTarget.id;
  13. if (this.data.replace) {
  14. wx.redirectTo({ url: `/module/article/pages/science-info/science-info?id=${id}` });
  15. } else {
  16. const url = `https://${HOST}/admin/editor/preview.html?popularScienceArticleId=${id}`;
  17. const item = {
  18. url,
  19. };
  20. wx.navigateTo({
  21. url: `/module/article/pages/science-info/science-info?url=${url}`,
  22. }).then((res) => {
  23. res.eventChannel.emit("load", item);
  24. });
  25. // wx.navigateTo({ url: `/module/article/pages/science-info/science-info?id=${id}` })
  26. // .then(res => { res.eventChannel.emit('load', this.data.item) })
  27. }
  28. }
  29. }
  30. })