index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // pages/mine/index.js
  2. const util = require('../../utils/util.js');
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. userInfo:{},
  10. modal: false,
  11. toastButton: [{
  12. text: "确定",
  13. type: '#5677fc'
  14. }],
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. this.setData({
  21. userInfo: app.globalData.userInfo
  22. })
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. if (typeof this.getTabBar === 'function' &&
  34. this.getTabBar()) {
  35. this.getTabBar().setData({
  36. current: 2 // 根据tab的索引值设置
  37. })
  38. }
  39. },
  40. /**
  41. * 生命周期函数--监听页面隐藏
  42. */
  43. onHide: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面卸载
  47. */
  48. onUnload: function () {
  49. },
  50. /**
  51. * 页面相关事件处理函数--监听用户下拉动作
  52. */
  53. onPullDownRefresh: function () {
  54. },
  55. /**
  56. * 页面上拉触底事件的处理函数
  57. */
  58. onReachBottom: function () {
  59. },
  60. /**
  61. * 用户点击右上角分享
  62. */
  63. onShareAppMessage: function () {
  64. },
  65. logout(){
  66. util.request(util.api.logout, {}, "GET", false, true,app.globalData.token).then((res)=>{
  67. if (res.code == 200) {
  68. wx.showToast({
  69. title: '退出登录成功!',
  70. })
  71. setTimeout(()=>{
  72. wx.navigateTo({
  73. url: '/pages/login/index',
  74. })
  75. },500)
  76. }
  77. }).catch((res) => {})
  78. },
  79. withdrawal:function(e){
  80. console.log(app.globalData.userInfo)
  81. if(app.globalData.userInfo.money<100){
  82. util.toast("金额大于1元才能提现")
  83. return;
  84. }
  85. wx.showModal({
  86. title: '提示',
  87. content: '是否确认提现到微信零钱?',
  88. success: function (res) {
  89. if (res.confirm) {
  90. util.request(util.api.withdrawMoney, {}, "POST", true, true,app.globalData.token).then((res)=>{
  91. console.log(res)
  92. if (res.code == 200) {
  93. // this.setData({
  94. // userInfo: res.result.userInfo,
  95. // })
  96. // app.globalData.userInfo = res.result.userInfo
  97. //存入缓存
  98. // wx.setStorage({
  99. // data: res.result.userInfo,
  100. // key: 'birthdayUserInfo',
  101. // })
  102. util.toast('提现申请已提交,请留意微信收款通知')
  103. }else{
  104. util.toast(res.message)
  105. }
  106. });
  107. } else if (res.cancel) {
  108. console.log('用户点击取消')
  109. }
  110. }
  111. })
  112. },
  113. handleClick(e) {
  114. let index = e.detail.index;
  115. this.hideToast()
  116. },
  117. showToast() {
  118. this.setData({
  119. modal: true
  120. })
  121. },
  122. hideToast() {
  123. this.setData({
  124. modal: false
  125. })
  126. },
  127. toInvite(){
  128. wx.navigateTo({
  129. url: '/pages/accountRecord/index',
  130. })
  131. },
  132. })