cyy-vue-material 1.0.10
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.
- package/dist/index.js +1 -0
- package/package.json +32 -0
- package/src/api/index.js +3 -0
- package/src/common/js/constant.js +5 -0
- package/src/common/js/index.js +1 -0
- package/src/index.js +19 -0
- package/src/package/cyy-goods/cyy-goods.vue +153 -0
- package/src/package/cyy-goodsOne/consult.vue +267 -0
- package/src/package/cyy-goodsOne/cyy-goodsOne.vue +241 -0
- package/src/package/cyy-image/cyy-image.vue +79 -0
- package/src/package/cyy-search/cyy-search.vue +67 -0
- package/src/package/cyy-slider/cyy-slider.vue +117 -0
- package/src/package/cyy-title/cyy-title.vue +46 -0
- package/src/package/index.js +6 -0
- package/src/utils/checkEnv.js +16 -0
- package/src/utils/fetchFactory.js +76 -0
- package/src/utils/index.js +2 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div v-for="(item, index) in resultArr" :key="cyy">
|
|
4
|
+
<img
|
|
5
|
+
mode="widthFix"
|
|
6
|
+
:style="[computedStyle, imgStyle]"
|
|
7
|
+
:src="item['imgUrl']"
|
|
8
|
+
alt=""
|
|
9
|
+
/>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import pick from 'lodash-es/pick.js';
|
|
16
|
+
import omit from 'lodash-es/omit.js';
|
|
17
|
+
import { handlePlat } from '../../utils/index.js';
|
|
18
|
+
import { isEmpty, isUndefined } from 'lodash-es';
|
|
19
|
+
export default {
|
|
20
|
+
name: 'cyy-cube',
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
imgStyle: {
|
|
24
|
+
width: '100%',
|
|
25
|
+
boxSizing: 'border-box'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
props: {
|
|
30
|
+
props: {
|
|
31
|
+
selectImg: Array,
|
|
32
|
+
borderRadius: Number,
|
|
33
|
+
paddingTop: Number,
|
|
34
|
+
paddingLeft: Number,
|
|
35
|
+
paddingRight: Number,
|
|
36
|
+
paddingBottom: Number,
|
|
37
|
+
defaultValue: Array
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
computed: {
|
|
41
|
+
resultArr() {
|
|
42
|
+
const { selectImg, defaultValue } = this.props;
|
|
43
|
+
const computedArr = selectImg
|
|
44
|
+
.filter((item) => !isUndefined(item))
|
|
45
|
+
.filter(
|
|
46
|
+
(item) => !Object.values(item).every((citem) => isUndefined(citem))
|
|
47
|
+
);
|
|
48
|
+
let arr = defaultValue;
|
|
49
|
+
if (!isEmpty(computedArr)) {
|
|
50
|
+
arr = computedArr;
|
|
51
|
+
}
|
|
52
|
+
console.log(52, arr);
|
|
53
|
+
return arr;
|
|
54
|
+
},
|
|
55
|
+
computedStyle() {
|
|
56
|
+
const variates = [
|
|
57
|
+
'borderRadius',
|
|
58
|
+
'paddingTop',
|
|
59
|
+
'paddingLeft',
|
|
60
|
+
'paddingRight',
|
|
61
|
+
'paddingBottom'
|
|
62
|
+
];
|
|
63
|
+
const params = pick(this.props, variates);
|
|
64
|
+
const resetProps = omit(this.props, variates);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
...handlePlat(params),
|
|
68
|
+
...resetProps
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
</script>
|
|
74
|
+
<style lang="less" scoped>
|
|
75
|
+
.lc-img-item {
|
|
76
|
+
width: 100%;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="overflow: hidden">
|
|
3
|
+
<div :style="[computedStyle]" @click="goSearch">
|
|
4
|
+
<div style="flex: 1">{{ props.value }}</div>
|
|
5
|
+
<img
|
|
6
|
+
:src="props.icon"
|
|
7
|
+
alt=""
|
|
8
|
+
style="width: 20px; height: 20px; margin-top: 7px; margin-right: 10px"
|
|
9
|
+
v-if="props.iconShow"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import pick from 'lodash-es/pick.js';
|
|
17
|
+
import omit from 'lodash-es/omit.js';
|
|
18
|
+
import { handlePlat, isLc } from '../../utils/index.js';
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
name: 'cyy-search',
|
|
22
|
+
props: {
|
|
23
|
+
props: {
|
|
24
|
+
value: String,
|
|
25
|
+
fontColor: String,
|
|
26
|
+
iconShow: Boolean,
|
|
27
|
+
backgroundColor: String,
|
|
28
|
+
borderRadius: Number,
|
|
29
|
+
icon: String,
|
|
30
|
+
marginTop: Number,
|
|
31
|
+
marginLeft: Number,
|
|
32
|
+
marginRight: Number,
|
|
33
|
+
marginBottom: Number
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
computed: {
|
|
37
|
+
computedStyle() {
|
|
38
|
+
const variates = [
|
|
39
|
+
'borderRadius',
|
|
40
|
+
'marginTop',
|
|
41
|
+
'marginLeft',
|
|
42
|
+
'marginRight',
|
|
43
|
+
'marginBottom'
|
|
44
|
+
];
|
|
45
|
+
const params = pick(this.props, variates);
|
|
46
|
+
const resetProps = omit(this.props, variates);
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
...handlePlat(params),
|
|
50
|
+
...resetProps,
|
|
51
|
+
display: 'flex',
|
|
52
|
+
height: '34px',
|
|
53
|
+
lineHeight: '34px',
|
|
54
|
+
paddingLeft: '20px'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
methods: {
|
|
59
|
+
goSearch() {
|
|
60
|
+
if (isLc) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.$routers.push('goodsList', { memberCode: this.memberCode });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
</script>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div v-if="lowCode">
|
|
4
|
+
<div class="lowCode-warp" :style="[sliderStyle]">
|
|
5
|
+
<img :src="resultArr[0]['imgUrl']" alt="" style="width: 100%" />
|
|
6
|
+
<ul>
|
|
7
|
+
<li v-for="(item, index) in resultArr" :key="cyy"></li>
|
|
8
|
+
</ul>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
<div v-else>
|
|
12
|
+
<swiper
|
|
13
|
+
:indicator-dots="true"
|
|
14
|
+
:autoplay="props.autoplay"
|
|
15
|
+
:interval="props.autoplayInterval"
|
|
16
|
+
:vertical="reDirection"
|
|
17
|
+
:circular="props.loop"
|
|
18
|
+
:style="{
|
|
19
|
+
height: imgH + 'rpx'
|
|
20
|
+
}"
|
|
21
|
+
>
|
|
22
|
+
<swiper-item
|
|
23
|
+
v-for="(item, index) in resultArr"
|
|
24
|
+
:key="cyy"
|
|
25
|
+
:style="[sliderStyle, { boxSizing: 'border-box' }]"
|
|
26
|
+
>
|
|
27
|
+
<img :src="item.imgUrl" alt="" mode="widthFix" style="width: 100%" />
|
|
28
|
+
</swiper-item>
|
|
29
|
+
</swiper>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
<script>
|
|
34
|
+
import { handlePlat, isLc } from '../../utils/index.js';
|
|
35
|
+
import { isEmpty, isUndefined } from 'lodash-es';
|
|
36
|
+
import pick from 'lodash-es/pick';
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
name: 'cyy-slider',
|
|
40
|
+
data() {
|
|
41
|
+
return {
|
|
42
|
+
lowCode: isLc
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
props: {
|
|
46
|
+
props: {
|
|
47
|
+
autoplay: Boolean,
|
|
48
|
+
autoplayInterval: Number,
|
|
49
|
+
direction: String,
|
|
50
|
+
loop: Boolean,
|
|
51
|
+
selectImg: Array,
|
|
52
|
+
defaultValue: Array,
|
|
53
|
+
imgHeight: Object,
|
|
54
|
+
marginTop: Number,
|
|
55
|
+
marginBottom: Number
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
computed: {
|
|
59
|
+
resultArr() {
|
|
60
|
+
const { selectImg, defaultValue } = this.props;
|
|
61
|
+
const computedArr = selectImg
|
|
62
|
+
.filter((item) => !isUndefined(item))
|
|
63
|
+
.filter(
|
|
64
|
+
(item) => !Object.values(item).every((citem) => isUndefined(citem))
|
|
65
|
+
);
|
|
66
|
+
let arr = defaultValue;
|
|
67
|
+
if (!isEmpty(computedArr)) {
|
|
68
|
+
arr = computedArr;
|
|
69
|
+
}
|
|
70
|
+
return arr;
|
|
71
|
+
},
|
|
72
|
+
imgH() {
|
|
73
|
+
const { imgHeight } = this.props;
|
|
74
|
+
return (imgHeight.height / imgHeight.width) * 750;
|
|
75
|
+
},
|
|
76
|
+
sliderStyle() {
|
|
77
|
+
const variates = ['marginTop', 'marginBottom'];
|
|
78
|
+
const params = pick(this.props, variates);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
...handlePlat(params)
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
reDirection() {
|
|
85
|
+
const { direction } = this.props;
|
|
86
|
+
return direction !== 'horizontal';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<style>
|
|
93
|
+
.lowCode-warp {
|
|
94
|
+
position: relative;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.lowCode-warp ul {
|
|
98
|
+
position: absolute;
|
|
99
|
+
bottom: 10px;
|
|
100
|
+
text-align: center;
|
|
101
|
+
width: 100%;
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.lowCode-warp li {
|
|
106
|
+
display: inline-block;
|
|
107
|
+
width: 8px;
|
|
108
|
+
height: 8px;
|
|
109
|
+
border-radius: 50%;
|
|
110
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
111
|
+
margin: 0 4px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.lowCode-warp li:first-child {
|
|
115
|
+
background-color: #000000;
|
|
116
|
+
}
|
|
117
|
+
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="[computedStyle]">{{ props.value }}</div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import { handlePlat } from '../../utils/index.js';
|
|
7
|
+
import pick from 'lodash-es/pick';
|
|
8
|
+
import omit from 'lodash-es/omit';
|
|
9
|
+
export default {
|
|
10
|
+
name: 'cyy-title',
|
|
11
|
+
props: {
|
|
12
|
+
props: {
|
|
13
|
+
value: String,
|
|
14
|
+
fontSize: Number,
|
|
15
|
+
textAlign: String,
|
|
16
|
+
color: String,
|
|
17
|
+
backgroundColor: String,
|
|
18
|
+
fontWeight: String,
|
|
19
|
+
fontStyle: String,
|
|
20
|
+
textDecoration: Boolean,
|
|
21
|
+
paddingTop: Number,
|
|
22
|
+
paddingLeft: Number,
|
|
23
|
+
paddingRight: Number,
|
|
24
|
+
paddingBottom: Number
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
computed: {
|
|
28
|
+
computedStyle() {
|
|
29
|
+
const variates = [
|
|
30
|
+
'fontSize',
|
|
31
|
+
'paddingTop',
|
|
32
|
+
'paddingLeft',
|
|
33
|
+
'paddingRight',
|
|
34
|
+
'paddingBottom'
|
|
35
|
+
];
|
|
36
|
+
const params = pick(this.props || {}, variates);
|
|
37
|
+
const resetProps = omit(this.props || {}, variates);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
...handlePlat(params),
|
|
41
|
+
...resetProps
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
</script>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Title } from "./cyy-title/cyy-title.vue";
|
|
2
|
+
export { default as Cube } from "./cyy-image/cyy-image.vue";
|
|
3
|
+
export { default as Search } from "./cyy-search/cyy-search.vue";
|
|
4
|
+
export { default as Goods } from "./cyy-goods/cyy-goods.vue";
|
|
5
|
+
export { default as Slider } from "./cyy-slider/cyy-slider.vue";
|
|
6
|
+
export { default as GoodsOne } from "./cyy-goodsOne/cyy-goodsOne.vue";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const isLc = process.env.VUE_APP_PLATFORM === 'low-code';
|
|
2
|
+
|
|
3
|
+
export const handlePlat = (params) => {
|
|
4
|
+
let result = {};
|
|
5
|
+
for (let key in params) {
|
|
6
|
+
result[key] = sumPix(params[key]);
|
|
7
|
+
}
|
|
8
|
+
return result;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const sumPix = (param) => {
|
|
12
|
+
if (isLc) {
|
|
13
|
+
return param + 'px';
|
|
14
|
+
}
|
|
15
|
+
return param * 2 + 'rpx';
|
|
16
|
+
};
|
|
@@ -0,0 +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 = {};
|