define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'common/services', 'common/directives','common/query/kind', 'common/query/brand', 'common/query/component', 'common/query/order', 'common/query/cart', 'common/query/goods', 'common/query/return' ,'angular-toaster', 'common/query/urlencryption', 'ui-jquery', 'common/query/bankTransfer', 'common/query/bankInfo', 'common/query/change', 'common/query/rate', 'common/query/logistics', 'common/query/address' ,'angular-toaster','common/query/collection', 'common/query/proofing', 'common/query/bill', 'common/query/user','file-upload', 'file-upload-shim', 'common/query/bankInfo' , 'common/query/responseLogistics', 'common/query/payment', 'common/query/afterSale', 'common/query/messageBoard', 'common/query/importDeclaration', 'common/query/enterprise', 'common/query/invoice', 'common/query/refund', 'common/query/recommendation', 'common/query/logisticsPort', 'common/query/storeInfo', 'common/query/tradeMessageNotice', 'common/query/tradeBasicProperties', 'common/query/browsingHistory', 'common/query/internalMessage', 'common/module/chat_web_module', 'angular-filter', 'common/query/vendor','common/query/seekPurchase', 'common/query/search', 'angular-sanitize', 'common/query/authority','common/query/purchase', 'common/b2bServices'], function(angularAMD) { 'use strict'; var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'common.services', 'common.directives', 'tool.directives', 'common.query.kind', 'brandServices', 'componentServices', 'orderServices', 'cartServices', 'goodsServices', 'returnServices' , 'toaster', 'urlencryptionServices', 'ui.jquery', 'bankTransfer', 'bankInfo', 'changeServices','rateServices', 'logisticsServices', 'addressServices', 'toaster','collection','proofingServices', 'billServices', 'common.query.user', 'angularFileUpload', 'bankInfo', 'responseLogisticsService', 'PaymentService', 'afterSaleService', 'messageBoardServices', 'table.directives', 'importDeclaration', 'common.query.enterprise', 'invoiceServices', 'refundModule', 'recommendation','logisticsPortService', 'storeInfoServices', 'tradeMessageNoticeModule', 'tradeBasicPropertiesServices', 'BrowsingHistory', 'internalMessageServices', 'WebChatModule', 'angular.filter', 'vendorServices','seekPurchaseServices', 'searchService', 'ngSanitize', 'authorityServices', 'purchaseServices', 'common.b2bServices']); app.init = function() { angularAMD.bootstrap(app); }; if (!Array.prototype.last){ Array.prototype.last = function(){ return this.length > 0 ? this[this.length - 1] : null; }; } if (!Array.prototype.first){ Array.prototype.first = function(){ return this.length > 0 ? this[0] : null; }; } // ui-router 路由配置 app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', function($stateProvider, $urlRouterProvider, $httpProvider){ $urlRouterProvider.otherwise("/index"); // 设置该app下js访问带cookie $httpProvider.defaults.withCredentials = true; $stateProvider.state('ssoIndex', angularAMD.route({ url: '/index', templateUrl: 'static/view/sso/forstore/ssoCenter.html', title: '帐户中心首页', controller : 'ssoCenterCtrl', controllerUrl : 'app/controllers/forstore/ssoCenterCtrl' })).state('ssoInfo', angularAMD.route({ url: '/info', templateUrl: 'static/view/sso/ssoInfo.html', title: '基本信息', controller: 'ssoInfoCtrl', controllerUrl: 'app/controllers/ssoInfoCtrl' })).state('ssoSecurity', angularAMD.route({ url: '/security', templateUrl: 'static/view/sso/securitySet.html', title: '安全设置', controller: 'securitySetCtrl', controllerUrl: 'app/controllers/securitySetCtrl' })).state('ssoManagement', angularAMD.route({ url: '/management?tab', templateUrl: 'static/view/sso/staffManagement.html', title: '员工管理', controller: 'staffManagementCtrl', controllerUrl: 'app/controllers/staffManagementCtrl' })).state('ssoPermission', angularAMD.route({ url: '/permission', templateUrl: 'static/view/sso/rolePermission.html', title: '角色权限', controller: 'rolePermissionCtrl', controllerUrl: 'app/controllers/rolePermissionCtrl' })).state('ssoAddress', angularAMD.route({ url: '/address', templateUrl: 'static/view/sso/ssoAddress.html', title: '收货地址', controller: 'ssoAddressCtrl', controllerUrl: 'app/controllers/ssoAddressCtrl' })).state('ssoInvoice', angularAMD.route({ url: '/invoice', templateUrl: 'static/view/sso/ssoInvoice.html', title: '发票管理', controller: 'ssoInvoiceCtrl', controllerUrl: 'app/controllers/ssoInvoiceCtrl' })).state('payAccount', angularAMD.route({ url: '/payAccount?status', title: '付款账户', templateUrl: 'static/view/usercenter/forstore/pay_center.html', controller: 'buyerPayCenterCtrl', controllerUrl: 'js/usercenter/controllers/forstore/pay_center_ctrl' })).state('gatheringAccount', angularAMD.route({ url: '/gatheringAccount?tab', templateUrl: 'static/view/vendor/forstore/pay_center.html', title: '收款账户', controller: 'vendorPayCenterCtrl', controllerUrl: 'js/vendor/controllers/forstore/pay_center_ctrl' })).state('approvalflow_log', angularAMD.route({ url: "/approvalflow/log", templateUrl: "static/view/sso/b2b/log.html", controller: 'LogCtrl', controllerUrl: 'js/sso/controllers/b2b/LogCtrl' })).state('approvalflow_flow', angularAMD.route({ url: "/approvalflow/flow", templateUrl: "static/view/sso/b2b/home.html", controller: 'approvalFlowCtrl', controllerUrl: 'js/sso/controllers/b2b/approvalFlowCtrl' })).state('baseInfo_myRequest', angularAMD.route({ url: "/myRequest", title: 'b2b企业圈-我的合作伙伴(全部)', templateUrl: 'static/view/sso/b2b/myRequest.html', controller: 'AddPartnerRequestCtrl', controllerUrl: 'app/controllers/b2b/addPartnerRequestCtrl' })).state('baseInfo_vendorInfo', angularAMD.route({ url: "/enume/vendorInfo", title: 'b2b企业圈-我的合作伙伴(供应商)', templateUrl: 'static/view/sso/b2b/vendorsInfo.html', controller: 'VendorsInfoCtrl', controllerUrl: 'app/controllers/b2b/vendorsInfoCtrl' })).state('baseInfo_customerInfo', angularAMD.route({ url: "/enume/customerInfo", title: 'b2b企业圈-我的合作伙伴(客户)', templateUrl: 'static/view/sso/b2b/customersInfo.html', controller: 'CustomersInfoCtrl', controllerUrl: 'app/controllers/b2b/customersInfoCtrl' })).state('baseInfo_servicerInfo', angularAMD.route({ url: "/enume/servicerInfo", title: 'b2b企业圈-我的合作伙伴(服务商)', templateUrl: 'static/view/sso/b2b/servicerInfo.html', controller: 'ServicerInfoCtrl', controllerUrl: 'app/controllers/b2b/servicerInfoCtrl' })).state('baseInfo_newPartner', angularAMD.route({ url: "/newPartner", title: 'b2b企业圈-新的合作伙伴', templateUrl: "static/view/sso/b2b/newPartner.html", controller: 'NewPartnerCtrl', controllerUrl: 'app/controllers/b2b/newPartnerCtrl' })).state('baseInfo_invitation', angularAMD.route({ url: "/enume/invitation", title: 'b2b企业圈-邀请注册记录', templateUrl: "static/view/sso/b2b/invitation.html", controller: 'InvitationCtrl', controllerUrl: 'app/controllers/b2b/invitationCtrl' })).state('partner_searchresult', angularAMD.route({ url: "/enume/searchresult", title: 'b2b企业圈-邀请注册记录', templateUrl: "static/view/sso/b2b/searchresult.html", controller: 'EnterpriseSearchCtrl', controllerUrl: 'app/controllers/b2b/enterpriseSearchCtrl' })) }]); // 高亮显示关键词 app.filter('getkey', ['$sce', '$rootScope', function ($sce, $rootScope) { var search = $rootScope.searchKeyword; return function (content, search) { content = encodeURI(content); search = encodeURI(search); var reg = new RegExp(search, 'gim'); var result = content.replace(reg, '$&'); result = decodeURIComponent(result); return $sce.trustAsHtml(result); }; $rootScope.searchKeyword = null;// 清除缓存的关键字 }]); // 状态码 -> 描述 app.filter('status', function(){ var statusConfig = { '101': '已提交', '102': '已审核', '103': '未通过', '104': '已通过', '313': '已激活', '316': '已过账', '310': '未启用', '311': '待审核', '312': '未激活', '350': '未开通', '351': '已开通', '317': '已创建' }; return function(data) { return statusConfig[data]; } }); // 状态码 -> 快递 app.filter('logisticsCompany', function(){ var logisticsCompanyConfig = { 'aae': 'AAE快递', 'aramex': 'Aramex快递', 'auspost': '澳大利亚邮政', 'annengwuliu': '安能物流快递', 'bht': 'BHT快递', 'baifudongfang': '百福东方物流', 'bangsongwuliu': '邦送物流', 'huitongkuaidi': '百世汇通快递', 'idada': '百成大达物流', 'coe': 'COE(东方快递)', 'city100': '城市100', 'chuanxiwuliu': '传喜物流', 'depx': 'DPEX', 'disifang': '递四方', 'dsukuaidi': 'D速物流', 'debangwuliu': '德邦物流', 'datianwuliu': '大田物流', 'dhl': 'DHL国际快递', 'dhlen': 'DHL(国际件)', 'dhlde': 'DHL(德国件)', 'dhlpoland': 'DHL(波兰件)', 'ems': 'EMS快递', 'emsguoji': 'EMS国际', 'fedex': 'FedEx(国际)', 'fedexus': 'FedEx(美国)', 'rufengda': '凡客如风大', 'feikangda': '飞康达物流', 'feibaokuaidi': '飞豹快递', 'fardarww': 'Fardar Worldwide', 'fandaguoji': '颿达国际', 'fedexuk': 'FedEx(英国件)', 'gangzhongnengda': '港中能达物流', 'gongsuda': '共速达', 'guotongkuaidi': '国通快递', 'gls': 'GLS', 'tiandihuayu': '华宇物流', 'hengluwuliu': '恒路物流', 'huaxialongwuliu': '华夏龙物流', 'hebeijianhua': '河北建华', 'jiajiwuliu': '佳吉物流', 'jiayiwuliu': '佳怡物流', 'jiayunmeiwuliu': '加运美快递', 'jixianda': '急先达物流', 'jinguangsudikuaijian': '京广速递快件', 'jinyuekuaidi': '晋越快递', 'jialidatong': '嘉里大通', 'jietekuaidi': '捷特快递', 'jd': '京东快递', 'jindawuliu': '金大物流', 'kuaijiesudi': '快捷快递', 'kangliwuliu': '康力物流', 'kuayue': '跨越物流', 'lianhaowuliu': '联昊通物流', 'longbangwuliu': '龙邦速递', 'lianbangkuaidi': '联邦快递', 'lejiedi': '乐捷递', 'lijisong': '立即送', 'minghangkuaidi': '民航快递', 'meiguokuaidi': '美国快递', 'menduimen': '门对门', 'mingliangwuliu': '明亮物流', 'ganzhongnengda': '能达速递', 'ocs': 'OCS', 'ontrac': 'OnTrac', 'pingandatengfei': '平安达腾飞', 'peixingwuliu': '陪行物流', 'quanfengkuaidi': '全峰快递', 'quanyikuaidi': '全一快递', 'quanritongkuaidi': '全日通快递', 'quanchenkuaidi': '全晨快递', 'sevendays': '7天连锁物流', 'shentong': '申通快递', 'shunfeng': '顺丰速运', 'suer': '速尔快递', 'haihongwangsong': '山东海红', 'shenghuiwuliu': '盛辉物流', 'shengfengwuliu': '盛丰物流', 'shangda': '上大物流', 'santaisudi': '三态速递', 'saiaodi': '赛澳递', 'shenganwuliu': '圣安物流', 'sxhongmajia': '山西红马甲', 'suijiawuliu': '穗佳物流', 'syjiahuier': '沈阳佳惠尔', 'tnt': 'TNT快递', 'tiantian': '天天快递', 'tonghetianxia': '通和天下', 'tianzong': '天纵物流', 'tntuk': 'TNT(英国件)', 'ups': 'UPS国际快递', 'wanxiangwuliu': '万象物流', 'weitepai': '微特派', 'wanjiawuliu': '万家物流', 'xinbangwuliu': '新邦物流', 'xinfengwuliu': '信丰物流', 'neweggozzo': '新蛋物流', 'hkpost': '香港邮政', 'xianglongyuntong': '祥龙运通物流', 'xianchengliansudi': '西安城联速递', 'yuantong': '圆通速递', 'yunda': '韵达快运', 'yuntongkuaidi': '运通快递', 'youzhengguonei': '邮政国内', 'youzhengguoji': '邮政国际', 'yuanchengwuliu': '远成物流', 'yafengsudi': '亚风速递', 'youshuwuliu': '优速快递', 'yuananda': '源安达快递', 'yuanfeihangwuliu': '原飞航物流', 'yuefengwuliu': '越丰物流', 'zhongtong': '中通快递', 'zhaijisong': '宅急送', 'zhongtiewuliu': '中铁快运', 'ztky': '中铁物流', 'zhongyouwuliu': '中邮物流', 'zhongtianwanyun': '中天万运', 'zhengzhoujianhua': '郑州建华', 'zhimakaimen': '芝麻开门' }; return function(data) { return logisticsCompanyConfig[data]; } }); app.run(['$rootScope', 'BaseService', 'AuthenticationService', function($rootScope, BaseService, AuthenticationService) { $rootScope.rootPath = BaseService.getRootPath(); $rootScope.page = 'sso';// 导航栏状态,'帐户中心'状态激活 AuthenticationService.getAuthentication().success(function (data) { data.enterprise = {}; angular.forEach(data.enterprises, function (item) { if (item.current) { data.enterprise = item; return; } }); $rootScope.userInfo = data; $rootScope.userInfo.enterprise.enName ? $rootScope.personage = true : $rootScope.personage = false; if ($rootScope.userInfo.enterprise) { $rootScope.userInfo.enterprise.enAdminuu === $rootScope.userInfo.userUU ? $rootScope.isAdmin = true : $rootScope.isAdmin = false; } else { $rootScope.isAdmin = false } }).error(function (error) { toaster.pop('error', '获取登录信息失败'); }) }]); app.controller('UserCenterHeaderCtrl', ['$scope', 'InternalMessage', /*'$rootScope',, '$q',*/ function ($scope, InternalMessage/*, $rootScope, , $q*/) { $scope.homeUrl = window.location.pathname.replace('/user', ''); // 获取未读消息数量 //根据用户的信息 InternalMessage.getUnReadCount({recRole: 'BUYER'}, function (data) { $scope.unReadMessage = data.count || 0; }, function (responge) { }) }]); app.controller('CollectCtrl', ['$scope', 'collectionService', 'toaster', '$rootScope', '$modal', function ($scope, collectionService, toaster, $rootScope, $modal) { $scope.collect = function (id) { var obj = {'componentid': id, 'kind': 2}; collectionService.saveEntity({}, obj, function(data) { // 打开莫模态框 $modal.open({ templateUrl : $rootScope.rootPath + '/static/view/usercenter/modal/collectModel.html', controller : 'CollectModelCtrl', size : 'sm', resolve : { haveAdd : function(){ if (data.data == "success"){ return true; } else{ return false; } } } }); $rootScope.componentCount++; }, function(error) { toaster.pop('error', '收藏失败', error); }); } }]); app.controller('CollectModelCtrl', ['$scope', '$modalInstance', 'haveAdd', function($scope, $modalInstance, haveAdd){ $scope.haveAdd = haveAdd; $scope.cancel = function() { $modalInstance.dismiss(); }; }]) app.controller('BankFeedBackCtrl', ['$scope','$modalInstance', function($scope, $modalInstance) { $scope.confirm = function() { $modalInstance.close(); }; $scope.dismiss = function() { $modalInstance.dismiss(); } }]); //物流信息 app.controller('listLogisticsCtrl', [ '$scope', '$modal', 'ResponseLogistics', '$modalInstance', 'lgtid', function($scope, $modal, ResponseLogistics, $modalInstance, lgtid){ $scope.Info = []; $scope.getlogistics = function() { ResponseLogistics.get({id: lgtid}, {}, function(data) { $scope.Info = data; }); }; $scope.getlogistics(); $scope.cancel = function() { $modalInstance.dismiss(); }; }]); app.filter('currencySysmbol', function() { return function(moneyParam, currency, add) { if(typeof(moneyParam) == 'undefined') { moneyParam = 0; } if(currency == 'RMB') { return "¥ " + moneyParam + " " + (typeof(add) == "undefined" ? '' : add); }else if(currency == "USD"){ return "$ " + moneyParam; }else { return moneyParam; } } }); app.filter('emailSymbol', function() { return function(email) { if(typeof(email) == 'undefined') { email = ''; } else { var index = email.indexOf('@'); email = email[0] + '***' + email.substring(index, email.length); } return email; } }); app.filter('telPhoneSymbol', function() { return function(telPhone) { if(typeof(telPhone) == 'undefined') { telPhone = ''; } else { telPhone = telPhone.substring(0, 3) + '****' + telPhone.substring(telPhone.length - 4, telPhone.length); } return telPhone; } }); app.filter('billTypeFilter', function() { return function(type) { var kindStr; switch(type) { case 1205 : kindStr = "增值税(专用)发票";break; case '1205' : kindStr = "增值税(专用)发票";break; case 1206 : kindStr = "增值税普通发票"; break; default: kindStr = "增值税普通发票"; break; } return kindStr; } }); /** * 配送规则提示共用控制器 */ app.controller('rule_tip_ctrl', ['$scope', 'toaster', '$modalInstance', 'type', 'tipModal', 'success', 'uuid', function ($scope, toaster, $modalInstance, type, tipModal, success, uuid) { $scope.tipModal = tipModal; $scope.type = type; $scope.success = success; $scope.uuid = uuid; $scope.cancelDelete = function () { $scope.tipModal = false; $modalInstance.dismiss(); }; $scope.hrefToNext = function (url) { $modalInstance.dismiss(); window.location.href = url; }; /** * 监听点击的事件 */ document.onclick = function (event) { if ($scope.tipModal) { if(event) { var tag = event.target; if(tag) { var attribute = tag.getAttribute("name"); while(tag.nodeName != 'BODY') { if(attribute == 'rule_model' || attribute == 'rule_cancel' || attribute == 'rule_href') { return ; } tag = tag.parentElement; attribute = tag.getAttribute("name"); } $scope.$apply(function () { $scope.tipModal = false; $modalInstance.close(); }); } } } }; }]); /** * 买家中心头部 */ app.controller('UserCenterHeaderCtrl', ['$scope', '$rootScope', 'BaseService', 'InternalMessage', '$http', 'toaster', function ($scope, $rootScope, BaseService, InternalMessage, $http, toaster) { $scope.homeUrl = BaseService.getRootPath(); InternalMessage.getUrl({}, function(data) { var url = data.url; if (url == "http://192.168.100.2:8080") { url = 'https://test-message.uuzcc.cn'; } var param = { 'receiverUu': data.userUU, 'receiverEnuu': data.enUU, 'consumerApp': 'MALL', 'isRead': 0 }; $http({ method: 'get', dataType: 'json', url: url + '/messages/count', params: param }).success(function (data) { $rootScope.unReadMessCount = data.count; }).error(function (err) { toaster.pop('error', err || '获取未读消息数量失败'); }); }); // InternalMessage.getUnread({isRead: 0}, function (data) { // $rootScope.unReadMessCount = data.toRead; // }, function (err) { // toaster.pop('error', err || '获取未读消息数量失败'); // }) }]); /*InternalMessage.getUnread({isRead: 0}, function (data) { $rootScope.unReadMessCount = data.toRead; }, function (err) { toaster.pop('error', err || '获取未读消息数量失败'); }) }]);*/ /** * 采购单状态 */ app.filter('orderStatus', function() { return function(status) { if (!status || status == '') { status = 501; } if (status == 501 || status == 503 || status == 504 || status == 524 || status == 525) { return '待付款'; } else if (status == 505 || status == 406 || status == 407 || status == 403 || status == 408) { return '待发货'; } else if (status == 404) { return '待收货'; } else if (status == 405) { return '待收款'; } else if (status == 520){ return '交易完成'; } else { return '已取消'; } } }); // 币别filter app.filter('currencyStr', function () { return function (str) { return typeof str == 'string' && str != 'RMB' && str != 'USD' ? str.startsWith('RMB') ? '¥' + str.substring(3, str.length) : '$' + str.substring(3, str.length) : '-'; } }); return app; });