add registerAction

This commit is contained in:
HelloWorld 2020-03-13 13:45:06 +08:00
parent 9d94997134
commit 6edf44671e
4 changed files with 32 additions and 8 deletions

View File

@ -36,13 +36,13 @@ exports.model = {
},
mysql: {
handle: mysql,
database: '',
prefix: 'think_',
database: 'mybookmarks',
prefix: '',
encoding: 'utf8',
host: '127.0.0.1',
port: '',
port: '3306',
user: 'root',
password: 'root',
password: '123456',
dateStrings: true
}
};
@ -55,7 +55,7 @@ exports.session = {
type: 'file',
common: {
cookie: {
name: 'thinkjs'
name: 'mybookmark'
// keys: ['werwer', 'werwer'],
// signed: true
}

21
src/controller/api.js Normal file
View File

@ -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 });
}
};

5
src/logic/api.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = class extends think.Logic {
indexAction() {
}
};

View File

@ -42,9 +42,7 @@ app.factory('bookmarkService', ['$http', '$q', function ($http, $q) {
},
register: function (params) {
var def = $q.defer();
$http.post('/api/register/', {
params: params
})
$http.post('/api/register/', params)
.success(function (data) {
def.resolve(data);
})