1. 修改消息列表页面展示的逻辑,取消掉自动调整登录页面 2. 添加消息详情为空的界面展示 review by 黄敬囿
Showing
14 changed files
with
129 additions
and
8 deletions
@@ -120,6 +120,7 @@ class App extends Component { | @@ -120,6 +120,7 @@ class App extends Component { | ||
120 | }).catch(error => { | 120 | }).catch(error => { |
121 | console.log(error); | 121 | console.log(error); |
122 | }); | 122 | }); |
123 | + | ||
123 | event.on('user-is-login', (loginedCallBack, loginSuccess) => { | 124 | event.on('user-is-login', (loginedCallBack, loginSuccess) => { |
124 | let userInfo = Taro.getStorageSync('userInfo'); | 125 | let userInfo = Taro.getStorageSync('userInfo'); |
125 | if (userInfo && userInfo.uid && userInfo.session_key) { | 126 | if (userInfo && userInfo.uid && userInfo.session_key) { |
@@ -138,6 +139,20 @@ class App extends Component { | @@ -138,6 +139,20 @@ class App extends Component { | ||
138 | }); | 139 | }); |
139 | } | 140 | } |
140 | }); | 141 | }); |
142 | + | ||
143 | + event.on('judge-user-is-login', (isLogined, isLoginCallback) => { | ||
144 | + let userInfo = Taro.getStorageSync('userInfo'); | ||
145 | + if (userInfo && userInfo.uid && userInfo.session_key) { | ||
146 | + if (isLogined) { | ||
147 | + isLogined(true); | ||
148 | + isLoginCallback(); | ||
149 | + } | ||
150 | + } else { | ||
151 | + if (isLogined) { | ||
152 | + isLogined(false); | ||
153 | + } | ||
154 | + } | ||
155 | + }); | ||
141 | } | 156 | } |
142 | 157 | ||
143 | componentDidHide () {} | 158 | componentDidHide () {} |
src/assets/images/no-data@3x.png
0 → 100644
32.5 KB
1 | +// src/components/no-data-show-view/no-data-show-view.js | ||
2 | +import router from '../../router/index.js' | ||
3 | +Component({ | ||
4 | + /** | ||
5 | + * 组件的属性列表 | ||
6 | + */ | ||
7 | + properties: { | ||
8 | + emptyText: { | ||
9 | + type: String, | ||
10 | + value: '这里什么都没有...' | ||
11 | + }, | ||
12 | + isLogin: { | ||
13 | + type: Boolean, | ||
14 | + value: true | ||
15 | + } | ||
16 | + }, | ||
17 | + | ||
18 | + /** | ||
19 | + * 组件的初始数据 | ||
20 | + */ | ||
21 | + data: { | ||
22 | + | ||
23 | + }, | ||
24 | + | ||
25 | + /** | ||
26 | + * 组件的方法列表 | ||
27 | + */ | ||
28 | + methods: { | ||
29 | + goToLogin() { | ||
30 | + router.go('nativeLogin'); | ||
31 | + } | ||
32 | + } | ||
33 | +}) |
1 | +<!--src/components/no-data-show-view/no-data-show-view.wxml--> | ||
2 | +<view class='no-data'> | ||
3 | + <image class='no-data-image' src='../../assets/images/no-data@3x.png'></image> | ||
4 | + <text class='no-data-text'>{{emptyText}}</text> | ||
5 | + <block wx:if="isLogin"> | ||
6 | + <text class='no-data-text no-data-btn' bindtap='goToLogin'>登录后查看更多</text> | ||
7 | + </block> | ||
8 | +</view> |
1 | +/* src/components/no-data-show-view/no-data-show-view.wxss */ | ||
2 | + | ||
3 | +.no-data { | ||
4 | + display: flex; | ||
5 | + flex-direction: column; | ||
6 | + align-items: center; | ||
7 | + justify-content: center; | ||
8 | +} | ||
9 | + | ||
10 | +.no-data .no-data-image { | ||
11 | + width: 280rpx; | ||
12 | + height: 280rpx; | ||
13 | + margin-bottom: 20rpx; | ||
14 | +} | ||
15 | + | ||
16 | +.no-data .no-data-text { | ||
17 | + font-size: 28rpx; | ||
18 | + color: #CCCCCC; | ||
19 | +} | ||
20 | + | ||
21 | +.no-data .no-data-btn { | ||
22 | + margin-top: 20rpx; | ||
23 | + line-height: 88rpx; | ||
24 | + color: #fff; | ||
25 | + text-align: center; | ||
26 | + background-color: #000; | ||
27 | + border-radius: 20rpx; | ||
28 | + width: 300rpx; | ||
29 | +} |
@@ -16,6 +16,7 @@ Page({ | @@ -16,6 +16,7 @@ Page({ | ||
16 | currentPage: 1, | 16 | currentPage: 1, |
17 | messageList: [], | 17 | messageList: [], |
18 | }, | 18 | }, |
19 | + isLogined: false, | ||
19 | }, | 20 | }, |
20 | 21 | ||
21 | /** | 22 | /** |
@@ -118,17 +119,19 @@ Page({ | @@ -118,17 +119,19 @@ Page({ | ||
118 | * 生命周期函数--监听页面显示 | 119 | * 生命周期函数--监听页面显示 |
119 | */ | 120 | */ |
120 | onShow: function () { | 121 | onShow: function () { |
121 | - event.emit('user-is-login', this.isLoginCallback, this.loginSuccess); | 122 | + event.emit('judge-user-is-login', this.isJudgeLogined, this.isLoginCallback); |
122 | }, | 123 | }, |
123 | 124 | ||
124 | isLoginCallback() { | 125 | isLoginCallback() { |
125 | - console.log('已经登录'); | ||
126 | this.fetchMessageTypeInfo(); | 126 | this.fetchMessageTypeInfo(); |
127 | this.fetchNewMessageList(); | 127 | this.fetchNewMessageList(); |
128 | }, | 128 | }, |
129 | 129 | ||
130 | - loginSuccess() { | ||
131 | - console.log('登录成功'); | 130 | + isJudgeLogined(isLogined) { |
131 | + console.log(isLogined); | ||
132 | + this.setData({ | ||
133 | + isLogined | ||
134 | + }) | ||
132 | }, | 135 | }, |
133 | 136 | ||
134 | /** | 137 | /** |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <view class="message-title"> | 2 | <view class="message-title"> |
3 | <text class='message-title'>消息</text> | 3 | <text class='message-title'>消息</text> |
4 | </view> | 4 | </view> |
5 | - | 5 | + <block wx:if="{{isLogined}}"> |
6 | <!-- 三个通知 --> | 6 | <!-- 三个通知 --> |
7 | <view class='message-header'> | 7 | <view class='message-header'> |
8 | <block wx:for="{{messageTypeList}}" wx:key="{{index}}"> | 8 | <block wx:for="{{messageTypeList}}" wx:key="{{index}}"> |
@@ -31,4 +31,10 @@ | @@ -31,4 +31,10 @@ | ||
31 | </view> | 31 | </view> |
32 | </block> | 32 | </block> |
33 | </view> | 33 | </view> |
34 | + </block> | ||
35 | + <block wx:else> | ||
36 | + <view class='empty'> | ||
37 | + <no-data-show-view isLogin="{{true}}"></no-data-show-view> | ||
38 | + </view> | ||
39 | + </block> | ||
34 | </view> | 40 | </view> |
@@ -95,3 +95,14 @@ | @@ -95,3 +95,14 @@ | ||
95 | margin-top: 20rpx; | 95 | margin-top: 20rpx; |
96 | height: 2rpx; | 96 | height: 2rpx; |
97 | } | 97 | } |
98 | + | ||
99 | +.empty { | ||
100 | + display: flex; | ||
101 | + justify-content: center; | ||
102 | + font-family: PingFang-SC-Regular; | ||
103 | + color: #999; | ||
104 | + font-size: 30rpx; | ||
105 | + letter-spacing: 0.8px; | ||
106 | + margin-top: 300rpx; | ||
107 | + height: 80%; | ||
108 | +} |
-
Please register or login to post a comment