Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ const qcloud = require('wafer2-client-sdk');
const config = require('./config');

App({
globalData:{
userslist:[
// for testing
// {
// avatar: "../images/tabbar/active.png",
// name: "blablabla"
// },
// {
// avatar: "../images/tabbar/active.png",
// name: "23333333"
// }
]
},

onLaunch: function() {
qcloud.setLoginUrl(config.service.loginUrl);
}
Expand Down
4 changes: 3 additions & 1 deletion client/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"pages/index/index",
"pages/me/me",
"pages/memories/memories",
"pages/editntc/editntc"
"pages/editntc/editntc",
"pages/userdetail/userdetail",
"pages/userslist/userslist"
],
"window":{
"backgroundColor":"#73a96b",
Expand Down
8 changes: 8 additions & 0 deletions client/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Page({
url: '../editntc/editntc'
})
},
/**
* Jump to userlist page
*/
JumpToUserslist: function () {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the name should be either users or user list, not users list. and the "L" in "list" should be capitalized.

wx.navigateTo({
url: '../userslist/userslist',
})
},
/**
* 生命周期函数--监听页面加载
*/
Expand Down
3 changes: 3 additions & 0 deletions client/pages/index/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
<view class='time'>
<text>Training starts at {{ time }}</text>
</view>
<view class='view-teammates'>
<button class='view-teammates-button' bindtap='JumpToUserslist'>View teammates</button>
</view>
</view>
5 changes: 5 additions & 0 deletions client/pages/index/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@
text-align: center;
margin-top: 20px;
margin-bottom: 30px;
}
.view-teammates-button {
width: 80%;
text-align: center;
color:#73a96b;
}
36 changes: 19 additions & 17 deletions client/pages/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,28 @@ const app = getApp();

function successfulLoginCallback(res) {
app.userInfo = res;
console.log(res);
wx.switchTab({
url: '../index/index',
})
// qcloud.request({
// url: config.service.userUrl + '?OpenId=' + app.userInfo.openId,
// method: 'GET',
// success: function (res) {
// //able to get user's personal information from server
// app.userInfo = Object.assign(app.userInfo, res.body);
// },
// fail: function (err) {
// // fail
// console.log('failed to get userinfo; err:');
// console.log(err);
// },
// complete: function () {
// // complete
// console.log('complete qcloud.request for getting userinfo');
// }
// });
qcloud.request({
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we comment out the block above and write this new block of code?

url: config.service.userUrl + '?OpenId=' + app.userInfo.openId,
method: 'GET',
success: function (res) {
//able to get user's personal information from server
console.log(res);
app.userInfo = Object.assign(app.userInfo, res.body);
},
fail: function (err) {
// fail
console.log('failed to get userinfo; err:');
console.log(err);
},
complete: function () {
// complete
console.log('complete qcloud.request for getting userinfo');
}
});
}

Page({
Expand Down
5 changes: 2 additions & 3 deletions client/pages/me/me.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// pages/me/me.js
const qcloud = require('wafer2-client-sdk');
const app = getApp();
const config = require('../../config');

Page({
data: {
Expand All @@ -12,9 +13,7 @@ Page({
btnDisable: true
},
onLoad: function () {
this.setData({
personal: app.userInfo
});
c
},

chineseNameInput: function (event) {
Expand Down
27 changes: 17 additions & 10 deletions client/pages/userinfo/userinfo.js → client/pages/userdetail/userdetail.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,66 +1,73 @@
// pages/userinfo/userinfo.js
// pages/userdetail/userdetail.js
const qcloud = require('wafer2-client-sdk');
const app = getApp();
const config = require('../../config');

Page({

/**
* 页面的初始数据
*/
data: {

userdetail: {},
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {

this.setData({
userdetail: app.globalData.userslist[options.index]
});
console.log(this.data.userdetail);
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

}
})
File renamed without changes.
23 changes: 23 additions & 0 deletions client/pages/userdetail/userdetail.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--pages/userdetail/userdetail.wxml-->
<view class="container">


<view class="userinfo"> <!-- avatar and username -->
<image class="userinfo-avatar" src="{{userdetail.avatar}}" mode="cover"></image>
<text class="userinfo-nickname">{{userdetail.name}}</text>
</view>


<view class="body"> <!-- info -->
<view class="info"> <!-- Chinese name -->
<!-- <text>Chinese name</text> -->
<!-- <text>{{userdetail.chinesename}}</text> -->
</view>
<view class="info"> <!-- English name -->
<!-- <text>English name</text> -->
<!-- <text>{{userdetail.englishname}}</text> -->
</view>
</view>


</view>
10 changes: 10 additions & 0 deletions client/pages/userdetail/userdetail.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.userinfo{
align-content: center;
justify-content: center;
}

.userinfo-avatar{
width: 100rpx;
height: 100rpx;
margin: 20px;
}
2 changes: 0 additions & 2 deletions client/pages/userinfo/userinfo.wxml

This file was deleted.

1 change: 0 additions & 1 deletion client/pages/userinfo/userinfo.wxss

This file was deleted.

101 changes: 101 additions & 0 deletions client/pages/userslist/userslist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// pages/userlist/userlist.js
const qcloud = require('wafer2-client-sdk');
const app = getApp();
const config = require('../../config');

Page({

/**
* 页面的初始数据
*/
data: {
//userslist info
userslist: []
},


/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log("onLoad userslist page");
this.getUserslist();
},

getUserslist: function (event) {
let that=this;
qcloud.request({
url: config.service.userUrl,
method: "GET",
// try to get all users' userinfo
success: function (res) {
// console.log(res);
console.log("Successfully gotten userslist.")
if(res.dara.code===0) {
app.setData({
// userslist: res.data.xxx
});
}
},
fail: function (err) {
console.log("Failed to get userslist.");
console.log(err);
},
complete: function() {
console.log("complete getting userslist.");
that.setData({
userslist: app.globalData.userslist
});
}
});
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

}
})
3 changes: 3 additions & 0 deletions client/pages/userslist/userslist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"usingComponents": {}
}
8 changes: 8 additions & 0 deletions client/pages/userslist/userslist.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<view class='userslist_wrap'>
<navigator class='user_item' url='../userdetail/userdetail?index={{index}}' wx:for='{{userslist}}' wx:key='{{OpenId}}'>
<!-- avator -->
<image class='user_avatar' src='{{item.avatar}}'></image>
<!-- name -->
<text class='user_name'>{{item.name}}</text>
</navigator>
</view>
20 changes: 20 additions & 0 deletions client/pages/userslist/userslist.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.user_avatar {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
border: 3rpx solid;
border-color:rgb(218, 218, 218);
margin: 20rpx;
}
.user-name {
font-size: 120px;
}
.user_item {
height: 60px;
display: flex;
align-items: center;
border-bottom: 3rpx solid;
border-bottom-color: rgb(233, 233, 233);


}
Loading