|
|
|
<template>
|
|
|
|
<view class="page-content " :class="(PageCur=='home'||PageCur=='scan')?'my-bg':''">
|
|
|
|
|
|
|
|
<home v-if="PageCur=='home'||PageCur=='scan'" :user-account="userAccount" :site="site"></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'
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
PageCur: 'home',
|
|
|
|
userAccount: {
|
|
|
|
totalCount: 0,
|
|
|
|
totalMoney: 0.00
|
|
|
|
},
|
|
|
|
site: {},
|
|
|
|
userMenu: uni.getStorageSync('userMenu')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onPullDownRefresh() {
|
|
|
|
this.getUserInfo()
|
|
|
|
},
|
|
|
|
onShow() {
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
getSiteInfo() {
|
|
|
|
cloudSiteApi.getSiteDetail().then(res => {
|
|
|
|
if (res.code === 20000) {
|
|
|
|
this.site = res.data.site
|
|
|
|
this.oilList = res.data.oil
|
|
|
|
uni.setStorage({
|
|
|
|
key: 'oilSite',
|
|
|
|
data: res.data.site
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getUserInfo() {
|
|
|
|
cloudSiteApi.getSiteBasicData().then(res => {
|
|
|
|
console.log('用户资料', res)
|
|
|
|
uni.stopPullDownRefresh();
|
|
|
|
if (res.code === 20000) {
|
|
|
|
this.userAccount = res.data
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
NavChange: function(e) {
|
|
|
|
this.PageCur = e.currentTarget.dataset.cur
|
|
|
|
if (this.PageCur == "scan") {
|
|
|
|
this.scanQr()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
scanQr() {
|
|
|
|
var scanUrl
|
|
|
|
this.userMenu.forEach((item, index) => {
|
|
|
|
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>
|