cyy-vue-material 1.0.19 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,76 +1,76 @@
1
- import { queryResourceGoodsPagePalt } from '../api/index.js';
2
- import { isLc } from './checkEnv';
3
- import { isEmpty, isEqual } from 'lodash-es';
4
-
5
- const handleParams = (obj) => {
6
- const formData = new URLSearchParams();
7
- for (let key in obj) {
8
- formData.append(key, obj[key]);
9
- }
10
- return formData;
11
- };
12
-
13
- const fetchGoodsInfo = (id) => {
14
- const { mGoodsInfo } = goodsCache[id];
15
- return mGoodsInfo;
16
- };
17
-
18
- const setGoodsInfo = (id, goods, data) => {
19
- goodsCache[id] = {
20
- mGoodsInfo: data,
21
- mGoods: goods
22
- };
23
- };
24
-
25
- const handleCache = (that) => {
26
- const { goods, id } = that.props;
27
- const { mGoods } = goodsCache[id] || {};
28
- return isEqual(goods, mGoods);
29
- };
30
-
31
- const fetchIO = async (that, paramObj) => {
32
- const { id, goods } = that.props;
33
- if (isEmpty(goods)) return Promise.resolve({ list: [] });
34
-
35
- const isEqualFlag = handleCache(that);
36
-
37
- if (isEqualFlag) {
38
- return Promise.resolve(fetchGoodsInfo(id));
39
- }
40
-
41
- const saasToken = localStorage.getItem('saas-token');
42
-
43
- return await fetch(
44
- process.env.REACT_APP_BASE_URL + queryResourceGoodsPagePalt,
45
- {
46
- method: 'POST',
47
- headers: {
48
- 'saas-token': saasToken,
49
- 'user-agent':
50
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36',
51
- 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
52
- },
53
- body: handleParams(paramObj)
54
- }
55
- )
56
- .then((res) => res.json())
57
- .then((res = {}) => {
58
- setGoodsInfo(id, goods, res);
59
- return res;
60
- });
61
- };
62
-
63
- const uniIo = (that, paramObj) => {
64
- return that.$ajax.run('find', paramObj);
65
- };
66
-
67
- function getGoodsImpl() {
68
- if (isLc) {
69
- return fetchIO;
70
- }
71
- return uniIo;
72
- }
73
-
74
- export const fetchGoodImpl = getGoodsImpl();
75
-
76
- export const goodsCache = {};
1
+ import { queryResourceGoodsPagePalt } from '../api/index.js';
2
+ import { isLc } from './checkEnv';
3
+ import { isEmpty, isEqual } from 'lodash-es';
4
+
5
+ const handleParams = (obj) => {
6
+ const formData = new URLSearchParams();
7
+ for (let key in obj) {
8
+ formData.append(key, obj[key]);
9
+ }
10
+ return formData;
11
+ };
12
+
13
+ const fetchGoodsInfo = (id) => {
14
+ const { mGoodsInfo } = goodsCache[id];
15
+ return mGoodsInfo;
16
+ };
17
+
18
+ const setGoodsInfo = (id, goods, data) => {
19
+ goodsCache[id] = {
20
+ mGoodsInfo: data,
21
+ mGoods: goods
22
+ };
23
+ };
24
+
25
+ const handleCache = (that) => {
26
+ const { goods, id } = that.props;
27
+ const { mGoods } = goodsCache[id] || {};
28
+ return isEqual(goods, mGoods);
29
+ };
30
+
31
+ const fetchIO = async (that, paramObj) => {
32
+ const { id, goods } = that.props;
33
+ if (isEmpty(goods)) return Promise.resolve({ list: [] });
34
+
35
+ const isEqualFlag = handleCache(that);
36
+
37
+ if (isEqualFlag) {
38
+ return Promise.resolve(fetchGoodsInfo(id));
39
+ }
40
+
41
+ const saasToken = localStorage.getItem('saas-token');
42
+
43
+ return await fetch(
44
+ process.env.REACT_APP_BASE_URL + queryResourceGoodsPagePalt,
45
+ {
46
+ method: 'POST',
47
+ headers: {
48
+ 'saas-token': saasToken,
49
+ 'user-agent':
50
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36',
51
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
52
+ },
53
+ body: handleParams(paramObj)
54
+ }
55
+ )
56
+ .then((res) => res.json())
57
+ .then((res = {}) => {
58
+ setGoodsInfo(id, goods, res);
59
+ return res;
60
+ });
61
+ };
62
+
63
+ const uniIo = (that, paramObj) => {
64
+ return that.$ajax.run('find', paramObj);
65
+ };
66
+
67
+ function getGoodsImpl() {
68
+ if (isLc) {
69
+ return fetchIO;
70
+ }
71
+ return uniIo;
72
+ }
73
+
74
+ export const fetchGoodImpl = getGoodsImpl();
75
+
76
+ export const goodsCache = {};
@@ -1,2 +1,2 @@
1
- export * from './checkEnv.js';
2
- export * from './fetchFactory';
1
+ export * from './checkEnv.js';
2
+ export * from './fetchFactory';