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
7010d758
Commit
7010d758
authored
Jan 25, 2021
by
程默
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
全局跳转
parent
0fd2aaa7
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
231 additions
and
143 deletions
+231
-143
custom-tab-bar/index.js
+21
-6
src/main.js
+4
-94
src/pages/index/index.vue
+5
-3
src/pages/tabBar1/index.vue
+24
-5
src/pages/tabBar2/index.vue
+17
-5
src/pages/tabBar3/index.vue
+17
-5
src/pages/tabbar4/index.vue
+17
-5
src/utils/mayi.js
+119
-0
src/utils/watch.js
+0
-19
static/nativeComponents/Banner/index.js
+6
-0
static/nativeComponents/Banner/index.wxml
+1
-1
No files found.
custom-tab-bar/index.js
View file @
7010d758
...
...
@@ -63,6 +63,12 @@ Component({
})
}
}
// ----------webview 变化
console
.
log
(
'启动1111'
)
app
.
webviewCallBack
=
function
(
state
,
params
)
{
console
.
log
(
'webview变化'
,
state
,
params
)
}
},
methods
:
{
init
()
{
...
...
@@ -80,7 +86,7 @@ Component({
app
.
globalData
.
tabBarPageLink
=
this
.
data
.
list
[
index
].
link
.
link
console
.
log
(
app
,
'aaaa'
)
this
.
toPage
(
this
.
data
.
list
[
index
].
link
)
this
.
toPage
(
this
.
data
.
list
[
index
].
link
,
index
)
// return
// app.$themeToLink(this.data.list[index].link)
...
...
@@ -88,12 +94,21 @@ Component({
// selected: index
// })
},
toPage
(
data
){
toPage
(
data
,
index
){
console
.
log
(
'index98'
,
index
)
// 跳转
wx
.
switchTab
({
url
:
'/pages/index/main'
,
})
if
(
data
.
link
==
'/'
)
{
wx
.
switchTab
({
url
:
'/pages/home/main'
,
})
}
else
{
wx
.
switchTab
({
url
:
`/pages/tabBar
${
index
}
/main`
,
})
// ?from=tabbar&backpath=${
// data.link
// }
}
}
}
})
src/main.js
View file @
7010d758
...
...
@@ -4,6 +4,7 @@ import Store from './store/index'
import
"../static/nicon/iconfont.css"
import
goodsApi
from
"./api/goods"
import
{
DFSImg
}
from
"@/utils/index"
;
import
{
$themeToLink
}
from
"@/utils/mayi"
Vue
.
config
.
productionTip
=
false
App
.
mpType
=
'app'
...
...
@@ -26,7 +27,7 @@ app.$mount()
// glob挂载到
let
mpApp
=
getApp
();
Vue
.
prototype
.
mpApp
=
mpApp
//
定义数据
回调函数
//
数据异步
回调函数
// 商城
mpApp
.
shopCallBack
=
function
()
{
}
// 多主题页面
...
...
@@ -38,99 +39,8 @@ mpApp.webviewCallBack = function () { }
console
.
log
(
'3555555'
,
wx
)
// 全局跳转 data为link对象
mpApp
.
$themeToLink
=
function
name
(
data
)
{
debugger
console
.
log
(
'393939'
)
let
type
=
data
.
type
;
if
(
type
==
undefined
||
type
==
'undefined'
)
{
if
(
data
.
length
>
0
)
{
// this.$nuxt.$router.push(data);
}
return
}
if
(
type
==
0
)
{
//无链接
return
}
else
if
(
type
==
1
)
{
//h5页面
//兼容
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
// this.$nuxt.$router.push(data.link);
toPage
(
data
.
link
)
}
else
{
if
(
data
.
link
.
startsWith
(
'http'
)
||
data
.
link
.
startsWith
(
'https'
))
{
// if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
wx
.
miniProgram
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
data
.
link
)
});
// } else {
// window.location = data.link
// }
}
else
{
window
.
location
.
href
=
data
.
link
;
}
}
}
else
if
(
type
==
1.1
)
{
//小程序页面 可能增加登录态拦截
if
(
this
.
$store
.
state
.
miniProgram
==
1
||
this
.
$store
.
state
.
miniProgram
==
2
)
{
wx
.
miniProgram
.
navigateTo
({
url
:
data
.
link
});
}
else
{
// Toast("暂不支持");
}
mpApp
.
$themeToLink
=
$themeToLink
}
else
if
(
type
==
1.2
)
{
//第三方链接
if
(
data
.
link
==
'outerChain:businessCenter'
)
{
// 进入商家中心外链
let
url
=
`
${
config
.
GUIDE_URL
}
/login?mixid=
${
this
.
$nuxt
.
$route
.
query
.
mixid
}
&back=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
;
window
.
location
.
href
=
url
;
return
}
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
// this.$nuxt.$router.push(data.link);
toPage
(
data
.
link
)
}
else
{
if
(
this
.
$store
.
state
.
miniProgram
==
1
||
this
.
$store
.
state
.
miniProgram
==
2
)
{
$mp
.
miniProgram
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
data
.
link
)
});
}
else
{
window
.
location
.
href
=
data
.
link
}
}
}
else
if
(
type
==
2
)
{
//功能
let
featureType
=
data
.
feature
.
type
;
if
(
featureType
==
'themeCouponClick'
||
featureType
==
0
)
{
//优惠券
this
.
$themeCouponClick
(
data
.
feature
.
value
.
couponCode
,
data
.
feature
.
value
);
}
else
if
(
featureType
==
1
)
{
//分享
console
.
log
(
'是分享了。。。。'
,
cb
);
// if (data.type == 2 && data.feature.type == 1) {
// //分享
// this.$nuxt.$SHARE({
// itemList: data.feature.value
// });
// }
}
else
if
(
featureType
==
"themeMemberCardClick"
||
featureType
==
2
)
{
//会员卡
// this.$themeMemberCardClick(data.feature.value);
}
}
else
if
(
type
==
3
)
{
//小程序跳转到小程序
// if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
// if (this.$store.getters['sceneModule/flushbonadingVisible']) {
// $mp.miniProgram.navigateTo({
// url: `/pages/toMini/toMini?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
// })
// return
// }
// $mp.miniProgram.navigateTo({
// url: `/pages/toMini/main?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
// })
// } else {
// Toast("暂不支持");
// }
}
else
{
//向后兼容
if
(
data
.
length
>
0
)
{
this
.
$nuxt
.
$router
.
push
(
data
.
link
);
}
}
}
function
toPage
(
backPath
,
backParams
)
{
wx
.
reLaunch
({
url
:
`../index/main?from=home&backpath=
${
backPath
}
¶ms=
${
encodeURIComponent
(
backParams
)}
`
});
}
// api
mpApp
.
goodsApi
=
goodsApi
;
mpApp
.
DFSImg
=
DFSImg
;
src/pages/index/index.vue
View file @
7010d758
<
template
>
<div>
{{
withoutScene
}}
<web-view
v-if=
"withoutScene"
:src=
"pageUrl"
@
message=
"getMessage"
@
error=
"handleError"
@
load=
"handleLoad"
></web-view>
</div>
</
template
>
...
...
@@ -41,7 +42,7 @@ export default {
shareOrderSn
:
""
,
shareTid
:
""
,
newWindowHref
:
''
,
withoutScene
:
tru
e
,
withoutScene
:
fals
e
,
sharePageList
:
[
"goods/"
,
"receivingGift"
,
...
...
@@ -92,6 +93,7 @@ export default {
success
:
res
=>
{
this
.
code
=
res
.
code
;
login
.
miniLogin
({
code
:
this
.
code
}).
then
(
res1
=>
{
this
.
withoutScene
=
true
;
console
.
log
(
res1
,
555555
)
if
(
res1
.
data
.
code
==
200
)
{
wx
.
setStorage
({
...
...
@@ -148,10 +150,10 @@ export default {
key
:
"sessionid"
,
data
:
params
.
sessionid
});
}
else
if
(
options
.
from
&&
options
.
from
==
"livedToIndex"
)
{
}
else
if
(
options
.
from
&&
(
options
.
from
==
"home"
||
options
.
from
==
"livedToIndex"
)
)
{
//来自直播详情
this
.
page
=
decodeURIComponent
(
options
.
backpath
);
this
.
params
+=
"&"
+
serialize
(
options
.
params
);
options
.
params
&&
(
this
.
params
+=
"&"
+
serialize
(
options
.
params
)
);
}
else
if
(
options
.
from
&&
options
.
from
==
"livedBackShop"
)
{
//直播页back到商城
this
.
page
=
decodeURIComponent
(
options
.
backpath
);
...
...
src/pages/tabBar1/index.vue
View file @
7010d758
<!--
tabbar
1
tabbar
-->
<
template
>
<div>
...
...
@@ -8,25 +8,44 @@
</
template
>
<
script
>
import
{
getUrlofLink
}
from
"../../utils/mayi.js"
;
export
default
{
data
()
{
return
{
link
:
process
.
env
.
BASE_URL
,
page
:
"/"
,
params
:
"?mixid="
+
this
.
$store
.
state
.
mixid
,
index
:
1
};
},
computed
:
{
pageUrl
()
{
return
this
.
link
+
this
.
page
+
this
.
params
;
}
return
this
.
link
+
this
.
page
+
this
.
params
;
}
,
},
onLoad
(
options
)
{
// tabbar 跳转
if
(
this
.
mpApp
.
globalData
.
tabBarPageLink
)
{
this
.
page
=
this
.
mpApp
.
globalData
.
tabBarPageLink
;
if
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
)
{
this
.
page
=
getUrlofLink
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
);
this
.
mpApp
.
globalData
.
tabBarPageLink
=
""
;
}
},
onShow
(){
console
.
log
(
'show'
)
if
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
)
{
this
.
page
=
getUrlofLink
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
);
this
.
mpApp
.
globalData
.
tabBarPageLink
=
""
;
}
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
},
methods
:
{
handleError
(
data
)
{
...
...
src/pages/tabBar2/index.vue
View file @
7010d758
<!--
tabbar
1
tabbar
-->
<
template
>
<div>
...
...
@@ -8,26 +8,38 @@
</
template
>
<
script
>
import
{
getUrlofLink
}
from
"../../utils/mayi.js"
;
export
default
{
data
()
{
return
{
link
:
process
.
env
.
BASE_URL
,
page
:
"/"
,
params
:
"?mixid="
+
this
.
$store
.
state
.
mixid
,
index
:
2
};
},
computed
:
{
pageUrl
()
{
return
this
.
link
+
this
.
page
+
this
.
params
;
}
return
this
.
link
+
this
.
page
+
this
.
params
;
}
,
},
onLoad
(
options
)
{
// tabbar 跳转
if
(
this
.
mpApp
.
globalData
.
tabBarPageLink
)
{
this
.
page
=
this
.
mpApp
.
globalData
.
tabBarPageLink
;
if
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
)
{
this
.
page
=
getUrlofLink
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
);
this
.
mpApp
.
globalData
.
tabBarPageLink
=
""
;
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
methods
:
{
handleError
(
data
)
{
wx
.
showLoading
({
...
...
src/pages/tabBar3/index.vue
View file @
7010d758
<!--
tabbar
1
tabbar
-->
<
template
>
<div>
...
...
@@ -8,26 +8,38 @@
</
template
>
<
script
>
import
{
getUrlofLink
}
from
"../../utils/mayi.js"
;
export
default
{
data
()
{
return
{
link
:
process
.
env
.
BASE_URL
,
page
:
"/"
,
params
:
"?mixid="
+
this
.
$store
.
state
.
mixid
,
index
:
3
};
},
computed
:
{
pageUrl
()
{
return
this
.
link
+
this
.
page
+
this
.
params
;
}
return
this
.
link
+
this
.
page
+
this
.
params
;
}
,
},
onLoad
(
options
)
{
// tabbar 跳转
if
(
this
.
mpApp
.
globalData
.
tabBarPageLink
)
{
this
.
page
=
this
.
mpApp
.
globalData
.
tabBarPageLink
;
if
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
)
{
this
.
page
=
getUrlofLink
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
);
this
.
mpApp
.
globalData
.
tabBarPageLink
=
""
;
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
methods
:
{
handleError
(
data
)
{
wx
.
showLoading
({
...
...
src/pages/tabbar4/index.vue
View file @
7010d758
<!--
tabbar
1
tabbar
-->
<
template
>
<div>
...
...
@@ -8,26 +8,38 @@
</
template
>
<
script
>
import
{
getUrlofLink
}
from
"../../utils/mayi.js"
;
export
default
{
data
()
{
return
{
link
:
process
.
env
.
BASE_URL
,
page
:
"/"
,
params
:
"?mixid="
+
this
.
$store
.
state
.
mixid
,
index
:
4
};
},
computed
:
{
pageUrl
()
{
return
this
.
link
+
this
.
page
+
this
.
params
;
}
return
this
.
link
+
this
.
page
+
this
.
params
;
}
,
},
onLoad
(
options
)
{
// tabbar 跳转
if
(
this
.
mpApp
.
globalData
.
tabBarPageLink
)
{
this
.
page
=
this
.
mpApp
.
globalData
.
tabBarPageLink
;
if
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
)
{
this
.
page
=
getUrlofLink
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
);
this
.
mpApp
.
globalData
.
tabBarPageLink
=
""
;
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
methods
:
{
handleError
(
data
)
{
wx
.
showLoading
({
...
...
src/utils/mayi.js
0 → 100644
View file @
7010d758
// 获取link 中页面地址(link兼容 有object或者string)
export
function
getUrlofLink
(
data
)
{
return
data
.
link
}
// 全局跳转
export
function
$themeToLink
(
data
)
{
let
app
=
getApp
()
let
footerVal
=
app
.
globalData
.
footerVal
.
componentData
.
list
;
console
.
log
(
'393939'
,
footerVal
)
let
type
=
data
.
type
;
if
(
type
==
undefined
||
type
==
'undefined'
)
{
if
(
data
.
length
>
0
)
{
// this.$nuxt.$router.push(data);
}
return
}
// 底部导航跳转
let
parseLink
=
getUrlofLink
(
data
)
let
isFooter
=
footerVal
.
findIndex
(
item
=>
{
return
item
.
link
.
link
==
parseLink
})
if
(
isFooter
>-
1
)
{
wx
.
switchTab
({
url
:
parseLink
==
'/'
?
'/pages/home/main'
:
`/pages/tabBar
${
isFooter
}
/main`
,
})
return
}
// -----------------
if
(
type
==
0
)
{
//无链接
return
}
else
if
(
type
==
1
)
{
//h5页面
//兼容
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
// this.$nuxt.$router.push(data.link);
toPage
(
data
.
link
)
}
else
{
if
(
data
.
link
.
startsWith
(
'http'
)
||
data
.
link
.
startsWith
(
'https'
))
{
// if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
wx
.
miniProgram
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
data
.
link
)
});
// } else {
// window.location = data.link
// }
}
else
{
window
.
location
.
href
=
data
.
link
;
}
}
}
else
if
(
type
==
1.1
)
{
//小程序页面 可能增加登录态拦截
if
(
this
.
$store
.
state
.
miniProgram
==
1
||
this
.
$store
.
state
.
miniProgram
==
2
)
{
wx
.
miniProgram
.
navigateTo
({
url
:
data
.
link
});
}
else
{
// Toast("暂不支持");
}
}
else
if
(
type
==
1.2
)
{
//第三方链接
if
(
data
.
link
==
'outerChain:businessCenter'
)
{
// 进入商家中心外链
let
url
=
`
${
config
.
GUIDE_URL
}
/login?mixid=
${
this
.
$nuxt
.
$route
.
query
.
mixid
}
&back=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
;
window
.
location
.
href
=
url
;
return
}
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
// this.$nuxt.$router.push(data.link);
toPage
(
data
.
link
)
}
else
{
if
(
this
.
$store
.
state
.
miniProgram
==
1
||
this
.
$store
.
state
.
miniProgram
==
2
)
{
$mp
.
miniProgram
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
data
.
link
)
});
}
else
{
window
.
location
.
href
=
data
.
link
}
}
}
else
if
(
type
==
2
)
{
//功能
let
featureType
=
data
.
feature
.
type
;
if
(
featureType
==
'themeCouponClick'
||
featureType
==
0
)
{
//优惠券
this
.
$themeCouponClick
(
data
.
feature
.
value
.
couponCode
,
data
.
feature
.
value
);
}
else
if
(
featureType
==
1
)
{
//分享
console
.
log
(
'是分享了。。。。'
,
cb
);
// if (data.type == 2 && data.feature.type == 1) {
// //分享
// this.$nuxt.$SHARE({
// itemList: data.feature.value
// });
// }
}
else
if
(
featureType
==
"themeMemberCardClick"
||
featureType
==
2
)
{
//会员卡
// this.$themeMemberCardClick(data.feature.value);
}
}
else
if
(
type
==
3
)
{
//小程序跳转到小程序
// if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
// if (this.$store.getters['sceneModule/flushbonadingVisible']) {
// $mp.miniProgram.navigateTo({
// url: `/pages/toMini/toMini?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
// })
// return
// }
// $mp.miniProgram.navigateTo({
// url: `/pages/toMini/main?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
// })
// } else {
// Toast("暂不支持");
// }
}
else
{
//向后兼容
if
(
data
.
length
>
0
)
{
this
.
$nuxt
.
$router
.
push
(
data
.
link
);
}
}
}
function
toPage
(
backPath
,
backParams
)
{
wx
.
navigateTo
({
url
:
`../index/main?from=home&backpath=
${
backPath
}
¶ms=
${
encodeURIComponent
(
backParams
)}
`
});
}
// check url是否为底部栏配置项
\ No newline at end of file
src/utils/watch.js
deleted
100644 → 0
View file @
0fd2aaa7
export
default
{
}
const
handler
=
{
get
:
function
(
obj
,
prop
)
{
console
.
log
(
obj
,
prop
,
'9999999999'
)
return
prop
in
obj
?
obj
[
prop
]
:
37
;
}
};
const
p
=
new
Proxy
({},
handler
);
p
.
a
=
1
;
p
.
b
=
undefined
;
console
.
log
(
p
.
a
,
p
.
b
);
// 1, undefined
console
.
log
(
'c'
in
p
,
p
.
c
);
// false, 37
static/nativeComponents/Banner/index.js
View file @
7010d758
...
...
@@ -31,5 +31,10 @@ Component({
console
.
log
(
val
,
'--------30'
)
this
.
setData
({
activeIndex
:
val
.
detail
.
current
});
},
onClick
(
data
){
let
item
=
data
.
currentTarget
.
dataset
.
item
;
console
.
log
(
data
.
currentTarget
.
dataset
.
item
,
'iiii'
)
app
.
$themeToLink
(
item
.
link
)
}
}
});
\ No newline at end of file
static/nativeComponents/Banner/index.wxml
View file @
7010d758
...
...
@@ -5,7 +5,7 @@
<swiper class="swiper" indicator-dots="{{indicatorDots}}"
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="true" bindchange="bannerChange">
<block wx:for="{{datas.componentData.imgList}}" wx:key="index">
<swiper-item>
<swiper-item
data-item="{{item}}" bindtap="onClick"
>
<view class="swiper-item">
<image src="{{item.imageUrl}}" style="width:100%;border-radius:{{datas.componentData.borderRadius*2}}rpx" mode="widthFix" class="bannerImgItem"></image>
</view>
...
...
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