// pages/person/person.js const app = getApp(); import recordSource from '../../utils/recordSource' const getReq = require('./../../config.js').getReq; Page({ /** * 页面的初始数据 */ data: { userInfo: { nickName: '', avatarUrl: '' }, bonus_rate: [], bonus_list_show: false, login_count: 1, addr_num: '', pre_pay_count: 0, // 待付款 10 pre_send_count: 0, // 待发货 20 pre_receive_count: 0, // 待收货 30 evaluate_count: 0, // 已收货 40 bonus_total: 0, fromSource: '', firstLoad: true, userInfo: app.globalData.userInfo }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ getAuth(e) { let { userInfo } = e.detail if (userInfo) { this.setData({ userInfo }) wx.reLaunch({ url: '/pages/index/index' }); } }, onShow: function () { if(!app.globalData.userInfo) { return; } let fromSource = this.data.fromSource if(this.data.firstLoad) { fromSource = recordSource(app, `act=member_order&op=orderCountState&client_type=mini`) this.setData({ fromSource: app.globalData.fromSource }) } else { app.setFromSource(this.data.fromSource) } const userInfo = app.globalData.userInfo || null; const nickName = userInfo.nickName || ''; const avatarUrl = userInfo.avatarUrl || '../../image/mine_logo_icon.png'; let self = this getReq({ act: 'cart', op: 'rate_money' }, function (res) { if (res.code == 200) { self.setData({ userInfo: { nickName, avatarUrl }, bonus_rate: res.datas.bonus_rate, firstLoad: false }) } }) getReq({ act: 'member_info', op: 'get' }, function (res) { if (res.code == 200) { self.setData({ addr_num: res.datas.sub_titles.addr_num, firstLoad: false }) } }) getReq({ act: 'member_order', op: 'orderCountState', from: fromSource }, function (res) { if (res.code == 200) { self.setData({ pre_pay_count: 0, // 待付款 10 pre_send_count: 0, // 待发货 20 pre_receive_count: 0, // 待收货 30 evaluate_count: 0, firstLoad: false }) let { order_count } = res.datas if(order_count.length) { let length = order_count.length for(let i = 0; i < length; i++) { let state_name = '' if(order_count[i]['order_state'] == 10) { state_name = 'pre_pay_count' } if(order_count[i]['order_state'] == 20) { state_name = 'pre_send_count' } if(order_count[i]['order_state'] == 30) { state_name = 'pre_receive_count' } if(order_count[i]['order_state'] == 40) { state_name = 'evaluate_count' } if(state_name) { self.setData({ [state_name]: order_count[i]['count'] }) } } } } }) getReq({ act: 'member_bonus', op: 'predepositex' }, function (res) { if (res.code == 200) { let { bonus_total } = res.datas self.setData({ bonus_total, firstLoad: false }) } }) }, shareBonus() { wx.navigateTo({ url: `/pages/shareBonus/shareBonus?type_sn=58841537878020836581` }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, bonus_list() { this.setData({ bonus_list_show: !this.data.bonus_list_show }) }, skip_help() { wx.navigateTo({ url: '/pages/webView/webView?url=https://passport.lrlz.com/hfive/feed_back/question_answer.html' }) }, skip_bonus_rule() { wx.navigateTo({ url: '/pages/webView/webView?url=https://passport.lrlz.com/hfive/panda_bonus_rule/index.html' }) }, skip_all_order() { wx.navigateTo({ url: '/pages/order_tabs/orderTabs' }) }, refund() { wx.showToast({ title: '客官!请在APP中完成退款申请', icon: 'none', duration: 2000 }) } })