articleProtocol.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // lionfish_comshop/pages/user/articleProtocol.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. list: ''
  9. },
  10. token: '',
  11. articleId: 0,
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. let id = options.id || 0;
  17. this.articleId = id;
  18. let about = options.about || 0;
  19. var token = wx.getStorageSync('token');
  20. this.token = token;
  21. wx.showLoading({ title: '加载中' });
  22. if (about){
  23. this.get_about_us();
  24. }else{
  25. this.get_article();
  26. }
  27. },
  28. /**
  29. * 获取列表
  30. */
  31. get_article: function () {
  32. let that = this;
  33. app.util.request({
  34. 'url': 'entry/wxapp/index',
  35. 'data': {
  36. controller: 'article.get_article',
  37. 'token': that.token,
  38. 'id': that.articleId
  39. },
  40. dataType: 'json',
  41. success: function (res) {
  42. wx.hideLoading();
  43. if (res.data.code == 0) {
  44. var list = res.data.data;
  45. that.setData({ article: list.content, title: list.title })
  46. wx.setNavigationBarTitle({
  47. title: list.title,
  48. })
  49. }
  50. }
  51. })
  52. },
  53. /**
  54. * 获取列表
  55. */
  56. get_about_us: function () {
  57. let that = this;
  58. app.util.request({
  59. 'url': 'entry/wxapp/index',
  60. 'data': {
  61. controller: 'user.get_about_us'
  62. },
  63. dataType: 'json',
  64. success: function (res) {
  65. wx.hideLoading();
  66. if (res.data.code == 0) {
  67. var list = res.data.data;
  68. that.setData({ article: list })
  69. wx.setNavigationBarTitle({
  70. title: '关于我们'
  71. })
  72. }
  73. }
  74. })
  75. },
  76. /**
  77. * 用户点击右上角分享
  78. */
  79. onShareAppMessage: function () {
  80. return {
  81. title: this.data.title,
  82. path: "",
  83. imageUrl: "",
  84. success: function() {},
  85. fail: function() {}
  86. };
  87. }
  88. })