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

47 lines
1.5 KiB
JavaScript

app.controller('RegController', ['$scope', '$http', '$location', 'alertService','$location','wx',
function ($scope, $http, $location, alertService, $location,wx) {
var vm = $scope;
vm.errDialog = alertService.create();
vm.successDialog = alertService.create();
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 {
vm.successDialog.showMessage("提示","注册且绑定微信成功", function(){
// $location.path("/activities");
// window.WeixinJSBridge.call('closeWindow');
wx.closeWindow();
});
}
}, function (response) {
vm.errDialog.showMessage('出错了',response.data);
});
}
}]);