Skip to content

Commit

Permalink
增加现在人数 和 欢迎语
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzyh committed Sep 29, 2016
1 parent 6bd64ae commit 86da0f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTitleText": "小程序聊天室",
"navigationBarTextStyle":"black"
}
}
15 changes: 8 additions & 7 deletions pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var app = getApp()

var message = '';

var text = '!!!!!欢迎来到聊天室!!!!!';
var text = '';

var user = {};

Expand All @@ -30,15 +30,16 @@ Page({
var that = this


websocket.connect(function(res) {
text = res.data +"\n" + text;
that.setData({
text:text
});
})
//调用应用实例的方法获取全局数据
app.getUserInfo(function(userInfo){
user = userInfo;

websocket.connect(user, function(res) {
text = res.data +"\n" + text;
that.setData({
text:text
});
})
})
}
})
4 changes: 2 additions & 2 deletions utils/websocket.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var url = 'ws://121.42.51.70:8080/ws';

function connect (func) {
function connect (user, func) {

wx.connectSocket({
url: url
url: url + '?username='+user.nickName
});

wx.onSocketMessage(func);
Expand Down

0 comments on commit 86da0f2

Please sign in to comment.