intro.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // pages/intro/intro.js
  2. const app = getApp()
  3. const host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. wx.request({
  15. url: host + '/api/wx/article?id=' + options.id,
  16. method: 'GET',
  17. success: res => {
  18. wx.setNavigationBarTitle({
  19. title: res.data.data.title,
  20. })
  21. this.setData({
  22. data: res.data.data
  23. })
  24. this.init()
  25. }
  26. })
  27. },
  28. init:function(){
  29. const query = wx.createSelectorQuery()
  30. const that=this
  31. query.select('#editor').context(function (res) {
  32. res.context.setContents({
  33. html: that.data.data.content
  34. })
  35. })
  36. .exec()
  37. },
  38. /**
  39. * 生命周期函数--监听页面初次渲染完成
  40. */
  41. onReady: function () {
  42. },
  43. /**
  44. * 生命周期函数--监听页面显示
  45. */
  46. onShow: function () {
  47. },
  48. /**
  49. * 生命周期函数--监听页面隐藏
  50. */
  51. onHide: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面卸载
  55. */
  56. onUnload: function () {
  57. },
  58. /**
  59. * 页面相关事件处理函数--监听用户下拉动作
  60. */
  61. onPullDownRefresh: function () {
  62. },
  63. /**
  64. * 页面上拉触底事件的处理函数
  65. */
  66. onReachBottom: function () {
  67. },
  68. /**
  69. * 用户点击右上角分享
  70. */
  71. onShareAppMessage: function () {
  72. }
  73. })