index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import {
  2. getBargainPoster,
  3. getCombinationPoster
  4. } from '../../../api/activity.js';
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. parameter: {
  12. 'navbar': '1',
  13. 'return': '1',
  14. 'title': '拼团海报',
  15. 'color': true,
  16. 'class': '0'
  17. },
  18. type: 0,
  19. id: 0,
  20. image: '',
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. var that = this;
  27. if (options.hasOwnProperty('type') && options.hasOwnProperty('id')) {
  28. that.setData({
  29. type: options.type,
  30. id: options.id
  31. });
  32. if (options.type == 1)
  33. that.setData({
  34. 'parameter.title': '砍价海报'
  35. });
  36. else
  37. that.setData({
  38. 'parameter.title': '拼团海报'
  39. });
  40. } else {
  41. return app.Tips({
  42. title: '参数错误',
  43. icon: 'none'
  44. }, {
  45. tab: 3,
  46. url: 1
  47. });
  48. }
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. this.getPosterInfo();
  55. },
  56. getPosterInfo: function () {
  57. var that = this,
  58. url = '';
  59. let data = {
  60. id: that.data.id,
  61. 'from': 'routine'
  62. };
  63. if (that.data.type == 1) {
  64. getBargainPoster({
  65. bargainId: that.data.id,
  66. 'from': 'routine'
  67. }).then(res => {
  68. that.setData({
  69. image: res.data.url
  70. });
  71. }).catch(err => {
  72. return app.Tips({
  73. title: err
  74. });
  75. })
  76. } else {
  77. getCombinationPoster(data).then(res => {
  78. that.setData({
  79. image: res.data.url
  80. });
  81. }).catch(err => {
  82. return app.Tips({
  83. title: err
  84. });
  85. })
  86. }
  87. },
  88. showImage: function () {
  89. var that = this;
  90. wx.previewImage({
  91. current: that.data.image,
  92. urls: [that.data.image],
  93. })
  94. },
  95. /**
  96. * 生命周期函数--监听页面初次渲染完成
  97. */
  98. onReady: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload: function () {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh: function () {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom: function () {
  119. },
  120. })