myhome.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function ()
  34. {
  35. if(!app.globalData.userInfo) {
  36. return;
  37. }
  38. this.setData({
  39. userInfo: app.globalData.userInfo
  40. })
  41. getReq({
  42. act: 'member_info',
  43. op: 'index',
  44. page_type: 'oil'
  45. }, (res) => {
  46. this.setData({
  47. firstLoad: false
  48. });
  49. if (res.code == 200) {
  50. if(res.datas) {
  51. const { cards, sub_titles } = res.datas
  52. const phone = app.getValueByKey('phone', cards)
  53. const petrochina = app.getValueByKey('petrochina', cards)
  54. const sinopec = app.getValueByKey('sinopec', cards)
  55. this.setData({ memberInfo: {...res.datas}, phone, petrochina, sinopec })
  56. }
  57. } else {
  58. app.showToast(res.message)
  59. }
  60. })
  61. },
  62. getAuth(e) {
  63. let { userInfo } = e.detail
  64. if (userInfo) {
  65. this.setData({
  66. userInfo:userInfo
  67. })
  68. wx.reLaunch({
  69. url: '/pages/index/index'
  70. });
  71. }
  72. },
  73. /**
  74. * 生命周期函数--监听页面隐藏
  75. */
  76. onHide: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面卸载
  80. */
  81. onUnload: function () {
  82. },
  83. /**
  84. * 页面相关事件处理函数--监听用户下拉动作
  85. */
  86. onPullDownRefresh: function () {
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom: function () {
  92. },
  93. /**
  94. * 用户点击右上角分享
  95. */
  96. onShareAppMessage: function () {
  97. }
  98. })