blance.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var check = require('../../../utils/check.js');
  4. var app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. referee:{},
  11. showAuth:false ,
  12. tipsShow:false,
  13. teamText:true,
  14. checked:false,
  15. tipType:1,
  16. topType:'blance'//头部显示内容
  17. },
  18. goList(){
  19. wx.navigateTo({
  20. url: '/pages/referee/blance/list/list',
  21. })
  22. },
  23. onChange(e) {
  24. console.log(e);
  25. this.setData({
  26. checked: e.detail,
  27. });
  28. },
  29. userProtocol(){
  30. wx.navigateTo({
  31. url: '/pages/referee/protocol/protocol'
  32. });
  33. },
  34. goCheckAuth(){//是否实名认证过
  35. let day=(new Date()).getDate();
  36. console.log(day);
  37. if(day!=8){
  38. wx.showModal({
  39. title: '提示',
  40. showCancel:false,
  41. content: '提现时间为每月8号,点击提现后2个工作日内到账。',
  42. });
  43. return false;
  44. }
  45. let that=this
  46. util.request(api.RefereeCashoutAuthCheck, {}).then(function(res) {
  47. if (res.errno === 0&&res.data) {
  48. that.goCashout();
  49. }
  50. else {
  51. that.setData({
  52. showAuth:true
  53. })
  54. }
  55. })
  56. },
  57. goCashout(){//提现申请
  58. let that=this
  59. wx.showModal({
  60. title: '提示',
  61. // content: '确定要将'+that.data.referee.commissionBlance+'全部提现吗?\n平台会代缴6%税',
  62. content: '提现金额为'+that.data.referee.commissionBlance+',手续费是6%,另外涉及个人所得税部分由引荐人自行承担并由第三方平台代扣代缴,故最终提现金额应以实际到账金额为准。',
  63. success: function (sm) {
  64. if (sm.confirm) {
  65. util.request(api.RefereeCashoutApply, {cashout:that.data.referee.commissionBlance}).then(function(res) {
  66. if (res.errno === 0) {
  67. wx.showToast({
  68. title: '提现申请成功',
  69. icon: 'none',
  70. duration: 2000
  71. });
  72. that.setData({
  73. showAuth:false
  74. })
  75. that.getBlance();
  76. }
  77. });
  78. } else if (sm.cancel) {
  79. console.log('用户点击取消')
  80. }
  81. }
  82. })
  83. },
  84. goCancel() {
  85. this.setData({
  86. showAuth:false
  87. })
  88. },
  89. bindinputName(e){
  90. let val=e.detail.value;
  91. this.setData({
  92. ['referee.refereeName']:val
  93. });
  94. },
  95. bindinputNid(e){
  96. let val=e.detail.value;
  97. this.setData({
  98. ['referee.refereeNid']:val
  99. })
  100. },
  101. cashoutAuth(){
  102. if(this.data.referee.refereeName==''){
  103. wx.showToast({
  104. title: '请输入真实姓名',
  105. icon: 'none',
  106. duration: 2000
  107. });
  108. return false;
  109. }else if(!check.isCardCheck(this.data.referee.refereeNid)){
  110. wx.showToast({
  111. title: '请输入正确的身份证号',
  112. icon: 'none',
  113. duration: 2000
  114. });
  115. return false;
  116. }else if(!this.data.checked){
  117. wx.showToast({
  118. title: '请阅读《用户条款》并勾选',
  119. icon: 'none',
  120. duration: 2000
  121. });
  122. return false;
  123. }
  124. util.request(api.RefereeCashoutAuth, {
  125. name:this.data.referee.refereeName,
  126. nid:this.data.referee.refereeNid,
  127. mobile:this.data.referee.refereeMobile
  128. }).then(res=> {
  129. if (res.errno == 0) {
  130. this.goCashout();
  131. }
  132. });
  133. },
  134. /**
  135. * 生命周期函数--监听页面加载
  136. */
  137. onLoad: function (options) {
  138. let topType=options.type;
  139. //如果不等于blance 则将待结算和余额位置调换
  140. if(topType){
  141. this.setData({
  142. topType:topType
  143. })
  144. }
  145. },
  146. /**
  147. * 生命周期函数--监听页面初次渲染完成
  148. */
  149. onReady: function () {
  150. },
  151. /**
  152. * 生命周期函数--监听页面显示
  153. */
  154. onShow: function () {
  155. this.getBlance();
  156. },
  157. getBlance(){
  158. let that = this;
  159. util.request(api.RefereeMyBlance, { }).then(function(res) {
  160. if (res.errno === 0) {
  161. that.setData({
  162. referee: res.data
  163. });
  164. }
  165. });
  166. },
  167. showTip1(){
  168. this.setData({
  169. tipType:1,
  170. tipsShow:true,
  171. })
  172. },
  173. showTip2(){
  174. this.setData({
  175. tipType:2,
  176. tipsShow:true,
  177. })
  178. },
  179. showTip3(){
  180. this.setData({
  181. tipType:3,
  182. tipsShow:true,
  183. })
  184. },
  185. onClickHide(){
  186. this.setData({
  187. tipsShow:false
  188. })
  189. },
  190. /**
  191. * 生命周期函数--监听页面隐藏
  192. */
  193. onHide: function () {
  194. },
  195. /**
  196. * 生命周期函数--监听页面卸载
  197. */
  198. onUnload: function () {
  199. },
  200. /**
  201. * 页面相关事件处理函数--监听用户下拉动作
  202. */
  203. onPullDownRefresh: function () {
  204. },
  205. /**
  206. * 页面上拉触底事件的处理函数
  207. */
  208. onReachBottom: function () {
  209. },
  210. /**
  211. * 用户点击右上角分享
  212. */
  213. onShareAppMessage: function () {
  214. }
  215. })