var util = require('../../../utils/util.js'); var api = require('../../../config/api.js'); var user = require('../../../services/user.js'); var app = getApp(); Page({ data: { unPayNum:0, unTakeNum:0, unEvalNum:0, userInfo: {}, curUser:{}, }, onLoad: function (options) { // 页面初始化 options为页面跳转所带来的参数 let that = this; }, onReady: function () { }, onShow: function () { let that = this; let userInfo = wx.getStorageSync('userInfo'); let token = wx.getStorageSync('token'); // 页面显示 if (userInfo && token) { app.globalData.userInfo = userInfo; app.globalData.token = token; this.setData({ userInfo: app.globalData.userInfo, }); util.request(api.getCurUser, { userInfo: app.globalData.userInfo }, 'POST').then(function (res) { if (res.errno === 0) { that.setData({ curUser: res.data }); } }); // 查询骑手信息 util.request(api.UcenterIndex, {}).then(function (res) { if (res.errno === 0) { if (res.data.countMap.orders > 0) { that.setData({ unPayNum: res.data.countMap.unPayNum, unPaymentNum: res.data.countMap.unPaymentNum, unTakeNum: res.data.countMap.unTakeNum, unEvalNum: res.data.countMap.unEvalNum }); } } }); } else { wx.navigateTo({ url: '/pages/auth/btnAuth/btnAuth', }) } }, onHide: function () { // 页面隐藏 }, onUnload: function () { // 页面关闭 }, bindMobile:function(){ wx.navigateTo({ url: '../../auth/newuser/newuser' }) }, // goLogin(){ // user.loginByWeixin().then(res => { // this.setData({ // userInfo: res.data.data.userInfo // }); // app.globalData.userInfo = res.data.data.userInfo; // app.globalData.token = res.data.token; // }).catch((err) => { // console.log(err) // }); // }, allOrder() { wx.navigateTo({ url: '/pages/ucenter/order/order' }) }, exitLogin: function () { wx.showModal({ title: '', confirmColor: '#b4282d', content: '退出登录?', success: function (res) { if (res.confirm) { wx.removeStorageSync('token'); wx.removeStorageSync('userInfo'); app.globalData.userInfo = { nickName: '点击头像登录', avatarUrl: 'http://120.76.26.84:80/group1/M00/00/02/rBJEdVvr3_eAJe0WAAAB_us54MA728.png' }; wx.switchTab({ url: '/pages/index/index' }); } } }) } })