Skip to content

Commit 7213509

Browse files
author
uniquexiaobai
committed
add logout
1 parent a32a3af commit 7213509

File tree

11 files changed

+44
-14
lines changed

11 files changed

+44
-14
lines changed

app.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ App({
55
var logs = wx.getStorageSync('logs') || []
66
logs.unshift(Date.now())
77
wx.setStorageSync('logs', logs);
8-
9-
console.log(wx.getStorageSync('user'));
10-
var user = wx.getStorageSync('user') || [];
11-
12-
if(!user) {
13-
wx.navigateTo({
14-
url: '../signin/signin'
15-
});
16-
}
178
},
189

1910
})

app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"pages/explore/explore",
55
"pages/famous/famous",
66
"pages/me/me",
7+
"pages/settings/settings",
78
"pages/logs/logs",
89
"pages/signin/signin"
910
],

pages/index/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ Page({
1919
});
2020
},
2121
onLoad: function () {
22-
var that = this
23-
//调用应用实例的方法获取全局数据
22+
var user = wx.getStorageSync('user');
23+
24+
console.log(user);
25+
if(!user) {
26+
wx.navigateTo({
27+
url: '../signin/signin'
28+
});
29+
}
2430
}
2531
});

pages/index/index.wxml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<view class="container col">
22
<view bindtap="bindViewTap" class="userinfo">
3-
<image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
43
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
54
<text>{{motto}}</text>
65
</view>

pages/me/me.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11

2-
var app = getApp()
2+
var app = getApp();
33
Page({
44
data: {
55
login: 'uniquexiaobai',
66
avatar_url: "https://avatars.githubusercontent.com/u/12796673?v=3"
7+
},
8+
9+
goRouteSettings: function() {
10+
wx.navigateTo({
11+
url: '../settings/settings'
12+
});
713
}
814
});

pages/me/me.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<text class="flex1">Edit Profile</text>
1010
<image src="/img/me/angle-right.png" class="icon-right"></image>
1111
</view>
12-
<view class="item">
12+
<view class="item" bindtap="goRouteSettings">
1313
<image src="/img/me/cog.png" class="icon"></image>
1414
<text class="flex1">Settings</text>
1515
<image src="/img/me/angle-right.png" class="icon-right"></image>

pages/me/me.wxss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.me {
2+
height: 100%;
23
background: #F0EFF5;
34
}
45
.item {

pages/settings/settings.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
Page({
3+
handleLogoutTap: function() {
4+
wx.clearStorageSync();
5+
wx.navigateTo({
6+
url: '../signin/signin'
7+
});
8+
}
9+
});

pages/settings/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"navigationBarTitleText": "Settings"
3+
}

pages/settings/settings.wxml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<view class="container col settings">
2+
<button class="logout" bindtap="handleLogoutTap" size="mini">Logout</button>
3+
</view>

0 commit comments

Comments
 (0)