Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl-group-course
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄志
ydl-group-course
Commits
77d41957
Commit
77d41957
authored
Mar 15, 2023
by
huangzhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加一个测试页面
parent
8f215cd6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
263 additions
and
18 deletions
+263
-18
config.js
src/config.js
+9
-5
pages.json
src/pages.json
+6
-0
my.vue
src/pages/my/my.vue
+39
-13
test.vue
src/pages/test/test.vue
+209
-0
No files found.
src/config.js
View file @
77d41957
...
@@ -6,11 +6,15 @@ let h2Prefix
...
@@ -6,11 +6,15 @@ let h2Prefix
let
ydlH5Prefix
let
ydlH5Prefix
if
(
isDevelopment
)
{
if
(
isDevelopment
)
{
hostPrefix
=
'https://testnewm.ydl.com'
// 开发
// hostPrefix = 'http://192.168.211.138'
// hostPrefix = 'https://testnewm.ydl.com'
apiPrefix
=
'https://testapi.ydl.com'
// // hostPrefix = 'http://192.168.211.138'
// hostPrefix = 'https://newm-test.ydl.com' // 下云
// apiPrefix = 'https://testapi.ydl.com'
// apiPrefix = 'https://api-test.ydl.com' // 下云
// 下云
hostPrefix
=
'https://newm-test.ydl.com'
// 下云
apiPrefix
=
'https://api-test.ydl.com'
// 下云
h2Prefix
=
'https://h2.yidianling.com'
h2Prefix
=
'https://h2.yidianling.com'
ydlH5Prefix
=
'https://testh5.ydl.com'
ydlH5Prefix
=
'https://testh5.ydl.com'
}
else
{
}
else
{
...
...
src/pages.json
View file @
77d41957
...
@@ -33,6 +33,12 @@
...
@@ -33,6 +33,12 @@
}
}
},
},
{
{
"path"
:
"pages/test/test"
,
"style"
:
{
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/login/login"
,
"path"
:
"pages/login/login"
,
"style"
:
{
"style"
:
{
"navigationStyle"
:
"custom"
,
"navigationStyle"
:
"custom"
,
...
...
src/pages/my/my.vue
View file @
77d41957
...
@@ -119,6 +119,14 @@ export default {
...
@@ -119,6 +119,14 @@ export default {
this
.
logoutVisible
=
true
this
.
logoutVisible
=
true
},
},
},
},
{
icon
:
'/static/icon_order.png'
,
label
:
'测试二维码'
,
callback
:
()
=>
{
this
.
handleSendMenuTrackData
(
'测试二维码'
)
this
.
navigateToOrder1
()
},
},
],
],
logoutVisible
:
false
,
logoutVisible
:
false
,
}
}
...
@@ -158,19 +166,19 @@ export default {
...
@@ -158,19 +166,19 @@ export default {
methods
:
{
methods
:
{
// 菜单项的埋点
// 菜单项的埋点
handleSendMenuTrackData
(
content
)
{
handleSendMenuTrackData
(
content
)
{
setTrackData
({
//
setTrackData({
events
:
[
//
events: [
{
//
{
event_id
:
'content_click'
,
//
event_id: 'content_click',
event_custom_properties
:
{
//
event_custom_properties: {
part
:
'ydl_user_my_page'
,
//
part: 'ydl_user_my_page',
position
:
'other_list'
,
//
position: 'other_list',
element
:
'other_column'
,
//
element: 'other_column',
content
,
//
content,
},
//
},
},
//
},
],
//
],
})
//
})
},
},
// 登录点击事件
// 登录点击事件
handleLoginClick
()
{
handleLoginClick
()
{
...
@@ -224,6 +232,24 @@ export default {
...
@@ -224,6 +232,24 @@ export default {
url
:
`/pages/web/web?title=已购订单&loadUrl=
${
encodeURIComponent
(
url
)}
`
,
url
:
`/pages/web/web?title=已购订单&loadUrl=
${
encodeURIComponent
(
url
)}
`
,
})
})
},
},
// 跳转订单
navigateToOrder1
()
{
// const aa =
// 'orderId=90230307003008&totalAmount=0.03&balance=9779&payType=5&title=%E6%94%AF%E4%BB%98%E4%B8%AD%E9%97%B4%E9%A1%B5%E9%9D%A2'
// uni.navigateTo({
// url: `/pages/pay/pay`,
// })
if
(
!
this
.
isLogin
)
{
this
.
handleLogin
()
return
}
const
url
=
`
${
hostPrefix
}
/h5-course/my/components/Buylist`
// const url = `${hostPrefix}/h5-course/detail/7747?uid&accessToken&appId=wx1106c32a36d87d49&isFromMin=weapp&miniType=groupActivity&ffrom=AppletWechatCourseFuLi×tamp=1678689403156`
uni
.
navigateTo
({
url
:
`/pages/test/test?title=已购订单&loadUrl=
${
encodeURIComponent
(
url
)}
`
,
})
},
},
},
}
}
</
script
>
</
script
>
...
...
src/pages/test/test.vue
0 → 100644
View file @
77d41957
<
template
>
<!--
<web-view
v-if=
"!!loadUrl"
:src=
"loadUrl"
@
onPostMessage=
"handlePostMessage"
@
message=
"handleMessage"
></web-view>
-->
<div>
<div>
<span>
scene::
</span>
<span>
{{
cccc
}}
</span>
</div>
<view
@
click=
"handleLoginClick(cccc)"
>
复制到剪切板
</view>
<div>
-------------
</div>
<div>
<span>
loadUrl::
</span>
<!--
<span>
{{
loadUrl
}}
</span>
-->
</div>
<div
class=
"test-url"
>
{{
loadUrl
}}
</div>
<view
@
click=
"handleLoginClick(loadUrl)"
>
复制到剪切板
</view>
<div>
-------------
</div>
<div>
<span>
options::
</span>
<!--
<span>
{{
loadUrl
}}
</span>
-->
</div>
<div
class=
"test-url"
>
{{
JSON
.
stringify
(
options
)
}}
</div>
<view
@
click=
"handleLoginClick(JSON.stringify(options))"
>
复制到剪切板
</view>
<div>
-------------
</div>
<!--
<div>
<span>
loadUrl::
</span>
<span>
{{
loadUrl
}}
</span>
</div>
-->
</div>
</
template
>
<
script
>
import
{
hostPrefix
}
from
'@/config.js'
import
{
ffrom
}
from
'@/utils/enums'
export
default
{
name
:
'WebPage'
,
data
()
{
return
{
cccc
:
'1'
,
loadUrl
:
''
,
options
:
{},
}
},
onLoad
(
options
)
{
// 监听登录成功事件
uni
.
$on
(
'loginSuccess'
,
this
.
handleLoginSuccess
)
this
.
options
=
options
||
{}
// 设置标题
if
(
this
.
options
.
title
)
{
uni
.
setNavigationBarTitle
({
title
:
this
.
options
.
title
,
})
}
this
.
cccc
=
options
.
scene
// 有scene,说明是扫描二维码进入
if
(
options
.
scene
)
{
uni
.
showLoading
({
title
:
'加载中'
,
})
this
.
getParamsByScene
(
options
.
scene
)
}
},
// 移除登录成功事件
onUnload
()
{
uni
.
$off
(
'loginSuccess'
,
this
.
handleLoginSuccess
)
},
mounted
()
{
// this.options.scene 无值,说明是非扫描二维码,此时自己拼装路径
if
(
!
this
.
options
.
scene
)
{
this
.
initWeviewUrl
()
}
},
methods
:
{
// 初始化页面地址
handleLoginClick
(
data
)
{
uni
.
setClipboardData
({
data
:
String
(
data
),
success
:
function
()
{
uni
.
showToast
({
title
:
'复制成功'
,
duration
:
1000
,
})
},
})
},
// 设置页面地址额外的通用参数
setCommonUrlParams
(
pageUrl
,
urlParmas
)
{
let
url
=
decodeURIComponent
(
pageUrl
)
const
query
=
{
uid
:
this
.
$store
.
state
.
user
.
uid
||
''
,
accessToken
:
this
.
$store
.
state
.
user
.
accessToken
||
''
,
appId
:
uni
.
getAccountInfoSync
().
miniProgram
.
appId
,
isFromMin
:
'weapp'
,
miniType
:
'groupActivity'
,
ffrom
,
timestamp
:
+
new
Date
(),
...
urlParmas
,
}
// 更新 url 中的参数
Object
.
keys
(
query
).
forEach
(
prop
=>
{
url
=
this
.
changeURLArg
(
url
,
prop
,
query
[
prop
])
})
return
url
},
// 初始化页面地址
initWeviewUrl
()
{
// 判断即将进入的页面是否需要登录
if
(
this
.
options
.
login
&&
!
this
.
$store
.
getters
.
isLogin
)
{
uni
.
navigateTo
({
url
:
'/pages/login/login?required=1'
,
})
}
else
{
this
.
loadUrl
=
this
.
setCommonUrlParams
(
this
.
options
.
loadUrl
||
this
.
options
.
load_url
)
console
.
log
(
this
.
loadUrl
)
}
},
// 二维码识别进入小程序携带参数 scene 需要通过接口解析具体数据
async
getParamsByScene
(
scene
)
{
const
appId
=
uni
.
getAccountInfoSync
().
miniProgram
.
appId
try
{
const
res
=
await
this
.
$request
.
get
(
`mini/wx/business/
${
appId
}
/qrCodeParam?scene=
${
scene
}
`
)
.
finally
(()
=>
(
this
.
loading
=
false
))
if
(
res
)
{
// https://testnewm.ydl.com/h5-course/detail/7529
const
url
=
`
${
hostPrefix
}
/h5-course/detail/
${
res
.
productId
}
`
// productId 商品id
// activityId 拼团活动id
// channel 活动渠道
// recordId 成团id
// shareUid 分享人id
// moreId 待定
const
params
=
[
'activityId'
,
'channel'
,
'recordId'
,
'shareUid'
].
reduce
((
acc
,
key
)
=>
{
// groupRecordId
if
(
res
[
key
]
||
res
[
key
]
===
0
)
{
// 为了保证参数连贯性,使用通用的 groupRecordId
if
(
key
===
'recordId'
)
{
acc
[
'groupRecordId'
]
=
res
[
key
]
}
else
{
acc
[
key
]
=
res
[
key
]
}
}
return
acc
},
{})
this
.
loadUrl
=
this
.
setCommonUrlParams
(
`
${
url
}
`
,
params
)
console
.
log
(
res
,
'二维码参数解析'
)
uni
.
hideLoading
()
}
else
{
uni
.
showToast
({
title
:
'二维码解析失败'
,
icon
:
'error'
,
})
uni
.
hideLoading
()
}
}
catch
(
err
)
{
console
.
log
(
err
,
'<<<<<请求错误'
)
}
},
// webview向外部发送消息
handlePostMessage
:
function
(
data
)
{
console
.
log
(
'接收到消息:'
+
JSON
.
stringify
(
data
.
detail
))
},
// webview向外部发送消息
handleMessage
:
function
(
data
)
{
console
.
log
(
'接收到消息22 Message:'
+
JSON
.
stringify
(
data
.
detail
))
},
// 更新 url 中的参数
changeURLArg
(
url
,
arg
,
value
)
{
const
pattern
=
arg
+
'=([^&]*)'
const
replaceText
=
arg
+
'='
+
value
if
(
url
.
match
(
pattern
))
{
const
exp
=
new
RegExp
(
`(
${
arg
}
=)([^&]*)`
,
'gi'
)
return
url
.
replace
(
exp
,
replaceText
)
}
else
{
if
(
url
.
match
(
'[
\
?]'
))
{
return
url
+
'&'
+
replaceText
}
else
{
return
url
+
'?'
+
replaceText
}
}
},
// 登录成功后重新初始化
handleLoginSuccess
()
{
this
.
init
()
},
},
}
</
script
>
<
style
lang=
"less"
scoped
>
.test-url
{
overflow
:
auto
;
}
</
style
>
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