wallet.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. var app = getApp()
  2. Page({
  3. data: {
  4. balance:'0.00',//显示余额
  5. imgUrl:'http://resource.weilaibike.com/xiaobanma/walletBg.png',
  6. show:false,
  7. money:''
  8. },
  9. getBalance:function (e) {
  10. var that = this;
  11. console.log(1=='1')
  12. wx.login({
  13. success: function (res) {
  14. // 发送 res.code 到后台换取 openId, sessionKey, unionId
  15. console.log(res.code)
  16. var data = {
  17. 'code': res.code
  18. };
  19. wx.request({
  20. url: 'https://yutang.web.ximengnaikang.com/api/login',
  21. method: 'POST',
  22. data:data,
  23. header: {
  24. 'content-type': 'application/x-www-form-urlencoded'
  25. },
  26. success: function (res) {
  27. console.log(res)
  28. that.setData({balance:res.data.data.user.wallet_money})
  29. wx.setStorageSync('userInfo', res.data.data.user)
  30. }
  31. })
  32. }
  33. })
  34. //获取实名认证状态
  35. },
  36. walletDetail: function () {
  37. wx.navigateTo({
  38. url: '/pages/wallet_details/wallet_details',
  39. })
  40. },
  41. input:function(e){
  42. console.log(e.detail.value>0.01)
  43. if(e.detail.value>0.01){
  44. this.setData({money:e.detail.value})
  45. }else{
  46. this.setData({money:''})
  47. }
  48. },
  49. tixian:function(){
  50. this.setData({show:true})
  51. },
  52. cencal:function(){
  53. this.setData({show:false,money:''})
  54. },
  55. submit:function(){
  56. wx.showToast({
  57. title: '暂不支持~',
  58. icon:'none'
  59. })
  60. },
  61. quanbu:function(){
  62. if(this.data.balance>=0.01){
  63. this.setData({money:this.data.balance})
  64. }else{
  65. wx.showToast({
  66. title: '当前余额不足',
  67. icon:'none'
  68. })
  69. }
  70. },
  71. onLoad: function (options) {
  72. },
  73. onReady: function () {
  74. },
  75. onShow: function () {
  76. this.getBalance();
  77. },
  78. onHide: function () {
  79. },
  80. onUnload: function () {
  81. },
  82. onPullDownRefresh: function () {
  83. },
  84. onReachBottom: function () {
  85. },
  86. onShareAppMessage: function () {
  87. }
  88. })