spread.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. var app = getApp();
  2. // pages/spread/spread.js
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. url: app.globalData.urlImages,
  9. code:'',
  10. userinfo:[],
  11. cont:'',
  12. first:0,
  13. limit:8,
  14. mainArray:[],
  15. hiddens:true
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. app.setBarColor();
  22. app.setUserInfo();
  23. this.getCode();
  24. var header = {
  25. 'content-type': 'application/x-www-form-urlencoded',
  26. };
  27. this.money(header);
  28. this.spread(header);
  29. this.userbill(header);
  30. },
  31. money: function (header){
  32. var that = this;
  33. wx.request({
  34. url: app.globalData.url + '/routine/auth_api/my?uid=' + app.globalData.uid,
  35. method: 'POST',
  36. header: header,
  37. success: function (res) {
  38. if (res.data.code==200){
  39. that.setData({
  40. userinfo: res.data.data
  41. })
  42. }else{
  43. that.setData({
  44. userinfo: []
  45. })
  46. }
  47. }
  48. });
  49. },
  50. getCode:function(){
  51. var that = this;
  52. wx.request({
  53. url: app.globalData.url + '/routine/auth_api/get_code?uid=' + app.globalData.uid,
  54. method: 'POST',
  55. success: function (res) {
  56. if (res.data.code == 200) {
  57. that.setData({
  58. code:res.data.msg
  59. })
  60. } else {
  61. wx.showToast({
  62. title: res.data.msg,
  63. icon: 'none',
  64. duration: 0
  65. })
  66. that.setData({
  67. code: ''
  68. })
  69. }
  70. console.log(that.data.code);
  71. }
  72. });
  73. },
  74. spread: function (header){
  75. var that = this;
  76. wx.request({
  77. url: app.globalData.url + '/routine/auth_api/get_spread_list?uid=' + app.globalData.uid,
  78. method: 'POST',
  79. header: header,
  80. success: function (res) {
  81. if (res.data.code == 200) {
  82. that.setData({
  83. cont: res.data.data.count
  84. })
  85. }else{
  86. that.setData({
  87. cont: 0
  88. })
  89. }
  90. }
  91. });
  92. },
  93. userbill: function (header){
  94. var that = this;
  95. that.setData({
  96. first:0
  97. });
  98. wx.request({
  99. url: app.globalData.url + '/routine/auth_api/user_balance_list?uid=' + app.globalData.uid,
  100. method: 'GET',
  101. data:{
  102. first: that.data.first,
  103. limit: that.data.limit,
  104. },
  105. success: function (res) {
  106. // console.log(res.data.data);
  107. if (res.data.code == 200) {
  108. that.setData({
  109. mainArray: res.data.data
  110. })
  111. }else{
  112. that.setData({
  113. mainArray:[]
  114. })
  115. }
  116. }
  117. })
  118. },
  119. cash:function(){
  120. wx.navigateTo({
  121. url: '../../pages/cash/cash?money='+this.data.userinfo.now_money,
  122. success: function (res) { },
  123. fail: function (res) { },
  124. complete: function (res) { },
  125. })
  126. },
  127. porder:function(){
  128. wx.navigateTo({
  129. url: '../../pages/promotion-order/promotion-order',
  130. success: function (res) { },
  131. fail: function (res) { },
  132. complete: function (res) { },
  133. })
  134. },
  135. /**
  136. * 生命周期函数--监听页面初次渲染完成
  137. */
  138. onReady: function () {
  139. },
  140. erm:function(e){
  141. this.setData({
  142. hiddens:false
  143. })
  144. this.getCode();
  145. },
  146. tanguan:function(e){
  147. this.setData({
  148. hiddens: true
  149. })
  150. },
  151. onReachBottom: function (p) {
  152. var that = this;
  153. var limit = that.data.limit;
  154. var first = that.data.first;
  155. if (!first) first = first+1;
  156. var firstS = first * limit;
  157. var mainArray = that.data.mainArray;
  158. wx.request({
  159. url: app.globalData.url + '/routine/auth_api/user_balance_list?uid=' + app.globalData.uid,
  160. method: 'GET',
  161. data: {
  162. first: firstS,
  163. limit: that.data.limit,
  164. },
  165. success: function (res) {
  166. if (res.data.code == 200) {
  167. for (var i = 0; i < res.data.data.length; i++) {
  168. mainArray.push(res.data.data[i])
  169. }
  170. that.setData({
  171. first: first + 1,
  172. mainArray: mainArray
  173. });
  174. } else {
  175. }
  176. }
  177. })
  178. },
  179. })