myhome.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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(app,{
  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. console.log(res.datas)
  51. if(res.datas) {
  52. const { cards, sub_titles } = res.datas
  53. const phone = app.getValueByKey('phone', cards)
  54. const petrochina = app.getValueByKey('petrochina', cards)
  55. const sinopec = app.getValueByKey('sinopec', cards)
  56. this.setData({ memberInfo: {...res.datas}, phone, petrochina, sinopec })
  57. }
  58. } else {
  59. app.showToast(res.message)
  60. }
  61. })
  62. },
  63. getAuth(e) {
  64. let { userInfo } = e.detail
  65. if (userInfo) {
  66. this.setData({
  67. userInfo:userInfo
  68. })
  69. wx.reLaunch({
  70. url: '/pages/index/index'
  71. });
  72. }
  73. },
  74. /**
  75. * 生命周期函数--监听页面隐藏
  76. */
  77. onHide: function () {
  78. },
  79. /**
  80. * 生命周期函数--监听页面卸载
  81. */
  82. onUnload: function () {
  83. },
  84. /**
  85. * 页面相关事件处理函数--监听用户下拉动作
  86. */
  87. onPullDownRefresh: function () {
  88. },
  89. /**
  90. * 页面上拉触底事件的处理函数
  91. */
  92. onReachBottom: function () {
  93. },
  94. /**
  95. * 用户点击右上角分享
  96. */
  97. onShareAppMessage: function () {
  98. }
  99. })