UNPKG

mobileoa-common-modules

Version:

移动办公平台前端公共功能模块

1,720 lines (1,375 loc) 528 kB
var mobileoaCommonModules = (function (require$$2,mobileoaCore,uiRouter,ngIonic,require$$4,require$$1,require$$1$1,intro) { 'use strict'; function interopDefault(ex) { return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var modules = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular.module('appconfig.init', ['mobileoa-core']); angular.module('appconfig.routes', ['ui.router']); angular.module('appconfig.services.appflowinit', ['mobileoa-core']); angular.module('appconfig.services', ['mobileoa-core', 'appconfig.services.appflowinit']); angular.module('appconfig.controller',['appconfig.services']); angular.module('appconfig', ['appconfig.init', 'appconfig.routes', 'appconfig.controller']); }); interopDefault(modules); var routes = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('appconfig.routes'); module.config(function($stateProvider) { $stateProvider .state('appconfig', { url: '/appconfig', template: '<ion-view cache-view="false"><ion-nav-view></ion-nav-view></ion-view>' }) .state('appconfig.serverManagement', { url: '/serverManagement', templateUrl: 'views/appconfig/serverConfig.tpl.html', controller:'appConfigCtrl' }); }); }); interopDefault(routes); var appConfigCtrl = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular .module('appconfig.controller') .controller('appConfigCtrl', appConfigCtrl); /** @ngInject */ function appConfigCtrl($scope) { // $scope.data = {}; // $scope.data.serverUrl = AppConfig.serverUrl; // $scope.data.vpnUrl = JSON.parse(window.localStorage.config).vpnUrl; // $scope.$watch('data', function() { // window.localStorage.serverUrl = $scope.data.serverUrl; // window.localStorage.config = JSON.stringify($scope.data); // /*调用相关插件的接口,将更改后的数据传入接口*/ // //todo // }, true); } }); interopDefault(appConfigCtrl); var appFlowConfigService = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular .module('appconfig.services') .factory('appFlowConfigService', appFlowConfigService); /** * @ngInject */ function appFlowConfigService(CacheService, LinkerService, $state) { var NEED_GESTRUE_PASSWORD = 'appconfig_need_gesture_password'; var appFlowConfigService = { needGesturePassword: needGesturePassword, setNeedGesturePassword: setNeedGesturePassword }; return appFlowConfigService; function needGesturePassword() { return CacheService.get(NEED_GESTRUE_PASSWORD, true); } function setNeedGesturePassword(need) { return CacheService.put(NEED_GESTRUE_PASSWORD, need); } } }); interopDefault(appFlowConfigService); var modules$2 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular.module('appInitFlow.services', []); angular.module('appInitFlow', ['appInitFlow.services']); }); interopDefault(modules$2); var appInitFlow = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('appInitFlow.services'); module.factory('appInitFlowService', function($rootScope, $q, $state, $window) { var isDevelop = $window.location.search && $window.location.search.indexOf('develop') > 0; var appInitFlow = {}, mapFn = {}, messageGetters = []; appInitFlow.MESSAGE_INIT = 'messageInit'; //appInitFlow.INITIALIZE_SET = 'initializeSet'; // app初始化设置 appInitFlow.INTRO_PAGE = 'introPage'; // 进入应用引导页 appInitFlow.SET_URL = 'setUrl'; // 省份选择 appInitFlow.APP_VERSION_UPDATE = 'appVersionUpdate';// 版本更新 appInitFlow.LOAD_APP_CONFIG = 'loadAppConfig';//加载应用配置节点 appInitFlow.LOCK= 'lock';//判定设备锁定节点 appInitFlow.AUTHENTICATE = 'authenticate';//身份认证节点 appInitFlow.JUDGE_BIND = 'judgeBind';//判断设备绑定节点 appInitFlow.CHECK_DEVICE_SAFE = 'checkDeviceSafe';//检测设备安全性节点 appInitFlow.initing = false; appInitFlow.inited = false; mapFn[appInitFlow.MESSAGE_INIT] = function() { return $q.all(messageGetters.map(function(getter) { return getter(); })) .then(function() { appInitFlow.nextAction(appInitFlow.MESSAGE_INIT); }, function() { //获取配置信息失败 }); }; /** * 产生默认的流程节点动作实现。 * * @param {String} actionName * @return {Function} */ function generateActionFn(actionName) { return function() { return appInitFlow.nextAction(actionName); }; } var notInBorwserAppActions = []; appInitFlow.setActionFn = function(actionName, fn) { var inApp = !!window.cordova; if (!inApp && notInBorwserAppActions.indexOf(actionName) !== -1) { mapFn[actionName] = generateActionFn(actionName); } else { mapFn[actionName] = fn; } }; /** * 开始app初始化流程。 * * @return {Boolean} 返回是否开始流程成功的状态。如果流程之前已开始,则返回false。 */ appInitFlow.start = function() { if (!appInitFlow.initing && !appInitFlow.inited) { appInitFlow.initing = true; mapFn[appInitFlow.MESSAGE_INIT](); //TODO show 初始化页面 return true; } return false; }; /** * 初始化需要的所有基本信息,以便流程中的节点使用 * @param {Function} fn */ appInitFlow.addMessageGetter = function(fn) { messageGetters.push(fn); }; /** * 进入app。 * */ appInitFlow.goToApp = function() { $state.go('core-notice'); }; appInitFlow.nextAction = function(actionName, state) { var next = null; appInitFlow.initing = true; /** acitonName阶段已经成功 */ $rootScope.$broadcast('actionSuccess', actionName); switch (actionName) { case appInitFlow.MESSAGE_INIT: next = appInitFlow.INTRO_PAGE; break; case appInitFlow.INTRO_PAGE: next = appInitFlow.SET_URL; break; case appInitFlow.SET_URL: next = appInitFlow.APP_VERSION_UPDATE; break; case appInitFlow.APP_VERSION_UPDATE: next = appInitFlow.LOAD_APP_CONFIG; break; case appInitFlow.LOAD_APP_CONFIG: next = appInitFlow.LOCK; break; case appInitFlow.LOCK: next = appInitFlow.AUTHENTICATE; break; case appInitFlow.AUTHENTICATE: if(isDevelop) { finish(); } else { next = appInitFlow.JUDGE_BIND; } break; case appInitFlow.JUDGE_BIND: next = appInitFlow.CHECK_DEVICE_SAFE; break; case appInitFlow.CHECK_DEVICE_SAFE: finish(); return; } function finish() { appInitFlow.initing = false; appInitFlow.inited = true; appInitFlow.goToApp(); } if (next) { if (mapFn[next]) { mapFn[next](function(state) { appInitFlow.nextAction(next, state); }, state); } else { appInitFlow.nextAction(next); } } }; return appInitFlow; }); }); interopDefault(appInitFlow); var modules$6 = createCommonjsModule(function (module) { var angular = interopDefault(require$$2); 'use strict'; angular.module('login.directives', ['login.services', 'ionic']); angular.module('login.routes', ['ui.router']); angular.module('login.services', ['mobileoa-core', 'ui.router', 'appInitFlow.services', 'appconfig.services']); angular.module('login', ['login.services', 'ionic', 'ui.router', 'login.routes', 'login.directives']); }); interopDefault(modules$6); var modules$10 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular.module('intro.services', ['mobileoa-core']); angular.module('intro.directives', ['intro.services']); module.exports = angular.module('intro', ['intro.services', 'intro.directives']); }); interopDefault(modules$10); var modules$8 = createCommonjsModule(function (module) { var angular = interopDefault(require$$2); 'use strict'; angular.module('notice.routes', ['ui.router']); angular.module('notice.services', ['mobileoa-core', 'appInitFlow.services']); angular.module('notice.directives', ['mobileoa-core']); angular.module('notice', ['notice.services', 'notice.directives', 'mobileoa-core', 'ionic', 'notice.routes', 'intro']); }); interopDefault(modules$8); var modules$12 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular.module('gesturepassword.services', ['mobileoa-core', 'ui.router', 'appconfig.services']); angular.module('gesturepassword.controller', ['gesturepassword.services', 'mobileoa-core', 'login.services']); angular.module('gesturepassword.directives.screen', ['ionic']); angular.module('gesturepassword.routes', ['ui.router']); angular.module('gesturepassword', ['gesturepassword.services', 'gesturepassword.controller', 'gesturepassword.directives.screen', 'gesturepassword.routes']); module.exports = angular.module('gesturepassword'); }); interopDefault(modules$12); var modules$4 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular.module('devicemanager.init', []); angular.module('devicemanager.services', ['ui.router', 'mobileoa-core', 'notice.services', 'gesturepassword.services']); angular.module('devicemanager.controller', ['mobileoa-core', 'login.services']); angular.module('devicemanager.routes', ['ui.router']); angular.module('devicemanager', ['devicemanager.services', 'devicemanager.controller', 'devicemanager.routes', 'devicemanager.init']); }); interopDefault(modules$4); var DeviceManager = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('devicemanager.services'); /** * 设备状态属性: * * * locakStatus {string} - 锁定状态,'LOCK' or 'UNLOCK', 表示设备是否被锁定,与当前登录人无关 * * bindUserId {string} @deprecated - 该设备已经绑定的人。与当前登录人无关 * * bindUsers {string[]} - 该设备已经绑定的人。 * * bind {boolean} - 当前登录人是否绑定过设备。与当前登录人相关 * * bindStatus {string} - 当前登录人与当前设备的绑定申请状态,`1`表示申请中,`2`表示申请通过,`3`表示申请没通过。与当前登录人相关 * * applyBindingUserId {string} - 发送绑定申请的人,与当前登录人一致。与当前登录人相关 * * 规则: * * 1. 如果获取到的状态中applyBindingUserId不是当前登录人,则与当前登录人相关的状态属性值将会被抛弃。 * */ /** * 同步设备状态 */ module.run(function($rootScope, DeviceManager) { DeviceManager.syncRemote(); $rootScope.$on('server.online', function() { DeviceManager.syncRemote(); }); $rootScope.$on('resume', function() { DeviceManager.syncRemote(); }); }); module.factory('DeviceStatusCache', function() { return { get: function() { var deviceStatusJSON = localStorage.getItem('deviceStatus'); return deviceStatusJSON? JSON.parse(deviceStatusJSON) : {}; }, set: function(deviceStatus) { if (deviceStatus) { localStorage.setItem('deviceStatus', JSON.stringify(deviceStatus)); } else { localStorage.removeItem('deviceStatus'); } } } }) .factory('DeviceStatusService', function($http, LinkerService) { return { /** * 获取设备状态 */ fetchDeviceStatus: function() { var userId = LinkerService.currentUserId || '', url = '/device/status/' + window.device.uuid + '?userId=' + userId; return $http.get(url).then(function(response) { return response.data; }); }, /** * 申请绑定 * @param {String} userId 用户id * @param {String} devSn 设备编码 * @return {Promise} */ submitApply: function(userId, devSn) { var params = {}; params.applyUserId = userId; params.devSn = devSn; return $http({ url: '/device/binding/', method: 'POST', data: params }).then(function(response) { return response.data; }); }, /** * 直接绑定人与设备 * @param {string} userId 绑定人 * @param {string} devSn 设备 */ bind: function(userId, devSn) { devSn = devSn === -1 ? window.device.uuid : devSn; var url = '/device/binding/passedBySelf/' + userId + '/' + devSn; return $http.put(url).then(function(response) { return response.data; }); } }; }); module.factory('DeviceManager', function($state, LinkerService, $toast, DeviceStatusCache, DeviceStatusService, $timeout) { function syncDeviceState(nextAction) { DeviceManager._deviceStatus = DeviceStatusCache.get(); DeviceManager.nextAction = nextAction ? nextAction : DeviceManager.nextAction; if (DeviceManager.nextAction) { DeviceManager.nextAction(); } } /** * 保存设置状态数据 * * @param {DeviceStatus} data */ function applyDeviceStateData(data) { var _deviceStatus = data || {}; DeviceManager._deviceStatus = _deviceStatus; DeviceStatusCache.set(_deviceStatus); } /** * 判别锁定状态是否发生变化 * * @param {DeviceStatus} deviceInfo * @param {DeviceStatus} oldDeviceInfo * @returns {boolean} */ function checkLockStatusChange(deviceInfo, oldDeviceInfo) { var newLockStatus = deviceInfo.lockStatus || 'UNLOCK'; var oldLockStatus = oldDeviceInfo.lockStatus || 'UNLOCK'; var lockPageStatusChange = newLockStatus === 'UNLOCK' && $state.$current.name === 'devicemanager.lockPage'; var unLockPageStatusChange = newLockStatus === 'LOCK' && $state.$current.name !== 'devicemanager.lockPage'; return (newLockStatus !== oldLockStatus) || lockPageStatusChange || unLockPageStatusChange; } function isArray(array) { return Object.prototype.toString.call(array) === "[object Array]"; } function indexOf(array, item) { if (!array) { return -1; } for (var i = 0, len = array.length; i < len; i++) { if (array[i] === item) { return i; } } return -1; } function isSameArray(array1, array2) { if ((!array1) && (!array2)) { return true; } if (array1 && !isArray(array1)) { array1 = [array1]; } if (array2 && !isArray(array2)) { array2 = [array2]; } array1 = array1 || []; array2 = array2 || []; if (array1.length !== array2.length) { return false; } else { for (var i = 0, len = array1.length; i < len; i++) { if (indexOf(array2, array1[0]) === -1) { return false; } } for (var i = 0, len = array2.length; i < len; i++) { if (indexOf(array1, array1[0]) === -1) { return false; } } return true; } } function getBindUser(deviceInfo) { if (deviceInfo.bindUsers) { return deviceInfo.bindUsers; } else { return deviceInfo.bindUserId ? [deviceInfo.bindUserId] : []; } } /** * 判别绑定状态是否发生变化 * * @param {DeviceStatus} deviceInfo * @param {DeviceStatus} oldDeviceInfo * @returns {boolean} */ function checkBindStatusChange(deviceInfo, oldDeviceInfo) { var newBindUserId = getBindUser(deviceInfo); var oldBindUserId = getBindUser(oldDeviceInfo); var newBind = deviceInfo.bindStatus || '1'; var oldBind = oldDeviceInfo.bindStatus || '1'; return !isSameArray(newBindUserId, oldBindUserId) || newBind !== oldBind; } /** * 从服务器同步设备状态 */ function syncRemote() { return DeviceStatusService.fetchDeviceStatus().then(function(status) { DeviceManager.changeDeviceInfo(status, true); }); } var DeviceManager = { sync: syncDeviceState, syncRemote: syncRemote, _deviceStatus: DeviceStatusCache.get(), applyDeviceStateData: applyDeviceStateData, /** * 获取设备编号 */ getDevSn: function() { return window.device.uuid; }, /** * 用户之前是否绑定过设备 * @return {Boolean} */ isBindedDevice: function() { var _deviceStatus = DeviceStatusCache.get(); return _deviceStatus !== null && _deviceStatus.bind; }, /** * 设备是否被锁定 * * @return {Boolean} */ isLocked: function() { var _deviceStatus = DeviceStatusCache.get(); return _deviceStatus !== null && _deviceStatus.lockStatus === 'LOCK'; }, /** * 设备是否已有绑定人。 * * @return {Boolean} */ isBinded: function() { var _deviceStatus = DeviceStatusCache.get(); var bindUsers = getBindUser(_deviceStatus); return _deviceStatus !== null && bindUsers.length > 0; }, /** * 设备是否绑定给某个用户 * * @param {String} userId 用户id * @return {Boolean} */ isBindedTo: function(userId) { var _deviceStatus = DeviceStatusCache.get(); var bindUsers = getBindUser(_deviceStatus); return _deviceStatus !== null && indexOf(bindUsers, userId) >= 0; }, /** * 获取当前认证用户与该设备的绑定申请状况。 * * @return {Boolean} */ getBindApplyStatus: function() { var _deviceStatus = DeviceStatusCache.get(); return _deviceStatus !== null && _deviceStatus.bindingStatus || -1; }, execLockJudge: function() { if (DeviceManager.isLocked()) { $state.go('devicemanager.lockPage'); } else { if (DeviceManager.lockNextAction) { DeviceManager.lockNextAction(); } else { $state.go('login'); } } }, judgeLocked: function(nextAction) { DeviceManager.lockNextAction = nextAction; DeviceManager.execLockJudge(); }, setLockStatus: function(lockStatus) { var deviceStatus = DeviceStatusCache.get(); deviceStatus.lockStatus = lockStatus; DeviceManager.changeDeviceInfo(deviceStatus); }, execBindJudge: function() { if (DeviceManager.isBindedTo(LinkerService.currentUserId) && DeviceManager.bindNextAction) { DeviceManager.bindNextAction(); } if (!DeviceManager.isBinded()) { $state.go('devicemanager.unBinded'); } else if (LinkerService.currentUserId && (!DeviceManager.isBindedTo(LinkerService.currentUserId))) { $state.go('devicemanager.bindedToOtherUser'); } }, judgeDeviceBind: function(nextAction) { DeviceManager.bindNextAction = nextAction; DeviceManager.execBindJudge(); }, /** * 变更设备状态 * * @param {DeviceStatus} deviceInfo 设备状态 */ changeDeviceInfo: function(deviceInfo, forceUpdateBindingInfo) { var currentUserId = LinkerService.currentUserId; var _deviceStatus = DeviceStatusCache.get(); var lockedChanged = checkLockStatusChange(deviceInfo, _deviceStatus); var bindChanged = checkBindStatusChange(deviceInfo, _deviceStatus); var isSelfBindInfo = currentUserId && currentUserId === deviceInfo.applyBindingUserId; if (!forceUpdateBindingInfo && !isSelfBindInfo) { _deviceStatus.lockStatus = deviceInfo.lockStatus; _deviceStatus.bindUserId = deviceInfo.bindUserId; _deviceStatus.bindUsers = deviceInfo.bindUsers; deviceInfo = _deviceStatus; } applyDeviceStateData(deviceInfo); if (lockedChanged) { DeviceManager.execLockJudge(); } else if (bindChanged && isSelfBindInfo) { if (deviceInfo.bindingStatus === '3') { $toast.showShortCenter('设备绑定未通过,请重新绑定!'); } DeviceManager.execBindJudge(); } }, /** * 直接绑定设备 * @param {string} userId 用户id * @param {string} devSn 设备编码 */ bind: function(userId, devSn) { return DeviceStatusService.bind(userId, devSn); }, /** * 申请绑定 * @param {string} userId 用户id * @param {string} devSn 设备编码 * @return {Promise} */ submitApply: function(userId, devSn) { return DeviceStatusService.submitApply(userId, devSn) .then(function() { return DeviceManager.syncRemote(); }); }, /** * 获取审核状态 */ viewApprovalStatus: function() { return DeviceStatusService.fetchDeviceStatus() .then(function(status) { var bindingStatus = status.bindingStatus; if(bindingStatus === '1') { $toast.showShortBottom('设备绑定申请仍处于审核阶段,请稍后...'); } else if(bindingStatus === '2') { DeviceManager.applyDeviceStateData(status); DeviceManager.bindNextAction(); } else if(bindingStatus === '3'){ DeviceManager.changeDeviceInfo(status); } else { $toast.showShortCenter('设备绑定申请审核遭遇未知错误,请您联系管理员!'); } }); }, /** * 获取绑定提示页面的提示状态 * * 0: 直接给出绑定按钮; * 1:已有申请,提示等待审核; * 2:提交申请; * 3:审批不通过,提示重新申请 * 4:绑定给自己人 */ getPageInfoStatus: function() { var _deviceStatus = DeviceStatusCache.get(); var bindStatus = 4; if(!this.isBinded()) { //未绑定任何人 if(!this.isBindedDevice()) { //用户之前未绑定过设备,直接给出绑定按钮。 bindStatus = 0; } else if(this.getBindApplyStatus() === '1') {//已有申请,提示等待审核 bindStatus = 1; } else if(this.getBindApplyStatus() !== '1' && this.getBindApplyStatus() !== '2'){ //提示提交申请 bindStatus = 2; } else if(_deviceStatus !== null && _deviceStatus.bindingStatus === '3') { bindStatus = 3; } } else if(!this.isBindedTo(LinkerService.currentUserId)) { //绑定过其他人 if(this.getBindApplyStatus() === '1') { //有申请,提示等待审核 bindStatus = 1; } else if (_deviceStatus !== null && _deviceStatus.bindingStatus === '3') { //申请不通过,重新申请 bindStatus = 3; } else {//无申请,有申请绑定按钮。 bindStatus = 2; } } return bindStatus; } }; return DeviceManager; }); }); interopDefault(DeviceManager); var LoginService = createCommonjsModule(function (module) { var angular = interopDefault(require$$2); var ionic = interopDefault(require$$4); 'use strict'; var module = angular.module('login.services'); module.factory('LoginService', function($http, $q, $rootScope, localforage, $state, LinkerService, AppConfig, sinoNetwork, appFlowConfigService) { var _loginSuccessAction = function() {}; /** * 登录。 * { * "success":true; //成功为true,失败为false * } */ function login(params, successFn) { successFn = successFn || _loginSuccess; params.devSn = window.device.uuid; params.device = getDeviceInfo(); return $http({ method: 'POST', url: '/login', data: params, timeout: 15000//15s }).then(function(response) { applyLoginResponse(response, successFn); return response.data; }); } /** * 注销登录。 * @return {Object} * { * "status":true; //成功为true,失败为false * } */ function logout() { var success = {status: true}, userId = LinkerService.currentUserId; localStorage.removeItem('userToken'); localStorage.removeItem('validDate'); LinkerService.logout(); $rootScope.$broadcast('logout', userId); return $q.when(success); } function calogin() { return sinoNetwork.getCACert().then(function(cert) { if (_.isEmpty(cert) || _.isEmpty(cert.cert)) { return {success: false, message: '登录失败,证书不存在!'}; } else { return login({cert: cert.cert}); } }); } /** * 判断用户是否曾经登录过 * * 方式为判断用户身份是否认证过,并且还在认证有效期内 * * @return {Boolean} */ function onceLogin() { var userId = localStorage.getItem('userId'), userToken = localStorage.getItem('userToken'), validDate = localStorage.getItem('validDate'); return $q.when((userId && userToken && validDate && parseInt(validDate) >= new Date().getTime())); } /** * 初始化流程登录方法 * * 1.若果初始化之前登录过,并且没有过期的话直接进入下一步 * 2.否则的话,我们查看是否可以同ca登录,若果ca证书存在的话,通过ca证书登录。 */ function onLoginAction(nextAction) { _loginSuccessAction = nextAction; onceLogin().then(function(success) { // 1、是否登录过 if (success && appFlowConfigService.needGesturePassword()) { // 2、登录过,并且需要手势密码 _loginSuccessAction(); return success; } else { return toPasswordOrCA();// 3、若果没有登录过,判断使用CA或者密码 } }); } function toPasswordOrCA() { return sinoNetwork.getCACert().then(function(cert) { if (_.isEmpty(cert.cert)) { $state.go('login'); } else { $state.go('calogin'); } }); } function getDeviceInfo() { var deviceInfo = {}, device = window.device; //设备唯一uuid deviceInfo.devSn = device.uuid; //手机设备型号 deviceInfo.devModel = device.model; //设备名称 deviceInfo.devName = device.model; //操作系统平台 deviceInfo.osType = device.platform; //对应操作系统的版本 deviceInfo.osVersion = device.version; //浏览器版本号 deviceInfo.browserVersion = ''; //app应用的版本号 deviceInfo.appVersion = AppConfig.version; deviceInfo.terminalType = ionic.Platform.isWebView()? 'app' : 'browser'; return deviceInfo; } function applyLoginResponse(response, successFn) { var data = response.data; if (data.success && !data.mask) { applyUserToken(response); applyUserId(response); applyValidateDate(response); successFn(response); } } function applyUserToken(response) { var userToken = response.headers('userToken')? response.headers('userToken') : response.data && response.data.userToken; localStorage.setItem('userToken', userToken); } function applyUserId(response) { var userId = response.data && response.data.userId; LinkerService.setCurrentUser(userId); localStorage.setItem('userId', userId); } function applyValidateDate(response) { var validDate = response.data && response.data.validDate; if (validDate) { validDate = _.parseDate(validDate, 'Y-m-d h:i:s').getTime(); } localStorage.setItem('validDate', validDate); } function _loginSuccess(response) { $rootScope.$broadcast('login', response.data); $rootScope.$broadcast('login.buildWebsocket'); if (jsUtil.isObjectExist('cordova.plugins.Keyboard') && window.cordova.plugins.Keyboard.isVisible) { window.cordova.plugins.Keyboard.close(); } if (_loginSuccessAction) { _loginSuccessAction(); } } function getLastLoginUser() { var userJSON = localStorage.getItem('lastLoginUser'); return userJSON ? JSON.parse(userJSON) : null; } return { login: login, logout: logout, calogin: calogin, onLoginAction: onLoginAction, getLastLoginUser: getLastLoginUser, defaultLoginSuccess: _loginSuccess }; }); }); interopDefault(LoginService); var GesturePasswordService = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('gesturepassword.services'); module.factory('GesturePasswordService', function(LinkerService, $state, appFlowConfigService, CacheService) { var GesturePasswordService = { nextAction: function() {}, completed: false, doComplete: doComplete, judgeGesturePassword: judgeGesturePassword, transferGesturePassword: transferGesturePassword, clear: clear }; return GesturePasswordService; function doComplete() { CacheService.put('app_config_set_need_gesture_password', true); GesturePasswordService.completed = true; if (GesturePasswordService.nextAction) { GesturePasswordService.nextAction(); } } function judgeGesturePassword(nextAction) { if (GesturePasswordService.completed) { return; } GesturePasswordService.nextAction = nextAction ? nextAction : GesturePasswordService.nextAction; GesturePasswordService.transferGesturePassword().then(function(gesturePassword) { if (appFlowConfigService.needGesturePassword() && gesturePassword) { $state.go('gesturepassword.validateGesturePwd'); } else if (appFlowConfigService.needGesturePassword() && !CacheService.get('app_config_set_need_gesture_password')) { $state.go('gesturepassword.setGesturePwd2Ignore'); } else if (appFlowConfigService.needGesturePassword() && !gesturePassword) { $state.go('gesturepassword.setGesturePwd2'); } else { doComplete(); } }); } /** * 版本v0.9.20 * 由于存储手势密码的缓存中的key值已作修改,优化版本更新时候会引起的问题 */ function transferGesturePassword() { return LinkerService.getCurrentUser().then(function (loginUser) { var value, key; if (loginUser && loginUser.userNamePinyin) { key = loginUser.userId + '_' + loginUser.userNamePinyin[0]; } value = localStorage.getItem(key); if (value) { localStorage.removeItem(key); localStorage.setItem('gesturepassword_' + loginUser.userId, value); } return localStorage.getItem('gesturepassword_' + loginUser.userId); }); } function clear() { return LinkerService.getCurrentUser().then(function(loginUser) { return localStorage.removeItem('gesturepassword_' + loginUser.userId); }); } }); }); interopDefault(GesturePasswordService); var modules$14 = createCommonjsModule(function (module) { var angular = interopDefault(require$$2); 'use strict'; angular.module('initializeset.directives', ['ionic']); angular.module('initializeset.routes', ['ui.router']); angular.module('initializeset.services', ['login.services', 'mobileoa-core']); angular.module('initializeset', ['initializeset.services', 'ionic', 'initializeset.routes', 'mobileoa-core', 'initializeset.directives']); }); interopDefault(modules$14); var IntroPageService = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('initializeset.services'); module.factory('IntroPageService', function($state, localforage) { var _nextAction; var services = { guidePage: function(nextAction, state) { _nextAction = nextAction; if (window.localStorage.passIntroPage === 'true') { nextAction(); } else { $state.go('initializeset-intro'); window.localStorage.passIntroPage = 'true'; } }, firstIntoAppWhenClick: function() { _nextAction(); } }; return services; }); }); interopDefault(IntroPageService); var SetUrlService = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('initializeset.services'); module.factory('SetUrlService', function($state, $q, configService, $rootScope, AppConfig) { var _nextAction; var InitializeSetUrlService = { setLoginUrl: function(nextAction) { _nextAction = nextAction; if (window.localStorage.passSetUrl === 'true') { InitializeSetUrlService.goNext(); } else { configService.getConfig().then(function(config) { if (config.length === 1) { InitializeSetUrlService.saveConfig(config[0]); InitializeSetUrlService.goNext(); } else { $state.go('initializeset-setUrl'); } }); } }, saveConfig: function(data) { return $q.all([AppConfig.saveLocalStorage(data), configService.saveAppConfig(data)]); }, goNext: function() { if (!window.SinoNetwork) { $rootScope.$broadcast('server.online'); } window.localStorage.passSetUrl = 'true'; _nextAction(); } }; return InitializeSetUrlService; }); }); interopDefault(SetUrlService); var DefaultAppFlowInitService = createCommonjsModule(function (module) { /* 初始化设置页面 */ 'use strict'; var angular = interopDefault(require$$2); angular .module('appconfig.services.appflowinit', ['appInitFlow.services', 'devicemanager.services', 'login.services', 'initializeset.services', 'appVersionUpdate']) .factory('DefaultAppFlowInitService', DefaultAppFlowInitService); /** @ngInject */ function DefaultAppFlowInitService(appInitFlowService, DeviceManager, LoginService, GesturePasswordService, $q, appVersionUpdate, IntroPageService, SetUrlService, AppConfig) { return { registerDefaultActions: function() { //0.9.23版本升级时,需要处理的升级问题 appInitFlowService.addMessageGetter(function() { var isIOS = ionic.Platform.isIOS(), sameVersion = localStorage.appVersion == '0.9.22' || localStorage.appVersion == '0.9.23', updated = localStorage['updateChange-v0.9.23']; if (isIOS && (!updated) && sameVersion) { localStorage['notices.version'] = '-1'; localStorage['updateChange-v0.9.23'] = 'true'; } return AppConfig.setAppConfig(); }); // 介绍页面 appInitFlowService.setActionFn(appInitFlowService.INTRO_PAGE, IntroPageService.guidePage); // 设置登录地址 appInitFlowService.setActionFn(appInitFlowService.SET_URL, SetUrlService.setLoginUrl); // app自动更新 appInitFlowService.setActionFn(appInitFlowService.APP_VERSION_UPDATE, appVersionUpdate.versionUpdate); // 加载应用配置信息 appInitFlowService.setActionFn(appInitFlowService.LOAD_APP_CONFIG, DeviceManager.sync); // 设备锁定节点的处理 appInitFlowService.setActionFn(appInitFlowService.LOCK, DeviceManager.judgeLocked); // 设置身份认证节点 appInitFlowService.setActionFn(appInitFlowService.AUTHENTICATE, LoginService.onLoginAction); // 判断设备绑定节点 appInitFlowService.setActionFn(appInitFlowService.JUDGE_BIND, DeviceManager.judgeDeviceBind); // 设置设备手势密码验证节点的处理 appInitFlowService.setActionFn(appInitFlowService.CHECK_DEVICE_SAFE, GesturePasswordService.judgeGesturePassword); }, start: function() { appInitFlowService.start(); } }; } }); interopDefault(DefaultAppFlowInitService); var app = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); module.exports = angular.module('appconfig'); }); interopDefault(app); var app$2 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); module.exports = angular.module('appInitFlow'); }); interopDefault(app$2); var modules$16 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('archivesincept.services', ['mobileoa-core']); angular.module('archivesincept.routes', ['ui.router']); angular.module('archivesincept', ['archivesincept.services', 'archivesincept.routes', 'tree']); }); interopDefault(modules$16); var ArchivesInceptService = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('archivesincept.services'); module.factory('ArchivesInceptService', function( BaseDataServiceFactory, LinkerService, $http) { var ArchivesInceptService = BaseDataServiceFactory.generate({ name: 'archivesincept', baseUrl: '/archives/incept', idPropertyName: 'id', subflagPropertyName: 'xiugai', flowType: 'xiugai' }); ArchivesInceptService.signin = function(archivesincept){ var userId = LinkerService.currentUserId; return $http.put('/archives/incept/' + userId +'/'+ archivesincept.id, { timeout: 15000 }).then(function(response) { return response; }); }; ArchivesInceptService.returnback = function(archivesincept){ var userId = LinkerService.currentUserId; return $http.post('/archives/incept/returnback', { userId: userId, id: archivesincept.id, reasonDocbackCal: archivesincept.reasonDocbackCal }); }; ArchivesInceptService.wanbi = function(archivesincept){ return $http.post('/archives/incept/update/' + archivesincept.id, { timeout: 15000 }).then(function(response) { return response; }); }; ArchivesInceptService.insertSW = function(archivesincept){ var userId = LinkerService.currentUserId; return $http.post('/archives/incept/insertSW/' + userId + '/'+archivesincept.id, { timeout: 15000 }); }; return ArchivesInceptService; }); }); interopDefault(ArchivesInceptService); var ArchivesInceptGroupCtrl = createCommonjsModule(function (module) { var angular = interopDefault(require$$2); 'use strict'; var module = angular.module('archivesincept'); module.controller('ArchivesInceptGroupCtrl', function($state, $toast, $sinoGoBackDelegate, ArchivesInceptService) { var ctrl = this; ctrl.todos = ArchivesInceptService.todos; ctrl.relatedList = ArchivesInceptService.relatedList; ctrl.toDetail = toDetail; ctrl.remove = remove; /** * 查看收文单据详情。 */ function toDetail(item) { $state.go('archivesincept-archivesinceptDetail', { id: item.id }); }; /** * 删除数据。 */ function remove(list, item) { return ArchivesInceptService.remove(item.id).then(function() { $toast.showLongCenter('收文单删除成功。'); list.remove(item); }, function() { $toast.showLongCenter('收文单删除失败,请检查网络连接。'); }); }; }); }); interopDefault(ArchivesInceptGroupCtrl); var ArchivesInceptAuthService = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('archivesincept.services'); /* * 收文单权限判断service */ module.factory('ArchivesInceptAuthService', function() { function ArchivesInceptAuthService(xzyz){ this.archivesincept = xzyz.archivesincept; } /** * 字段说明: * 草稿:xiugai=0 * 流程中:xiugai=1 * 流程结束:xiugai=2 * 撤办:xiugai=5 * xiugai的值选择范围(0、1、2、5) */ ArchivesInceptAuthService.prototype = { /** * 文秘可以签收 * @return {[type]} [description] */ signin: function(){ return this.archivesincept.flag === '1'; }, returnback: function () { return this.archivesincept.flag === '2' || this.archivesincept.flag === '1'; }, wanbi: function () { return this.archivesincept.flag === '2'; } }; return ArchivesInceptAuthService; }); }); interopDefault(ArchivesInceptAuthService); var ArchivesInceptDetailCtrl = createCommonjsModule(function (module) { var angular = interopDefault(require$$2); 'use strict'; var module = angular.module('archivesincept'); module.controller('ArchivesInceptDetailCtrl', function( $scope, $q, $stateParams, $toast,$ionicPopup,$sinoGoBackDelegate, ArchivesInceptService, ArchivesInceptAuthService) { var ctrl = this; ctrl.init = init; ctrl.save = save; ctrl.refreshWorkFlowInfo = refreshWorkFlowInfo; ctrl.signin = signin; ctrl.returnback = returnback; ctrl.insertSW = insertSW; ctrl.wanbi = wanbi; /** * 初始化页面 * @return */ $scope.$on('$ionicView.enter',function(){ ctrl.init(); }); /** * 初始化 */ function init() { var id = $stateParams.id ? $stateParams.id : null; ctrl.loadingState = 1; return ArchivesInceptService.get(id).then(function(data) { ctrl.ArchivesInceptData = data; ctrl.archivesincept = data.archivesincept; setParams(ctrl.archivesincept); ctrl.auth = new ArchivesInceptAuthService(ctrl.ArchivesInceptData); }).then(function() { ctrl.loadingState = 2; }, function() { ctrl.loadingState = 3; }); }; function setParams(archivesincept){ var biaozhi = archivesincept.deptflag; if (biaozhi == '0' || biaozhi === '部门发文') { biaozhi = '部门发文' } else if (biaozhi == '1' || biaozhi === '部门发文') { biaozhi = '局发文' } ctrl.biaozhi = biaozhi; }; /* * 刷新方法 */ function refreshWorkFlowInfo() { var workflowInfoPromise = ArchivesInceptService.getWorkflowInfo(ctrl.archivesincept.id, ctrl.archivesincept.xiugai); var notionListPromise = ArchivesInceptService.getNotionList(ctrl.archivesincept.xiugai, ctrl.archivesincept.id); return $q.all([workflowInfoPromise, notionListPromise]).then(function(datas) { ctrl.ArchivesInceptData.workflow = datas[0]; ctrl.ArchivesInceptData.notionList = datas[1]; }).then(function() { ctrl.auth = new ArchivesInceptAuthService(ctrl.ArchivesInceptData); }); }; /** * 保存收文单数据。 */ function save(){ return ArchivesInceptService.save(ctrl.archivesincept) .then(function(changeArchivesIncept) { ctrl.ArchivesInceptData.archivesincept = changeArchivesIncept; ctrl.archivesincept = changeArchivesIncept; ctrl.auth = new ArchivesInceptAuthService(ctrl.ArchivesInceptData); }); }; /** * 签收功能 */ function signin(){ ArchivesInceptService.signin(ctrl.archivesincept) .then(function() { $toast.showLongCenter('签收成功!'); $sinoGoBackDelegate.back(); }),function(){ $toast.showLongCenter('签收失败,请检查网络连接。'); }; }; /** * 退文功能 **/ function returnback() { if (!ctrl.archivesincept.reasonDocbackCal) { $toast.showLongCenter('请填写退文原因!'); return false; } ArchivesInceptService.returnback(ctrl.archivesincept) .then(function(){ $toast.showLongCenter('退文成功!'); $sinoGoBackDelegate.back(); }),function(){ $toast.showLongCenter('退文失败,请检查网络连接。'); }; }; /** * 处理完毕按钮 **/ function wanbi() { ArchivesInceptService.wanbi(ctrl.archivesincept) .then(function(){ $toast.showLongCenter('办毕完成!'); $sinoGoBackDelegate.back(); }),function(){ $toast.showLongCenter('办毕失败,请检查网络连接。'); }; }; /** * 生成收文单按钮 **/ function insertSW() { ArchivesInceptService.insertSW(ctrl.archivesincept) .then(function(){ $toast.showLongCenter('生成收文单完成!'); $sinoGoBackDelegate.back(); }),function(){ $toast.showLongCenter('生成收文单失败,请检查网络连接。'); }; }; }); }); interopDefault(ArchivesInceptDetailCtrl); var routes$2 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('archivesincept.routes'); module.config(function($stateProvider) { $stateProvider .state('archivesincept-archivesinceptGroup', { url:'/archivesincept/archivesinceptgroup', templateUrl: 'views/archivesincept/archivesInceptGroup.tpl.html', controller: 'ArchivesInceptGroupCtrl as groupCtrl', data: { title: '收文库', url: 'archivesincept-archivesinceptGroup' }, resolve: { type: function() { return 'xiugai'; } } }) .state('archivesincept-archivesinceptDetail', { url: '/archivesincept/:id/archivesinceptDetail', templateUrl: 'views/archivesincept/archivesInceptDetail.tpl.html', controller: 'ArchivesInceptDetailCtrl as detailCtrl', data: { title: '详情', url: 'archivesincept-archivesinceptDetail' }, resolve: { id: ['$stateParams', function($stateParams) { return $stateParams.id; }], type: function(){ return 'xiugai'; } } }); }); }); interopDefault(routes$2); var init = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); var module = angular.module('archivesincept'); module.run(function(AppConfig, WorkflowConfig) { AppConfig.addModule({ moduleName: 'ARCHIVES_INCEPT', state: 'archivesincept-archivesinceptGroup', text: '收文库', detailState:{ state:'archivesincept-archivesinceptDetail', params: { id: '${id}' } }, moduleClass: 'ion-ios-paper-outline', flowType:'xiugai', order: 10 }); }); }); interopDefault(init); var app$4 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); module.exports = angular.module('archivesincept'); }); interopDefault(app$4); var modules$20 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular.module('webmail.routes', ['ui.router']); angular.module('webmail.services', ['mobileoa-core']); var module = angular.module('webmail', ['webmail.routes', 'webmail.services']); module.exports = module; }); interopDefault(modules$20); var modules$18 = createCommonjsModule(function (module) { var angular = interopDefault(require$$2); 'use strict'; var module = angular.module('cmamail', ['webmail.services']); module.exports = module; }); interopDefault(modules$18); var modules$22 = createCommonjsModule(function (module) { 'use strict'; var angular = interopDefault(require$$2); angular.module('webmail.routes', ['ui.router']); angular.module('webmail.services', ['mobileoa-core']); var module = angular.module('webmail', ['webmail.routes', 'webmail.services']); module.exports = module; }); interopDefault(modules$22); var webm