blance.js 4.9 KB

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