初始化(包含登录模块)
This commit is contained in:
105
pages/API/navigator/navigator.vue
Normal file
105
pages/API/navigator/navigator.vue
Normal file
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<view>
|
||||
<page-head :title="title"></page-head>
|
||||
<view class="uni-padding-wrap uni-common-mt">
|
||||
<view class="uni-btn-v">
|
||||
<button @tap="navigateTo">跳转新页面,并传递数据</button>
|
||||
<button @tap="navigateBack">返回上一页</button>
|
||||
<button @tap="redirectTo">在当前页面打开</button>
|
||||
<button @tap="switchTab">切换到模板选项卡</button>
|
||||
<button v-if="!hasLeftWin" @tap="reLaunch">关闭所有页面,打开首页</button>
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<button @tap="customAnimation">使用自定义动画打开页面</button>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef APP-PLUS || H5 -->
|
||||
<button @tap="preloadPage">预载复杂页面</button>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<button @tap="unPreloadPage">取消页面预载</button>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef APP-PLUS || H5 -->
|
||||
<button @tap="navigateToPreloadPage">打开复杂页面</button>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
const preloadPageUrl = '/pages/extUI/calendar/calendar'
|
||||
import { mapState } from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: 'navigate'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
hasLeftWin: state => !state.noMatchLeftWindow
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
navigateTo() {
|
||||
uni.navigateTo({
|
||||
url: 'new-page/new-vue-page-1?data=Hello'
|
||||
})
|
||||
},
|
||||
navigateBack() {
|
||||
uni.navigateBack();
|
||||
},
|
||||
redirectTo() {
|
||||
uni.redirectTo({
|
||||
url: 'new-page/new-vue-page-1'
|
||||
});
|
||||
},
|
||||
switchTab() {
|
||||
uni.switchTab({
|
||||
url: '/pages/tabBar/template/template'
|
||||
});
|
||||
},
|
||||
reLaunch() {
|
||||
if (this.hasLeftWin) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/component/view/view'
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.reLaunch({
|
||||
url: '/pages/tabBar/component/component'
|
||||
});
|
||||
},
|
||||
customAnimation(){
|
||||
uni.navigateTo({
|
||||
url: 'new-page/new-vue-page-1?data=使用自定义动画打开页面',
|
||||
animationType: 'slide-in-bottom',
|
||||
animationDuration: 200
|
||||
})
|
||||
},
|
||||
preloadPage(){
|
||||
uni.preloadPage({
|
||||
url: preloadPageUrl,
|
||||
success(){
|
||||
uni.showToast({
|
||||
title:'页面预载成功'
|
||||
})
|
||||
},
|
||||
fail(){
|
||||
uni.showToast({
|
||||
title:'页面预载失败'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
unPreloadPage(){
|
||||
uni.unPreloadPage({
|
||||
url: preloadPageUrl
|
||||
})
|
||||
},
|
||||
navigateToPreloadPage(){
|
||||
uni.navigateTo({
|
||||
url: preloadPageUrl
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
83
pages/API/navigator/new-page/new-nvue-page-1.nvue
Normal file
83
pages/API/navigator/new-page/new-nvue-page-1.nvue
Normal file
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<view class="root">
|
||||
<view class="page-body">
|
||||
<view class="new-page__color" @click="setColorIndex(colorIndex>1?0:colorIndex+1)" :style="{backgroundColor:currentColor}">
|
||||
<text class="new-page__color-text">点击改变颜色</text>
|
||||
</view>
|
||||
<view class="new-page__text-box">
|
||||
<text class="new-page__text">点击上方色块使用vuex在页面之间进行通讯</text>
|
||||
</view>
|
||||
<view class="new-page__button">
|
||||
<button class="new-page__button-item" @click="navToNvue">跳转NVUE页面</button>
|
||||
<button class="new-page__button-item" @click="navToVue">跳转VUE页面</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import {mapState,mapGetters,mapMutations} from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
...mapState(['colorIndex','colorList']),
|
||||
...mapGetters(['currentColor'])
|
||||
},
|
||||
methods:{
|
||||
...mapMutations(['setColorIndex']),
|
||||
navToNvue(){
|
||||
uni.navigateTo({
|
||||
url:'new-nvue-page-2'
|
||||
})
|
||||
},
|
||||
navToVue(){
|
||||
uni.navigateTo({
|
||||
url:'new-vue-page-2'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.new-page__text {
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.root{
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.page-body{
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.new-page__text-box{
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.new-page__color{
|
||||
width: 200px;
|
||||
height: 100px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.new-page__color-text{
|
||||
font-size: 14px;
|
||||
color: #FFFFFF;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.new-page__button-item{
|
||||
margin-top: 15px;
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
69
pages/API/navigator/new-page/new-nvue-page-2.nvue
Normal file
69
pages/API/navigator/new-page/new-nvue-page-2.nvue
Normal file
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<view class="root">
|
||||
<view class="page-body">
|
||||
<view class="new-page__color" @click="setColorIndex(colorIndex>1?0:colorIndex+1)" :style="{backgroundColor:currentColor}">
|
||||
<text class="new-page__color-text">点击改变颜色</text>
|
||||
</view>
|
||||
<view class="new-page__text-box">
|
||||
<text class="new-page__text">点击上方色块使用vuex在页面之间进行通讯</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import {mapState,mapGetters,mapMutations} from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
...mapState(['colorIndex','colorList']),
|
||||
...mapGetters(['currentColor'])
|
||||
},
|
||||
methods:{
|
||||
...mapMutations(['setColorIndex'])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.new-page__text {
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.root{
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.page-body{
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.new-page__text-box{
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.new-page__color{
|
||||
width: 200px;
|
||||
height: 100px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.new-page__color-text{
|
||||
font-size: 14px;
|
||||
color: #FFFFFF;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.new-page__button-item{
|
||||
margin-top: 15px;
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
108
pages/API/navigator/new-page/new-vue-page-1.vue
Normal file
108
pages/API/navigator/new-page/new-vue-page-1.vue
Normal file
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<view class="root">
|
||||
<page-head :title="title"></page-head>
|
||||
<view class="page-body">
|
||||
<view class="new-page__text-box">
|
||||
<text class="new-page__text">从上个页面接收到参数:{{data}}</text>
|
||||
</view>
|
||||
<view class="new-page__color" @click="setColorIndex(colorIndex>1?0:colorIndex+1)" :style="{backgroundColor:currentColor}">
|
||||
<text class="new-page__color-text">点击改变颜色</text>
|
||||
</view>
|
||||
<view class="new-page__text-box">
|
||||
<text class="new-page__text">点击上方色块使用vuex在页面之间进行通讯</text>
|
||||
</view>
|
||||
<view class="new-page__button">
|
||||
<!-- #ifndef VUE3-->
|
||||
<button class="new-page__button-item" @click="navToNvue">跳转NVUE页面</button>
|
||||
<!-- #endif -->
|
||||
<button class="new-page__button-item" @click="navToVue">跳转VUE页面</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import {mapState,mapGetters,mapMutations} from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: '新页面',
|
||||
data:""
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
...mapState(['colorIndex','colorList']),
|
||||
...mapGetters(['currentColor'])
|
||||
},
|
||||
onLoad(e){
|
||||
if(e.data){
|
||||
this.data = e.data;
|
||||
}
|
||||
uni.$on('postMsg',(res)=>{
|
||||
uni.showModal({
|
||||
content: `收到uni.$emit消息:${res.msg}`,
|
||||
showCancel: false
|
||||
})
|
||||
})
|
||||
},
|
||||
onUnload() {
|
||||
uni.$off('postMsg')
|
||||
},
|
||||
methods:{
|
||||
...mapMutations(['setColorIndex']),
|
||||
navToNvue(){
|
||||
uni.navigateTo({
|
||||
url:'new-nvue-page-1'
|
||||
})
|
||||
},
|
||||
navToVue(){
|
||||
uni.navigateTo({
|
||||
url:'new-vue-page-2'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.new-page__text {
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.root{
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.page-body{
|
||||
/* flex: 1; */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.new-page__text-box{
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.new-page__color{
|
||||
display: flex;
|
||||
width: 200px;
|
||||
height: 100px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.new-page__color-text{
|
||||
font-size: 14px;
|
||||
color: #FFFFFF;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.new-page__button-item{
|
||||
margin-top: 15px;
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
84
pages/API/navigator/new-page/new-vue-page-2.vue
Normal file
84
pages/API/navigator/new-page/new-vue-page-2.vue
Normal file
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<view class="root">
|
||||
<view class="page-body">
|
||||
<view class="new-page__color" @click="setColorIndex(colorIndex>1?0:colorIndex+1)" :style="{backgroundColor:currentColor}">
|
||||
<text class="new-page__color-text">点击改变颜色</text>
|
||||
</view>
|
||||
<view class="new-page__text-box">
|
||||
<text class="new-page__text">点击上方色块使用vuex在页面之间进行通讯</text>
|
||||
</view>
|
||||
<view class="new-page__button">
|
||||
<button class="new-page__button-item" @click="emitMsg">向上一页面传递数据</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import {
|
||||
mapState,
|
||||
mapGetters,
|
||||
mapMutations
|
||||
} from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['colorIndex', 'colorList']),
|
||||
...mapGetters(['currentColor'])
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['setColorIndex']),
|
||||
emitMsg() {
|
||||
uni.$emit('postMsg', {
|
||||
msg: 'From: Vue Page'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.new-page__text {
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.root {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.page-body {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.new-page__text-box {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.new-page__color {
|
||||
display: flex;
|
||||
width: 200px;
|
||||
height: 100px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.new-page__color-text {
|
||||
font-size: 14px;
|
||||
color: #FFFFFF;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.new-page__button-item {
|
||||
margin-top: 15px;
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user