Blame view

components/TabBar/TabBar.vue 2.13 KB
290144e9   易尊强   第一次
1
2
  <template>
  	<view class="page-total-content">
e6b161ae   易尊强   2/23
3
4
5
6
7
8
9
10
11
12
  		<view>
  			<image src="../../static/bottom.png" style="width: 100%; height: 264rpx;"></image>
  		</view>
  		<view class="page-total">
  			<view class="tab-list">
  				<view class="list" v-for="(item,index) in TabBarList" @click="onTabBar(item,index)" :key="index">
  					<image :src="item.acImg" mode="widthFix" v-show="tabBarShow === index"></image>
  					<image :src="item.img" mode="widthFix" v-show="tabBarShow != index"></image>
  					<text :class="{'action':tabBarShow===index}">{{item.name}}</text>
  				</view>
290144e9   易尊强   第一次
13
14
15
  			</view>
  		</view>
  	</view>
290144e9   易尊强   第一次
16
17
18
19
20
21
  </template>
  
  <script>
  	export default {
  		data() {
  			return {
e6b161ae   易尊强   2/23
22
  				TabBarList: [{
290144e9   易尊强   第一次
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  						index: 0,
  						name: '首页',
  						img: '/static/tabBar/tab_01.png',
  						acImg: '/static/tabBar/tab_02.png'
  					},
  					{
  						index: 1,
  						name: '我的',
  						img: '/static/tabBar/tab_11.png',
  						acImg: '/static/tabBar/tab_12.png'
  					},
  				],
  				codeheight: 0,
  				isOverall: 0,
  				phoneModel: '',
  			};
  		},
e6b161ae   易尊强   2/23
40
  		props: {
290144e9   易尊强   第一次
41
42
43
44
45
46
47
  			tabBarShow: {
  				type: Number,
  				default: 0,
  			}
  		},
  		mounted() {
  			try {
e6b161ae   易尊强   2/23
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  				const res = uni.getSystemInfoSync();
  				let that = this;
  				// 获取系统信息
  				uni.getSystemInfo({
  					success(res) {
  						console.log(res.brand) //手机牌子
  						console.log(res.model) //手机型号
  						console.log(res.screenWidth) //屏幕宽度
  						console.log(res.screenHeight) //屏幕高度
  						that.codeheight = Math.round(res.screenHeight);
  						that.phoneModel = res.model
  						if (res.model.search('iPhone')) {
  							that.isOverall = 0;
  						} else if (Math.round(res.screenHeight) > 740) {
  							that.isOverall = 1;
  						}
  						console.log(that.isOverall);
  					}
  				});
290144e9   易尊强   第一次
67
  			} catch (e) {
e6b161ae   易尊强   2/23
68
  				// error
290144e9   易尊强   第一次
69
70
  			}
  		},
e6b161ae   易尊强   2/23
71
  		methods: {
290144e9   易尊强   第一次
72
73
74
75
  			/**
  			 * @param {Object} item
  			 * @param {Number} index
  			 */
e6b161ae   易尊强   2/23
76
  			onTabBar(item, index) {
290144e9   易尊强   第一次
77
  				// this.tabBarShow = index;
e6b161ae   易尊强   2/23
78
  				switch (index) {
290144e9   易尊强   第一次
79
80
  					case 0:
  						wx.switchTab({
e6b161ae   易尊强   2/23
81
  							url: '/pages/home/home'
290144e9   易尊强   第一次
82
83
84
85
  						})
  						break;
  					case 1:
  						wx.switchTab({
e6b161ae   易尊强   2/23
86
  							url: '/pages/my/my'
290144e9   易尊强   第一次
87
  						})
e6b161ae   易尊强   2/23
88
  						break;
290144e9   易尊强   第一次
89
90
91
92
93
94
95
96
  				}
  			}
  		}
  	}
  </script>
  
  <style scoped lang="scss">
  	@import 'TabBar.scss';
e6b161ae   易尊强   2/23
97
  </style>