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
a7506ca8
Commit
a7506ca8
authored
Jul 12, 2023
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态修改首页背景
parent
8880dee3
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
235 additions
and
39 deletions
+235
-39
src/App.vue
+2
-2
src/components/ThemeDataPlant.vue
+46
-25
src/components/common/CustomNav.vue
+119
-0
src/main.js
+2
-0
src/pages/home/index.vue
+5
-1
src/pages/home/main.json
+1
-0
static/nativeComponents/Banner/index.js
+60
-11
No files found.
src/App.vue
View file @
a7506ca8
...
@@ -15,8 +15,8 @@ export default {
...
@@ -15,8 +15,8 @@ export default {
console
.
log
(
extConfig
,
"-----------extConfig"
);
console
.
log
(
extConfig
,
"-----------extConfig"
);
if
(
JSON
.
stringify
(
extConfig
)
==
"{}"
)
{
if
(
JSON
.
stringify
(
extConfig
)
==
"{}"
)
{
let
shopItem
=
{
let
shopItem
=
{
development
:
{
mixid
:
"ssa"
,
"shopid"
:
2342
},
//五粮液uat
//
development: { mixid: "ssa", "shopid": 2342}, //五粮液uat
//
development: { mixid: "antgood", "shopid": 67},
development
:
{
mixid
:
"antgood"
,
"shopid"
:
67
},
production
:
{
"mixid"
:
"qiyeCT"
,
"shopid"
:
1045
},
// 道可
production
:
{
"mixid"
:
"qiyeCT"
,
"shopid"
:
1045
},
// 道可
// production: { "mixid":"metasense_doctors", "shopid": 1238 }, // 册为医护端
// production: { "mixid":"metasense_doctors", "shopid": 1238 }, // 册为医护端
// production: { "mixid":"3QqsFT", "shopid": 1337 },
// production: { "mixid":"3QqsFT", "shopid": 1337 },
...
...
src/components/ThemeDataPlant.vue
View file @
a7506ca8
<
template
>
<
template
>
<div
<div
ref=
"ThemeDataPlant"
class=
"ThemeDataPlant"
:style=
"
{
ref=
"ThemeDataPlant"
'position': pageCode == 14 ? 'fixed' : '',
class=
"ThemeDataPlant"
:style=
"
{
'position':pageCode == 14?'fixed':'',
'background-color': pageSettingData.backgroundColor,
'background-color': pageSettingData.backgroundColor,
'background-image': bacImage,
'background-image': bacImage,
'background-size': pageSettingData.backgroundFit!='equiratioFill'?'100% auto':'cover',
'background-size': pageSettingData.backgroundFit != 'equiratioFill' ? '100% auto' : 'cover',
'background-repeat':pageSettingData.backgroundFit == 'repeat'? 'repeat': 'no-repeat',
'background-repeat': pageSettingData.backgroundFit == 'repeat' ? 'repeat' : 'no-repeat',
'background-position':pageSettingData.backgroundFit == 'equiratioFill'?'center':'',
'background-position': pageSettingData.backgroundFit == 'equiratioFill' ? 'center' : '',
'background-attachment': pageSettingData.backgroundImageLock? 'fixed': 'local'}"
'background-attachment': pageSettingData.backgroundImageLock ? 'fixed' : 'local',
>
}">
<div
class=
"imgRgb"
:style=
"
{
background: 'linear-gradient(180deg, ' + imgRgb + ' 42.64%, rgba(255,255,255, 0) 100%)',
}">
</div>
</div>
</div>
</
template
>
</
template
>
...
@@ -18,42 +18,52 @@
...
@@ -18,42 +18,52 @@
export
default
{
export
default
{
props
:
{
props
:
{
pageCode
:
{
pageCode
:
{
type
:
Number
,
type
:
Number
,
default
:
1
default
:
1
}
}
},
},
components
:
{
components
:
{
// 'area-navigation' : () => import('~/components/theme/components/other/area-navigation')
// 'area-navigation' : () => import('~/components/theme/components/other/area-navigation')
},
},
data
()
{
data
()
{
return
{
return
{
flag
:
false
,
flag
:
false
,
render
:
true
,
render
:
true
,
pageInfo
:{},
pageInfo
:
{},
pageData
:{},
pageData
:
{},
pageSettingData
:{},
pageSettingData
:
{},
bacImage
:
""
bacImage
:
""
,
imgRgb
:
""
,
// 背景主色调
};
};
},
},
created
(){
created
()
{
if
(
this
.
mpApp
.
globalData
.
pageList
)
{
if
(
this
.
mpApp
.
globalData
.
pageList
)
{
this
.
pageInfo
=
this
.
mpApp
.
globalData
.
pageList
.
filter
((
item
)
=>
item
.
pageCode
==
this
.
pageCode
)[
0
];
this
.
pageInfo
=
this
.
mpApp
.
globalData
.
pageList
.
filter
((
item
)
=>
item
.
pageCode
==
this
.
pageCode
)[
0
];
this
.
pageSettingData
=
JSON
.
parse
(
this
.
pageInfo
.
pageSettingData
);
this
.
pageSettingData
=
JSON
.
parse
(
this
.
pageInfo
.
pageSettingData
);
console
.
log
(
this
.
pageInfo
.
pageSettingData
,
'kl'
)
console
.
log
(
this
.
pageInfo
.
pageSettingData
,
'kl'
)
}
else
{
}
else
{
let
_this
=
this
let
_this
=
this
this
.
mpApp
.
indexBgCallBack
=
function
(
data
)
{
this
.
mpApp
.
indexBgCallBack
=
function
(
data
)
{
_this
.
pageInfo
=
_this
.
mpApp
.
globalData
.
pageList
.
filter
((
item
)
=>
item
.
pageCode
==
_this
.
pageCode
)[
0
];
_this
.
pageInfo
=
_this
.
mpApp
.
globalData
.
pageList
.
filter
((
item
)
=>
item
.
pageCode
==
_this
.
pageCode
)[
0
];
_this
.
pageSettingData
=
JSON
.
parse
(
_this
.
pageInfo
.
pageSettingData
);
_this
.
pageSettingData
=
JSON
.
parse
(
_this
.
pageInfo
.
pageSettingData
);
console
.
log
(
_this
.
pageSettingData
,
'kl1'
)
console
.
log
(
_this
.
pageSettingData
,
'kl1'
)
_this
.
bacImage
=
`url(
${
_this
.
pageSettingData
.
backgroundImage
}
)`
_this
.
bacImage
=
`url(
${
_this
.
pageSettingData
.
backgroundImage
}
)`
}
}
}
}
this
.
mpApp
.
setHomeBgImg
=
this
.
setHomeBgImg
;
},
},
mounted
(){
mounted
()
{
this
.
bacImage
=
`url(
${
this
.
pageSettingData
.
backgroundImage
}
)`
this
.
bacImage
=
`url(
${
this
.
pageSettingData
.
backgroundImage
}
)`
},
},
computed
:{
computed
:
{
},
methods
:
{
setHomeBgImg
({
backgroundImage
,
imgRgb
})
{
console
.
log
(
imgRgb
,
'-imgRgb'
)
this
.
bacImage
=
backgroundImage
;
this
.
imgRgb
=
imgRgb
;
}
}
}
};
};
...
@@ -61,12 +71,23 @@ export default {
...
@@ -61,12 +71,23 @@ export default {
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.ThemeDataPlant
{
.ThemeDataPlant
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
position
:
absolute
;
position
:
absolute
;
top
:
0
;
top
:
0
;
z-index
:
-1
;
z-index
:
-1
;
.imgRgb
{
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
z-index
:
1
;
opacity
:
0.5
;
}
}
}
.ThemeDataPlant
::before
{
.ThemeDataPlant
::before
{
content
:
" "
;
content
:
" "
;
//
position
:
var
(
--lock
);
//
position
:
var
(
--lock
);
...
...
src/components/common/CustomNav.vue
0 → 100644
View file @
a7506ca8
<
template
>
<div
class=
"CustomNav"
>
<div
class=
"navFixedBg"
:style=
"
{ 'height': navHeight + 'px' }">
</div>
<div
class=
"navBg"
:style=
"
{ 'height': navHeight + 'px', background: 'rgba(255,255,255,' + (customBgOpacity ? bgOpacity : 1) + ')' }">
<div
class=
"content"
:style=
"
{ 'top': navTop + 'px', height: navConHeight + 'px' }">
{{
title
||
shopName
}}
</div>
</div>
</div>
</
template
>
<
script
type=
"text/ecmascript-6"
>
const
app
=
getApp
();
const
{
log
}
=
app
;
export
default
{
name
:
"CustomNav"
,
props
:
{
title
:
{
type
:
String
,
default
:
""
,
},
customBgOpacity
:
{
type
:
Boolean
,
default
:
false
,
}
},
data
()
{
return
{
navHeight
:
0
,
navTop
:
0
,
navConHeight
:
0
,
bgOpacity
:
0
,
}
},
components
:
{},
computed
:
{
shopName
()
{
// let shopName = app.globalData && app.globalData.shopInfo && app.globalData.shopInfo.shopName;
let
shopName
=
wx
.
getStorageSync
(
"shopName"
);
return
shopName
||
""
;
},
listHeight
()
{
return
`calc(100vh -
${
this
.
navConHeight
}
px -
${
this
.
navTop
}
px - 0.5rem )`
},
topBgHeight
()
{
return
`calc(2rem +
${
this
.
navTop
}
px)`
},
topHeight
()
{
return
`calc(2rem +
${
this
.
navTop
}
px)`
}
},
created
()
{
},
onLoad
()
{
this
.
getNavbarInfo
();
},
onShow
()
{
},
onReady
()
{
},
onHide
()
{
},
onUnload
()
{
},
onPageScroll
(
el
)
{
this
.
getScroll
(
el
);
},
mounted
()
{
},
methods
:
{
getScroll
(
el
)
{
let
opacity
=
(
el
.
scrollTop
/
100
).
toFixed
(
1
)
-
0
;
this
.
bgOpacity
=
opacity
>
1
?
1
:
opacity
;
},
getNavbarInfo
()
{
let
menuInfo
=
wx
.
getMenuButtonBoundingClientRect
();
console
.
log
(
menuInfo
,
'-menuInfo'
)
let
res
=
wx
.
getSystemInfoSync
()
console
.
log
(
res
,
'-getSystemInfoSync'
)
this
.
navTop
=
res
.
statusBarHeight
;
this
.
navHeight
=
(
res
.
statusBarHeight
+
menuInfo
.
height
+
(
menuInfo
.
top
-
res
.
statusBarHeight
)
*
2
)
this
.
navConHeight
=
(
menuInfo
.
height
+
(
menuInfo
.
top
-
res
.
statusBarHeight
)
*
2
);
console
.
log
(
this
.
navTop
,
this
.
navHeight
,
this
.
navConHeight
,
'-this.navConHeight'
)
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.CustomNav
{
position
:
relative
;
z-index
:
9999
;
.navFixedBg
{
width
:
100%
;
}
.navBg
{
position
:
fixed
;
width
:
100%
;
left
:
0
;
top
:
0
;
}
.content
{
position
:
absolute
;
left
:
0
;
width
:
100%
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
color
:
#333
;
}
}
</
style
>
src/main.js
View file @
a7506ca8
...
@@ -102,6 +102,8 @@ mpApp.getFilterGoodsData = function () { }
...
@@ -102,6 +102,8 @@ mpApp.getFilterGoodsData = function () { }
mpApp
.
openSelectGoods
=
function
()
{
}
mpApp
.
openSelectGoods
=
function
()
{
}
// 打开选择商品规格(2B)弹窗
// 打开选择商品规格(2B)弹窗
mpApp
.
openTwoBAddCart
=
function
()
{
}
mpApp
.
openTwoBAddCart
=
function
()
{
}
// 动态设置首页背景图片
mpApp
.
setHomeBgImg
=
function
()
{}
/**
/**
* 组件点击行为收集
* 组件点击行为收集
...
...
src/pages/home/index.vue
View file @
a7506ca8
<
template
>
<
template
>
<div
class=
"domain"
:style=
"
{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}">
<div
class=
"domain"
:style=
"
{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}">
<pageLoading
v-if=
"pageLoading"
></pageLoading>
<pageLoading
v-if=
"pageLoading"
></pageLoading>
<!-- 自定义导航头 -->
<div
style=
"position:relative;"
>
<div
style=
"position:relative;"
>
<div
v-if=
"showSpokesManHome"
>
<div
v-if=
"showSpokesManHome"
>
<get-index-homepage
class=
"getIndexHomePage"
></get-index-homepage>
<get-index-homepage
class=
"getIndexHomePage"
></get-index-homepage>
</div>
</div>
<CustomNav
:customBgOpacity=
"true"
></CustomNav>
<StoreAddr
@
toUpdate=
"reloadEnterShopRule"
@
toPageLoading=
"toPageLoading"
ref=
"StoreAddr"
></StoreAddr>
<StoreAddr
@
toUpdate=
"reloadEnterShopRule"
@
toPageLoading=
"toPageLoading"
ref=
"StoreAddr"
></StoreAddr>
<ThemeDataPlant></ThemeDataPlant>
<ThemeDataPlant></ThemeDataPlant>
<div
v-for=
"(item,index) in pageData"
:key=
"index"
>
<div
v-for=
"(item,index) in pageData"
:key=
"index"
>
...
@@ -188,6 +190,7 @@ import mpvueCropper from '@/components/mpvue-cropper'
...
@@ -188,6 +190,7 @@ import mpvueCropper from '@/components/mpvue-cropper'
import
tool
from
'../../utils/tool.js'
import
tool
from
'../../utils/tool.js'
import
StoreAddr
from
"@/components/common/StoreAddr.vue"
;
import
StoreAddr
from
"@/components/common/StoreAddr.vue"
;
import
pageLoading
from
"@/components/common/pageLoading.vue"
;
import
pageLoading
from
"@/components/common/pageLoading.vue"
;
import
CustomNav
from
"@/components/common/CustomNav.vue"
;
const
app
=
getApp
();
const
app
=
getApp
();
const
{
log
}
=
app
;
const
{
log
}
=
app
;
export
default
{
export
default
{
...
@@ -255,7 +258,8 @@ export default {
...
@@ -255,7 +258,8 @@ export default {
TwoBAddCart
,
TwoBAddCart
,
brandList
,
brandList
,
StoreAddr
,
StoreAddr
,
pageLoading
pageLoading
,
CustomNav
},
},
computed
:
{
computed
:
{
applySucessEntryFlag
()
{
applySucessEntryFlag
()
{
...
...
src/pages/home/main.json
View file @
a7506ca8
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
"set-my-homepage"
:
"/static/nativeComponents/SetMyHomePage/index"
,
"set-my-homepage"
:
"/static/nativeComponents/SetMyHomePage/index"
,
"apply-sucess-entry"
:
"/static/nativeComponents/ApplySucessEntry/index"
"apply-sucess-entry"
:
"/static/nativeComponents/ApplySucessEntry/index"
},
},
"navigationStyle"
:
"custom"
,
"enablePullDownRefresh"
:
true
,
"enablePullDownRefresh"
:
true
,
"backgroundColor"
:
"#f5f5f5"
"backgroundColor"
:
"#f5f5f5"
}
}
static/nativeComponents/Banner/index.js
View file @
a7506ca8
const
app
=
getApp
()
const
app
=
getApp
()
;
Component
({
Component
({
properties
:
{
properties
:
{
// 这里定义了innerText属性,属性值可以在组件使用时指定
// 这里定义了innerText属性,属性值可以在组件使用时指定
...
@@ -19,32 +19,78 @@ Component({
...
@@ -19,32 +19,78 @@ Component({
indicatorDots
:
false
,
indicatorDots
:
false
,
vertical
:
false
,
vertical
:
false
,
autoplay
:
true
,
autoplay
:
true
,
interval
:
2
000
,
interval
:
3
000
,
duration
:
500
,
duration
:
500
,
activeIndex
:
0
,
activeIndex
:
0
,
bannerHeight
:
0
,
bannerHeight
:
0
,
firstLoad
:
false
,
firstLoad
:
false
,
newArr
:
[]
,
newArr
:
[]
},
},
ready
()
{
ready
()
{
console
.
log
(
'----------------------30'
)
console
.
log
(
app
.
setHomeBgImg
,
"----------------------30"
);
this
.
setData
({
'newArr'
:
this
.
newList
()})
this
.
setData
({
newArr
:
this
.
newList
()
});
console
.
log
(
this
.
data
.
newArr
,
this
.
newList
(),
'--------32'
)
this
.
bannerChange
({
detail
:
{
current
:
0
}
});
console
.
log
(
this
.
data
.
newArr
,
this
.
newList
(),
"--------32"
);
},
},
methods
:
{
methods
:
{
newList
(){
newList
()
{
return
this
.
data
.
datas
.
componentData
.
imgList
.
filter
(
item
=>
item
.
visible
==
undefined
||
item
.
visible
==
1
)
||
[]
return
(
this
.
data
.
datas
.
componentData
.
imgList
.
filter
(
item
=>
item
.
visible
==
undefined
||
item
.
visible
==
1
)
||
[]
);
},
},
customMethod
()
{
customMethod
()
{
console
.
log
(
"hello world! I am learning 微信小程序"
);
console
.
log
(
"hello world! I am learning 微信小程序"
);
},
},
bannerChange
(
val
)
{
async
bannerChange
(
val
)
{
let
{
newArr
}
=
this
.
data
;
let
{
changeHomePageFlag
}
=
this
.
data
.
datas
.
componentData
;
let
_this
=
this
;
// 如果开启了修改首页背景图
let
imageUrl
=
`url(
${
newArr
[
val
.
detail
.
current
].
imageUrl
}
?x-oss-process=image/blur,r_50,s_50)`
;
if
(
changeHomePageFlag
&&
app
.
setHomeBgImg
)
{
if
(
newArr
[
val
.
detail
.
current
].
imgRgb
)
{
app
.
setHomeBgImg
({
backgroundImage
:
imageUrl
,
imgRgb
:
newArr
[
val
.
detail
.
current
].
imgRgb
});
}
else
{
await
wx
.
request
({
url
:
`
${
newArr
[
val
.
detail
.
current
].
imageUrl
}
?x-oss-process=image/average-hue`
,
data
:
{},
header
:
{
"content-type"
:
"application/json"
},
method
:
"GET"
,
dataType
:
"json"
,
responseType
:
"text"
,
success
:
result
=>
{
let
imgRgb
=
`#
${
result
.
data
.
RGB
.
split
(
"x"
)[
1
]}
`
;
app
.
setHomeBgImg
({
backgroundImage
:
imageUrl
,
imgRgb
});
newArr
[
val
.
detail
.
current
].
imgRgb
=
imgRgb
;
_this
.
setData
({
newArr
});
},
fail
:
()
=>
{},
complete
:
()
=>
{}
});
}
}
this
.
setData
({
activeIndex
:
val
.
detail
.
current
});
this
.
setData
({
activeIndex
:
val
.
detail
.
current
});
},
},
onClick
(
data
)
{
onClick
(
data
)
{
let
item
=
data
.
currentTarget
.
dataset
.
item
;
let
item
=
data
.
currentTarget
.
dataset
.
item
;
console
.
log
(
data
.
currentTarget
.
dataset
.
item
,
"iiii"
);
console
.
log
(
data
.
currentTarget
.
dataset
.
item
,
"iiii"
);
app
.
trackCpn
(
data
,
this
.
data
.
datas
.
componentName
,
item
)
app
.
trackCpn
(
data
,
this
.
data
.
datas
.
componentName
,
item
)
;
app
.
$themeToLink
(
item
.
link
);
app
.
$themeToLink
(
item
.
link
);
},
},
loadImg
(
e
)
{
loadImg
(
e
)
{
...
@@ -53,7 +99,10 @@ Component({
...
@@ -53,7 +99,10 @@ Component({
return
;
return
;
}
}
firstLoad
=
true
;
firstLoad
=
true
;
let
winWid
=
wx
.
getSystemInfoSync
().
windowWidth
-
this
.
data
.
datas
.
componentData
.
paddingList
[
2
].
value
-
this
.
data
.
datas
.
componentData
.
paddingList
[
3
].
value
;
//获取当前屏幕的宽度
let
winWid
=
wx
.
getSystemInfoSync
().
windowWidth
-
this
.
data
.
datas
.
componentData
.
paddingList
[
2
].
value
-
this
.
data
.
datas
.
componentData
.
paddingList
[
3
].
value
;
//获取当前屏幕的宽度
let
imgh
=
e
.
detail
.
height
;
//图片高度
let
imgh
=
e
.
detail
.
height
;
//图片高度
let
imgw
=
e
.
detail
.
width
;
let
imgw
=
e
.
detail
.
width
;
let
swiperH
=
winWid
*
imgh
/
imgw
+
"px"
;
let
swiperH
=
winWid
*
imgh
/
imgw
+
"px"
;
...
...
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