myhome.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // pages/myhome/myhome.js
  2. const config = require('../../config.js')
  3. const getReq = config.getReq
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. memberInfo: {},
  11. sinopec:{},
  12. petrochina:{},
  13. phone: {},
  14. userInfo: app.globalData.userInfo
  15. },
  16. handleMore(e) {
  17. const { cardtype } = e.currentTarget.dataset
  18. // app.navigateto(`/pages/postageManage/postageManage?card_type=${cardtype}`)
  19. app.navigateto('/pages/invitees/invitees')
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. },
  26. /**
  27. * 生命周期函数--监听页面初次渲染完成
  28. */
  29. onReady: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow: function ()
  35. {
  36. if(!app.globalData.userInfo) {
  37. return;
  38. }
  39. this.setData({
  40. userInfo: app.globalData.userInfo
  41. })
  42. getReq(app,{
  43. act: 'member_info',
  44. op: 'index',
  45. page_type: 'oil'
  46. }, (res) => {
  47. this.setData({
  48. firstLoad: false
  49. });
  50. if (res.code == 200) {
  51. console.log(res.datas)
  52. if(res.datas) {
  53. const { cards, sub_titles } = res.datas
  54. const phone = app.getValueByKey('phone', cards)
  55. const petrochina = app.getValueByKey('petrochina', cards)
  56. const sinopec = app.getValueByKey('sinopec', cards)
  57. this.setData({ memberInfo: {...res.datas}, phone, petrochina, sinopec })
  58. }
  59. } else {
  60. app.showToast(res.message)
  61. }
  62. })
  63. },
  64. getAuth(e) {
  65. let { userInfo } = e.detail
  66. if (userInfo) {
  67. this.setData({
  68. userInfo:userInfo
  69. })
  70. wx.reLaunch({
  71. url: '/pages/index/index'
  72. });
  73. }
  74. },
  75. /**
  76. * 生命周期函数--监听页面隐藏
  77. */
  78. onHide: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面卸载
  82. */
  83. onUnload: function () {
  84. },
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh: function () {
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom: function () {
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {
  99. }
  100. })