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
2627491e
Commit
2627491e
authored
May 18, 2021
by
张卓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页h5版,代码重复,首页企业微信pageurl解码
parent
c6bfe646
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
125 deletions
+40
-125
src/pages/index/index.vue
+1
-1
src/pages/wxArticle/index.vue
+39
-124
No files found.
src/pages/index/index.vue
View file @
2627491e
...
@@ -52,7 +52,7 @@ export default {
...
@@ -52,7 +52,7 @@ export default {
},
},
computed
:
{
computed
:
{
pageUrl
()
{
pageUrl
()
{
return
this
.
link
+
this
.
page
+
this
.
params
;
return
decodeURIComponent
(
this
.
link
+
this
.
page
+
this
.
params
)
;
}
}
},
},
watch
:
{
watch
:
{
...
...
src/pages/wxArticle/index.vue
View file @
2627491e
<!--
第三方url
-->
<
template
>
<div>
<web-view
:src=
"link"
@
message=
"getMessage"
@
error=
"handleError"
@
load=
"handleLoad"
></web-view>
</div>
</
template
>
<
script
>
<
script
>
let
forUrlAddKey
;
let
getUrlKey
;
if
(
process
.
browser
)
{
forUrlAddKey
=
require
(
"mayi-front-tools/forUrlAddKey"
).
default
getUrlKey
=
require
(
"mayi-front-tools/getUrlKey"
).
default
}
import
{
serialize
,
getQueryVariable
,
DFSImg
}
from
"@/utils/index"
;
import
{
serialize
,
getQueryVariable
,
DFSImg
}
from
"@/utils/index"
;
export
default
{
export
default
{
data
(){
data
(){
...
@@ -10,8 +30,25 @@ export default {
...
@@ -10,8 +30,25 @@ export default {
}
}
},
},
onLoad
(
options
){
onLoad
(
options
){
console
.
log
(
decodeURIComponent
(
options
.
link
),
'地址'
)
console
.
log
(
decodeURIComponent
(
options
.
link
),
'地址'
,
wx
.
getStorageSync
(
"sessionid"
),
forUrlAddKey
(
decodeURIComponent
(
options
.
link
),{
token
:
wx
.
getStorageSync
(
"sessionid"
),
jwt
:
1
}))
if
(
getUrlKey
(
decodeURIComponent
(
options
.
link
),
'login'
)
!=
'1'
)
{
this
.
link
=
decodeURIComponent
(
options
.
link
)
this
.
link
=
decodeURIComponent
(
options
.
link
)
}
else
{
if
(
wx
.
getStorageSync
(
"sessionid"
))
{
this
.
link
=
forUrlAddKey
(
decodeURIComponent
(
options
.
link
),
{
token
:
wx
.
getStorageSync
(
"sessionid"
),
jwt
:
1
}
)
}
else
{
let
url
=
`/pages/login/main?scene=sso&back=
${
options
.
link
}
`
;
wx
.
navigateTo
({
url
})
}
}
},
},
async
onShareAppMessage
(
res
)
{
async
onShareAppMessage
(
res
)
{
let
url
=
''
let
url
=
''
...
@@ -63,140 +100,18 @@ export default {
...
@@ -63,140 +100,18 @@ export default {
let
len
=
res
.
target
.
data
.
length
-
1
;
let
len
=
res
.
target
.
data
.
length
-
1
;
console
.
log
(
res
,
"h5消息"
,
res
.
target
.
data
[
len
]);
console
.
log
(
res
,
"h5消息"
,
res
.
target
.
data
[
len
]);
this
.
shareShopName
=
res
.
target
.
data
[
len
].
shareShopName
||
""
;
this
.
shareShopName
=
res
.
target
.
data
[
len
].
shareShopName
||
""
;
if
(
res
.
target
.
data
[
len
].
shareLogoUrl
)
{
this
.
shareLogoUrl
=
DFSImg
(
res
.
target
.
data
[
len
].
shareLogoUrl
,
500
,
400
);
this
.
shareLogoUrl
=
DFSImg
(
res
.
target
.
data
[
len
].
shareLogoUrl
,
500
,
400
);
this
.
newWindowHref
=
res
.
target
.
data
[
len
].
shareImgUrl
;
// + '&fromVisitorOpenId=' + wx.getStorageSync("openid")
console
.
log
(
"分享信息:"
,
this
.
shareLogoUrl
,
this
.
shareShopName
,
1111111
,
res
);
},
handleError
(
data
)
{
wx
.
showLoading
({
title
:
"网页加载失败 请右上角刷新"
,
});
},
}
};
</
script
>
<
style
lang=
"scss"
scoped
></
style
>
<
template
>
<div>
<web-view
:src=
"link"
@
message=
"getMessage"
@
error=
"handleError"
@
load=
"handleLoad"
></web-view>
</div>
</
template
>
<
script
>
import
indexApi
from
"@/api/index.js"
;
export
default
{
data
()
{
return
{
link
:
""
,
shareShopName
:
''
,
//分享名称
shareLogoUrl
:
''
,
//分享图片url
newWindowHref
:
''
,
//分享页面url
};
},
async
onLoad
(
options
)
{
console
.
log
(
'wxarticle'
,
options
)
// options.scene="64a77cd6aeac4c1db46e3f7d53596fe6"
if
(
options
.
link
)
{
this
.
link
=
decodeURIComponent
(
options
.
link
);
}
else
if
(
options
.
scene
)
{
//扫码
let
data
=
await
this
.
getParams
(
options
.
scene
);
if
(
data
.
sso
)
{
if
(
!
wx
.
getStorageSync
(
"sessionid"
))
{
wx
.
redirectTo
({
url
:
`../login/main?scene=sso&back=
${
data
.
link
}
`
,
});
}
else
{
let
link
=
decodeURIComponent
(
data
.
link
).
replace
(
"${token}"
,
wx
.
getStorageSync
(
"sessionid"
)
);
this
.
link
=
decodeURIComponent
(
link
);
}
}
}
},
methods
:
{
getParams
(
options
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
indexApi
.
getShareSceneRecord
(
options
)
.
then
((
res
)
=>
{
if
(
res
.
data
.
code
==
"200"
)
{
let
scene
=
JSON
.
parse
(
res
.
data
.
data
.
scene
);
resolve
(
scene
);
}
}
})
.
catch
((
err
)
=>
{});
});
},
//右上角分享时触发
getMessage
(
res
)
{
let
len
=
res
.
target
.
data
.
length
-
1
;
console
.
log
(
res
,
"h5消息"
,
res
.
target
.
data
[
len
]);
this
.
shareShopName
=
res
.
target
.
data
[
len
].
shareShopName
||
""
;
this
.
shareLogoUrl
=
DFSImg
(
res
.
target
.
data
[
len
].
shareLogoUrl
,
500
,
400
);
this
.
newWindowHref
=
res
.
target
.
data
[
len
].
shareImgUrl
;
// + '&fromVisitorOpenId=' + wx.getStorageSync("openid")
this
.
newWindowHref
=
res
.
target
.
data
[
len
].
shareImgUrl
;
// + '&fromVisitorOpenId=' + wx.getStorageSync("openid")
console
.
log
(
"分享信息:"
,
this
.
shareLogoUrl
,
this
.
shareShopName
,
1111111
,
res
);
console
.
log
(
"分享信息:"
,
this
.
shareLogoUrl
,
this
.
shareShopName
,
1111111
,
res
);
},
},
//加载成功
handleLoad
()
{
console
.
log
(
"网页加载成功"
);
},
handleError
(
data
)
{
handleError
(
data
)
{
wx
.
showLoading
({
wx
.
showLoading
({
title
:
"网页加载失败 请右上角刷新"
,
title
:
"网页加载失败 请右上角刷新"
,
});
});
},
},
},
async
onShareAppMessage
(
res
)
{
let
url
=
''
console
.
log
(
this
.
newWindowHref
+
'this.newWindowHref'
)
//分享路径
if
(
this
.
newWindowHref
){
url
=
this
.
newWindowHref
;
}
else
{
url
=
res
.
webViewUrl
;
}
//分享页面去掉登录态
if
(
url
.
indexOf
(
"sessionid"
)
>
-
1
)
{
url
=
url
.
split
(
"?"
)[
0
]
+
"?mixid="
+
this
.
shopId
;
}
this
.
shareUrl
=
url
;
console
.
log
(
this
.
shareUrl
,
"index12"
);
console
.
log
(
`/pages/index/main?link=
${
encodeURIComponent
(
this
.
shareUrl
)}
`
,
'测试直播分享相关'
)
return
{
title
:
this
.
shareShopName
,
// 默认是小程序的名称
path
:
`/pages/wxArticle/main?link=
${
encodeURIComponent
(
this
.
shareUrl
)}
`
,
// 默认是当前页面
imageUrl
:
this
.
shareLogoUrl
,
success
:
function
(
res
)
{
// 转发成功之后的回调
if
(
res
.
errMsg
==
"shareAppMessage:ok"
)
{
console
.
log
(
res
,
"分享成功"
);
}
},
fail
:
function
()
{
// 转发失败之后的回调
if
(
res
.
errMsg
==
"shareAppMessage:fail cancel"
)
{
// 用户取消转发
console
.
log
(
res
,
"分享失败"
);
}
else
if
(
res
.
errMsg
==
"shareAppMessage:fail"
)
{
// 转发失败,其中 detail message 为详细失败信息
}
}
},
complete
:
function
()
{
// 转发结束之后的回调(转发成不成功都会执行)
}
};
},
};
};
</
script
>
</
script
>
...
...
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