goodsDetails.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. var app = getApp();
  2. var util = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. currentTab: 0,
  9. pageSize: 10,
  10. navList: [{
  11. name: "全部",
  12. status: "-1"
  13. }, {
  14. name: "已完成",
  15. status: "1"
  16. }, {
  17. name: "未完成",
  18. status: "0"
  19. },
  20. {
  21. name: "已取消",
  22. status: "2"
  23. }
  24. ],
  25. list: [],
  26. loadText: "没有更多记录了~",
  27. containerHeight: 0,
  28. info: {},
  29. noData: 0,
  30. loadMore: true
  31. },
  32. page: 1,
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. var sysInfo = wx.getSystemInfoSync();
  38. console.log(sysInfo.windowHeight)
  39. this.setData({
  40. containerHeight: sysInfo.windowHeight - Math.round(sysInfo.windowHeight / 375 * 48) - 130
  41. });
  42. var that = this;
  43. if (!util.check_login()) {
  44. this.setData({
  45. needAuth: true
  46. })
  47. } else {
  48. this.getInfo();
  49. this.getData();
  50. }
  51. },
  52. getInfo: function () {
  53. wx.showLoading();
  54. var token = wx.getStorageSync('token');
  55. let that = this;
  56. app.util.request({
  57. url: 'entry/wxapp/user',
  58. data: {
  59. controller: 'distribution.get_commission_info',
  60. token: token
  61. },
  62. dataType: 'json',
  63. success: function (res) {
  64. wx.hideLoading();
  65. if (res.data.code == 0) {
  66. // Todo
  67. that.setData({ info: res.data.data })
  68. } else {
  69. wx.showModal({
  70. title: '提示',
  71. content: res.data.msg,
  72. showCancel: false,
  73. success(res) {
  74. if (res.confirm) {
  75. console.log('用户点击确定')
  76. wx.reLaunch({
  77. url: '/lionfish_comshop/pages/user/me',
  78. })
  79. }
  80. }
  81. })
  82. }
  83. }
  84. })
  85. },
  86. getData: function(){
  87. let that = this;
  88. let token = wx.getStorageSync('token');
  89. let currentTab = this.data.currentTab;
  90. let state = this.data.navList[currentTab].status;
  91. wx.showLoading();
  92. app.util.request({
  93. 'url': 'entry/wxapp/index',
  94. 'data': {
  95. controller: 'distribution.listorder_list',
  96. token: token,
  97. state: state,
  98. page: this.page
  99. },
  100. dataType: 'json',
  101. success: function (res) {
  102. console.log(res)
  103. if (res.data.code == 0) {
  104. let list = res.data.data;
  105. let oldList = that.data.list;
  106. list = oldList.concat(list);
  107. that.page++;
  108. that.setData({ list })
  109. } else {
  110. // 无数据
  111. if (that.page == 1) that.setData({ noData: 1 })
  112. that.setData({ loadMore: false })
  113. }
  114. wx.hideLoading();
  115. }
  116. })
  117. },
  118. getCurrentList: function () {
  119. if (!this.data.loadMore) return false;
  120. this.getData();
  121. this.setData({
  122. isHideLoadMore: false
  123. })
  124. },
  125. bindChange: function (t) {
  126. this.page = 1;
  127. this.setData({
  128. currentTab: 1 * t.detail.current,
  129. list: [],
  130. noData: 0,
  131. loadMore: true
  132. }, () => {
  133. console.log('我变啦');
  134. this.getData();
  135. });
  136. },
  137. /**
  138. * 切换导航
  139. */
  140. switchNav: function (e) {
  141. if (this.data.currentTab === 1 * e.target.dataset.current) return false;
  142. this.setData({
  143. currentTab: 1 * e.target.dataset.current
  144. });
  145. }
  146. })