Skip to content

Commit

Permalink
add cookie supports,improve Account
Browse files Browse the repository at this point in the history
  • Loading branch information
stkevintan committed Jun 22, 2015
1 parent 3050ae9 commit 3b38b0c
Show file tree
Hide file tree
Showing 9 changed files with 1,550 additions and 165 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ release/
node_modules/
*.exe
*.py
.directory
.directory
*Test*
22 changes: 15 additions & 7 deletions controller/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,27 @@ var Account = function () {
phone: $('#login').find('input[name="phone"]'),
password: $('#login').find('input[name="password"]')
}
this.isLogin = false;
this.listen(this);
this.load();
}

Account.prototype = {
load: function () {
loadUser: function (uid) {
//获得登录信息
var userData = fm.getUserData();
if (userData) {
this.setUserProfile(userData.profile);
uid = uid || fm.getUserID();
var that = this;
if (uid) {
api.userProfile(uid, function (err, res) {
if (err) {
console.log(err);
that.setUserProfile();
showNotify('获取用户信息失败,请重新登录');
} else {
that.setUserProfile(res);
}
});
} else {
this.setUserProfile();
console.log('user not login');
that.setUserProfile();
}
},
unsign: function () {
Expand Down
13 changes: 8 additions & 5 deletions controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var api = require('./model/NetEaseMusic');
var utils = require('./model/Utils');
var PltM = require('./model/PlaylistModel');
var EntryM = require('./model/EntryModel');
//var lrcParser = require('./model/LrcParser');

var Event = (function () {
var w = $(window);
return {
Expand All @@ -30,7 +30,7 @@ var Event = (function () {
}
})();
var showNotify = function (msg) {
var notification = new Notification('网易音乐盒', {
new Notification('网易音乐盒', {
body: msg
});
}
Expand Down Expand Up @@ -69,11 +69,11 @@ var entry = {
net: new EntryM({
mode: 0,
name: '云音乐',
onload: function () {
return fm.getUserData();
},
loader: function (callback) {
api.getNet(callback);
},
onload: function () {
return fm.getUserID() === null ? false : true;
}
})
},
Expand All @@ -96,6 +96,9 @@ var player = new Player();
var settings = new Settings();
var category = new Category();

//加载用户信息
account.loadUser();
//加载播放列表
category.loadPlaylists(null, true);

//table屏蔽选中
Expand Down
8 changes: 2 additions & 6 deletions controller/lrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ Lrc.prototype = {
if (type < 0 && curTop > h) {
//scroll down
d = Math.max(-this.$.ulDOM.offsetHeight >> 1, h);
console.log(d);
}
if (d) {
this.$.ulDOM.style.marginTop = curTop + d + 'px';
}
},
setDesc: function (opt) {
this.$.pic.attr('src', opt.pic);
this.$.pic.attr('src', opt.pic || '');
this.$.title.text(opt.title);
this.$.album.text(opt.album);
this.$.artist.text(opt.artist);
Expand Down Expand Up @@ -76,14 +75,11 @@ Lrc.prototype = {
this.lrcObj = null;
this._index = -1;
if (!songM.id) {
console.log('this is local file');
this.setLrc();
} else {
var that = this;
api.songLyric(songM.id, function (err, res) {
if (err) {
console.log(err);
} else {
if (!err) {
that.lrcObj = new that.parse(res);
}
that.setLrc();
Expand Down
Loading

0 comments on commit 3b38b0c

Please sign in to comment.