index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="warp">
  3. <uni-grid class="grid" :column="3" :show-border="false" :square="false" @change="change">
  4. <uni-grid-item v-for="(item, index) in list" :index="index" :key="index">
  5. <view class="grid-item-box" @click="itemClick(item.url)">
  6. <image class="image" :src="item.src" mode="aspectFill" />
  7. <text class="text">{{ item.text }}</text>
  8. </view>
  9. </uni-grid-item>
  10. </uni-grid>
  11. </view>
  12. </template>
  13. <script setup lang="ts">
  14. import { ref } from 'vue';
  15. import { onShow } from '@dcloudio/uni-app';
  16. const token = ref(null);
  17. const user = ref(null);
  18. const list = ref([
  19. // {
  20. // url: '/pages/scan/index',
  21. // src: '/static/scan_fill.png',
  22. // text: '扫描入库'
  23. // },
  24. {
  25. url: '/pages/instock/index',
  26. src: '/static/weigh_fill.png',
  27. text: '称重'
  28. },
  29. {
  30. url: '/pages/warehouseScan/index',
  31. src: '/static/houscan.png',
  32. text: '仓库扫描'
  33. },
  34. {
  35. url: '/pages/scanLotno/index',
  36. src: '/static/link.png',
  37. text: '托盘/批次'
  38. },
  39. {
  40. url:'/pages/waybillDeliveryOrder/index',
  41. src: '/static/dispatch.png',
  42. text: '派送单'
  43. }
  44. ]);
  45. onShow(() => {
  46. token.value = uni.getStorageSync('token');
  47. user.value = uni.getStorageSync('user');
  48. console.log('show---', { token: token.value, user: user.value });
  49. });
  50. const itemClick = (url) => {
  51. console.log(url);
  52. if (token.value) {
  53. uni.navigateTo({
  54. url
  55. });
  56. } else {
  57. uni.navigateTo({
  58. url: '/pages/login/index'
  59. });
  60. }
  61. };
  62. const change = () => {};
  63. const logout = () => {
  64. uni.removeStorageSync('token');
  65. uni.removeStorageSync('user');
  66. token.value = uni.getStorageSync('token');
  67. user.value = uni.getStorageSync('user');
  68. };
  69. </script>
  70. <style lang="scss">
  71. .image {
  72. width: 36px;
  73. height: 36px;
  74. }
  75. .text {
  76. font-size: 14px;
  77. margin-top: 10px;
  78. }
  79. .grid {
  80. margin-top: 20px;
  81. }
  82. .grid-item-box {
  83. flex: 1;
  84. // position: relative;
  85. /* #ifndef APP-NVUE */
  86. display: flex;
  87. /* #endif */
  88. flex-direction: column;
  89. align-items: center;
  90. justify-content: center;
  91. padding: 15px 0;
  92. }
  93. .grid-dot {
  94. position: absolute;
  95. top: 5px;
  96. right: 15px;
  97. }
  98. </style>