articleProtocol.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // lionfish_comshop/pages/user/articleProtocol.js
  2. var util = require('../../utils/util.js');
  3. var app = getApp();
  4. var WxParse = require('../../wxParse/wxParse.js');
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. list: ''
  11. },
  12. token: '',
  13. id: 0,
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. let id = options.id || 0;
  19. this.id = id;
  20. let about = options.about || 0;
  21. var token = wx.getStorageSync('token');
  22. this.token = token;
  23. wx.showLoading({ title: '加载中' });
  24. if (about){
  25. this.get_about_us();
  26. }else{
  27. this.get_article();
  28. }
  29. },
  30. /**
  31. * 获取列表
  32. */
  33. get_article: function () {
  34. let that = this;
  35. app.util.request({
  36. 'url': 'entry/wxapp/index',
  37. 'data': {
  38. controller: 'article.get_article',
  39. 'token': that.token,
  40. 'id': that.id
  41. },
  42. dataType: 'json',
  43. success: function (res) {
  44. wx.hideLoading();
  45. if (res.data.code == 0) {
  46. var list = res.data.data;
  47. WxParse.wxParse('article', 'html', list.content, that, 15);
  48. wx.setNavigationBarTitle({
  49. title: list.title
  50. })
  51. }
  52. }
  53. })
  54. },
  55. /**
  56. * 获取列表
  57. */
  58. get_about_us: function () {
  59. let that = this;
  60. app.util.request({
  61. 'url': 'entry/wxapp/index',
  62. 'data': {
  63. controller: 'user.get_about_us'
  64. },
  65. dataType: 'json',
  66. success: function (res) {
  67. wx.hideLoading();
  68. if (res.data.code == 0) {
  69. var list = res.data.data;
  70. WxParse.wxParse('article', 'html', list, that, 15);
  71. wx.setNavigationBarTitle({
  72. title: '关于我们'
  73. })
  74. }
  75. }
  76. })
  77. },
  78. /**
  79. * 生命周期函数--监听页面初次渲染完成
  80. */
  81. onReady: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload: function () {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function () {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function () {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. }
  113. })