index.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { share } from "../../utils/http"
  2. // pages/outlink/index.ts
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. url: '',
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad(query: { url: string }) {
  14. const url = decodeURIComponent(query.url)
  15. if (url.indexOf('mp.weixin') > 0) {
  16. wx.setNavigationBarTitle({
  17. title: '详细内容',
  18. })
  19. } else {
  20. wx.setNavigationBarTitle({
  21. title: '空间展示',
  22. })
  23. }
  24. this.setData({
  25. url,
  26. })
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady() {},
  32. /**
  33. * 生命周期函数--监听页面显示
  34. */
  35. onShow() {},
  36. /**
  37. * 生命周期函数--监听页面隐藏
  38. */
  39. onHide() {},
  40. /**
  41. * 生命周期函数--监听页面卸载
  42. */
  43. onUnload() {},
  44. /**
  45. * 页面相关事件处理函数--监听用户下拉动作
  46. */
  47. onPullDownRefresh() {},
  48. /**
  49. * 页面上拉触底事件的处理函数
  50. */
  51. onReachBottom() {},
  52. /**
  53. * 用户点击右上角分享
  54. */
  55. onShareAppMessage() {
  56. let pages = getCurrentPages(); //获取所有页面栈实例列表
  57. let nowPage = pages[pages.length - 1]; //当前页页面实例
  58. return {
  59. title: share.title,
  60. path: `/${nowPage.route}`,
  61. imageUrl: share.imageUrl,
  62. success(res) {
  63. console.log('success(res)==', res);
  64. },
  65. fail(res) {
  66. console.log('fail(res)==', res);
  67. }
  68. }
  69. },
  70. })