person.js 4.7 KB

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