You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
312 lines
8.4 KiB
312 lines
8.4 KiB
<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" :menusList = 'menusList' :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.showToast({ |
|
// title:'这里是show' |
|
// }) |
|
//console.log('这里是indexonshow') |
|
uni.setStorageSync('orderType',null) |
|
// uni.preloadPage({url: "/pages/station-info/scan-camera/scan-camera"}); |
|
const token = uni.getStorageSync('Authorization') |
|
const openid = uni.getStorageSync('device') |
|
// //console.log('++++++++++++') |
|
// //console.log(token) |
|
// //console.log(openid) |
|
// //console.log('++++++++++++') |
|
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() { |
|
// uni.showToast({ |
|
// title:'这里是onLoad' |
|
// }) |
|
// uni.navigateTo({ |
|
// url:'/pages/stationDetail/ZYSite' |
|
// }) |
|
let _that =this |
|
const Menus = uni.getStorageSync('userMenu') |
|
//console.log('这里是接收menus处',Menus) |
|
let menusList = [] |
|
Menus.forEach((item,index,Menus)=>{ |
|
if(item.roleName != 'ROOT' ){ |
|
// this.Splicing(item) |
|
menusList.push(this.Splicing(item)) |
|
} |
|
}) |
|
//console.log('这里是menusLisPush',menusList) |
|
// uni.setStorageSync('menusLists',menusList) |
|
let check = uni.getStorageSync('checkFirst') |
|
//console.log(check) |
|
if(check){ |
|
_that.checkUser = true |
|
} |
|
uni.setStorageSync('menusChangeList',menusList) |
|
this.menusList = menusList |
|
//console.log('这里是menusfor循环完成处',this.menusList) |
|
// this.getUserInfo() |
|
this.longiCheck() |
|
// //console.log('++++++++') |
|
//console.log('这里是传值处menus',this.menusList) |
|
this.getPosition() |
|
}, |
|
methods: { |
|
getPosition(){ |
|
let that = this |
|
uni.getLocation({ |
|
type: 'gcj02', |
|
success: function(res) { |
|
uni.setStorage({ |
|
key:'location', |
|
data:res |
|
}) |
|
} |
|
}); |
|
}, |
|
changMenus(data){ |
|
//console.log('这里是获取子级数据的地方+++++',data) |
|
this.menusList =data |
|
}, |
|
longiCheck(){ |
|
let userInfo = uni.getStorageSync('loginUser'), |
|
_that =this |
|
//console.log(userInfo) |
|
oliUserApi.getByPhone(userInfo.userPhone).then((res)=>{ |
|
//console.log('调用') |
|
if(res.code == 20000){ |
|
_that.checkList = 'show' |
|
_that.oliList = res.data |
|
_that.changeChannel.username = _that.loginUser.userPhone |
|
_that.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).then(res => { |
|
// //console.log('油站基本资料', res) |
|
// uni.stopPullDownRefresh(); |
|
// if (res.code === 20000) { |
|
// // this.userAccount = res.data.oil |
|
// this.site = res.data.site |
|
// } |
|
// }) |
|
// }, |
|
// getUserInfo() { |
|
// // 获取云站当前登录用户的基础资料 |
|
// oliSiteApi.getSiteBasicData(this.channelId).then(res => { |
|
// //console.log('用户资料', res) |
|
// uni.stopPullDownRefresh(); |
|
// if (res.code === 20000) { |
|
// uni.setStorageSync('ueserList',res.data) |
|
// this.userAccount = res.data |
|
// } |
|
// }) |
|
|
|
// }, |
|
NavChange: function(e) { |
|
this.PageCur = e.currentTarget.dataset.cur |
|
if (this.PageCur == "scan") { |
|
this.scanQr() |
|
} |
|
}, |
|
|
|
scanQr() { |
|
var scanUrl |
|
let _that = this |
|
this.menusList.forEach((item, index) => { |
|
//console.log('1') |
|
//console.log(index) |
|
//console.log(_that.userMenu) |
|
//console.log(item.name) |
|
//console.log('2') |
|
if (item.name === '扫码加油') { |
|
// scanUrl = item.path |
|
scanUrl = '/pages/station-info/scan-camera/scan-camera' |
|
uni.navigateTo({ |
|
url: scanUrl, |
|
fail: (err) => { |
|
// //console.log(err) |
|
}, |
|
success: (res) => { |
|
// //console.log('chengg', res) |
|
} |
|
}) |
|
} |
|
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>
|
|
|