partnerMineEarnings.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // pages/partner/mineEarnings/mineEarnings.js
  2. var that;
  3. var Util = require('../../utils/util.js');
  4. var app = getApp();
  5. Page({
  6. data: {
  7. urlHttp: '',
  8. hiddenmodal: true, //提示弹窗
  9. userPhoto: '', //用户头像
  10. userName: '', //用户昵称
  11. recordList : {},//提现记录
  12. accountList:{},//账户信息
  13. allMoney : 0, //账户总金额
  14. allEarnings : 0, //累计收益
  15. allInviteNum : 0, //邀请数量
  16. },
  17. onLoad: function (options) {
  18. var that = this;
  19. var host = getApp().globalData.servsers;
  20. var un_id = getApp().globalData.un_id;
  21. var openid = getApp().globalData.openid;
  22. console.log("un_id:" + un_id);
  23. console.log("openid:" + openid);
  24. if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
  25. wx.navigateTo({
  26. url: '/pages/authorize/authorize?link=partnerMineEarnings',
  27. })
  28. }else{
  29. console.log(getApp().globalData.userInfo);
  30. var userPhoto = getApp().globalData.userInfo.avatarUrl;
  31. var userName = getApp().globalData.userInfo.nickName;
  32. that.setData({
  33. urlHttp: host,
  34. userPhoto: userPhoto,
  35. userName: userName
  36. })
  37. }
  38. },
  39. onShow: function () {
  40. var that = this;
  41. var host = getApp().globalData.servsers;
  42. var un_id = getApp().globalData.un_id;
  43. var openid = getApp().globalData.openid;
  44. var userRole = getApp().globalData.userRole;
  45. // //获取用户账户信息
  46. wx.request({
  47. url: host + "api/distributeSell/getMyEarnInfo",
  48. data: {
  49. userId : un_id, //当前用户userId
  50. userRole: userRole, //用户角色
  51. },
  52. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  53. header: {
  54. 'Accept': 'application/json'
  55. },
  56. success: function (res) {
  57. console.log(res);
  58. if (res.data.code == '200') {
  59. that.setData({
  60. allMoney: res.data.data.accountBalance, //账户总金额
  61. allEarnings: res.data.data.accumulativeTotalEarn, //累计收益
  62. allInviteNum: res.data.data.sharePersonNum, //邀请数量
  63. })
  64. }
  65. if (res == null || res.data == null) {
  66. console.error('网络请求失败');
  67. return;
  68. }
  69. }
  70. })
  71. // //提现记录
  72. // wx.request({
  73. // url: host + "api/distributeSell/getExtractApplyList",
  74. // data: {
  75. // userId : un_id, //当前用户userId
  76. // userRole: userRole, //用户角色
  77. // },
  78. // method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  79. // header: {
  80. // 'Accept': 'application/json'
  81. // },
  82. // success: function (res) {
  83. // if(res.data.code == '200'){
  84. // that.setData({
  85. // recordList: res.data.data.rows
  86. // })
  87. // }
  88. // if (res == null || res.data == null) {
  89. // console.error('网络请求失败');
  90. // return;
  91. // }
  92. // }
  93. // })
  94. },
  95. //邀请数量 、 累计收益 : 详情入口
  96. inviteRecord:function(e){
  97. var that = this;
  98. var id = e.currentTarget.dataset.id;
  99. wx.navigateTo({
  100. url: '/pages/partnerCommonRecord/partnerCommonRecord?id=' + id,
  101. })
  102. },
  103. //申请提现
  104. applyWithdrawal:function(e){
  105. var that = this;
  106. that.setData({
  107. hiddenmodal: false,
  108. modalCont: '账户金额不足提现最低金额'
  109. })
  110. setTimeout(function () {
  111. that.setData({
  112. hiddenmodal: true
  113. })
  114. }, 1000)
  115. },
  116. //邀请好友 - 页面分享
  117. // onShareAppMessage: function (res) {
  118. // var that = this;
  119. // var host = getApp().globalData.servsers;
  120. // var un_id = getApp().globalData.un_id;
  121. // var fromUserPhoto = getApp().globalData.userInfo.avatarUrl;
  122. // var fromUserName = getApp().globalData.userInfo.nickName;
  123. // if (res.from === 'button') {
  124. // // 来自页面内转发按钮
  125. // }
  126. // return {
  127. // title: that.data.title,
  128. // path: '/pages/partnerShare/partnerShare?fromUserId=' + un_id + '&fromUserPhoto=' + fromUserPhoto + '&fromUserName=' + fromUserName,
  129. // imageUrl: '',
  130. // success: function (res) {
  131. // // 转发成功
  132. // that.setData({
  133. // hiddenmodal: false,
  134. // modalCont: '分享成功'
  135. // })
  136. // setTimeout(function () {
  137. // that.setData({
  138. // hiddenmodal: true
  139. // })
  140. // }, 1000)
  141. // },
  142. // fail: function (res) {
  143. // // 取消分享、转发失败
  144. // }
  145. // }
  146. // },
  147. onShareAppMessage: function (res) {
  148. var that = this;
  149. var host = getApp().globalData.servsers;
  150. var un_id = getApp().globalData.un_id;
  151. var fromUserPhoto = getApp().globalData.userInfo.avatarUrl;
  152. var fromUserName = getApp().globalData.userInfo.nickName;
  153. var fromUserRole = getApp().globalData.userRole;
  154. console.log("share-un_id:" + un_id);
  155. if (res.from === 'button') {
  156. // 来自页面内转发按钮
  157. }
  158. return {
  159. title: that.data.title,
  160. path: '/pages/midAutumn/midAutumn?fromUserId=' + un_id + '&fromUserRole=' + fromUserRole,
  161. imageUrl: '/images/share_img.jpg',
  162. success: function (res) {
  163. // 转发成功
  164. that.setData({
  165. hiddenmodal: false,
  166. modalCont: '分享成功'
  167. })
  168. setTimeout(function () {
  169. that.setData({
  170. hiddenmodal: true
  171. })
  172. }, 1000)
  173. },
  174. fail: function (res) {
  175. // 取消分享、转发失败
  176. }
  177. }
  178. },
  179. })