person.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // pages/person/person.js
  2. const app = getApp();
  3. const getReq = require('./../../config.js').getReq;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. userInfo:{
  10. nickName:'',
  11. avatarUrl:''
  12. },
  13. bonus_rate:[],
  14. bonus_list_show:false,
  15. login_count:1
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. },
  22. /**
  23. * 生命周期函数--监听页面初次渲染完成
  24. */
  25. onReady: function () {
  26. },
  27. /**
  28. * 生命周期函数--监听页面显示
  29. */
  30. onShow: function () {
  31. const count = this.data.login_count;
  32. if (!app.globalData.userInfo && count <= 2) {
  33. this.setData({
  34. login_count: this.data.login_count+1
  35. })
  36. wx.navigateTo({
  37. url: '/pages/login/login'
  38. });
  39. return;
  40. }
  41. if (!app.globalData.userInfo && count > 2) {
  42. this.setData({
  43. login_count: 1
  44. })
  45. wx.switchTab({
  46. url: '/pages/index/index'
  47. });
  48. return;
  49. }
  50. const userInfo = app.globalData.userInfo || null;
  51. const nickName = userInfo.nickName || '';
  52. const avatarUrl = userInfo.avatarUrl || '';
  53. let self = this
  54. getReq({
  55. act: 'cart',
  56. op: 'rate_money'
  57. }, function (res) {
  58. if (res.code == 200) {
  59. self.setData({
  60. userInfo: { nickName, avatarUrl },
  61. bonus_rate: res.datas.bonus_rate
  62. })
  63. }
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面隐藏
  68. */
  69. onHide: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面卸载
  73. */
  74. onUnload: function () {
  75. },
  76. /**
  77. * 页面相关事件处理函数--监听用户下拉动作
  78. */
  79. onPullDownRefresh: function () {
  80. },
  81. /**
  82. * 页面上拉触底事件的处理函数
  83. */
  84. onReachBottom: function () {
  85. },
  86. bonus_list(){
  87. this.setData({
  88. bonus_list_show: !this.data.bonus_list_show
  89. })
  90. },
  91. skip_help(){
  92. wx.navigateTo({
  93. url: '/pages/webView/webView?url=https://passport.lrlz.com/hfive/feed_back/question_answer.html'
  94. })
  95. },
  96. skip_all_order(){
  97. wx.navigateTo({
  98. url: '/pages/order_tabs/orderTabs'
  99. })
  100. },
  101. refund(){
  102. wx.showToast({
  103. title: '客官!请在APP中完成退款申请',
  104. icon: 'none',
  105. duration: 2000
  106. })
  107. }
  108. })