// pages/person/person.js const app = getApp(); 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 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { const count = this.data.login_count; if (!app.globalData.userInfo && count <= 2) { this.setData({ login_count: this.data.login_count + 1 }) wx.navigateTo({ url: '/pages/login/login' }); return; } if (!app.globalData.userInfo && count > 2) { this.setData({ login_count: 1 }) wx.switchTab({ url: '/pages/index/index' }); return; } const userInfo = app.globalData.userInfo || null; const nickName = userInfo.nickName || ''; const avatarUrl = userInfo.avatarUrl || ''; 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 }) } }) getReq({ act: 'member_info', op: 'get' }, function (res) { if (res.code == 200) { self.setData({ addr_num: res.datas.sub_titles.addr_num }) } }) getReq({ act: 'member_order', op: 'orderCountState' }, 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 }) 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 }) } }) }, shareBonus() { // let url = encodeURIComponent('https://passport.lrlz.com/mobile/index.php?act=bonusex&op=open&client_type=wap&type_sn=36061535965140897218') // wx.navigateTo({ // url: `/pages/shareBonus/shareBonus?url=${url}` // }) wx.navigateTo({ url: `/pages/pandaBonus/pandaBonus` }) }, shareWebview() { let url = encodeURIComponent('https://passport.lrlz.com/hfive/test_mini_share/index.html') wx.navigateTo({ url: `/pages/webView/webView?url=${url}` }) }, payIndex() { wx.reLaunch({ url: "/pages/index/index" }) }, /** * 生命周期函数--监听页面隐藏 */ 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 }) } })