cms-web.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // pages/cms-web.js
  2. const api = require('../../utils/o2Api.js');
  3. const util = require('../../utils/util.js');
  4. Page({
  5. /**
  6. * Page initial data
  7. */
  8. data: {
  9. workUrl: '',
  10. navTitle: ''
  11. },
  12. /**
  13. * Lifecycle function--Called when page load
  14. */
  15. onLoad: function (options) {
  16. var id = options.id;
  17. var title = decodeURIComponent(options.title);
  18. if (id && id != '') {
  19. var url = api.cmsWebUrl(id);
  20. var who = wx.getStorageSync('who');
  21. var tokenName = wx.getStorageSync('tokenName');
  22. var token = ''
  23. if (who && who.token) {
  24. token = who.token;
  25. url = url + '&'+tokenName+'=' + token;
  26. }
  27. url = url + '#wechat_redirect';
  28. this.setData({
  29. workUrl: url,
  30. navTitle: title
  31. });
  32. }else {
  33. util.toast('没有传入信息id!');
  34. wx.navigateBack({
  35. delta: 1,
  36. });
  37. }
  38. },
  39. /**
  40. * Lifecycle function--Called when page is initially rendered
  41. */
  42. onReady: function () {
  43. },
  44. /**
  45. * Lifecycle function--Called when page show
  46. */
  47. onShow: function () {
  48. },
  49. /**
  50. * Lifecycle function--Called when page hide
  51. */
  52. onHide: function () {
  53. },
  54. /**
  55. * Lifecycle function--Called when page unload
  56. */
  57. onUnload: function () {
  58. },
  59. /**
  60. * Page event handler function--Called when user drop down
  61. */
  62. onPullDownRefresh: function () {
  63. },
  64. /**
  65. * Called when page reach bottom
  66. */
  67. onReachBottom: function () {
  68. },
  69. /**
  70. * Called when user click on the top right corner to share
  71. */
  72. onShareAppMessage: function () {
  73. }
  74. })