index.js 3.1 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/icon_ruchangqianshou.png',
  12. tit:'入厂签收',
  13. url:"/pages/signIn/siginIn"
  14. },
  15. {
  16. icon:'/image/home/icon_fenjianluru.png',
  17. tit:'分拣录入',
  18. url:"/pages/sorting/choice/choice"
  19. },
  20. {
  21. icon:'/image/home/icon_zhijian.png',
  22. tit:'质检上挂',
  23. url:"/pages/control/choice/choice"
  24. },
  25. // {
  26. // icon:'/image/home//icon_yichang.png',
  27. // url:"/pages/error/yichang/index",
  28. // tit:'异常单'
  29. // },
  30. {
  31. icon:'/image/home/icon_yiwupandian.png',
  32. tit:'衣物盘点',
  33. url:'/pages/record/record'
  34. },
  35. ]
  36. },
  37. onPullDownRefresh:function(){
  38. this.index()
  39. },
  40. /**
  41. * 生命周期函数--监听页面加载
  42. */
  43. onLoad: function (options) {
  44. this.index()
  45. },
  46. index(){
  47. var that=this;
  48. api.useApi(app.globalData.baseAppUrl + "api/admin/sorting", {
  49. }, "get").then(function (res) {
  50. console.log(res);
  51. if (res.code != 200) {
  52. wx.showLoading({
  53. title: res.message.msg,
  54. })
  55. setTimeout(function () {
  56. wx.hideLoading();
  57. wx.removeStorageSync('token')
  58. wx.reLaunch({
  59. url: '/pages/login/login',
  60. })
  61. }, 2000);
  62. } else {
  63. wx.hideLoading();
  64. var data=res.message.data
  65. wx.setStorageSync('title', data.user.adminable.title)
  66. that.setData({
  67. userinfo:data
  68. })
  69. }
  70. }).catch(function (err) {
  71. console.log(222);
  72. })
  73. },
  74. toUrl(e){
  75. let {url} = e.currentTarget.dataset
  76. wx.navigateTo({
  77. url,
  78. })
  79. },
  80. loginOut(){
  81. app.api.useApi(app.globalData.baseAppUrl + "api/admin/logout", {
  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. })