person.js 5.2 KB

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