第一次提交
This commit is contained in:
0
pages/index/index.js
Normal file
0
pages/index/index.js
Normal file
13
pages/index/index.scss
Normal file
13
pages/index/index.scss
Normal file
@@ -0,0 +1,13 @@
|
||||
.page_body{
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
|
||||
// background: linear-gradient(133deg, rgba(219,235,250,0.9) 2%, rgba(241,248,253,0.9) 100%);
|
||||
.page_container{
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
140
pages/index/index.vue
Normal file
140
pages/index/index.vue
Normal file
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<view :style="{paddingTop:`${setingMenuData.top}px`}" class="page_body">
|
||||
<view class="page_container">
|
||||
<home ref="home" v-show="tabBarIndex==0"></home>
|
||||
<charging-station ref='ChargingStation' v-show="tabBarIndex==1"></charging-station>
|
||||
<order ref="order" v-if="tabBarIndex==3"></order>
|
||||
<personal @switchTabBar='switchTabBar' v-if="tabBarIndex==4"></personal>
|
||||
</view>
|
||||
<tab-bar v-model="tabBarIndex"></tab-bar>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tool from '../../utils/tool.js'
|
||||
import tabBar from "@/components/tabBar/tabBar.vue"
|
||||
import home from "../home/index.vue"
|
||||
import ChargingStation from "../ChargingStation/index.vue"
|
||||
import order from "../order/index.vue"
|
||||
import personal from "../personal/index.vue"
|
||||
import x from "./index.js"
|
||||
export default {
|
||||
components: {
|
||||
tabBar,
|
||||
home,
|
||||
ChargingStation,
|
||||
order,
|
||||
personal
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
user: uni.getStorageSync('user'),
|
||||
location: null,
|
||||
setingMenuData: null,
|
||||
tabBarIndex: 0,
|
||||
Anticorrosive: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
tabBarIndex(n,o) {
|
||||
let that = this
|
||||
if(n==1){
|
||||
this.$refs.ChargingStation.onshow()
|
||||
}else if(n==2){
|
||||
this.readyScanCode({
|
||||
success(){
|
||||
that.scanCode();
|
||||
},
|
||||
fail(){
|
||||
if(n!==o) that.tabBarIndex = o;
|
||||
if(n==o) that.tabBarIndex=0;
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.init()
|
||||
},
|
||||
onLoad() {
|
||||
this.onOrderUpdate();
|
||||
},
|
||||
onShow() {
|
||||
this.showInit()
|
||||
},
|
||||
methods: {
|
||||
readyScanCode({success,fail}){
|
||||
if(!this.user){
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '登录后才可扫码下单哦',
|
||||
confirmText:'去登陆',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/index'
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
fail()
|
||||
}
|
||||
}
|
||||
});
|
||||
return
|
||||
}
|
||||
try{
|
||||
success()
|
||||
}catch(e){
|
||||
fail()
|
||||
}
|
||||
},
|
||||
async scanCode() {
|
||||
|
||||
let res = await this.tool.scanCode().catch(err=>{
|
||||
console.log('取消');
|
||||
this.tabBarIndex = 0
|
||||
});
|
||||
if (res?.result) {
|
||||
let routingParameter = this.tool.routingParameterGeneration({
|
||||
type:'qrCode',
|
||||
qrCode:encodeURIComponent(res.result),
|
||||
pointTo:'activeScanCode'
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: `/ChargingStation/pages/placeOrder/index${routingParameter}`
|
||||
})
|
||||
}
|
||||
},
|
||||
switchTabBar(e) {
|
||||
this.tabBarIndex = e
|
||||
},
|
||||
onOrderUpdate() {
|
||||
uni.$on('orderUpdate', () => {
|
||||
this.$refs.order.seach()
|
||||
})
|
||||
},
|
||||
showInit() {
|
||||
this.tool.getCards();
|
||||
if(this.tabBarIndex==2){
|
||||
this.tabBarIndex = 0
|
||||
}
|
||||
},
|
||||
async getPosition(callback) {
|
||||
await this.tool.getLocation().then(res => {
|
||||
this.location = uni.getStorageSync('location')
|
||||
}).catch(err => {});
|
||||
},
|
||||
async init() {
|
||||
this.Anticorrosive = this.tool.Anticorrosive;
|
||||
this.getSetingMenu(); //获取胶囊数据
|
||||
},
|
||||
getSetingMenu() {
|
||||
this.setingMenuData = wx.getMenuButtonBoundingClientRect();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import 'index.scss';
|
||||
</style>
|
||||
Reference in New Issue
Block a user