myGroupon.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. orderList: [],
  6. showType: 0
  7. },
  8. onLoad: function(options) {
  9. // 页面初始化 options为页面跳转所带来的参数
  10. },
  11. onPullDownRefresh() {
  12. // wx.showNavigationBarLoading() //在标题栏中显示加载
  13. this.getOrderList();
  14. // wx.hideNavigationBarLoading() //完成停止加载
  15. wx.stopPullDownRefresh() //停止下拉刷新
  16. },
  17. getOrderList() {
  18. wx.showLoading({
  19. title: '加载中',
  20. });
  21. setTimeout(function() {
  22. wx.hideLoading()
  23. }, 2000);
  24. let that = this;
  25. util.request(api.GroupOnMy, {
  26. showType: that.data.showType
  27. }).then(function(res) {
  28. if (res.errno === 0) {
  29. that.setData({
  30. orderList: res.data.list
  31. });
  32. wx.hideLoading();
  33. }
  34. });
  35. },
  36. switchTab: function(event) {
  37. let showType = event.currentTarget.dataset.index;
  38. this.setData({
  39. showType: showType
  40. });
  41. this.getOrderList();
  42. },
  43. onReady: function() {
  44. // 页面渲染完成
  45. },
  46. onShow: function() {
  47. // 页面显示
  48. this.getOrderList();
  49. },
  50. onHide: function() {
  51. // 页面隐藏
  52. },
  53. onUnload: function() {
  54. // 页面关闭
  55. }
  56. })