1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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) {
- that.setData({
- unPayNum: res.data.countMap.unPayNum,
- unTakeNum: res.data.countMap.unTakeNum,
- unEvalNum: res.data.countMap.unEvalNum
- });
- }
- });
- },
- onHide: function () {
- // 页面隐藏
- },
- onUnload: function () {
- // 页面关闭
- },
- bindMobile:function(){
- wx.navigateTo({
- url: '../../auth/newuser/newuser'
- })
- },
- goLogin(){
- user.loginByWeixin().then(res => {
- this.setData({
- userInfo: res.data.userInfo
- });
- app.globalData.userInfo = res.data.userInfo;
- app.globalData.token = res.data.token;
- }).catch((err) => {
- console.log(err)
- });
- },
- 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: 'https://www.meiping123.com/upload/20171125/1721207662403.png'
- };
- wx.switchTab({
- url: '/pages/index/index'
- });
- }
- }
- })
- }
- })
|