index.js 2.2 KB

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