|
@@ -0,0 +1,78 @@
|
|
1
|
+import Taro, { Component } from '@tarojs/taro'
|
|
2
|
+import { connect } from '@tarojs/redux'
|
|
3
|
+import * as actions from '@actions/user'
|
|
4
|
+import './index.scss'
|
|
5
|
+
|
|
6
|
+@connect(state => state.user, { ...actions })
|
|
7
|
+export default class Index extends Component {
|
|
8
|
+ config = {
|
|
9
|
+ navigationBarTitleText: '登录'
|
|
10
|
+ }
|
|
11
|
+ state = {}
|
|
12
|
+
|
|
13
|
+ getUserInfo() {
|
|
14
|
+ const { dispatchUpdateUserInfo } = this.props
|
|
15
|
+ const sessionKey = Taro.getStorageSync('sessionKey')
|
|
16
|
+ // 获取用户信息
|
|
17
|
+ Taro.getUserInfo({
|
|
18
|
+ success: res => {
|
|
19
|
+ const payload = Object.assign(res, { sessionKey })
|
|
20
|
+ // const { userInfo: { nickName, gender, country, city, province } } = payload
|
|
21
|
+ // App.zhuge.identify(nickName, {
|
|
22
|
+ // '昵称': nickName,
|
|
23
|
+ // '性别': gender == 1 ? '男' : '女',
|
|
24
|
+ // '国家': country,
|
|
25
|
+ // '省份': province,
|
|
26
|
+ // '城市': city
|
|
27
|
+ // })
|
|
28
|
+
|
|
29
|
+ // 用户信息保存至服务器
|
|
30
|
+ dispatchUpdateUserInfo(payload).then(res => {
|
|
31
|
+ this.toPage(true)
|
|
32
|
+ })
|
|
33
|
+ },
|
|
34
|
+ fail: () => {
|
|
35
|
+ this.toPage(false)
|
|
36
|
+ }
|
|
37
|
+ })
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ toPage(succed) {
|
|
41
|
+ const router = Taro.getStorageSync('router')
|
|
42
|
+ const { query, path } = router
|
|
43
|
+
|
|
44
|
+ if (!succed && path === 'pages/signin/index') {
|
|
45
|
+ return
|
|
46
|
+ }
|
|
47
|
+ if (path === 'pages/project/index' || path === 'pages/shop/index' || path === 'pages/person/index') {
|
|
48
|
+ Taro.switchTab({
|
|
49
|
+ url: '/' + path
|
|
50
|
+ })
|
|
51
|
+ return
|
|
52
|
+ }
|
|
53
|
+ Taro.reLaunch({
|
|
54
|
+ url: `/${path}?${query.params}`
|
|
55
|
+ })
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ render() {
|
|
59
|
+ return (
|
|
60
|
+ <View>
|
|
61
|
+ <View className="userinfo">
|
|
62
|
+ <View className="userinfo-avatar">
|
|
63
|
+ <open-data type="userAvatarUrl"></open-data>
|
|
64
|
+ </View>
|
|
65
|
+ <View className="userinfo-name">
|
|
66
|
+ <open-data type="userNickName"></open-data>
|
|
67
|
+ </View>
|
|
68
|
+ </View>
|
|
69
|
+ <View className='line'></View>
|
|
70
|
+ <View className='content'>
|
|
71
|
+ <View>申请获取以下权限</View>
|
|
72
|
+ <Text>获得你的公开信息(昵称,头像等)</Text>
|
|
73
|
+ </View>
|
|
74
|
+ <Button className='bottom' open-type="getUserInfo" lang="zh_CN" onGetUserInfo={this.getUserInfo}>授权登录</Button>
|
|
75
|
+ </View>
|
|
76
|
+ )
|
|
77
|
+ }
|
|
78
|
+}
|