person.js 4.9 KB

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