logs.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. var app = getApp();
  2. Page({
  3. data: {
  4. open: true,
  5. user: '',
  6. balance: '', //我的钱包
  7. actionSheetHidden: true,
  8. state: '',
  9. arr: [],
  10. show: '',
  11. screenHeight: '',
  12. adHeight: '',
  13. img: app.globalData.imgUrl,
  14. title: app.globalData.title,
  15. identity:''
  16. },
  17. onGotUserInfo: function (e) {
  18. console.log(e)
  19. var that = this;
  20. wx.showLoading({
  21. title: '登陆中请稍等...',
  22. mask: true
  23. })
  24. if (e.detail.userInfo) {
  25. var data = e.detail.userInfo;
  26. wx.request({
  27. url: 'https://yutang.web.ximengnaikang.com/api/syncUserInfo',
  28. method: 'POST',
  29. data: data,
  30. header: {
  31. 'content-type': 'application/x-www-form-urlencoded',
  32. 'Authorization': wx.getStorageSync('token')
  33. },
  34. success: function (res) {
  35. console.log(res)
  36. if (res.statusCode == 200) {
  37. wx.showToast({
  38. title: '授权成功',
  39. icon: 'none'
  40. })
  41. wx.setStorageSync('userInfo', res.data.data.user)
  42. that.setData({
  43. user: res.data.data.user
  44. })
  45. } else {
  46. wx.showToast({
  47. title: '登陆失败请重试',
  48. icon: 'none'
  49. })
  50. }
  51. }
  52. })
  53. } else {
  54. wx.showToast({
  55. title: '授权失败',
  56. icon: 'none'
  57. })
  58. }
  59. },
  60. tap: function (e) {
  61. console.log(e)
  62. var url = e.currentTarget.dataset.url;
  63. console.log(url)
  64. var userInfo = wx.getStorageSync('userInfo');
  65. console.log(userInfo)
  66. if (userInfo == undefined || userInfo == '') {
  67. wx.showModal({
  68. title: '用户授权',
  69. content: '此功能需要获取您的昵称等公开信息,请到小程序的设置中打开用户权限!',
  70. cancelText: '下次再说',
  71. confirmText: '去授权',
  72. success: function (res) {
  73. if (res.confirm) {
  74. wx.navigateTo({
  75. url: '../login/login',
  76. })
  77. }
  78. }
  79. })
  80. } else {
  81. wx.navigateTo({
  82. url: '/pages/' + url + '/' + url
  83. })
  84. }
  85. },
  86. onLoad: function (options) {
  87. this.setData({
  88. screenHeight: app.globalData.screenHeight
  89. })
  90. //获取实名认证状态
  91. },
  92. buy: function () {
  93. wx.navigateTo({
  94. url: '/pages/recharge/recharge',
  95. })
  96. },
  97. look() {
  98. wx.navigateTo({
  99. url: '/pages/riding_card/riding_card',
  100. })
  101. },
  102. onReady: function () {
  103. },
  104. onShow: function () {
  105. var that = this;
  106. that.setData({
  107. user: wx.getStorageSync('userInfo'),
  108. identity:wx.getStorageSync('userInfo').role
  109. })
  110. console.log(this.data.identity)
  111. // app.request("/card_riding/user_card", '', "GET").then(res => {
  112. // console.log(res)
  113. // that.setData({ arr: res.data.user_card,show:res.data.is_card_begin })
  114. // })
  115. // app.request("/user/status", '', "GET").then(res => {
  116. // console.log(res)
  117. // if (res.statusCode == 200) {
  118. // if (res.data.is_card_certified == 1) {
  119. // this.setData({
  120. // state: '已实名'
  121. // })
  122. // } else {
  123. // this.setData({
  124. // state: '未实名'
  125. // })
  126. // }
  127. // wx.setStorageSync('userState', res.data)
  128. // }
  129. // })
  130. },
  131. onHide: function () {
  132. },
  133. onUnload: function () {
  134. },
  135. onPullDownRefresh: function () {
  136. wx.showNavigationBarLoading();
  137. var that = this;
  138. // app.request("/me", '', "GET").then(res => {
  139. // 200 == res.statusCode && wx.setStorageSync("userInfo", res.data), that.setData({
  140. // user: res.data
  141. // })
  142. // wx.hideNavigationBarLoading()
  143. // wx.stopPullDownRefresh();
  144. // })
  145. },
  146. onReachBottom: function () {
  147. },
  148. onShareAppMessage: function () {
  149. }
  150. })