spread.js 4.1 KB

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