science-card.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // module/article/components/science-card/science-card.ts
  2. // import { HOST } from "../../../../app.config";
  3. import { Get } from "../../../../lib/request/method";
  4. Component({
  5. properties: {
  6. item: { type: Object, value: {} },
  7. index: { type: Number, value: 0 },
  8. replace: { type: Boolean, value: false },
  9. },
  10. data: {},
  11. methods: {
  12. async toInfoPage(event: WechatMiniprogram.TouchEvent) {
  13. const id = event.currentTarget.id;
  14. if (this.data.replace) {
  15. wx.redirectTo({ url: `/module/article/pages/science-info/science-info?id=${id}` });
  16. } else {
  17. const id = event.currentTarget.id;
  18. // const url = `https://${HOST}/admin/editor/preview.html?popularScienceArticleId=${id}`;
  19. try {
  20. const res = await Get(`/psarticle/clickPsarticle`, {
  21. params: { popularScienceArticleId: id },
  22. });
  23. const url = res?.data;
  24. const item = {
  25. url,
  26. };
  27. wx.navigateTo({
  28. url: `/module/article/pages/science-info/science-info`,
  29. }).then((res) => {
  30. res.eventChannel.emit("load", item);
  31. });
  32. } catch (error) {
  33. console.log(error);
  34. }
  35. // const url = `https://${HOST}/admin/editor/preview.html?popularScienceArticleId=${id}`;
  36. // const item = {
  37. // url,
  38. // };
  39. // wx.navigateTo({
  40. // url: `/module/article/pages/science-info/science-info?url=${url}`,
  41. // }).then((res) => {
  42. // res.eventChannel.emit("load", item);
  43. // });
  44. // wx.navigateTo({ url: `/module/article/pages/science-info/science-info?id=${id}` })
  45. // .then(res => { res.eventChannel.emit('load', this.data.item) })
  46. }
  47. }
  48. }
  49. })