add registerAction
This commit is contained in:
parent
9d94997134
commit
6edf44671e
|
|
@ -36,13 +36,13 @@ exports.model = {
|
||||||
},
|
},
|
||||||
mysql: {
|
mysql: {
|
||||||
handle: mysql,
|
handle: mysql,
|
||||||
database: '',
|
database: 'mybookmarks',
|
||||||
prefix: 'think_',
|
prefix: '',
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: '',
|
port: '3306',
|
||||||
user: 'root',
|
user: 'root',
|
||||||
password: 'root',
|
password: '123456',
|
||||||
dateStrings: true
|
dateStrings: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -55,7 +55,7 @@ exports.session = {
|
||||||
type: 'file',
|
type: 'file',
|
||||||
common: {
|
common: {
|
||||||
cookie: {
|
cookie: {
|
||||||
name: 'thinkjs'
|
name: 'mybookmark'
|
||||||
// keys: ['werwer', 'werwer'],
|
// keys: ['werwer', 'werwer'],
|
||||||
// signed: true
|
// signed: true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
const Base = require('./base.js');
|
||||||
|
|
||||||
|
module.exports = class extends Base {
|
||||||
|
indexAction() {
|
||||||
|
return this.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
async registerAction() {
|
||||||
|
try {
|
||||||
|
let data = this.post();
|
||||||
|
let res = await this.model("users").add(data);
|
||||||
|
this.json({ code: 0, data: res, msg: "注册成功" });
|
||||||
|
} catch (error) {
|
||||||
|
this.json({ code: 1, data: '', msg: error.toString() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
autoLoginAction() {
|
||||||
|
this.json({ "succ": true });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
module.exports = class extends think.Logic {
|
||||||
|
indexAction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -42,9 +42,7 @@ app.factory('bookmarkService', ['$http', '$q', function ($http, $q) {
|
||||||
},
|
},
|
||||||
register: function (params) {
|
register: function (params) {
|
||||||
var def = $q.defer();
|
var def = $q.defer();
|
||||||
$http.post('/api/register/', {
|
$http.post('/api/register/', params)
|
||||||
params: params
|
|
||||||
})
|
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
def.resolve(data);
|
def.resolve(data);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue