admin.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // pages/admin/admin.js
  2. const app = getApp()
  3. const link = app.globalData.url
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. page:1,
  10. pageSize:10,
  11. openId:"",
  12. userStatus:0,
  13. goodsList:[],
  14. count:0
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. //获取金额
  21. var that = this
  22. that.page = 1
  23. that.pageSize = 10
  24. that.openId = wx.getStorageSync('openId')
  25. that.userStatus = 3
  26. wx.request( {
  27. url: link + "/v1/forward/lhf",
  28. header: {
  29. "Content-Type": "application/json",
  30. "function":"/v1/admin/data"
  31. },
  32. method: "POST",
  33. data: { openId: "" },
  34. success (res) {
  35. console.log(res)
  36. that.setData({
  37. wallet: res.data.data
  38. })
  39. }
  40. })
  41. wx.request( {
  42. url: link + "/v1/forward/lhf",
  43. header: {
  44. "Content-Type": "application/json",
  45. "function":"/v1/user/order/list"
  46. },
  47. method: "POST",
  48. data: { openId: "o0PAf400H9fbwDN6-a8ndU4di0JI",pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus},
  49. complete: function( res ) {
  50. console.log(res)
  51. if( res == null || res.data == null ) {
  52. console.error( '网络请求失败' );
  53. return;
  54. }
  55. console.log(res.data.data.rows)
  56. //that.count = res.data.data.count
  57. if (res.data.data.rows.orderInfo == null){
  58. that.count = res.data.data.count
  59. that.setData({
  60. goodsList: res.data.data.rows.orderInfo,
  61. lType:"end"
  62. })
  63. } else{
  64. that.count = res.data.data.count
  65. that.data.goodsList = res.data.data.rows.orderInfo
  66. that.setData({
  67. goodsList: that.data.goodsList,
  68. lType:"false"
  69. })
  70. }
  71. }
  72. })
  73. },
  74. /**
  75. * 生命周期函数--监听页面初次渲染完成
  76. */
  77. onReady: function () {
  78. },
  79. /**
  80. * 生命周期函数--监听页面显示
  81. */
  82. onShow: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload: function () {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh: function () {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom: function () {
  103. //获取数据
  104. var that = this;
  105. if (that.page * that.pageSize >= that.count ){
  106. //提示页码到了
  107. that.setData({
  108. lType:"end"
  109. })
  110. return
  111. }
  112. that.page +=1
  113. wx.request( {
  114. url: link + "/v1/forward/lhf",
  115. header: {
  116. "Content-Type": "application/json",
  117. "function":"/v1/user/order/list"
  118. },
  119. method: "POST",
  120. data: { openId: "o0PAf400H9fbwDN6-a8ndU4di0JI",pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus},
  121. complete: function( res ) {
  122. wx.hideLoading();
  123. console.log(res)
  124. for (var i = 0; i < res.data.data.rows.orderInfo.length; i++) {
  125. that.data.goodsList.push( res.data.data.rows.orderInfo[i]);
  126. }
  127. that.setData({
  128. goodsList: that.data.goodsList,
  129. })
  130. console.log(res.data.data.goods_search_response)
  131. if( res == null || res.data == null ) {
  132. console.error( '网络请求失败' );
  133. return;
  134. }
  135. }
  136. })
  137. },
  138. /**
  139. * 用户点击右上角分享
  140. */
  141. onShareAppMessage: function () {
  142. }
  143. })