grouponDetail.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. id: 0,
  6. orderId: 0,
  7. groupon: {},
  8. linkGrouponId: 0,
  9. joiners: [],
  10. orderInfo: {},
  11. orderGoods: [],
  12. expressInfo: {},
  13. flag: false,
  14. handleOption: {}
  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.linkGrouponId
  30. }
  31. },
  32. showShare: function() {
  33. this.sharePop.togglePopup();
  34. },
  35. onPullDownRefresh() {
  36. this.getOrderDetail();
  37. wx.stopPullDownRefresh() //停止下拉刷新
  38. },
  39. expandDetail: function() {
  40. let that = this;
  41. this.setData({
  42. flag: !that.data.flag
  43. })
  44. },
  45. getOrderDetail: function() {
  46. wx.showLoading({
  47. title: '加载中',
  48. });
  49. setTimeout(function() {
  50. wx.hideLoading()
  51. }, 2000);
  52. let that = this;
  53. util.request(api.GroupOnDetail, {
  54. grouponId: that.data.id
  55. }).then(function(res) {
  56. if (res.errno === 0) {
  57. that.setData({
  58. joiners: res.data.joiners,
  59. groupon: res.data.groupon,
  60. linkGrouponId: res.data.linkGrouponId,
  61. orderId: res.data.orderInfo.id,
  62. orderInfo: res.data.orderInfo,
  63. orderGoods: res.data.orderGoods,
  64. handleOption: res.data.orderInfo.handleOption,
  65. expressInfo: res.data.expressInfo
  66. });
  67. wx.hideLoading();
  68. }
  69. });
  70. },
  71. onReady: function() {
  72. // 页面渲染完成
  73. this.sharePop = this.selectComponent("#sharePop");
  74. },
  75. onShow: function() {
  76. // 页面显示
  77. },
  78. onHide: function() {
  79. // 页面隐藏
  80. },
  81. onUnload: function() {
  82. // 页面关闭
  83. }
  84. });