person.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. self.setData({
  66. userInfo: { nickName, avatarUrl },
  67. bonus_rate: res.datas.bonus_rate
  68. })
  69. }
  70. })
  71. getReq({
  72. act: 'member_info',
  73. op: 'get'
  74. }, function (res) {
  75. if (res.code == 200) {
  76. self.setData({
  77. addr_num: res.datas.sub_titles.addr_num
  78. })
  79. }
  80. })
  81. getReq({
  82. act: 'member_order',
  83. op: 'orderCountState'
  84. }, function (res) {
  85. if (res.code == 200) {
  86. self.setData({
  87. pre_pay_count: 0, // 待付款 10
  88. pre_send_count: 0, // 待发货 20
  89. pre_receive_count: 0, // 待收货 30
  90. evaluate_count: 0
  91. })
  92. let { order_count } = res.datas
  93. if(order_count.length) {
  94. let length = order_count.length
  95. for(let i = 0; i < length; i++) {
  96. let state_name = ''
  97. if(order_count[i]['order_state'] == 10) {
  98. state_name = 'pre_pay_count'
  99. }
  100. if(order_count[i]['order_state'] == 20) {
  101. state_name = 'pre_send_count'
  102. }
  103. if(order_count[i]['order_state'] == 30) {
  104. state_name = 'pre_receive_count'
  105. }
  106. if(order_count[i]['order_state'] == 40) {
  107. state_name = 'evaluate_count'
  108. }
  109. if(state_name) {
  110. self.setData({
  111. [state_name]: order_count[i]['count']
  112. })
  113. }
  114. }
  115. }
  116. }
  117. })
  118. getReq({
  119. act: 'member_bonus',
  120. op: 'predepositex'
  121. }, function (res) {
  122. if (res.code == 200) {
  123. let { bonus_total } = res.datas
  124. self.setData({
  125. bonus_total
  126. })
  127. }
  128. })
  129. },
  130. shareBonus() {
  131. wx.navigateTo({
  132. url: `/pages/shareBonus/shareBonus?type_sn=16711536579728954218`
  133. // url: `/pages/shareBonus/shareBonus?type_sn=21991536583136231606`
  134. })
  135. },
  136. /**
  137. * 生命周期函数--监听页面隐藏
  138. */
  139. onHide: function () {
  140. },
  141. /**
  142. * 生命周期函数--监听页面卸载
  143. */
  144. onUnload: function () {
  145. },
  146. /**
  147. * 页面相关事件处理函数--监听用户下拉动作
  148. */
  149. onPullDownRefresh: function () {
  150. },
  151. /**
  152. * 页面上拉触底事件的处理函数
  153. */
  154. onReachBottom: function () {
  155. },
  156. bonus_list() {
  157. this.setData({
  158. bonus_list_show: !this.data.bonus_list_show
  159. })
  160. },
  161. skip_help() {
  162. wx.navigateTo({
  163. url: '/pages/webView/webView?url=https://passport.lrlz.com/hfive/feed_back/question_answer.html'
  164. })
  165. },
  166. skip_bonus_rule() {
  167. wx.navigateTo({
  168. url: '/pages/webView/webView?url=https://passport.lrlz.com/hfive/panda_bonus_rule/index.html'
  169. })
  170. },
  171. skip_all_order() {
  172. wx.navigateTo({
  173. url: '/pages/order_tabs/orderTabs'
  174. })
  175. },
  176. refund() {
  177. wx.showToast({
  178. title: '客官!请在APP中完成退款申请',
  179. icon: 'none',
  180. duration: 2000
  181. })
  182. }
  183. })