index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // pages/user/info/info.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. userInfo: wx.getStorageSync('userInfo') || {},
  9. company: wx.getStorageSync('company') || {},
  10. logout: wx.getStorageSync('logout') || app.globalData.logout || false,
  11. showChangeCompanyName: wx.getStorageSync('showChangeCompanyName'),
  12. menuList: [{
  13. name: "已发货",
  14. value: 3,
  15. icon: "icon-yifahuo2"
  16. },
  17. {
  18. name: "已签收",
  19. value: 4,
  20. icon: "icon-yiqianshou"
  21. },
  22. {
  23. name: "已取消",
  24. value: 5,
  25. icon: "icon-yiquxiao2"
  26. },
  27. {
  28. name: "全部订单",
  29. value: '',
  30. icon: "icon-quanbudingdan"
  31. },
  32. ]
  33. },
  34. /**
  35. * 生命周期函数--监听页面加载
  36. */
  37. onLoad(options) {
  38. },
  39. /**
  40. * 生命周期函数--监听页面初次渲染完成
  41. */
  42. onReady() {
  43. // if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  44. // let userInfo = wx.getStorageSync('userInfo');
  45. // if (userInfo && userInfo.userId) {
  46. // app.globalData.tabbar.list[0].show = false;
  47. // } else {
  48. // app.globalData.tabbar.list[0].show = true;
  49. // }
  50. // this.getTabBar().setData({
  51. // selectIndex: 4,
  52. // tabbar: app.globalData.tabbar
  53. // })
  54. // }
  55. },
  56. autoLogin1() {
  57. // app.globalData.changeCompanyName = true;
  58. app.globalData.innerShow = true;
  59. return;
  60. },
  61. async ok() {
  62. try {
  63. await app.autoLogin();
  64. await this.onShow();
  65. } catch (e) {
  66. console.error(e);
  67. wx.navigateTo({
  68. url: '/pages/login/login',
  69. })
  70. } finally {
  71. app.globalData.innerShow = false;
  72. }
  73. },
  74. async ok1() {
  75. try {
  76. await app.autoLogin();
  77. await this.onShow();
  78. } catch (e) {
  79. console.error(e);
  80. wx.navigateTo({
  81. url: '/pages/login/login',
  82. })
  83. } finally {
  84. app.globalData.innerShow = false;
  85. }
  86. },
  87. /**
  88. * 生命周期函数--监听页面显示
  89. */
  90. async onShow() {
  91. setTimeout(() => {
  92. wx.setNavigationBarTitle({
  93. title: app.globalData.tabbar.list[3].text,
  94. });
  95. }, 500);
  96. if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  97. // let userInfo = wx.getStorageSync('userInfo');
  98. // if (userInfo && userInfo.userId) {
  99. // app.globalData.tabbar.list[0].show = false;
  100. // } else {
  101. // app.globalData.tabbar.list[0].show = true;
  102. // }
  103. setTimeout(() => {
  104. this.getTabBar().setData({
  105. selectIndex: 3,
  106. tabbar: app.globalData.tabbar
  107. })
  108. }, 500);
  109. }
  110. // await app.autoLogin();
  111. // this.setData({
  112. // userInfo: wx.getStorageSync('userInfo'),
  113. // company: wx.getStorageSync('company'),
  114. // })
  115. let logout = wx.getStorageSync('logout') || app.globalData.logout || false;
  116. this.setData({
  117. userInfo: wx.getStorageSync('userInfo'),
  118. company: wx.getStorageSync('company'),
  119. companyName: wx.getStorageSync('companyName'),
  120. virtualInventoryName: wx.getStorageSync('virtualInventoryName'),
  121. showChangeCompanyName: wx.getStorageSync('showChangeCompanyName'),
  122. logout
  123. });
  124. if (logout) {
  125. return;
  126. }
  127. if (!wx.getStorageSync('userInfo')) {
  128. return;
  129. }
  130. await app.getUserInfo(this);
  131. this.setData({
  132. userInfo: wx.getStorageSync('userInfo'),
  133. company: wx.getStorageSync('company'),
  134. })
  135. },
  136. changeCompanyName() {
  137. app.globalData.changeCompanyName = true;
  138. },
  139. /**
  140. * 生命周期函数--监听页面隐藏
  141. */
  142. onHide() {
  143. },
  144. /**
  145. * 生命周期函数--监听页面卸载
  146. */
  147. onUnload() {
  148. },
  149. /**
  150. * 页面相关事件处理函数--监听用户下拉动作
  151. */
  152. onPullDownRefresh() {
  153. },
  154. /**
  155. * 页面上拉触底事件的处理函数
  156. */
  157. onReachBottom() {
  158. },
  159. /**
  160. * 用户点击右上角分享
  161. */
  162. onShareAppMessage() {
  163. }
  164. })