grouponDetail.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. id: 0,
  6. groupon: {},
  7. joiners: [],
  8. orderInfo: {},
  9. orderGoods: [],
  10. rules: {},
  11. active: 0,
  12. steps: [],
  13. activeIcon: '',
  14. activeColor: ''
  15. },
  16. onLoad: function(options) {
  17. // 页面初始化 options为页面跳转所带来的参数
  18. this.setData({
  19. id: options.id
  20. });
  21. this.getOrderDetail();
  22. },
  23. // 页面分享
  24. onShareAppMessage: function() {
  25. let that = this;
  26. return {
  27. title: '邀请团购',
  28. desc: '唯爱与美食不可辜负',
  29. path: '/pages/index/index?grouponId=' + this.data.id
  30. }
  31. },
  32. getOrderDetail: function() {
  33. let that = this;
  34. util.request(api.GroupOnDetail, {
  35. grouponId: that.data.id
  36. }).then(function(res) {
  37. if (res.errno === 0) {
  38. let _steps = [{
  39. text: '已开团'
  40. },
  41. {
  42. text: '开团中'
  43. },
  44. {
  45. text: '开团成功'
  46. }
  47. ]
  48. let _active = res.data.groupon.status
  49. let _activeIcon = 'success'
  50. let _activeColor = '#07c160'
  51. if (res.data.groupon.status === 3) {
  52. _steps = [{
  53. text: '已开团'
  54. },
  55. {
  56. text: '开团中'
  57. },
  58. {
  59. text: '开团失败'
  60. }
  61. ]
  62. _active = 2
  63. _activeIcon = 'fail'
  64. _activeColor = '#EE0A24'
  65. }
  66. that.setData({
  67. joiners: res.data.joiners,
  68. groupon: res.data.groupon,
  69. orderInfo: res.data.orderInfo,
  70. orderGoods: res.data.orderGoods,
  71. rules: res.data.rules,
  72. active: _active,
  73. steps: _steps,
  74. activeIcon: _activeIcon,
  75. activeColor: _activeColor
  76. });
  77. }
  78. });
  79. },
  80. onReady: function() {
  81. // 页面渲染完成
  82. },
  83. onShow: function() {
  84. // 页面显示
  85. },
  86. onHide: function() {
  87. // 页面隐藏
  88. },
  89. onUnload: function() {
  90. // 页面关闭
  91. }
  92. });