app.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. 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) {
  2. 'use strict';
  3. 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']);
  4. app.init = function() {
  5. angularAMD.bootstrap(app);
  6. };
  7. if (!Array.prototype.last){
  8. Array.prototype.last = function(){
  9. return this.length > 0 ? this[this.length - 1] : null;
  10. };
  11. }
  12. if (!Array.prototype.first){
  13. Array.prototype.first = function(){
  14. return this.length > 0 ? this[0] : null;
  15. };
  16. }
  17. // ui-router 路由配置
  18. app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', function($stateProvider, $urlRouterProvider, $httpProvider){
  19. $urlRouterProvider.otherwise("/index");
  20. // 设置该app下js访问带cookie
  21. $httpProvider.defaults.withCredentials = true;
  22. $stateProvider.state('ssoIndex', angularAMD.route({
  23. url: '/index',
  24. templateUrl: 'static/view/sso/forstore/ssoCenter.html',
  25. title: '帐户中心首页',
  26. controller : 'ssoCenterCtrl',
  27. controllerUrl : 'app/controllers/forstore/ssoCenterCtrl'
  28. })).state('ssoInfo', angularAMD.route({
  29. url: '/info',
  30. templateUrl: 'static/view/sso/ssoInfo.html',
  31. title: '基本信息',
  32. controller: 'ssoInfoCtrl',
  33. controllerUrl: 'app/controllers/ssoInfoCtrl'
  34. })).state('ssoSecurity', angularAMD.route({
  35. url: '/security',
  36. templateUrl: 'static/view/sso/securitySet.html',
  37. title: '安全设置',
  38. controller: 'securitySetCtrl',
  39. controllerUrl: 'app/controllers/securitySetCtrl'
  40. })).state('ssoManagement', angularAMD.route({
  41. url: '/management?tab',
  42. templateUrl: 'static/view/sso/staffManagement.html',
  43. title: '员工管理',
  44. controller: 'staffManagementCtrl',
  45. controllerUrl: 'app/controllers/staffManagementCtrl'
  46. })).state('ssoPermission', angularAMD.route({
  47. url: '/permission',
  48. templateUrl: 'static/view/sso/rolePermission.html',
  49. title: '角色权限',
  50. controller: 'rolePermissionCtrl',
  51. controllerUrl: 'app/controllers/rolePermissionCtrl'
  52. })).state('ssoAddress', angularAMD.route({
  53. url: '/address',
  54. templateUrl: 'static/view/sso/ssoAddress.html',
  55. title: '收货地址',
  56. controller: 'ssoAddressCtrl',
  57. controllerUrl: 'app/controllers/ssoAddressCtrl'
  58. })).state('ssoInvoice', angularAMD.route({
  59. url: '/invoice',
  60. templateUrl: 'static/view/sso/ssoInvoice.html',
  61. title: '发票管理',
  62. controller: 'ssoInvoiceCtrl',
  63. controllerUrl: 'app/controllers/ssoInvoiceCtrl'
  64. })).state('payAccount', angularAMD.route({
  65. url: '/payAccount?status',
  66. title: '付款账户',
  67. templateUrl: 'static/view/usercenter/forstore/pay_center.html',
  68. controller: 'buyerPayCenterCtrl',
  69. controllerUrl: 'js/usercenter/controllers/forstore/pay_center_ctrl'
  70. })).state('gatheringAccount', angularAMD.route({
  71. url: '/gatheringAccount?tab',
  72. templateUrl: 'static/view/vendor/forstore/pay_center.html',
  73. title: '收款账户',
  74. controller: 'vendorPayCenterCtrl',
  75. controllerUrl: 'js/vendor/controllers/forstore/pay_center_ctrl'
  76. })).state('approvalflow_log', angularAMD.route({
  77. url: "/approvalflow/log",
  78. templateUrl: "static/view/sso/b2b/log.html",
  79. controller: 'LogCtrl',
  80. controllerUrl: 'js/sso/controllers/b2b/LogCtrl'
  81. })).state('approvalflow_flow', angularAMD.route({
  82. url: "/approvalflow/flow",
  83. templateUrl: "static/view/sso/b2b/home.html",
  84. controller: 'approvalFlowCtrl',
  85. controllerUrl: 'js/sso/controllers/b2b/approvalFlowCtrl'
  86. })).state('baseInfo_myRequest', angularAMD.route({
  87. url: "/myRequest",
  88. title: 'b2b企业圈-我的合作伙伴(全部)',
  89. templateUrl: 'static/view/sso/b2b/myRequest.html',
  90. controller: 'AddPartnerRequestCtrl',
  91. controllerUrl: 'app/controllers/b2b/addPartnerRequestCtrl'
  92. })).state('baseInfo_vendorInfo', angularAMD.route({
  93. url: "/enume/vendorInfo",
  94. title: 'b2b企业圈-我的合作伙伴(供应商)',
  95. templateUrl: 'static/view/sso/b2b/vendorsInfo.html',
  96. controller: 'VendorsInfoCtrl',
  97. controllerUrl: 'app/controllers/b2b/vendorsInfoCtrl'
  98. })).state('baseInfo_customerInfo', angularAMD.route({
  99. url: "/enume/customerInfo",
  100. title: 'b2b企业圈-我的合作伙伴(客户)',
  101. templateUrl: 'static/view/sso/b2b/customersInfo.html',
  102. controller: 'CustomersInfoCtrl',
  103. controllerUrl: 'app/controllers/b2b/customersInfoCtrl'
  104. })).state('baseInfo_servicerInfo', angularAMD.route({
  105. url: "/enume/servicerInfo",
  106. title: 'b2b企业圈-我的合作伙伴(服务商)',
  107. templateUrl: 'static/view/sso/b2b/servicerInfo.html',
  108. controller: 'ServicerInfoCtrl',
  109. controllerUrl: 'app/controllers/b2b/servicerInfoCtrl'
  110. })).state('baseInfo_newPartner', angularAMD.route({
  111. url: "/newPartner",
  112. title: 'b2b企业圈-新的合作伙伴',
  113. templateUrl: "static/view/sso/b2b/newPartner.html",
  114. controller: 'NewPartnerCtrl',
  115. controllerUrl: 'app/controllers/b2b/newPartnerCtrl'
  116. })).state('baseInfo_invitation', angularAMD.route({
  117. url: "/enume/invitation",
  118. title: 'b2b企业圈-邀请注册记录',
  119. templateUrl: "static/view/sso/b2b/invitation.html",
  120. controller: 'InvitationCtrl',
  121. controllerUrl: 'app/controllers/b2b/invitationCtrl'
  122. })).state('partner_searchresult', angularAMD.route({
  123. url: "/enume/searchresult",
  124. title: 'b2b企业圈-邀请注册记录',
  125. templateUrl: "static/view/sso/b2b/searchresult.html",
  126. controller: 'EnterpriseSearchCtrl',
  127. controllerUrl: 'app/controllers/b2b/enterpriseSearchCtrl'
  128. }))
  129. }]);
  130. // 高亮显示关键词
  131. app.filter('getkey', ['$sce', '$rootScope', function ($sce, $rootScope) {
  132. var search = $rootScope.searchKeyword;
  133. return function (content, search) {
  134. content = encodeURI(content);
  135. search = encodeURI(search);
  136. var reg = new RegExp(search, 'gim');
  137. var result = content.replace(reg, '<font color="red">$&</font>');
  138. result = decodeURIComponent(result);
  139. return $sce.trustAsHtml(result);
  140. };
  141. $rootScope.searchKeyword = null;// 清除缓存的关键字
  142. }]);
  143. // 状态码 -> 描述
  144. app.filter('status', function(){
  145. var statusConfig = {
  146. '101': '已提交',
  147. '102': '已审核',
  148. '103': '未通过',
  149. '104': '已通过',
  150. '313': '已激活',
  151. '316': '已过账',
  152. '310': '未启用',
  153. '311': '待审核',
  154. '312': '未激活',
  155. '350': '未开通',
  156. '351': '已开通',
  157. '317': '已创建'
  158. };
  159. return function(data) {
  160. return statusConfig[data];
  161. }
  162. });
  163. // 状态码 -> 快递
  164. app.filter('logisticsCompany', function(){
  165. var logisticsCompanyConfig = {
  166. 'aae': 'AAE快递',
  167. 'aramex': 'Aramex快递',
  168. 'auspost': '澳大利亚邮政',
  169. 'annengwuliu': '安能物流快递',
  170. 'bht': 'BHT快递',
  171. 'baifudongfang': '百福东方物流',
  172. 'bangsongwuliu': '邦送物流',
  173. 'huitongkuaidi': '百世汇通快递',
  174. 'idada': '百成大达物流',
  175. 'coe': 'COE(东方快递)',
  176. 'city100': '城市100',
  177. 'chuanxiwuliu': '传喜物流',
  178. 'depx': 'DPEX',
  179. 'disifang': '递四方',
  180. 'dsukuaidi': 'D速物流',
  181. 'debangwuliu': '德邦物流',
  182. 'datianwuliu': '大田物流',
  183. 'dhl': 'DHL国际快递',
  184. 'dhlen': 'DHL(国际件)',
  185. 'dhlde': 'DHL(德国件)',
  186. 'dhlpoland': 'DHL(波兰件)',
  187. 'ems': 'EMS快递',
  188. 'emsguoji': 'EMS国际',
  189. 'fedex': 'FedEx(国际)',
  190. 'fedexus': 'FedEx(美国)',
  191. 'rufengda': '凡客如风大',
  192. 'feikangda': '飞康达物流',
  193. 'feibaokuaidi': '飞豹快递',
  194. 'fardarww': 'Fardar Worldwide',
  195. 'fandaguoji': '颿达国际',
  196. 'fedexuk': 'FedEx(英国件)',
  197. 'gangzhongnengda': '港中能达物流',
  198. 'gongsuda': '共速达',
  199. 'guotongkuaidi': '国通快递',
  200. 'gls': 'GLS',
  201. 'tiandihuayu': '华宇物流',
  202. 'hengluwuliu': '恒路物流',
  203. 'huaxialongwuliu': '华夏龙物流',
  204. 'hebeijianhua': '河北建华',
  205. 'jiajiwuliu': '佳吉物流',
  206. 'jiayiwuliu': '佳怡物流',
  207. 'jiayunmeiwuliu': '加运美快递',
  208. 'jixianda': '急先达物流',
  209. 'jinguangsudikuaijian': '京广速递快件',
  210. 'jinyuekuaidi': '晋越快递',
  211. 'jialidatong': '嘉里大通',
  212. 'jietekuaidi': '捷特快递',
  213. 'jd': '京东快递',
  214. 'jindawuliu': '金大物流',
  215. 'kuaijiesudi': '快捷快递',
  216. 'kangliwuliu': '康力物流',
  217. 'kuayue': '跨越物流',
  218. 'lianhaowuliu': '联昊通物流',
  219. 'longbangwuliu': '龙邦速递',
  220. 'lianbangkuaidi': '联邦快递',
  221. 'lejiedi': '乐捷递',
  222. 'lijisong': '立即送',
  223. 'minghangkuaidi': '民航快递',
  224. 'meiguokuaidi': '美国快递',
  225. 'menduimen': '门对门',
  226. 'mingliangwuliu': '明亮物流',
  227. 'ganzhongnengda': '能达速递',
  228. 'ocs': 'OCS',
  229. 'ontrac': 'OnTrac',
  230. 'pingandatengfei': '平安达腾飞',
  231. 'peixingwuliu': '陪行物流',
  232. 'quanfengkuaidi': '全峰快递',
  233. 'quanyikuaidi': '全一快递',
  234. 'quanritongkuaidi': '全日通快递',
  235. 'quanchenkuaidi': '全晨快递',
  236. 'sevendays': '7天连锁物流',
  237. 'shentong': '申通快递',
  238. 'shunfeng': '顺丰速运',
  239. 'suer': '速尔快递',
  240. 'haihongwangsong': '山东海红',
  241. 'shenghuiwuliu': '盛辉物流',
  242. 'shengfengwuliu': '盛丰物流',
  243. 'shangda': '上大物流',
  244. 'santaisudi': '三态速递',
  245. 'saiaodi': '赛澳递',
  246. 'shenganwuliu': '圣安物流',
  247. 'sxhongmajia': '山西红马甲',
  248. 'suijiawuliu': '穗佳物流',
  249. 'syjiahuier': '沈阳佳惠尔',
  250. 'tnt': 'TNT快递',
  251. 'tiantian': '天天快递',
  252. 'tonghetianxia': '通和天下',
  253. 'tianzong': '天纵物流',
  254. 'tntuk': 'TNT(英国件)',
  255. 'ups': 'UPS国际快递',
  256. 'wanxiangwuliu': '万象物流',
  257. 'weitepai': '微特派',
  258. 'wanjiawuliu': '万家物流',
  259. 'xinbangwuliu': '新邦物流',
  260. 'xinfengwuliu': '信丰物流',
  261. 'neweggozzo': '新蛋物流',
  262. 'hkpost': '香港邮政',
  263. 'xianglongyuntong': '祥龙运通物流',
  264. 'xianchengliansudi': '西安城联速递',
  265. 'yuantong': '圆通速递',
  266. 'yunda': '韵达快运',
  267. 'yuntongkuaidi': '运通快递',
  268. 'youzhengguonei': '邮政国内',
  269. 'youzhengguoji': '邮政国际',
  270. 'yuanchengwuliu': '远成物流',
  271. 'yafengsudi': '亚风速递',
  272. 'youshuwuliu': '优速快递',
  273. 'yuananda': '源安达快递',
  274. 'yuanfeihangwuliu': '原飞航物流',
  275. 'yuefengwuliu': '越丰物流',
  276. 'zhongtong': '中通快递',
  277. 'zhaijisong': '宅急送',
  278. 'zhongtiewuliu': '中铁快运',
  279. 'ztky': '中铁物流',
  280. 'zhongyouwuliu': '中邮物流',
  281. 'zhongtianwanyun': '中天万运',
  282. 'zhengzhoujianhua': '郑州建华',
  283. 'zhimakaimen': '芝麻开门'
  284. };
  285. return function(data) {
  286. return logisticsCompanyConfig[data];
  287. }
  288. });
  289. app.run(['$rootScope', 'BaseService', 'AuthenticationService', function($rootScope, BaseService, AuthenticationService) {
  290. $rootScope.rootPath = BaseService.getRootPath();
  291. $rootScope.page = 'sso';// 导航栏状态,'帐户中心'状态激活
  292. AuthenticationService.getAuthentication().success(function (data) {
  293. data.enterprise = {};
  294. angular.forEach(data.enterprises, function (item) {
  295. if (item.current) {
  296. data.enterprise = item;
  297. return;
  298. }
  299. });
  300. $rootScope.userInfo = data;
  301. $rootScope.userInfo.enterprise.enName ? $rootScope.personage = true : $rootScope.personage = false;
  302. if ($rootScope.userInfo.enterprise) {
  303. $rootScope.userInfo.enterprise.enAdminuu === $rootScope.userInfo.userUU ? $rootScope.isAdmin = true : $rootScope.isAdmin = false;
  304. } else {
  305. $rootScope.isAdmin = false
  306. }
  307. }).error(function (error) {
  308. toaster.pop('error', '获取登录信息失败');
  309. })
  310. }]);
  311. app.controller('UserCenterHeaderCtrl', ['$scope', 'InternalMessage', /*'$rootScope',, '$q',*/ function ($scope, InternalMessage/*, $rootScope, , $q*/) {
  312. $scope.homeUrl = window.location.pathname.replace('/user', '');
  313. // 获取未读消息数量
  314. //根据用户的信息
  315. InternalMessage.getUnReadCount({recRole: 'BUYER'}, function (data) {
  316. $scope.unReadMessage = data.count || 0;
  317. }, function (responge) {
  318. })
  319. }]);
  320. app.controller('CollectCtrl', ['$scope', 'collectionService', 'toaster', '$rootScope', '$modal', function ($scope, collectionService, toaster, $rootScope, $modal) {
  321. $scope.collect = function (id) {
  322. var obj = {'componentid': id, 'kind': 2};
  323. collectionService.saveEntity({}, obj, function(data) {
  324. // 打开莫模态框
  325. $modal.open({
  326. templateUrl : $rootScope.rootPath + '/static/view/usercenter/modal/collectModel.html',
  327. controller : 'CollectModelCtrl',
  328. size : 'sm',
  329. resolve : {
  330. haveAdd : function(){
  331. if (data.data == "success"){
  332. return true;
  333. } else{
  334. return false;
  335. }
  336. }
  337. }
  338. });
  339. $rootScope.componentCount++;
  340. }, function(error) {
  341. toaster.pop('error', '收藏失败', error);
  342. });
  343. }
  344. }]);
  345. app.controller('CollectModelCtrl', ['$scope', '$modalInstance', 'haveAdd', function($scope, $modalInstance, haveAdd){
  346. $scope.haveAdd = haveAdd;
  347. $scope.cancel = function() {
  348. $modalInstance.dismiss();
  349. };
  350. }])
  351. app.controller('BankFeedBackCtrl', ['$scope','$modalInstance', function($scope, $modalInstance) {
  352. $scope.confirm = function() {
  353. $modalInstance.close();
  354. };
  355. $scope.dismiss = function() {
  356. $modalInstance.dismiss();
  357. }
  358. }]);
  359. //物流信息
  360. app.controller('listLogisticsCtrl', [ '$scope', '$modal', 'ResponseLogistics', '$modalInstance', 'lgtid', function($scope, $modal, ResponseLogistics, $modalInstance, lgtid){
  361. $scope.Info = [];
  362. $scope.getlogistics = function() {
  363. ResponseLogistics.get({id: lgtid}, {}, function(data) {
  364. $scope.Info = data;
  365. });
  366. };
  367. $scope.getlogistics();
  368. $scope.cancel = function() {
  369. $modalInstance.dismiss();
  370. };
  371. }]);
  372. app.filter('currencySysmbol', function() {
  373. return function(moneyParam, currency, add) {
  374. if(typeof(moneyParam) == 'undefined') {
  375. moneyParam = 0;
  376. }
  377. if(currency == 'RMB') {
  378. return "¥ " + moneyParam + " " + (typeof(add) == "undefined" ? '' : add);
  379. }else if(currency == "USD"){
  380. return "$ " + moneyParam;
  381. }else {
  382. return moneyParam;
  383. }
  384. }
  385. });
  386. app.filter('emailSymbol', function() {
  387. return function(email) {
  388. if(typeof(email) == 'undefined') {
  389. email = '';
  390. } else {
  391. var index = email.indexOf('@');
  392. email = email[0] + '***' + email.substring(index, email.length);
  393. }
  394. return email;
  395. }
  396. });
  397. app.filter('telPhoneSymbol', function() {
  398. return function(telPhone) {
  399. if(typeof(telPhone) == 'undefined') {
  400. telPhone = '';
  401. } else {
  402. telPhone = telPhone.substring(0, 3) + '****' + telPhone.substring(telPhone.length - 4, telPhone.length);
  403. }
  404. return telPhone;
  405. }
  406. });
  407. app.filter('billTypeFilter', function() {
  408. return function(type) {
  409. var kindStr;
  410. switch(type) {
  411. case 1205 :
  412. kindStr = "增值税(专用)发票";break;
  413. case '1205' :
  414. kindStr = "增值税(专用)发票";break;
  415. case 1206 :
  416. kindStr = "增值税普通发票"; break;
  417. default:
  418. kindStr = "增值税普通发票"; break;
  419. }
  420. return kindStr;
  421. }
  422. });
  423. /**
  424. * 配送规则提示共用控制器
  425. */
  426. app.controller('rule_tip_ctrl', ['$scope', 'toaster', '$modalInstance', 'type', 'tipModal', 'success', 'uuid', function ($scope, toaster, $modalInstance, type, tipModal, success, uuid) {
  427. $scope.tipModal = tipModal;
  428. $scope.type = type;
  429. $scope.success = success;
  430. $scope.uuid = uuid;
  431. $scope.cancelDelete = function () {
  432. $scope.tipModal = false;
  433. $modalInstance.dismiss();
  434. };
  435. $scope.hrefToNext = function (url) {
  436. $modalInstance.dismiss();
  437. window.location.href = url;
  438. };
  439. /**
  440. * 监听点击的事件
  441. */
  442. document.onclick = function (event) {
  443. if ($scope.tipModal) {
  444. if(event) {
  445. var tag = event.target;
  446. if(tag) {
  447. var attribute = tag.getAttribute("name");
  448. while(tag.nodeName != 'BODY') {
  449. if(attribute == 'rule_model' ||
  450. attribute == 'rule_cancel' || attribute == 'rule_href') {
  451. return ;
  452. }
  453. tag = tag.parentElement;
  454. attribute = tag.getAttribute("name");
  455. }
  456. $scope.$apply(function () {
  457. $scope.tipModal = false;
  458. $modalInstance.close();
  459. });
  460. }
  461. }
  462. }
  463. };
  464. }]);
  465. /**
  466. * 买家中心头部
  467. */
  468. app.controller('UserCenterHeaderCtrl', ['$scope', '$rootScope', 'BaseService', 'InternalMessage', '$http', 'toaster', function ($scope, $rootScope, BaseService, InternalMessage, $http, toaster) {
  469. $scope.homeUrl = BaseService.getRootPath();
  470. InternalMessage.getUrl({}, function(data) {
  471. var url = data.url;
  472. if (url == "http://192.168.100.2:8080") {
  473. url = 'https://test-message.uuzcc.cn';
  474. }
  475. var param = {
  476. 'receiverUu': data.userUU,
  477. 'receiverEnuu': data.enUU,
  478. 'consumerApp': 'MALL',
  479. 'isRead': 0
  480. };
  481. $http({
  482. method: 'get',
  483. dataType: 'json',
  484. url: url + '/messages/count',
  485. params: param
  486. }).success(function (data) {
  487. $rootScope.unReadMessCount = data.count;
  488. }).error(function (err) {
  489. toaster.pop('error', err || '获取未读消息数量失败');
  490. });
  491. });
  492. // InternalMessage.getUnread({isRead: 0}, function (data) {
  493. // $rootScope.unReadMessCount = data.toRead;
  494. // }, function (err) {
  495. // toaster.pop('error', err || '获取未读消息数量失败');
  496. // })
  497. }]);
  498. /*InternalMessage.getUnread({isRead: 0}, function (data) {
  499. $rootScope.unReadMessCount = data.toRead;
  500. }, function (err) {
  501. toaster.pop('error', err || '获取未读消息数量失败');
  502. })
  503. }]);*/
  504. /**
  505. * 采购单状态
  506. */
  507. app.filter('orderStatus', function() {
  508. return function(status) {
  509. if (!status || status == '') {
  510. status = 501;
  511. }
  512. if (status == 501 || status == 503 || status == 504 || status == 524 || status == 525) {
  513. return '待付款';
  514. } else if (status == 505 || status == 406 || status == 407 || status == 403 || status == 408) {
  515. return '待发货';
  516. } else if (status == 404) {
  517. return '待收货';
  518. } else if (status == 405) {
  519. return '待收款';
  520. } else if (status == 520){
  521. return '交易完成';
  522. } else {
  523. return '已取消';
  524. }
  525. }
  526. });
  527. // 币别filter
  528. app.filter('currencyStr', function () {
  529. return function (str) {
  530. return typeof str == 'string' && str != 'RMB' && str != 'USD' ? str.startsWith('RMB') ? '¥' + str.substring(3, str.length) : '$' + str.substring(3, str.length) : '-';
  531. }
  532. });
  533. return app;
  534. });