123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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,
- });
- if (wx.getStorageSync('storeId')) {
- util.request(api.ChooseStoreId, {
- storeId: wx.getStorageSync('storeId'),
- merchSn: wx.getStorageSync('merchSn')
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
- wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
- that.reLoad();
- }
- });
- }
- 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 () {
- // 页面关闭
- },
- reLoad: function () {
- let that = this;
- if (wx.getStorageSync('storeId')) {
- if (wx.getStorageSync('userId')) {
- wx.request({
- url: api.updateLoginUser,
- data: {
- userId: wx.getStorageSync('userId'), storeId: wx.getStorageSync('storeId'), merchSn: wx.getStorageSync('merchSn')
- },
- method: 'POST',
- header: {
- 'Content-Type': 'application/json'
- },
- success: function (wxRes) {
- if (wxRes.data.errno === 0) {
- // console.log("用户信息更新成功");
- }
- },
- fail: function (err) {
- console.log("failed");
- }
- });
- }
- }
- },
- 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'
- });
- }
- }
- })
- }
- })
|