myhome.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. },
  15. handleMore(e) {
  16. const { cardtype } = e.currentTarget.dataset
  17. app.navigateto(`/pages/postageManage/postageManage?card_type=${cardtype}`)
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. getReq({
  34. act: 'member_info',
  35. op: 'index',
  36. page_type: 'oil'
  37. }, (res) => {
  38. this.setData({
  39. firstLoad: false
  40. });
  41. if (res.code == 200) {
  42. if(res.datas) {
  43. const { cards, sub_titles } = res.datas
  44. const phone = app.getValueByKey('phone', cards)
  45. const petrochina = app.getValueByKey('petrochina', cards)
  46. const sinopec = app.getValueByKey('sinopec', cards)
  47. this.setData({ memberInfo: {...res.datas}, phone, petrochina, sinopec })
  48. }
  49. } else {
  50. app.showToast(res.message)
  51. }
  52. })
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh: function () {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom: function () {
  73. },
  74. /**
  75. * 用户点击右上角分享
  76. */
  77. onShareAppMessage: function () {
  78. }
  79. })