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.

117 line
2.8 KiB

  1. let config = require("../../config/config.js");
  2. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  3. let app = getApp();
  4. const Http = require("../../utils/HttpBasics");
  5. const util = require("../../utils/util");
  6. const imgurl = require("../../utils/imgurl");
  7. Page({
  8. data: {
  9. mouldType: 0,
  10. mouldConfig:{},
  11. navigationBarHeight,
  12. data: {},
  13. couponId: null,
  14. orderId: "",
  15. day: "",
  16. hour: "",
  17. wmhome: imgurl.wmhome.url,
  18. minute: "",
  19. nodes: '',
  20. goHomeUrl: "",
  21. },
  22. onLoad(options) {
  23. if (app.globalData.token) {
  24. this.setData({
  25. mouldType: app.globalData.mouldType,
  26. mouldConfig: app.globalData.mouldConfig,
  27. goHomeUrl: app.globalData.goHomeUrl,
  28. })
  29. let that = this;
  30. if (options.id) {
  31. Http.get({
  32. url: config.api.bannerDetail,
  33. data: {
  34. id: options.id
  35. }
  36. }).then(res => {
  37. if (res.data.type == 2) {
  38. that.setData({
  39. nodes: res.data.html
  40. })
  41. }
  42. that.setData({
  43. data: res.data
  44. });
  45. }).catch(err => {
  46. wx.showToast({
  47. title: err.errMsg,
  48. icon: 'none',
  49. duration: 2000,
  50. mask: false
  51. });
  52. })
  53. }
  54. }else{
  55. app.tokenCallback = token =>{
  56. this.setData({
  57. mouldType: app.globalData.mouldType,
  58. mouldConfig: app.globalData.mouldConfig,
  59. goHomeUrl: app.globalData.goHomeUrl,
  60. })
  61. let that = this;
  62. if (options.id) {
  63. Http.get({
  64. url: config.api.bannerDetail,
  65. data: {
  66. id: options.id
  67. }
  68. }).then(res => {
  69. if (res.data.type == 2) {
  70. that.setData({
  71. nodes: res.data.html
  72. })
  73. }
  74. that.setData({
  75. data: res.data
  76. });
  77. }).catch(err => {
  78. wx.showToast({
  79. title: err.errMsg,
  80. icon: 'none',
  81. duration: 2000,
  82. mask: false
  83. });
  84. })
  85. }
  86. }
  87. }
  88. },
  89. goback: function () {
  90. let this_=this
  91. wx.switchTab({
  92. url: this_.data.goHomeUrl,
  93. })
  94. },
  95. onShareAppMessage: function (options) {
  96. var that = this;
  97. console.log(`/pages/bannerdetail/index?id=${that.data.data.id}`)
  98. var shareObj = {
  99. title: that.data.title,
  100. path: `/pages/bannerdetail/index?id=${that.data.data.id}`,
  101. success: function (res) {
  102. if (res.errMsg == 'shareAppMessage:ok') { }
  103. },
  104. fail: function (error) {
  105. if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
  106. }
  107. };
  108. console.log(shareObj)
  109. return shareObj;
  110. },
  111. });