<template> <view class="page-content " :class="(PageCur=='home'||PageCur=='scan')?'my-bg':''"> <!-- <uni-nav-bar left-icon="back" left-text="返回" right-text="菜单" title="导航栏组件"></uni-nav-bar> --> <home ref='homecheck' v-if="PageCur=='home'||PageCur=='scan'" :user-account="userAccount" @changMenus='changMenus' :site="userAccount" :checkUser='checkUser'></home> <setup v-if="PageCur=='setup'"></setup> <view class="bottom-view"> <view class="padding-top radius shadow bottom-bar-fixed"> <view class="cu-bar tabbar bg-white"> <view class="action text-gray" @tap="NavChange" data-cur="home"> <view class="cuIcon-homefill sl" :class="PageCur=='home'?'text-red':'text-gray'"></view> <text :class="PageCur=='home'?'text-red':'text-gray'"> 加油站 </text> </view> <view class="action text-gray add-action" @tap="NavChange" data-cur="scan"> <button class="cu-btn cuIcon-scan sl shadow" :class="PageCur=='scan'?'bg-main-oil':'bg-gradual-orange'"></button> <text :class="PageCur=='scan'?'text-red':'text-gray'"> 一键扫码 </text> </view> <view class="action text-gray" @tap="NavChange" data-cur="setup"> <view class="cuIcon-peoplefill sl" :class="PageCur=='setup'?'text-red':'text-gray'"></view> <text :class="PageCur=='setup'?'text-red':'text-gray'"> 我的 </text> </view> </view> </view> </view> </view> </template> <script> import cloudSiteApi from '@/api/cloud-site.js' import oliSiteApi from '@/api/oli-site.js' import oliUserApi from '@/api/oli-user.js' export default { data() { return { checkUser: false, changeChannel: { username: '', channelId: '', unionId: '' }, PageCur: 'home', userAccount: { totalCount: 0, totalMoney: 0.00 }, loginUser: uni.getStorageSync('loginUser'), channelId: uni.getStorageSync('channelId'), menusList: [], site: {}, userMenu: uni.getStorageSync('userMenu') } }, onPullDownRefresh() { // this.getUserInfo() this.$refs.homecheck.checkInfo() uni.redirectTo({ url: '../../packageOrders/pages/printTicket/printTicket' }) }, onShow() { uni.setStorageSync('orderType', null) // uni.preloadPage({url: "/pages/station-info/scan-camera/scan-camera"}); const token = uni.getStorageSync('Authorization') const openid = uni.getStorageSync('device') if (token && openid) { // this.getUserInfo() // this.getSiteInfo() } else { // uni.showToast({ // title: '您还没有登录哦', // icon: "none" // }) // setTimeout(function() { // uni.reLaunch({ // url: '/pages/login/boforeLogin/boforeLogin', // success: () => { // //console.log('跳转成功') // }, // fail: (err) => { // //console.log(err) // } // }) // }, 1500); } }, onLoad() { const token = uni.getStorageSync('Authorization') if (!token) return let check = uni.getStorageSync('checkFirst') if (check) { this.checkUser = true } this.menusList = uni.getStorageSync('menusChangeList') || [] // const Menus = uni.getStorageSync('userMenu') // let menusList = [] // Menus.forEach((item, index, Menus) => { // if (item.roleName != 'ROOT') { // menusList.push(this.Splicing(item)) // } // }) // let check = uni.getStorageSync('checkFirst') // if (check) { // _that.checkUser = true // } // uni.setStorageSync('menusChangeList', menusList) // this.menusList = menusList this.longiCheck() this.getPosition() }, methods: { checkLogin() { const token = uni.getStorageSync('Authorization') if (!token) { uni.showModal({ content: '您还没有登录哦', confirmText: '前往登录', success: res => { if (res.confirm) { uni.reLaunch({ url: '/pages/login/boforeLogin/boforeLogin' }) } } }) return false } return true }, getPosition() { // console.log('getPositiongetPositiongetPositiongetPosition') let that = this uni.getLocation({ type: 'gcj02', success: function(res) { uni.setStorage({ key: 'location', data: res }) } }); }, changMenus(data) { this.menusList = data }, longiCheck() { let userInfo = uni.getStorageSync('loginUser') oliUserApi.getByPhone(userInfo.userPhone).then((res) => { if (res.code == 20000) { this.checkList = 'show' this.oliList = res.data this.changeChannel.username = this.loginUser.userPhone this.changeChannel.unionId = uni.getStorageSync('unionId') } else { uni.showToast({ title: '请求失败,请稍后再试', icon: 'none' }) } }) }, // Splicing(list) { // let obj = { // cuIcon: '', // path: '', // color: '', // badge: 0, // name: '' // } // if (list.roleName == '扫码加油') { // obj.cuIcon = 'scan', // obj.path = '/pages/station-info/scan-camera/scan-camera', // obj.color = 'olive', // obj.badge = 0, // obj.name = list.roleName // } else if (list.roleName == '经营分析') { // obj.cuIcon = 'new', // obj.path = '', // obj.color = 'orange', // obj.badge = 0, // obj.name = list.roleName // } else if (list.roleName == '加油订单') { // obj.cuIcon = 'form', // obj.path = '/packageOrders/pages/orderList/orderList', // obj.color = 'yellow', // obj.badge = 0, // obj.name = list.roleName // } else if (list.roleName == '油站二维码') { // obj.cuIcon = 'qr_code', // obj.path = '/packageQr/pages/qrsite/QrCode_xy', // obj.color = 'cyan', // obj.badge = 0, // obj.name = list.roleName // } else if (list.roleName == '员工管理') { // obj.cuIcon = 'expressman', // obj.path = '/packageStaff/pages/staff/List/List', // obj.color = 'mauve', // obj.badge = 0, // obj.name = list.roleName // } else if (list.roleName == '油站信息') { // obj.cuIcon = 'punch', // obj.path = '/packageQr/pages/partnership/partnership', // obj.color = 'blue', // obj.badge = 0, // obj.name = list.roleName // } else if (list.roleName == '交易统计') { // obj.cuIcon = 'punch', // obj.path = '/pages/TransactionStatistics/TransactionStatistics', // obj.color = 'blue', // obj.badge = 0, // obj.name = list.roleName // } else if (list.roleName == '星油云站超级管理员') { // obj.cuIcon = 'punch', // obj.path = ' ', // obj.color = 'blue', // obj.badge = 0, // obj.name = list.roleName // } // return obj // }, // getSiteInfo() { // //获取油站基本资料 // oliSiteApi.getSiteDetail(this.channelId) // }, // getUserInfo() { // // 获取云站当前登录用户的基础资料 // oliSiteApi.getSiteBasicData(this.channelId) // }, NavChange: function(e) { if (!this.checkLogin()) return this.PageCur = e.currentTarget.dataset.cur if (this.PageCur == "scan") { this.scanQr() } }, scanQr() { let scanUrl = "" this.menusList.forEach((item, index) => { if (item.name === '扫码加油') { scanUrl = '/pages/station-info/scan-camera/scan-camera' uni.navigateTo({ url: scanUrl }) } if ((index == this.userMenu.length - 1) && !scanUrl) { uni.showToast({ title: '抱歉,您没有扫码权限', icon: 'none' }) } }) }, } } </script> <style scoped> .bottom-bar { position: relative; padding-top: 50px; margin-bottom: 0; margin-top: 0; } .bottom-bar-fixed { position: fixed; bottom: 0; padding-top: 70rpx; width: 100%; } .bottom-view { max-height: 200rpx; } </style>