123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <template>
- <view class="container">
- <view class="pages">
- <Home ref="homeRef" v-if="current==0" />
- <Equipment ref="equipmentRef" v-if="current==1" />
- <Commodity ref="commodityRef" v-if="current==2" />
- <Account ref="accountRef" v-if="current==3" />
- </view>
- <u-tabbar v-if="menu&&menu.length>0" v-model="current" :list="list" :mid-button="false"></u-tabbar>
- </view>
- </template>
- <script setup>
- import Home from './components/home.vue'
- import Equipment from './components/equipment.vue'
- import Commodity from './components/commodity.vue'
- import Account from './components/account.vue'
- import {
- watch,
- computed,
- onBeforeMount,
- onMounted,
- reactive,
- toRefs,
- ref
- } from "vue";
- import {
- onShow,
- onLoad
- } from '@dcloudio/uni-app'
- import usePermissionStore from '@/stores/permission.js'
- const current = ref(0)
- const client = ref(null)
- const tabName = ref(null)
- const list = ref([{
- iconPath: "home",
- selectedIconPath: "home-fill",
- text: '平台运维',
- },
- {
- iconPath: "photo",
- selectedIconPath: "photo-fill",
- text: '质检出场',
- },
- {
- iconPath: "play-right",
- selectedIconPath: "play-right-fill",
- text: '数据中心',
- },
- {
- iconPath: "account",
- selectedIconPath: "account-fill",
- text: '商户运营',
- },
- ])
- onShow(() => {
- console.log('onShow')
- // 版本自动更新代码
- const updateManager = wx.getUpdateManager()
- updateManager.onUpdateReady(function() {
- wx.showModal({
- title: '更新检测',
- content: '检测到新版本,是否重启小程序?',
- success: function(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
- updateManager.onUpdateFailed(function() {
- // 新的版本下载失败
- wx.showModal({
- title: '已有新版本咯',
- content: '请您删除当前小程序,重新打开呦~',
- showCancel: false
- })
- })
- })
- onLoad((o) => {
- console.log('onLoad', o)
- if (o.tabName) { //公库添加商品到私库完毕,显示商品界面
- tabName.value = o.tabName;
- if (menu.value && menu.value.length > 0) {
- menu.value.forEach((item, index) => {
- if (item.name == o.tabName) {
- tcurrent.value = index
- }
- })
- }
- }
- })
- const menu = computed(() => JSON.parse(usePermissionStore().permissions_menu))
- watch(
- () => menu,
- (menu, prevMenu) => {
- if (menu.length > 0) {
- tabName.value = menu[0].name
- } else {
- tabName.value = null
- }
- }
- )
- function tabChange(e) {
- current.value = e
- }
- function tabClick(e) {
- tabName.value = e.name
- }
- </script>
- <style lang="scss">
- .container {
- .pages {
- height: 100%;
- }
- .u-page__item__slot-icon {
- width: 44rpx;
- height: 44rpx;
- }
- }
- </style>
|