Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
66613e44
Commit
66613e44
authored
Dec 22, 2021
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
富文本组件
parent
8f5b85ad
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
3 deletions
+102
-3
src/components/basicTool/rich-text/index.vue
+83
-0
src/components/basicTool/transverse-label/index.vue
+11
-1
src/components/custom-list/index.vue
+2
-1
src/pages/home/index.vue
+6
-1
No files found.
src/components/basicTool/rich-text/index.vue
0 → 100644
View file @
66613e44
<
template
>
<!-- 富文本组件 -->
<div
class=
"rich-text"
:style=
"
{ padding: padding + 'px', background: backgroundColor }"
>
<div
v-html=
"richText"
></div>
</div>
</
template
>
<
script
type=
"text/ecmascript-6"
>
/**
* 处理富文本里的图片宽度自适应
* 1.去掉img标签里的style、width、height属性
* 2.img标签添加style属性:max-width:100%;height:auto
* 3.修改所有style里的width属性为max-width:100%
* 4.去掉<br/>标签
* @param html
* @returns {void|string|*}
*/
function
formatRichText
(
html
)
{
let
newContent
=
html
.
replace
(
/<img
[^
>
]
*>/gi
,
function
(
match
,
capture
)
{
match
=
match
.
replace
(
/style="
[^
"
]
+"/gi
,
""
).
replace
(
/style='
[^
'
]
+'/gi
,
""
);
match
=
match
.
replace
(
/width="
[^
"
]
+"/gi
,
""
).
replace
(
/width='
[^
'
]
+'/gi
,
""
);
match
=
match
.
replace
(
/height="
[^
"
]
+"/gi
,
""
)
.
replace
(
/height='
[^
'
]
+'/gi
,
""
);
return
match
;
});
newContent
=
newContent
.
replace
(
/style="
[^
"
]
+"/gi
,
function
(
match
,
capture
)
{
match
=
match
.
replace
(
/width:
[^
;
]
+;/gi
,
"max-width:100%;"
)
.
replace
(
/width:
[^
;
]
+;/gi
,
"max-width:100%;"
);
return
match
;
});
newContent
=
newContent
.
replace
(
/<br
[^
>
]
*
\/
>/gi
,
""
);
newContent
=
newContent
.
replace
(
/\<img/gi
,
'<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"'
);
return
newContent
;
}
export
default
{
name
:
"rich-text"
,
props
:
{
render
:
{
type
:
Boolean
,
default
:
false
,
},
datas
:
{
type
:
Object
,
default
:
{},
},
},
data
()
{
return
{};
},
components
:
{},
computed
:
{
padding
()
{
return
this
.
datas
.
componentData
[
"padding"
];
},
backgroundColor
()
{
return
this
.
datas
.
componentData
[
"backgroundColor"
];
},
richText
()
{
return
formatRichText
(
this
.
datas
.
componentData
[
"richText"
]);
},
},
created
()
{},
mounted
()
{},
methods
:
{},
};
</
script
>
<
style
lang=
"scss"
scoped
>
.rich-text
{
/deep/
img
{
max-width
:
100%
!important
;
height
:
auto
;
}
}
</
style
>
src/components/basicTool/transverse-label/index.vue
View file @
66613e44
...
@@ -139,6 +139,12 @@
...
@@ -139,6 +139,12 @@
<div
v-if=
"item1.componentCode == 'share-picture' && item1.componentInfo.visible == 1"
>
<div
v-if=
"item1.componentCode == 'share-picture' && item1.componentInfo.visible == 1"
>
<share-picture
:datas=
"item1"
:indexs=
"index"
></share-picture>
<share-picture
:datas=
"item1"
:indexs=
"index"
></share-picture>
</div>
</div>
<div
v-if=
"item1.componentCode == 'custom-list' && item1.componentInfo.visible == 1"
>
<custom-list
:datas=
"item1"
></custom-list>
</div>
<!--
<div
v-if=
"item1.componentCode == 'rich-text' && item1.componentInfo.visible == 1"
>
<rich-text
:datas=
"item1"
></rich-text>
</div>
-->
<!--
<component
<!--
<component
:is=
"item1.componentCode"
:is=
"item1.componentCode"
:datas=
"item1"
:datas=
"item1"
...
@@ -163,6 +169,8 @@ import coupon from "@/components/activity/coupon";
...
@@ -163,6 +169,8 @@ import coupon from "@/components/activity/coupon";
import
integralTurntable
from
"@/components/activity/integralTurntable"
;
import
integralTurntable
from
"@/components/activity/integralTurntable"
;
import
information
from
'@/components/content/information/index'
import
information
from
'@/components/content/information/index'
import
spellGroup
from
'@/components/activity/spellGroup'
import
spellGroup
from
'@/components/activity/spellGroup'
import
customList
from
"@/components/custom-list"
;
import
richText
from
"@/components/basicTool/rich-text"
;
let
rect
=
''
,
vanTabsThis
=
[];
let
rect
=
''
,
vanTabsThis
=
[];
export
default
{
export
default
{
name
:
"transverse-label"
,
name
:
"transverse-label"
,
...
@@ -199,7 +207,9 @@ export default {
...
@@ -199,7 +207,9 @@ export default {
coupon
,
coupon
,
integralTurntable
,
integralTurntable
,
information
,
information
,
spellGroup
spellGroup
,
customList
,
richText
},
},
computed
:
{
computed
:
{
tabList
:
{
tabList
:
{
...
...
src/components/custom-list/index.vue
View file @
66613e44
...
@@ -87,7 +87,8 @@ export default {
...
@@ -87,7 +87,8 @@ export default {
}
}
index
.
outDataSourceData
(
query
).
then
(
res
=>
{
index
.
outDataSourceData
(
query
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
if
(
res
.
data
.
code
==
200
){
this
.
comDataList
=
res
.
data
.
data
.
records
||
[];
this
.
comDataList
=
res
.
data
.
data
.
data
||
[];
this
.
comDataList
=
this
.
comDataList
.
slice
(
0
,
this
.
showCont
-
1
);
if
(
this
.
comDataList
&&
this
.
comDataList
.
length
>
0
){
if
(
this
.
comDataList
&&
this
.
comDataList
.
length
>
0
){
this
.
comDataList
.
forEach
((
item
,
index
)
=>
{
this
.
comDataList
.
forEach
((
item
,
index
)
=>
{
item
.
comStr
=
compiler
(
this
.
datas
.
componentData
.
comStr
,
item
);
item
.
comStr
=
compiler
(
this
.
datas
.
componentData
.
comStr
,
item
);
...
...
src/pages/home/index.vue
View file @
66613e44
...
@@ -96,6 +96,9 @@
...
@@ -96,6 +96,9 @@
<div
v-if=
"item.componentCode == 'custom-list' && item.componentInfo.visible == 1"
>
<div
v-if=
"item.componentCode == 'custom-list' && item.componentInfo.visible == 1"
>
<custom-list
:datas=
"item"
></custom-list>
<custom-list
:datas=
"item"
></custom-list>
</div>
</div>
<div
v-if=
"item.componentCode == 'rich-text' && item.componentInfo.visible == 1"
>
<rich-text
:datas=
"item"
></rich-text>
</div>
</div>
</div>
<bottomCont></bottomCont>
<bottomCont></bottomCont>
...
@@ -149,6 +152,7 @@ import couponPopup from '@/components/couponPopup.vue'
...
@@ -149,6 +152,7 @@ import couponPopup from '@/components/couponPopup.vue'
import
NewUser
from
"../../components/newCustomer/newUser"
;
import
NewUser
from
"../../components/newCustomer/newUser"
;
import
NewPolite
from
"../../components/newCustomer/newPolite"
;
import
NewPolite
from
"../../components/newCustomer/newPolite"
;
import
customList
from
"../../components/custom-list"
;
import
customList
from
"../../components/custom-list"
;
import
richText
from
"../../components/basicTool/rich-text"
;
import
{
setTabBarActive
,
checkTabbarPage
,
themeColor
,
checkShowConditionIds
}
from
"../../utils/mayi.js"
;
import
{
setTabBarActive
,
checkTabbarPage
,
themeColor
,
checkShowConditionIds
}
from
"../../utils/mayi.js"
;
import
indexApi
from
"@/api/index.js"
;
import
indexApi
from
"@/api/index.js"
;
import
{
throttle
,
concatUrl
}
from
"../../utils/index.js"
import
{
throttle
,
concatUrl
}
from
"../../utils/index.js"
...
@@ -205,7 +209,8 @@ export default {
...
@@ -205,7 +209,8 @@ export default {
birthPopup
,
birthPopup
,
mpvueCropper
,
mpvueCropper
,
woTimeout
,
woTimeout
,
'custom-list'
:
customList
'custom-list'
:
customList
,
'rich-text'
:
richText
,
},
},
onShareAppMessage
(
res
)
{
onShareAppMessage
(
res
)
{
let
{
shopCode
}
=
app
.
globalData
.
shopInfo
;
let
{
shopCode
}
=
app
.
globalData
.
shopInfo
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment