articleDetail.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {
  2. get,
  3. } from '../../utils/http';
  4. import {
  5. removeCss,
  6. } from '../../utils/util';
  7. var WxParse = require('../../components/local/wxParse/wxParse.js');
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. spinning: true,
  14. detail: {},
  15. id:'',
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. console.log(options,'options');
  22. this.setData({
  23. id:options.id
  24. })
  25. this.getArticleInfo(options.id)
  26. },
  27. /**
  28. * 生命周期函数--监听页面初次渲染完成
  29. */
  30. onReady: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面显示
  34. */
  35. onShow: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面隐藏
  39. */
  40. onHide: function () {
  41. },
  42. /**
  43. * 生命周期函数--监听页面卸载
  44. */
  45. onUnload: function () {
  46. },
  47. /**
  48. * 页面相关事件处理函数--监听用户下拉动作
  49. */
  50. onPullDownRefresh: function () {
  51. },
  52. /**
  53. * 页面上拉触底事件的处理函数
  54. */
  55. onReachBottom: function () {
  56. },
  57. /**
  58. * 用户点击右上角分享
  59. */
  60. onShareAppMessage: function () {
  61. return {
  62. path: `/pages/articleDetail/articleDetail?id=${this.data.id}`
  63. };
  64. },
  65. /**
  66. * 获取秘籍详情
  67. * /api/info/info
  68. */
  69. getArticleInfo(info_id) {
  70. get('api/info/info', {
  71. info_id
  72. }, (res) => {
  73. WxParse.wxParse('article', 'html', res.data.content, this, 5);
  74. // res.data.content = removeCss(res.data.content)
  75. this.setData({
  76. detail: res.data,
  77. spinning: false
  78. })
  79. })
  80. },
  81. wxParseTagATap(e){
  82. var href = e.currentTarget.dataset.src;
  83. if(href=='/pages/article/article'||href=='/pages/home/home'||href=='pages/shoppingMall/shoppingMall'||href=='pages/orderBy/orderBy'||href=='pages/member/member'){
  84. wx.switchTab({
  85. url: href,
  86. })
  87. }else{
  88. wx.navigateTo({
  89. url: href,
  90. })
  91. }
  92. }
  93. })