app.js
4.43 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import Taro, { Component } from '@tarojs/taro'
import '@tarojs/async-await'
import { Provider, connect } from '@tarojs/redux'
import { bindActionCreators } from 'redux';
import Index from './pages/index'
import createStore from './store'
import * as globalData from './actions/globalData';
import udid from './utils/udid';
import './app.scss'
import event from './utils/event';
import { loginAction } from './libs/login/login.js'
import getPrivateKey from './libs/request/getPrivateKey.js'
const store = createStore();
@connect(({ globalData, user }) => ({
globalData
}), (dispatch) => {
return bindActionCreators({
...globalData
}, dispatch)
})
class App extends Component {
config = {
pages: [
'pages/index/index',
'pages/search/index',
'pages/searchList/index',
'pages/filter/index',
'pages/productDetail/index',
'pages/sell/index',
'pages/classify/index',
'pages/message/message/message',
'pages/message/messageDetail/messageDetail',
'pages/userCenter/index',
'pages/login/index',
'pages/orderList/index',
'pages/nativeTest/nativeTest',
'pages/userCenter/collection/collection',
'pages/userCenter/addressManager/addressManager',
'pages/userCenter/addressManager/addressEditer/addressEditer',
'pages/userCenter/addressManager/addressEditer/addressPicker',
'pages/order/orderConfirm/orderConfirm',
'pages/order/orderSuccess/orderSuccess',
'pages/order/orderProtocol/orderProtocol',
'pages/nativeLogin/nativeLogin',
'pages/myassets/index',
'pages/orderDetail/index',
'pages/orderList/orderlistcell',
'pages/orderDetail/logistics/logistics',
],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
// navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black'
},
tabBar: {
color: '#bbb',
selectedColor: '#08304B',
backgroundColor: '#fff',
borderStyle: '#eee',
list: [{
pagePath: 'pages/index/index',
text: '首页',
iconPath: './static/images/tab-icon-01.png',
selectedIconPath: './static/images/tab-icon-01-focus.png'
},{
pagePath: 'pages/classify/index',
text: '分类',
iconPath: './static/images/tab-icon-02.png',
selectedIconPath: './static/images/tab-icon-02-focus.png'
}, {
pagePath: 'pages/message/message/message',
text: '消息',
iconPath: './static/images/tab-icon-03.png',
selectedIconPath: './static/images/tab-icon-03-focus.png'
}, {
pagePath: 'pages/userCenter/index',
text: '我的',
iconPath: './static/images/tab-icon-04.png',
selectedIconPath: './static/images/tab-icon-04-focus.png'
}]
}
};
componentWillMount () {
let {setSystemInfo, wechatLogin, setSessionkey} = this.props;
// 获取系统信息
let systemInfo = Taro.getSystemInfoSync();
systemInfo.screenHeight = !systemInfo.screenHeight ? systemInfo.windowHeight : systemInfo.screenHeight;
systemInfo.screenWidth = !systemInfo.screenWidth ? systemInfo.windowWidth : systemInfo.screenWidth;
setSystemInfo(systemInfo);
this.props.setUdid(udid.get());
setSessionkey();
Taro.checkSession({
success: () =>{
//登录态未过期
console.log('登录态未过期');
this.props.setWxThirdSession();
this.props.setUserInfo();
this.props.setWxUnionId();
// this.props.getUnionTypeWithUid(this.props.globalData.userInfo.uid); // 有赚
},
fail: () => {
console.log('登录已经过期')
//登录态过期
Taro.setStorage({key: 'WXThird_session', data: ''});
Taro.setStorage({key: 'userInfo', data: ''});
Taro.setStorage({key: 'unionID', data: ''});
Taro.setStorage({key: 'user_union_type', data: ''});
Taro.setStorage({key: 'session_key', data: ''});
}
}).catch(error => {
console.log(error);
});
event.on('user-is-login', (loginedCallBack, loginSuccess) => {
let userInfo = Taro.getStorageSync('userInfo');
if (userInfo && userInfo.uid && userInfo.session_key) {
if (loginedCallBack) {
loginedCallBack();
}
} else {
event.on('my-user-login-success', () => {
event.off('my-user-login-success');
if (loginSuccess) {
loginSuccess();
}
})
Taro.navigateTo({
url: '/pages/nativeLogin/nativeLogin'
});
}
});
}
componentDidHide () {}
componentCatchError () {}
render () {
return (
<Provider store={store}>
<Index />
</Provider>
)
}
}
Taro.render(<App />, document.getElementById('app'));