多租户商城-商户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.8 KiB

  1. const ShopIdKey = 'cereShopId'
  2. const ProjectKey = 'project'
  3. export function setShopId(shopId) {
  4. return sessionStorage.setItem(ShopIdKey, shopId)
  5. }
  6. export function getShopId() {
  7. var fullUrl = window.location.search;
  8. if (fullUrl.indexOf("?") != -1) {
  9. fullUrl = fullUrl.substring(1);
  10. var paramStrs = fullUrl.split("&");
  11. for(let i=0;i<paramStrs.length;i++){
  12. const newStrs = paramStrs[i].split("=");
  13. if(newStrs[0] === ShopIdKey){
  14. return newStrs[1];
  15. }
  16. }
  17. }
  18. return localStorage.getItem(ShopIdKey)
  19. }
  20. export function initShopId() {
  21. var fullUrl = window.location.search;
  22. var cereShopId = '0';
  23. if (fullUrl.indexOf("?") != -1) {
  24. fullUrl = fullUrl.substring(1);
  25. var paramStrs = fullUrl.split("&");
  26. for(let i=0;i<paramStrs.length;i++){
  27. const newStrs = paramStrs[i].split("=");
  28. if(newStrs[0] === ShopIdKey){
  29. cereShopId = newStrs[1];
  30. break;
  31. }
  32. }
  33. }
  34. sessionStorage.setItem(ShopIdKey, cereShopId)
  35. }
  36. export function getProject() {
  37. var fullUrl = window.location.search;
  38. if (fullUrl.indexOf("?") != -1) {
  39. fullUrl = fullUrl.substring(1);
  40. var paramStrs = fullUrl.split("&");
  41. for(let i=0;i<paramStrs.length;i++){
  42. const newStrs = paramStrs[i].split("=");
  43. if(newStrs[0] === ProjectKey){
  44. return newStrs[1];
  45. }
  46. }
  47. }
  48. return localStorage.getItem(ProjectKey)
  49. }
  50. export function initProject() {
  51. var fullUrl = window.location.search;
  52. var cereShopId = '0';
  53. if (fullUrl.indexOf("?") != -1) {
  54. fullUrl = fullUrl.substring(1);
  55. var paramStrs = fullUrl.split("&");
  56. for(let i=0;i<paramStrs.length;i++){
  57. const newStrs = paramStrs[i].split("=");
  58. if(newStrs[0] === ProjectKey){
  59. cereShopId = newStrs[1];
  60. break;
  61. }
  62. }
  63. }
  64. sessionStorage.setItem(ProjectKey, cereShopId)
  65. }