星油云站
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.

159 lines
3.6 KiB

5 years ago
<template>
4 years ago
<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>
5 years ago
</view>
4 years ago
<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>
5 years ago
</view>
4 years ago
<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>
5 years ago
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import cloudSiteApi from '@/api/cloud-site.js'
5 years ago
export default {
data() {
return {
4 years ago
PageCur: 'home',
userAccount: {
totalCount: 0,
totalMoney: 0.00
},
4 years ago
site: {},
userMenu: uni.getStorageSync('userMenu')
}
},
onPullDownRefresh() {
this.getUserInfo()
},
4 years ago
onShow() {
// uni.preloadPage({url: "/pages/station-info/scan-camera/scan-camera"});
4 years ago
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);
5 years ago
}
},
5 years ago
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
}
})
},
4 years ago
NavChange: function(e) {
this.PageCur = e.currentTarget.dataset.cur
if (this.PageCur == "scan") {
this.scanQr()
}
},
scanQr() {
4 years ago
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)
}
5 years ago
})
4 years ago
4 years ago
}
if ((index == this.userMenu.length - 1) && !scanUrl) {
uni.showToast({
title: '抱歉,您没有扫码权限',
icon: 'none'
})
}
5 years ago
})
},
5 years ago
}
4 years ago
}
5 years ago
</script>
<style scoped>
5 years ago
.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%;
}
4 years ago
.bottom-view {
max-height: 200rpx;
5 years ago
}
</style>