|
@@ -1,8 +1,6 @@
|
1
|
1
|
|
2
|
|
-import { useState, useRef, useEffect } from 'react'
|
|
2
|
+import { useState } from 'react'
|
3
|
3
|
import Taro from '@tarojs/taro'
|
4
|
|
-import withLayout from '@/layouts'
|
5
|
|
-import Popup from '@/components/Popup'
|
6
|
4
|
import AuthPage from '@/components/AuthPage'
|
7
|
5
|
import boy from '@/assets/icons/UserCenter/boy.png'
|
8
|
6
|
import girl from '@/assets/icons/UserCenter/girl.png'
|
|
@@ -14,89 +12,49 @@ import HomeLogo from '@/assets/icons/UserCenter/HomeLogo.png'
|
14
|
12
|
import ContactMe from '@/assets/icons/UserCenter/ContactMe.png'
|
15
|
13
|
import collect from '@/assets/icons/UserCenter/collect.png'
|
16
|
14
|
import Rules from '@/assets/icons/UserCenter/Rules.png'
|
17
|
|
-import UserImages from '@/assets/icons/ProCard/8kb.jpg'
|
|
15
|
+import DefaultImage from '@/assets/icons/UserCenter/DefaultImage.png'
|
18
|
16
|
import cutoverUser from '@/assets/icons/UserCenter/cutoverUser.png'
|
19
|
|
-import touristON from '@/assets/icons/UserCenter/touristON.png'
|
20
|
|
-import touristOFF from '@/assets/icons/UserCenter/touristOFF.png'
|
21
|
|
-import hotelBossON from '@/assets/icons/UserCenter/hotelBossON.png'
|
22
|
|
-import hotelBossOFF from '@/assets/icons/UserCenter/hotelBossOFF.png'
|
23
|
|
-import shopBossON from '@/assets/icons/UserCenter/shopBossON.png'
|
24
|
|
-import shopBossOFF from '@/assets/icons/UserCenter/shopBossOFF.png'
|
|
17
|
+import SwitchSelect from '@/components/SwitchSelect'
|
|
18
|
+import { useModel } from '@/store'
|
25
|
19
|
import './MineCss/style.less'
|
26
|
20
|
|
27
|
21
|
|
28
|
22
|
|
29
|
|
-export default withLayout((props) => {
|
30
|
|
- const { router, person } = props
|
31
|
|
- const [showCutover, setShowCutover] = useState(false)
|
32
|
|
- // const [userState] = useRef({})
|
33
|
|
- const [userLogin, setUserLogin] = useState('NotLogin')
|
34
|
|
-
|
35
|
|
- const [userImage, setUserImage] = useState(UserImages)
|
36
|
|
- const [userName, setUserName] = useState('请点击登陆')
|
37
|
|
- const [userSex, setUserSex] = useState(girl)
|
38
|
|
-
|
39
|
|
-
|
40
|
|
-
|
41
|
|
- // // 我的行程
|
42
|
|
- // const HomeLogo = () => {
|
43
|
|
- // Taro.navigateTo({ url: '/pages/MineUserAll/Rules/index' })
|
44
|
|
- // }
|
45
|
|
-
|
46
|
|
- useEffect(() => {
|
47
|
|
- if (userImage === UserImages) {
|
48
|
|
- Taro.showToast({
|
49
|
|
- title: '未登陆,请先登陆',
|
50
|
|
- icon: 'error',
|
51
|
|
- duration: 2000
|
52
|
|
- })
|
53
|
|
- } else {
|
54
|
|
- setUserLogin('Login')
|
55
|
|
- }
|
56
|
|
- }, [userName, userImage])
|
|
23
|
+export default (props) => {
|
|
24
|
+ const { person } = props
|
57
|
25
|
|
|
26
|
+ const { getAvatar } = useModel('person')
|
|
27
|
+ const [showCutover, setShowCutover] = useState(false)
|
|
28
|
+ const hasAvatar = !!person.avatar
|
|
29
|
+ const hidePhone = person.phone.replace(/^(\d{3})\d{4}(\d+)/, "$1****$2")
|
58
|
30
|
|
59
|
31
|
const ShowMoldeOn = () => {
|
60
|
32
|
setShowCutover(true)
|
61
|
33
|
}
|
62
|
|
- const ok = () => {
|
63
|
|
- setShowCutover(false)
|
64
|
|
- }
|
65
|
|
-
|
66
|
|
-
|
67
|
|
-
|
68
|
34
|
|
69
|
35
|
// 通过getUserProfile获取微信用户信息
|
70
|
36
|
const handleGetUserProfile = () => {
|
71
|
|
- if (userImage === UserImages && userName === '请点击登陆') {
|
72
|
|
- Taro.getUserProfile({
|
73
|
|
- lang: 'zh_CN',
|
74
|
|
- desc: "获取你的昵称、头像、地区及性别",
|
75
|
|
- success: res => {
|
76
|
|
- const avatarUrl = res.userInfo.avatarUrl
|
77
|
|
- const nickName = res.userInfo.nickName
|
78
|
|
- const gender = res.userInfo.gender
|
79
|
|
- setUserImage(avatarUrl)
|
80
|
|
- setUserName(nickName)
|
81
|
|
- if (gender === 0) {
|
82
|
|
-
|
83
|
|
- } else {
|
84
|
|
- setUserSex(boy)
|
85
|
|
-
|
86
|
|
- }
|
87
|
|
- console.log('getUserProfile', res);
|
88
|
|
-
|
89
|
|
- },
|
90
|
|
- fail: () => {
|
91
|
|
- //拒绝授权
|
92
|
|
- console.error("您拒绝了请求");
|
93
|
|
- return;
|
|
37
|
+ if (hasAvatar) return;
|
|
38
|
+
|
|
39
|
+ Taro.getUserProfile({
|
|
40
|
+ lang: 'zh_CN',
|
|
41
|
+ desc: "获取你的昵称、头像、地区及性别",
|
|
42
|
+ success: (res) => {
|
|
43
|
+ console.log("🚀 ~ file: Mine.jsx ~ line 75 ~ handleGetUserProfile ~ res", res)
|
|
44
|
+ const sessionKey = Taro.getStorageSync('sessionKey')
|
|
45
|
+ const data = {
|
|
46
|
+ ...res,
|
|
47
|
+ sessionKey,
|
94
|
48
|
}
|
95
|
|
- })
|
96
|
|
- } else {
|
97
|
|
-
|
98
|
|
- }
|
|
49
|
+ getAvatar(data)
|
99
|
50
|
|
|
51
|
+ },
|
|
52
|
+ fail: () => {
|
|
53
|
+ //拒绝授权
|
|
54
|
+ console.error("您拒绝了请求");
|
|
55
|
+ return;
|
|
56
|
+ }
|
|
57
|
+ })
|
100
|
58
|
|
101
|
59
|
};
|
102
|
60
|
//#region
|
|
@@ -135,102 +93,75 @@ export default withLayout((props) => {
|
135
|
93
|
Taro.navigateTo({ url: '/pages/MineUserAll/Rules/index' })
|
136
|
94
|
}
|
137
|
95
|
|
138
|
|
- const goToHotel = () => {
|
139
|
|
- Taro.redirectTo({ url: '/hotel/pages/landlord/landlord' })
|
140
|
|
- }
|
141
|
|
- const goToShop = () => {
|
142
|
|
- Taro.redirectTo({ url: '/shop/pages/spread/spreadIndex' })
|
143
|
|
- }
|
144
|
96
|
//#endregion
|
145
|
97
|
|
146
|
98
|
return !person.phone ? <AuthPage /> : (
|
147
|
99
|
<scroll-view scroll-y style='height: 77vh;' >
|
148
|
100
|
<view className='User-box'>
|
149
|
101
|
{/* 身份切换 */}
|
150
|
|
- <Popup show={showCutover} maskClosable={false}>
|
151
|
|
- <view className='User-box-sths' >
|
152
|
|
- <view className='User-box-selectUser'>请选择身份:</view>
|
153
|
|
- <view className='User-box-tourist' onClick={ok}>
|
154
|
|
- <image className='Ubs-tourist-image' src={touristON} />
|
155
|
|
- <text className='Ubs-tourist-text'>游客</text>
|
156
|
|
- </view>
|
157
|
|
- <view className='User-box-hotelBoss' onClick={goToHotel}>
|
158
|
|
- <image className='Ubs-hotelBoss-image' src={hotelBossOFF} />
|
159
|
|
- <text className='Ubs-hotelBoss-text'>民宿老板</text>
|
160
|
|
-
|
161
|
|
- </view>
|
162
|
|
- <view className='User-box-shopBoss' onClick={goToShop}>
|
163
|
|
- <image className='Ubs-shopBoss-image' src={shopBossOFF} />
|
164
|
|
- <text className='Ubs-shopBoss-text'>店铺老板</text>
|
165
|
|
- </view>
|
166
|
|
- </view>
|
167
|
|
- </Popup>
|
|
102
|
+ <SwitchSelect show={showCutover} maskClosable />
|
168
|
103
|
<view className='User-info'>
|
169
|
104
|
<view className='User-photos-box'>
|
170
|
|
- <image src={userImage} className='User-photos' />
|
|
105
|
+ <image src={person.avatar || { DefaultImage }} className='User-photos' />
|
171
|
106
|
</view>
|
172
|
107
|
<view className='User-info-all'>
|
173
|
|
- <view onClick={() => handleGetUserProfile()} className='User-name'>{userName}</view>
|
174
|
|
- <view className='User-phone'>136****9434</view>
|
175
|
|
- <image className='User-sex' src={userSex} />
|
|
108
|
+ <view onClick={handleGetUserProfile} className='User-name'>{hasAvatar ? person.nickName : '点击授权头像'}</view>
|
|
109
|
+ <view className='User-phone'>{hidePhone}</view>
|
|
110
|
+ <image className='User-sex' src={person.sex === 1 ? boy : girl} />
|
176
|
111
|
</view>
|
177
|
112
|
{/* 切换身份 */}
|
178
|
113
|
<view onClick={ShowMoldeOn} className='User-info-cutover'>
|
179
|
114
|
<image className='User-info-cutover-image' src={cutoverUser} />
|
180
|
115
|
</view>
|
181
|
116
|
</view>
|
182
|
|
- {
|
183
|
|
- userLogin === 'Login' &&
|
184
|
|
- <view>
|
185
|
|
- <view className='buy-list-box'>
|
186
|
|
- <view className='buy-list-Paybox' onClick={handleTobePaid} >
|
187
|
|
- <image className='buy-list-PayLogo' src={awaitPay} />
|
188
|
|
- <view className='buy-list-goPay'>待支付</view>
|
189
|
|
- <view className='buy-list-OrderNumber'>2笔订单</view>
|
190
|
|
- </view>
|
191
|
|
- <view className='buy-list-Paybox ' onClick={handleTobeWritten} >
|
192
|
|
- <image className='buy-list-PayLogo' src={ToShop} />
|
193
|
|
- <view className='buy-list-goPay'>待核销</view>
|
194
|
|
- <view className='buy-list-OrderNumber'>1个订单</view>
|
195
|
|
- </view>
|
196
|
|
- <view className='buy-list-Paybox ' onClick={handleAllOrder} >
|
197
|
|
- <image className='buy-list-PayLogo' src={AllOrder} />
|
198
|
|
- <view className='buy-list-goPay'>全部订单</view>
|
199
|
|
- <view className='buy-list-OrderNumber'>查看详情</view>
|
200
|
|
- </view>
|
201
|
|
- <view className='buy-list-Paybox ' onClick={handleRefund} >
|
202
|
|
- <image className='buy-list-PayLogo' src={Refund} />
|
203
|
|
- <view className='buy-list-goPay'>退款/售后</view>
|
204
|
|
- <view className='buy-list-OrderNumber'>2笔订单</view>
|
205
|
|
- </view>
|
|
117
|
+ <view>
|
|
118
|
+ <view className='buy-list-box'>
|
|
119
|
+ <view className='buy-list-Paybox' onClick={handleTobePaid} >
|
|
120
|
+ <image className='buy-list-PayLogo' src={awaitPay} />
|
|
121
|
+ <view className='buy-list-goPay'>待支付</view>
|
|
122
|
+ <view className='buy-list-OrderNumber'>2笔订单</view>
|
|
123
|
+ </view>
|
|
124
|
+ <view className='buy-list-Paybox ' onClick={handleTobeWritten} >
|
|
125
|
+ <image className='buy-list-PayLogo' src={ToShop} />
|
|
126
|
+ <view className='buy-list-goPay'>待核销</view>
|
|
127
|
+ <view className='buy-list-OrderNumber'>1个订单</view>
|
|
128
|
+ </view>
|
|
129
|
+ <view className='buy-list-Paybox ' onClick={handleAllOrder} >
|
|
130
|
+ <image className='buy-list-PayLogo' src={AllOrder} />
|
|
131
|
+ <view className='buy-list-goPay'>全部订单</view>
|
|
132
|
+ <view className='buy-list-OrderNumber'>查看详情</view>
|
206
|
133
|
</view>
|
207
|
|
- <view className='Badge-box'>
|
208
|
|
- <view className='Badge-list' onClick={handleHomeLogo}>
|
209
|
|
- <image className='Badge-list-logo' src={HomeLogo} />
|
210
|
|
- <text className='Badge-list-titme'> 入住指引</text>
|
211
|
|
- <text className='Badge-list-gt'>></text>
|
212
|
|
- </view>
|
213
|
|
- <view className='Badge-list' onClick={handleCollect}>
|
214
|
|
- <image className='Badge-list-logo' src={collect} />
|
215
|
|
- <text className='Badge-list-titme'> 我的收藏</text>
|
216
|
|
- <text className='Badge-list-gt'>></text>
|
217
|
|
- </view>
|
218
|
|
- <view className='Badge-list' onClick={handleContactMe}>
|
219
|
|
- <image className='Badge-list-logo' src={ContactMe} />
|
220
|
|
- <text className='Badge-list-titme'> 联系我们</text>
|
221
|
|
- <text className='Badge-list-gt'>></text>
|
222
|
|
- </view>
|
223
|
|
- <view className='Badge-list' onClick={handleRules}>
|
224
|
|
- <image className='Badge-list-logo' src={Rules} />
|
225
|
|
- <text className='Badge-list-titme'> 协议声明</text>
|
226
|
|
- <text className='Badge-list-gt'>></text>
|
227
|
|
- </view>
|
|
134
|
+ <view className='buy-list-Paybox ' onClick={handleRefund} >
|
|
135
|
+ <image className='buy-list-PayLogo' src={Refund} />
|
|
136
|
+ <view className='buy-list-goPay'>退款/售后</view>
|
|
137
|
+ <view className='buy-list-OrderNumber'>2笔订单</view>
|
228
|
138
|
</view>
|
229
|
139
|
</view>
|
230
|
|
-
|
231
|
|
- }
|
|
140
|
+ <view className='Badge-box'>
|
|
141
|
+ <view className='Badge-list' onClick={handleHomeLogo}>
|
|
142
|
+ <image className='Badge-list-logo' src={HomeLogo} />
|
|
143
|
+ <text className='Badge-list-titme'> 入住指引</text>
|
|
144
|
+ <text className='Badge-list-gt'>></text>
|
|
145
|
+ </view>
|
|
146
|
+ <view className='Badge-list' onClick={handleCollect}>
|
|
147
|
+ <image className='Badge-list-logo' src={collect} />
|
|
148
|
+ <text className='Badge-list-titme'> 我的收藏</text>
|
|
149
|
+ <text className='Badge-list-gt'>></text>
|
|
150
|
+ </view>
|
|
151
|
+ <view className='Badge-list' onClick={handleContactMe}>
|
|
152
|
+ <image className='Badge-list-logo' src={ContactMe} />
|
|
153
|
+ <text className='Badge-list-titme'> 联系我们</text>
|
|
154
|
+ <text className='Badge-list-gt'>></text>
|
|
155
|
+ </view>
|
|
156
|
+ <view className='Badge-list' onClick={handleRules}>
|
|
157
|
+ <image className='Badge-list-logo' src={Rules} />
|
|
158
|
+ <text className='Badge-list-titme'> 协议声明</text>
|
|
159
|
+ <text className='Badge-list-gt'>></text>
|
|
160
|
+ </view>
|
|
161
|
+ </view>
|
|
162
|
+ </view>
|
232
|
163
|
|
233
|
164
|
</view>
|
234
|
165
|
</scroll-view>
|
235
|
166
|
)
|
236
|
|
-})
|
|
167
|
+}
|