ソースを参照

【修改底部导航和退出登录】

master
GL 4年前
コミット
7939f2d7d5
4個のファイルの変更78行の追加34行の削除
  1. +36
    -32
      src/App.vue
  2. +31
    -0
      src/stores/index.js
  3. +1
    -1
      src/views/home/index.vue
  4. +10
    -1
      src/views/person/index.vue

+ 36
- 32
src/App.vue ファイルの表示

@@ -15,37 +15,39 @@
</template>

<script>
import {mapState,mapMutations} from 'vuex'

export default {
name: 'App',
data() {
return {
footBarList: [
{
iconY: require('./assets/images/home-y.png'),
iconN: require('./assets/images/home-n.png'),
checked: true,
title: '首页',
path: 'home',
},
/* {
iconY: require('./assets/images/bill1.png'),
iconN: require('./assets/images/bill.png'),
checked: false,
title: '账单',
path: 'vueView',
}, */
{
iconY: require('./assets/images/user-y.png'),
iconN: require('./assets/images/user-n.png'),
checked: false,
title: '我的',
path: 'person',
},
]
// footBarList: [
// {
// iconY: require('./assets/images/home-y.png'),
// iconN: require('./assets/images/home-n.png'),
// checked: true,
// title: '首页',
// path: 'home',
// },
// /* {
// iconY: require('./assets/images/bill1.png'),
// iconN: require('./assets/images/bill.png'),
// checked: false,
// title: '账单',
// path: 'vueView',
// }, */
// {
// iconY: require('./assets/images/user-y.png'),
// iconN: require('./assets/images/user-n.png'),
// checked: false,
// title: '我的',
// path: 'person',
// },
// ]
};
},
computed: {
...mapState(['footBarList']),
// 动态设置过渡样式
direction: function() {
const currentPath = this.$route.path;
@@ -72,17 +74,19 @@ export default {
}
},
created() {
let index = sessionStorage.getItem('navIndex') != 'undefined' ? sessionStorage.getItem('navIndex') : 0
this.selRouter(index)
// let index = sessionStorage.getItem('navIndex') != 'undefined' ? sessionStorage.getItem('navIndex') : 0
this.selRouter(0)
console.log(this.selRouter,this.footBarList,"??|");
},
methods: {
selRouter(index) {
sessionStorage.setItem('navIndex',index)
this.footBarList.map(item => {
item.checked = false;
})
this.footBarList[index].checked = true;
},
...mapMutations(['selRouter']),
// selRouter(index) {
// sessionStorage.setItem('navIndex',index)
// this.footBarList.map(item => {
// item.checked = false;
// })
// this.footBarList[index].checked = true;
// },


}


+ 31
- 0
src/stores/index.js ファイルの表示

@@ -14,9 +14,40 @@ export default new Vuex.Store({
token: '461675506000465920',
merchant_id:'',
merchant_id_scan:'',
footBarList: [//底部导航
{
iconY: require('@/assets/images/home-y.png'),
iconN: require('@/assets/images/home-n.png'),
checked: true,
title: '首页',
path: 'home',
},
/* {
iconY: require('./assets/images/bill1.png'),
iconN: require('./assets/images/bill.png'),
checked: false,
title: '账单',
path: 'vueView',
}, */
{
iconY: require('@/assets/images/user-y.png'),
iconN: require('@/assets/images/user-n.png'),
checked: false,
title: '我的',
path: 'person',
},
],

},
mutations: {
selRouter(state,index) {
sessionStorage.setItem('navIndex',index)
state.footBarList.map(item => {
item.checked = false;
})
state.footBarList[index].checked = true;
},

setToken (state, token) {
state.token = token
},


+ 1
- 1
src/views/home/index.vue ファイルの表示

@@ -69,7 +69,7 @@ import { Toast } from "vant";
import {formatDate} from '@/filters'
// 组件
export default {
name: 'page-index',
// name: 'page-index',
components: {

},


+ 10
- 1
src/views/person/index.vue ファイルの表示

@@ -45,13 +45,14 @@
</div>

<button class="logout-btn">退出登录</button>
<button class="logout-btn" @click="eliminate">退出登录</button>

</div>
</template>

<script type="text/babel">
// 组件
import {mapMutations} from 'vuex'
export default {
name: 'page-index',
components: {
@@ -77,6 +78,7 @@ export default {

},
methods: {
...mapMutations(['selRouter']),
goToPage(index) {
this.$router.push({
path: this.routerUrl[index-1],
@@ -86,6 +88,13 @@ export default {
})
console.log(index)
},
//回到首页清除路由记录
eliminate(){
this.selRouter(0)
this.$router.replace({
path:'/'
})
},
/**
* 检查用户是否有权限修改收款账户
*/


読み込み中…
キャンセル
保存