socialforge/public/javascripts/wechat/controllers/reg.js

47 lines
1.5 KiB
JavaScript
Raw Normal View History

app.controller('RegController', ['$scope', '$http', '$location', 'alertService','$location','wx',
function ($scope, $http, $location, alertService, $location,wx) {
2016-06-17 18:18:03 +08:00
var vm = $scope;
vm.errDialog = alertService.create();
2016-06-29 21:09:49 +08:00
vm.successDialog = alertService.create();
2016-06-17 18:18:03 +08:00
vm.goLogin = function () {
$location.path("/login");
}
vm.isagreed = true;
vm.agreed = function (_isagreed) {
vm.isagreed = !_isagreed;
};
vm.reg = function (frm, user) {
frm.$setSubmitted();
console.log(frm);
if (!frm.$valid) {
console.log(frm.$error);
return;
}
console.log(user);
$http.post(
apiUrl + "users",
{login: user.username, password: user.password, mail: user.email}
).then(function (response) {
if (response.data.status != 0) {
vm.errDialog.showMessage('出错了',response.data.message);
} else {
2016-06-29 21:09:49 +08:00
vm.successDialog.showMessage("提示","注册且绑定微信成功", function(){
// $location.path("/activities");
// window.WeixinJSBridge.call('closeWindow');
wx.closeWindow();
2016-06-29 21:09:49 +08:00
});
2016-06-17 18:18:03 +08:00
}
}, function (response) {
2016-06-29 21:09:49 +08:00
vm.errDialog.showMessage('出错了',response.data);
2016-06-17 18:18:03 +08:00
});
}
}]);