index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // pages/tabber/home/index.js
  2. const api = require('../../utils/api');
  3. const app=getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. menuList:[
  10. {
  11. icon:'/image/home/wuliugailan@3x.png',
  12. tit:'物流概览',
  13. url:"/pages/logistics/index"
  14. },
  15. {
  16. icon:'/image/home/icon_qujianxiangqing@3x.png',
  17. tit:'柜前取送',
  18. url:"/pages/take/index"
  19. },
  20. {
  21. icon:'/image/home/icon_qianshou@3x.png',
  22. tit:'物流签收',
  23. url:"/pages/signFor/index"
  24. },
  25. {
  26. icon:'/image/home/icon_daishoudian@3x.png',
  27. tit:'代收点',
  28. url:"/pages/servicePoint/index"
  29. },
  30. {
  31. icon:'/image/home/icon_guiziguanli@3x.png',
  32. url:"/pages/cabinet/index",
  33. tit:'柜子管理'
  34. },
  35. {
  36. icon:'/image/home/icon_sousuoyundan@3x.png',
  37. url:"/pages/serah/index",
  38. tit:'搜索运单'
  39. },
  40. ],
  41. userinfo:"",
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. var that=this;
  48. app.api.useApi(app.globalData.baseAppUrl + "api/admin/UserInfo", {
  49. appid: wx.getAppBaseInfo().host.appId
  50. }, "post").then(function (res) {
  51. console.log(res);
  52. if (res.code == 200) {
  53. wx.showLoading({
  54. title: '请重新登录',
  55. })
  56. setTimeout(function () {
  57. wx.hideLoading();
  58. wx.reLaunch({
  59. url: '/pages/login/login',
  60. })
  61. }, 1000);
  62. } else {
  63. wx.hideLoading();
  64. wx.removeStorageSync('token')
  65. that.setdata({
  66. userinfo:res.message.data
  67. })
  68. }
  69. }).catch(function (err) {
  70. console.log(222);
  71. })
  72. },
  73. toUrl(e){
  74. let {url} = e.currentTarget.dataset
  75. wx.navigateTo({
  76. url,
  77. })
  78. },
  79. loginOut(){
  80. app.api.useApi(app.globalData.baseAppUrl + "api/admin/logout", {
  81. appid: wx.getAppBaseInfo().host.appId
  82. }, "post").then(function (res) {
  83. wx.showLoading({
  84. title: '退出中',
  85. })
  86. console.log(res);
  87. if (res.code != 200) {
  88. wx.showLoading({
  89. title: '失败请重试',
  90. })
  91. setTimeout(function () {
  92. wx.hideLoading();
  93. }, 1000);
  94. } else {
  95. wx.hideLoading();
  96. wx.removeStorageSync('token')
  97. wx.reLaunch({
  98. url: '/pages/login/login',
  99. })
  100. }
  101. }).catch(function (err) {
  102. console.log(222);
  103. })
  104. }
  105. })