-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.we
99 lines (95 loc) · 3.6 KB
/
index.we
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
<div>
<wxc-tabbar class="tabbar" tab-items={{tabItems}}></wxc-tabbar>
</div>
</template>
<style>
</style>
<script>
require('weex-components');
module.exports = {
data: {
dir: 'examples',
tabItems: [
{
index: 0,
title: "频道",
titleColor: 0x0,
icon: "",
image: "http://gtms01.alicdn.com/tps/i1/TB1qw.hMpXXXXagXXXX9t7RGVXX-46-46.png",
selectedImage: "http://gtms04.alicdn.com/tps/i4/TB16jjPMpXXXXazXVXX9t7RGVXX-46-46.png",
src: "Baji/modules/channels.js",
visibility: "hidden"
},
{
index: 1,
title: "正在直播",
titleColor: 0x0,
icon: "",
image: "http://gtms03.alicdn.com/tps/i3/TB1LEn9MpXXXXaUXpXX9t7RGVXX-46-46.png",
selectedImage: "http://gtms02.alicdn.com/tps/i2/TB1qysbMpXXXXcnXXXX9t7RGVXX-46-46.png",
src: "Baji/modules/channel-list.js",
visibility: "visible"
},
{
index: 2,
title: "登录",
titleColor: 0x0,
icon: "",
image: "http://gtms01.alicdn.com/tps/i1/TB1B0v5MpXXXXcvXpXX9t7RGVXX-46-46.png",
selectedImage: "http://gtms04.alicdn.com/tps/i4/TB1NxY5MpXXXXcrXpXX9t7RGVXX-46-46.png",
src: "Baji/modules/login.js",
visibility: "hidden"
}
]
},
ready: function() {
// var params = {
// 'animated': 'false',
// 'url': this.baseURL + 'Baji/modules/launch.js'
// };
// var navigator = require('@weex-module/navigator');
// navigator.push(params, function(e) {
// //callback
// });
},
created: function () {
var bundleUrl = this.$getConfig().bundleUrl;
var nativeBase;
var isAndroidAssets = bundleUrl.indexOf('file://assets/') >= 0;
var isiOSAssets = bundleUrl.indexOf('file:///') >= 0 && bundleUrl.indexOf('WeexDemo.app') > 0;
if (isAndroidAssets) {
nativeBase = 'file://assets/';
} else if (isiOSAssets) {
nativeBase = bundleUrl.substring(0, bundleUrl.lastIndexOf('/') + 1);
} else {
var host = 'localhost:12580';
var matches = /\/\/([^\/]+?)\//.exec(this.$getConfig().bundleUrl);
if (matches && matches.length >= 2) {
host = matches[1];
}
nativeBase = 'http://' + host + '/' + this.dir + '/build/';
}
var h5Base = './' + this.dir + '/build/';
// in Native
var base = nativeBase;
if (typeof window === 'object') {
// in Browser or WebView
this.baseURL = base = h5Base;
}
for (var i = 0; i < this.tabItems.length; i++) {
var tabItem = this.tabItems[i];
tabItem.src = base + tabItem.src;
}
},
methods: {
ready: function (e) {
var vm = this;
vm.$on('tabBar.onClick', function (e) {
var detail = e.detail;
nativeLog('tabBar.onClick ' + detail.index);
});
},
}
}
</script>