index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // pages/yuezhan/html_detail/index.js.js
  2. const WxParse = require('../../../common/component/wxParse/wxParse.js');
  3. const { recordAccess } = require('../../../utils/util.js');
  4. const { serverName, request } = require('../../../utils/services');
  5. const {
  6. newRequestFns,
  7. newServerName
  8. } = require('../../../utils/newServices.js');
  9. const app = getApp();
  10. Page({
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. forwardImg: 'https://4dscene.4dage.com/cgaii/images/join/forwardImg.jpg'
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. recordAccess(options)
  22. console.log(options)
  23. let { imageUrl, relayUrl, id: sceneId, isShare } = options;
  24. this.setData({
  25. imageUrl,
  26. relayUrl,
  27. sceneId
  28. })
  29. let {
  30. bannerHtml
  31. } = app.globalData
  32. // if (isShare){
  33. this.getHtml()
  34. // }else{
  35. // WxParse.wxParse('description', 'html', bannerHtml, this, 5);
  36. // }
  37. },
  38. getHtml:function(){
  39. let {sceneId} = this.data
  40. newRequestFns["getBannerDetail"]({
  41. bannerId: sceneId
  42. }, "", res => {
  43. let { url: description, imageUrl, relayUrl} = res.data.data
  44. this.setData({
  45. relayUrl: relayUrl
  46. })
  47. WxParse.wxParse('description', 'html', description, this, 5);
  48. },fail => {
  49. wx.showToast({
  50. title: '页面不存在',
  51. icon: 'none'
  52. });
  53. setTimeout(() => {
  54. wx.switchTab({
  55. url: '/pages/yuezhan/index',
  56. })
  57. }, 1000);
  58. })
  59. },
  60. /**
  61. * 生命周期函数--监听页面初次渲染完成
  62. */
  63. onReady: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面显示
  67. */
  68. onShow: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面隐藏
  72. */
  73. onHide: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload: function () {
  79. },
  80. /**
  81. * 页面相关事件处理函数--监听用户下拉动作
  82. */
  83. onPullDownRefresh: function () {
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function () {
  89. },
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage: function () {
  94. let { sceneId, imageUrl, relayUrl, forwardImg } = this.data;
  95. console.log(relayUrl, imageUrl, 666)
  96. return {
  97. path: `/pages/yuezhan/html_detail/index?id=${sceneId}&isShare=1&imageUrl=${imageUrl}&relayUrl=${relayUrl}`,
  98. imageUrl: relayUrl || imageUrl || forwardImg
  99. }
  100. }
  101. })