person.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // pages/person/person.js
  2. const app = getApp();
  3. const getReq = require('./../../config.js').getReq;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. userInfo: {
  10. nickName: '',
  11. avatarUrl: ''
  12. },
  13. bonus_rate: [],
  14. bonus_list_show: false,
  15. login_count: 1,
  16. addr_num: '',
  17. pre_pay_count: 0, // 待付款 10
  18. pre_send_count: 0, // 待发货 20
  19. pre_receive_count: 0, // 待收货 30
  20. evaluate_count: 0, // 已收货 40
  21. bonus_total: 0
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady: function () {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow: function () {
  37. const count = this.data.login_count;
  38. if (!app.globalData.userInfo && count <= 2) {
  39. this.setData({
  40. login_count: this.data.login_count + 1
  41. })
  42. wx.navigateTo({
  43. url: '/pages/login/login'
  44. });
  45. return;
  46. }
  47. if (!app.globalData.userInfo && count > 2) {
  48. this.setData({
  49. login_count: 1
  50. })
  51. wx.switchTab({
  52. url: '/pages/index/index'
  53. });
  54. return;
  55. }
  56. const userInfo = app.globalData.userInfo || null;
  57. const nickName = userInfo.nickName || '';
  58. const avatarUrl = userInfo.avatarUrl || '';
  59. let self = this
  60. getReq({
  61. act: 'cart',
  62. op: 'rate_money'
  63. }, function (res) {
  64. if (res.code == 200) {
  65. console.log(res);
  66. self.setData({
  67. userInfo: { nickName, avatarUrl },
  68. bonus_rate: res.datas.bonus_rate
  69. })
  70. }
  71. })
  72. getReq({
  73. act: 'member_info',
  74. op: 'get'
  75. }, function (res) {
  76. if (res.code == 200) {
  77. console.log('member_info:', res);
  78. self.setData({
  79. addr_num: res.datas.sub_titles.addr_num
  80. })
  81. }
  82. })
  83. getReq({
  84. act: 'member_order',
  85. op: 'orderCountState'
  86. }, function (res) {
  87. if (res.code == 200) {
  88. console.log('member_order:', res);
  89. let { order_count } = res.datas;
  90. if(order_count.length) {
  91. let length = order_count.length
  92. for(let i = 0; i < length; i++) {
  93. let state_name = ''
  94. if(order_count[i]['order_state'] == 10) {
  95. state_name = 'pre_pay_count'
  96. }
  97. if(order_count[i]['order_state'] == 20) {
  98. state_name = 'pre_send_count'
  99. }
  100. if(order_count[i]['order_state'] == 30) {
  101. state_name = 'pre_receive_count'
  102. }
  103. if(order_count[i]['order_state'] == 40) {
  104. state_name = 'evaluate_count'
  105. }
  106. if(state_name) {
  107. self.setData({
  108. [state_name]: order_count[i]['count']
  109. })
  110. }
  111. }
  112. }
  113. }
  114. })
  115. getReq({
  116. act: 'member_bonus',
  117. op: 'predepositex'
  118. }, function (res) {
  119. if (res.code == 200) {
  120. console.log('member_bonus:', res);
  121. let { bonus_total } = res.datas
  122. self.setData({
  123. bonus_total
  124. })
  125. }
  126. })
  127. },
  128. /**
  129. * 生命周期函数--监听页面隐藏
  130. */
  131. onHide: function () {
  132. },
  133. /**
  134. * 生命周期函数--监听页面卸载
  135. */
  136. onUnload: function () {
  137. },
  138. /**
  139. * 页面相关事件处理函数--监听用户下拉动作
  140. */
  141. onPullDownRefresh: function () {
  142. },
  143. /**
  144. * 页面上拉触底事件的处理函数
  145. */
  146. onReachBottom: function () {
  147. },
  148. bonus_list() {
  149. this.setData({
  150. bonus_list_show: !this.data.bonus_list_show
  151. })
  152. },
  153. skip_help() {
  154. wx.navigateTo({
  155. url: '/pages/webView/webView?url=https://passport.lrlz.com/hfive/feed_back/question_answer.html'
  156. })
  157. },
  158. skip_all_order() {
  159. wx.navigateTo({
  160. url: '/pages/order_tabs/orderTabs'
  161. })
  162. },
  163. refund() {
  164. wx.showToast({
  165. title: '客官!请在APP中完成退款申请',
  166. icon: 'none',
  167. duration: 2000
  168. })
  169. }
  170. })