index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // pages/newsDetail/index.js
  2. var app = getApp();
  3. var wxParse = require('../../wxParse/wxParse.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. parameter: {
  10. 'navbar': '1',
  11. 'return': '1',
  12. 'title': '新闻详情',
  13. 'color': false
  14. },
  15. id:0,
  16. articleInfo:[],
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. if (options.hasOwnProperty('id')){
  23. this.setData({ id: options.id});
  24. }else{
  25. wx.navigateBack({delta: 1 });
  26. }
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady: function () {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow: function () {
  37. this.getArticleOne();
  38. },
  39. getArticleOne:function(){
  40. var that = this;
  41. app.baseGet(app.U({ c: 'article_api', a: 'visit', q:{id : that.data.id} }), function (res) {
  42. that.setData({ 'parameter.title': res.data.title, articleInfo: res.data });
  43. //html转wxml
  44. wxParse.wxParse('content', 'html', res.data.content, that, 0);
  45. }, function (res) { console.log(res); }, true);
  46. },
  47. /**
  48. * 生命周期函数--监听页面隐藏
  49. */
  50. onHide: function () {
  51. },
  52. /**
  53. * 生命周期函数--监听页面卸载
  54. */
  55. onUnload: function () {
  56. },
  57. /**
  58. * 页面相关事件处理函数--监听用户下拉动作
  59. */
  60. onPullDownRefresh: function () {
  61. },
  62. /**
  63. * 页面上拉触底事件的处理函数
  64. */
  65. onReachBottom: function () {
  66. },
  67. /**
  68. * 用户点击右上角分享
  69. */
  70. onShareAppMessage: function () {
  71. }
  72. })