index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/point"
  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. },
  48. onPullDownRefresh:function(){
  49. this.getuser();
  50. },
  51. onShow:function(){
  52. this.getuser();
  53. },
  54. getuser(){
  55. var that=this;
  56. app.api.useApi(app.globalData.baseAppUrl + "api/admin/UserInfo", {
  57. appid: wx.getAccountInfoSync().miniProgram.appId
  58. }, "get").then(function (res) {
  59. console.log(res);
  60. if (res.code != 200) {
  61. wx.showLoading({
  62. title: '请重新登录',
  63. })
  64. setTimeout(function () {
  65. wx.hideLoading();
  66. wx.removeStorageSync('token')
  67. wx.reLaunch({
  68. url: '/pages/login/login',
  69. })
  70. }, 1000);
  71. } else {
  72. wx.hideLoading();
  73. that.setData({
  74. userinfo:res.message.data
  75. })
  76. }
  77. }).catch(function (err) {
  78. console.log(222);
  79. })
  80. },
  81. toUrl(e){
  82. let {url} = e.currentTarget.dataset
  83. wx.navigateTo({
  84. url,
  85. })
  86. },
  87. loginOut(){
  88. app.api.useApi(app.globalData.baseAppUrl + "api/admin/logout", {
  89. appid: wx.getAppBaseInfo().host.appId
  90. }, "post").then(function (res) {
  91. wx.showLoading({
  92. title: '退出中',
  93. })
  94. console.log(res);
  95. if (res.code != 200) {
  96. wx.showLoading({
  97. title: '失败请重试',
  98. })
  99. setTimeout(function () {
  100. wx.hideLoading();
  101. }, 1000);
  102. } else {
  103. wx.hideLoading();
  104. wx.removeStorageSync('token')
  105. wx.reLaunch({
  106. url: '/pages/login/login',
  107. })
  108. }
  109. }).catch(function (err) {
  110. console.log(222);
  111. })
  112. }
  113. })