123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- angular.module('push')
- .controller('EditDataCtrl', function ($scope, $ionicPopup, $ionicActionSheet, $stateParams, AccountService, UtilService, UserService, AreaService, ConfigService, $ionicHistory) {
- //TODO
- if($scope.app){
- $scope.setStatusBar(0);
- }
- $scope.userInfo = UserService.user.user;
- if ($scope.userInfo.orgType == 1) {
- $scope.orgname = '企业';
- }
- if ($scope.userInfo.orgType == 2) {
- $scope.orgname = '学校';
- }
- // 编辑头像
- $scope.show_header = function () {
- // 弹出头像选择框
- $ionicActionSheet.show({
- cancelOnStateChange: true,
- cssClass: 'action_s',
- cancelText: '取消',
- buttons: [
- {text: "拍照"},
- {text: "从相册上传"}
- ],
- buttonClicked: function (index) {
- if (index == 0) {
- openCamera(1);
- } else {
- openCamera(0);
- }
- return true;
- },
- destructiveButtonClicked: function () {
- return true;
- }
- });
- };
- var openCamera = function (srcType) {
- var options = {
- // Some common settings are 20, 50, and 100
- quality: 50,
- destinationType: Camera.DestinationType.FILE_URI,
- // In this app, dynamically set the picture source, Camera or photo gallery
- sourceType: srcType,
- encodingType: Camera.EncodingType.JPEG,
- mediaType: Camera.MediaType.PICTURE,
- allowEdit: false,
- correctOrientation: true //Corrects Android orientation quirks
- };
- navigator.camera.getPicture(function (imageData) {
- $scope.imgurl = imageData;
- $scope.showLoadingToast();
- UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) {
- AccountService.setuserName(response[0].userPhoto, 3).then(function (res) {
- $scope.userInfo.photo = res.photo;
- UserService.user.user.photo = res.photo;
- }, function () {
- });
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- });
- }, function (message) {
- }, options);
- };
- $scope.user = {
- oldpwd: "",
- newpwd: "",
- twopwd: ""
- };
- //修改密码
- $scope.updatepwd = function () {
- if ($scope.user.oldpwd == "") {
- UtilService.showMess("旧密码不能为空!");
- } else if ($scope.user.newpwd == "") {
- UtilService.showMess("新密码不能为空!");
- } else if ($scope.user.newpwd.length < 6 || $scope.user.newpwd.length > 20) {
- UtilService.showMess("请输入6-20位英文数字组合的新密码!");
- } else if ($scope.user.twopwd == "") {
- UtilService.showMess("重复密码不能为空!");
- } else if ($scope.user.twopwd.length < 6 || $scope.user.twopwd.length > 20) {
- UtilService.showMess("请输入6-20位英文数字组合的重复密码!");
- } else {
- if ($scope.user.newpwd != $scope.user.twopwd) {
- UtilService.showMess("两次密码不同!");
- } else {
- $scope.showLoadingToast();
- AccountService.setuserPwd($scope.user.oldpwd, $scope.user.newpwd, 2).then(function (response) {
- if (response.status) {
- UtilService.showMess("恭喜,修改密码成功!");
- logout();
- } else {
- UtilService.showMess("旧密码输入错误!");
- }
- $scope.hideLoadingToast();
- }, function (response) {
- $scope.hideLoadingToast();
- });
- }
- }
- };
- //退出登录
- var logout = function () {
- ConfigService.islogin = false;
- UserService.user = {};
- UserService.id = "0";
- ConfigService.comefrom = "320412000";
- $ionicHistory.clearCache();
- $scope.go('tab.account');
- };
- // 编辑用户名
- $scope.showPopup = function () {
- $scope.data = {
- name: $scope.userInfo.userName
- };
- // 调用$ionicPopup弹出编辑用户名
- var myShow = $ionicPopup.show({
- template: "<div style='height:74px;'>" +
- "<input type='text' maxlength='15' ng-model='data.name' style='border-radius:4px;border:1px solid #e9e9ea;text-indent: 11px;'>" +
- "<span class='pop_subtitle'>2-15个字,支持中英文、数字</span>" +
- "</div>",
- title: "编辑用户名",
- scope: $scope,
- buttons: [
- {
- text: "取消"
- },
- {
- text: '<span class="pop_right_button">确认</span>',
- type: "button-positive",
- onTap: function (e) {
- if (!UtilService.isDefined($scope.data.name)) {
- UtilService.showMess("用户名不能为空");
- return $scope.data.name;
- }
- AccountService.setuserName($scope.data.name, 1);
- $scope.userInfo.userName = $scope.data.name;
- return $scope.data.name;
- }
- }
- ]
- })
- .then(function (res) {
- $scope.organizationName = [res].join(" ");
- });
- };
- // 编辑个性签名
- $scope.showSignature = function () {
- $scope.data = {
- intro: $scope.userInfo.intro
- };
- // 调用$ionicPopup弹出编辑个性签名
- $ionicPopup.show({
- template: "<div style='height:115px;'>" +
- "<textarea maxlength='126' rows='4' ng-model='data.intro' style='border-radius:5px;border:1px solid #e9e9ea;text-indent:11px;padding: 9px 4px 4px;'></textarea>" +
- "<span class='pop_subtitle'>126个字以内</span>" +
- "</div>",
- title: "编辑个性签名",
- scope: $scope,
- buttons: [
- {
- text: "取消"
- },
- {
- text: '<span class="pop_right_button">确认</span>',
- type: "button-positive",
- onTap: function (e) {
- if (!UtilService.isDefined($scope.data.intro)) {
- UtilService.showMess("个性签名不能为空");
- return $scope.data.intro;
- }
- AccountService.setuserName($scope.data.intro, 4);
- $scope.userInfo.intro = $scope.data.intro;
- return $scope.data.intro;
- }
- }
- ]
- })
- .then(function (res) {
- $scope.organizationBrief = [res].join(" ");
- });
- };
- // 编辑机构名
- $scope.show_org = function () {
- $scope.data = {
- orgName: $scope.userInfo.orgName
- };
- // 调用$ionicPopup弹出编辑机构名
- $ionicPopup.show({
- template: "<div style='height:90px;'>" +
- "<input type='text' maxlength='13' ng-model='data.orgName' style='border-radius:4px;border:1px solid #e9e9ea;text-indent:11px;'>" +
- "<span class='pop_subtitle'>13个字以内</span>" +
- "</div>",
- title: "编辑机构名",
- scope: $scope,
- buttons: [
- {
- text: "取消"
- },
- {
- text: '<span class="pop_right_button">确认</span>',
- type: "button-positive",
- onTap: function (e) {
- AccountService.setuserName($scope.data.orgName, 5);
- $scope.userInfo.orgName = $scope.data.orgName;
- return $scope.data.orgName;
- }
- }
- ]
- })
- .then(function (res) {
- $scope.organizationBrief = [res].join(" ");
- });
- };
- // 编辑机构类型
- $scope.show_style = function () {
- $scope.data = {
- orgType: $scope.userInfo.orgType
- };
- // 调用$ionicPopup弹出编辑机构类型
- $ionicPopup.show({
- template: "<div>" +
- " <label class='style_p'>" +
- "<input type='radio' ng-model='data.orgType' value='1'/>" +
- "企业" +
- "</label> " +
- "<label class='style_p'>" +
- "<input type='radio' ng-model='data.orgType' value='2' />" +
- "学校" +
- "</label>" +
- "</div>",
- title: "编辑机构类型",
- scope: $scope,
- buttons: [
- {
- text: "取消"
- },
- {
- text: '<span class="pop_right_button">确认</span>',
- type: "button-positive",
- onTap: function (e) {
- AccountService.setuserName($scope.data.orgType, 6);
- $scope.userInfo.orgType = $scope.data.orgType;
- if ($scope.userInfo.orgType == 1) {
- $scope.orgname = '企业';
- }
- if ($scope.userInfo.orgType == 2) {
- $scope.orgname = '学校';
- }
- return $scope.data.orgType;
- }
- }
- ]
- })
- .then(function (res) {
- $scope.organizationBrief = [res].join(" ");
- });
- };
- // 编辑联系人
- $scope.show_link = function () {
- $scope.data = {
- linkman: $scope.userInfo.linkman
- };
- // 调用$ionicPopup弹出编辑联系人
- $ionicPopup.show({
- template: "<div style='height:90px;'>" +
- "<input type='text' maxlength='5' ng-model='data.linkman' style='border-radius:4px;border:1px solid #e9e9ea;text-indent:11px;'>" +
- "<span class='pop_subtitle'>5个字以内</span>" +
- "</div>",
- title: "编辑联系人",
- scope: $scope,
- buttons: [
- {
- text: "取消"
- },
- {
- text: '<span class="pop_right_button">确认</span>',
- type: "button-positive",
- onTap: function (e) {
- AccountService.setuserName($scope.data.linkman, 8);
- $scope.userInfo.linkman = $scope.data.linkman;
- return $scope.data.linkman;
- }
- }
- ]
- })
- .then(function (res) {
- $scope.organizationBrief = [res].join(" ");
- });
- };
- // 编辑联系电话
- $scope.show_tel = function () {
- $scope.data = {
- contactNumber: $scope.userInfo.contactNumber
- };
- // 调用$ionicPopup弹出编辑联系电话
- $ionicPopup.show({
- template: "<div style='height:75px;'>" +
- "<input type='number' maxlength='13' ng-model='data.contactNumber' style='border-radius:4px;border:1px solid #e9e9ea;text-indent:11px;'>" +
- "<span class='pop_subtitle'>请输入正确手机号或固定电话,固定电话请加区号</span>" +
- "</div>",
- title: "编辑联系电话",
- scope: $scope,
- buttons: [
- {
- text: "取消"
- },
- {
- text: '<span class="pop_right_button">确认</span>',
- type: "button-positive",
- onTap: function (e) {
- AccountService.setuserName($scope.data.contactNumber, 9);
- $scope.userInfo.contactNumber = $scope.data.contactNumber;
- return $scope.data.contactNumber;
- }
- }
- ]
- })
- .then(function (res) {
- $scope.organizationBrief = [res].join(" ");
- });
- };
- // 编辑联系邮箱
- $scope.show_email = function () {
- $scope.data = {
- contactEmail: $scope.userInfo.contactEmail
- };
- // 调用$ionicPopup弹出编辑联系邮箱
- $ionicPopup.show({
- template: "<div style='height:75px;'>" +
- "<input type='email' maxlength='26' ng-model='data.contactEmail' style='border-radius:4px;border:1px solid #e9e9ea;text-indent:11px;'>" +
- "<span class='pop_subtitle'>请输入正确邮箱,包含@.元素</span>" +
- "</div>",
- title: "编辑联系邮箱",
- scope: $scope,
- buttons: [
- {
- text: "取消"
- },
- {
- text: '<span class="pop_right_button">确认</span>',
- type: "button-positive",
- onTap: function (e) {
- AccountService.setuserName($scope.data.contactEmail, 9);
- $scope.userInfo.contactEmail = $scope.data.contactEmail;
- return $scope.data.contactEmail;
- }
- }
- ]
- })
- .then(function (res) {
- $scope.organizationBrief = [res].join(" ");
- });
- };
- //修改简介
- $scope.editIntro = function () {
- AccountService.setuserName($scope.intro, 10).then(function (response) {
- }, function () {
- });
- };
- if (angular.isDefined(AreaService.cityid) && AreaService.cityid.length > 0) {
- AccountService.setuserName(AreaService.cityid, 7).then(function (response) {
- $scope.userInfo.region = AreaService.cityname;
- AreaService.cityid = "";
- AreaService.cityname = "";
- }, function () {
- });
- }
- if (angular.isDefined(AreaService.infobook) && AreaService.infobook.length > 0) {
- AccountService.setuserName(AreaService.infobook, 10).then(function (response) {
- $scope.userInfo.data = AreaService.infobook;
- AreaService.infobook = "";
- }, function () {
- });
- }
- $scope.goProvince = function () {
- ConfigService.cityflg = 2;
- $scope.go('chooseProvince');
- };
- //显示二维码
- $scope.showMyMessage = function () {
- $(".fixedTwo").css("display", "block");
- };
- //隐藏二维码
- $scope.hiddenTwoCode = function () {
- $(".fixedTwo").css("display", "none");
- };
- });
|