factory.js 899 B

123456789101112131415161718192021222324
  1. starter.factory('User', function ($resource, $q, $filter, cfg, formatFilter, global) {
  2. global.erp_api = "http://192.168.1.36:13210/api/";
  3. return {
  4. sn: $resource(formatFilter('{0}erp/comp/', cfg.api)),
  5. user: function (actionname) {
  6. return $resource(formatFilter('{0}ext_erp/Comp/{1}/0/', cfg.api, actionname == undefined ? "" : actionname))
  7. }
  8. };
  9. })
  10. .config(function ($httpProvider) {
  11. $httpProvider.interceptors.push(function ($q, cfg, global) {
  12. return {
  13. 'request': function (config) {
  14. if (config.url.indexOf("ext_erp") != -1) {
  15. config.headers['cid'] = JSON.stringify({"linkid": global.user.compno, "langid": "TW", "phone": global.user.cellphone});
  16. // config.headers['sn'] = global.sn;
  17. }
  18. return config;
  19. }
  20. };
  21. });
  22. })