myhome.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. pre_pay_count: 0, // 待付款 10
  15. pre_send_count: 0, // 待发货 20
  16. pre_receive_count: 0, // 待收货 30
  17. evaluate_count: 0, // 已收货 40
  18. userInfo: app.globalData.userInfo
  19. },
  20. handleMore(e) {
  21. const { cardtype } = e.currentTarget.dataset
  22. if(cardtype === 'invitees') {
  23. app.navigateto('/pages/invitees/invitees')
  24. } else {
  25. app.navigateto(`/pages/postageManage/postageManage?card_type=${cardtype}`)
  26. }
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. },
  33. /**
  34. * 生命周期函数--监听页面初次渲染完成
  35. */
  36. onReady: function () {
  37. },
  38. /**
  39. * 生命周期函数--监听页面显示
  40. */
  41. onShow: function ()
  42. {
  43. if(!app.globalData.userInfo) {
  44. return;
  45. }
  46. this.setData({
  47. userInfo: app.globalData.userInfo
  48. })
  49. this.getData()
  50. },
  51. getData(){
  52. let self = this;
  53. getReq(app,{
  54. act: 'member_info',
  55. op: 'index',
  56. page_type: 'oil'
  57. }, (res) => {
  58. this.setData({
  59. firstLoad: false
  60. });
  61. if (res.code == 200) {
  62. console.log(res.datas)
  63. if(res.datas) {
  64. const { cards, sub_titles } = res.datas
  65. const phone = app.getValueByKey('phone', cards)
  66. const petrochina = app.getValueByKey('petrochina', cards)
  67. const sinopec = app.getValueByKey('sinopec', cards)
  68. this.setData({ memberInfo: {...res.datas}, phone, petrochina, sinopec })
  69. }
  70. } else {
  71. app.showToast(res.message)
  72. }
  73. })
  74. getReq(app, {
  75. act: 'member_vorder',
  76. op: 'orderCountState'
  77. }, function (res) {
  78. if (res.code == 200) {
  79. self.setData({
  80. pre_pay_count: 0, // 待付款 10
  81. pre_send_count: 0, // 待发货 20
  82. pre_receive_count: 0, // 待收货 30
  83. evaluate_count: 0,
  84. firstLoad: false
  85. })
  86. let { order_count } = res.datas
  87. if (order_count.length) {
  88. let length = order_count.length
  89. for (let i = 0; i < length; i++) {
  90. let state_name = ''
  91. if (order_count[i]['order_state'] == 10) {
  92. state_name = 'pre_pay_count'
  93. }
  94. if (order_count[i]['order_state'] == 20) {
  95. state_name = 'pre_send_count'
  96. }
  97. if (order_count[i]['order_state'] == 30) {
  98. state_name = 'pre_receive_count'
  99. }
  100. if (order_count[i]['order_state'] == 40) {
  101. state_name = 'evaluate_count'
  102. }
  103. if (state_name) {
  104. self.setData({
  105. [state_name]: order_count[i]['count']
  106. })
  107. }
  108. }
  109. }
  110. }
  111. })
  112. },
  113. getAuth(e) {
  114. let { userInfo } = e.detail
  115. if (userInfo) {
  116. this.setData({
  117. userInfo:userInfo
  118. })
  119. wx.reLaunch({
  120. url: '/pages/index/index'
  121. });
  122. }
  123. },
  124. /**
  125. * 生命周期函数--监听页面隐藏
  126. */
  127. onHide: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面卸载
  131. */
  132. onUnload: function () {
  133. },
  134. /**
  135. * 页面相关事件处理函数--监听用户下拉动作
  136. */
  137. onPullDownRefresh: function () {
  138. },
  139. /**
  140. * 页面上拉触底事件的处理函数
  141. */
  142. onReachBottom: function () {
  143. },
  144. /**
  145. * 用户点击右上角分享
  146. */
  147. onShareAppMessage: function () {
  148. // return app.cardShareInfo();
  149. }
  150. })