C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 line
2.6 KiB

  1. let app = getApp();
  2. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  3. var WxParse = require('../../wxParse/wxParse.js');
  4. const config = require("../../config/config");
  5. const Http = require("../../utils/HttpBasics");
  6. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  7. let configUrls = extConfig.attr.configUrl;
  8. console.log(configUrls)
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. navigationBarHeight,
  15. url: config.url,
  16. token: app.globalData.token,
  17. id: '',
  18. date: new Date()
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. if (app.globalData.token) {
  25. const that = this;
  26. that.setData({
  27. url: config.url,
  28. id: options.id,
  29. token: app.globalData.token
  30. })
  31. if (options && options.id) {
  32. wx.request({
  33. url: configUrls + config.api.printHtmlById,
  34. data: {
  35. token: app.globalData.token,
  36. id: options.id,
  37. date: new Date()
  38. },
  39. header: {
  40. 'content-type': 'application/html'
  41. },
  42. success: function (res) {
  43. var temp = WxParse.wxParse('article', 'html', res.data, that, 5);
  44. }
  45. })
  46. }
  47. } else {
  48. app.tokenCallback = token => {
  49. const that = this;
  50. that.setData({
  51. url: config.url,
  52. id: options.id,
  53. token: app.globalData.token
  54. })
  55. if (options && options.id) {
  56. wx.request({
  57. url: configUrls + config.api.printHtmlById,
  58. data: {
  59. token: app.globalData.token,
  60. id: options.id,
  61. date: new Date()
  62. },
  63. header: {
  64. 'content-type': 'application/html'
  65. },
  66. success: function (res) {
  67. var temp = WxParse.wxParse('article', 'html', res.data, that, 5);
  68. }
  69. })
  70. }
  71. }
  72. }
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow: function () {
  78. this.setData({
  79. date: new Date()
  80. })
  81. },
  82. onShareAppMessage: function (options) {
  83. var that = this;
  84. console.log(`/pages/freeBannerDetail/index?id=${that.data.data.id}`)
  85. var shareObj = {
  86. title: that.data.title,
  87. path: `/pages/freeBannerDetail/index?id=${that.data.data.id}`,
  88. success: function (res) {
  89. if (res.errMsg == 'shareAppMessage:ok') { }
  90. },
  91. fail: function (error) {
  92. if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
  93. }
  94. };
  95. console.log(shareObj)
  96. return shareObj;
  97. },
  98. })