Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
D-GSQ
uni-app
提交
19382f29
U
uni-app
项目概览
D-GSQ
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
19382f29
编写于
8月 26, 2022
作者:
d-u-a
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增 ad-interactive
上级
11efa0b2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
126 addition
and
109 deletion
+126
-109
packages/uni-cli-shared/components/ad-interactive.vue
packages/uni-cli-shared/components/ad-interactive.vue
+126
-109
未找到文件。
packages/uni-cli-shared/components/ad-interactive.vue
浏览文件 @
19382f29
<
template
>
<view
@
click=
"onclick"
>
<slot
:options=
"options"
:data=
"adData"
/>
<slot
:options=
"options"
:data=
"adData"
:loading=
"loading"
:error=
"errorMessage"
/>
</view>
</
template
>
<
script
>
const
AD_URL
=
'
https://wxac1.dcloud.net.cn/tuiaApplet
/acs
'
const
AD_REPORT_URL
=
'
https://wxac1.dcloud.net.cn/tuiaApplet
/acs
'
const
WEBVIEW_PATH
=
'
/uni_modules/uni-ad-interactive/pages/uni-ad-interactive/uni-ad-interactive
'
const
AD_URL
=
'
https://wxac1.dcloud.net.cn/openPage
/acs
'
const
AD_REPORT_URL
=
'
https://wxac1.dcloud.net.cn/openPage
/acs
'
//
const WEBVIEW_PATH = '/uni_modules/uni-ad-interactive/pages/uni-ad-interactive/uni-ad-interactive'
const
events
=
{
load
:
'
load
'
,
close
:
'
close
'
,
error
:
'
error
'
}
const
events
=
{
load
:
'
load
'
,
close
:
'
close
'
,
error
:
'
error
'
}
const
OpenTypes
=
{
Interactive
:
'
interactive
'
}
const
OpenTypes
=
{
Interactive
:
'
interactive
'
}
export
default
{
name
:
'
AdInteractive
'
,
props
:
{
options
:
{
type
:
[
Object
,
Array
],
default
()
{
return
{}
export
default
{
name
:
'
AdInteractive
'
,
props
:
{
options
:
{
type
:
[
Object
,
Array
],
default
()
{
return
{}
}
},
disabled
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
adpid
:
{
type
:
[
Number
,
String
],
default
:
''
},
openType
:
{
type
:
String
,
default
:
'
interactive
'
},
openPagePath
:
{
type
:
String
,
default
:
""
}
},
adpid
:
{
type
:
[
Number
,
String
],
default
:
''
},
openUrl
:
{
type
:
String
,
default
:
WEBVIEW_PATH
}
},
data
()
{
return
{
adData
:
{}
}
},
created
()
{
this
.
_uniAdPlugin
=
null
this
.
_interactiveUrl
=
null
if
(
this
.
openType
===
OpenTypes
.
Interactive
)
{
this
.
getAdData
()
}
},
methods
:
{
show
()
{
if
(
this
.
_uniAdPlugin
===
null
)
{
this
.
_uniAdPlugin
=
this
.
selectComponent
(
'
.uni-ad-plugin
'
)
data
()
{
return
{
adData
:
null
,
loading
:
false
,
errorMessage
:
""
}
this
.
_uniAdPlugin
.
show
()
},
getAdData
()
{
if
(
!
this
.
adpid
)
{
this
.
$emit
(
events
.
error
,
{
code
:
-
5002
,
message
:
'
invalid adpid
'
})
return
created
()
{
this
.
_uniAdPlugin
=
null
this
.
_interactiveUrl
=
null
if
(
this
.
openPagePath
)
{
this
.
getAdData
()
}
},
methods
:
{
show
()
{
if
(
this
.
_uniAdPlugin
===
null
)
{
this
.
_uniAdPlugin
=
this
.
selectComponent
(
'
.uni-ad-plugin
'
)
}
this
.
_uniAdPlugin
.
show
()
},
getAdData
()
{
if
(
!
this
.
adpid
)
{
this
.
$emit
(
events
.
error
,
{
code
:
-
5002
,
message
:
'
invalid adpid
'
})
return
}
uni
.
request
({
url
:
AD_URL
,
method
:
'
POST
'
,
data
:
{
adpid
:
this
.
adpid
},
timeout
:
5000
,
dataType
:
'
json
'
,
success
:
(
res
)
=>
{
console
.
log
(
res
.
data
)
this
.
loading
=
true
if
(
res
.
statusCode
!==
200
)
{
this
.
$emit
(
events
.
error
,
{
code
:
res
.
statusCode
,
message
:
res
.
statusCode
})
return
}
uni
.
request
({
url
:
AD_URL
,
method
:
'
POST
'
,
data
:
{
adpid
:
this
.
adpid
},
timeout
:
5000
,
dataType
:
'
json
'
,
success
:
(
res
)
=>
{
if
(
res
.
statusCode
!==
200
)
{
this
.
$emit
(
events
.
error
,
{
errCode
:
res
.
statusCode
,
errMsg
:
res
.
statusCode
})
return
}
const
responseData
=
res
.
data
if
(
responseData
.
ret
===
0
)
{
this
.
_interactiveUrl
=
responseData
.
data
.
adp_url
this
.
adData
.
imgUrl
=
responseData
.
data
.
icon_url
this
.
adData
.
openUrl
=
this
.
openUrl
+
'
?url=
'
+
encodeURIComponent
(
this
.
_interactiveUrl
)
this
.
$emit
(
events
.
load
,
{})
}
else
{
const
responseData
=
res
.
data
if
(
responseData
.
ret
===
0
)
{
this
.
_interactiveUrl
=
responseData
.
data
.
adp_url
this
.
adData
=
{
imgUrl
:
responseData
.
data
.
icon_url
,
openPath
:
this
.
openPagePath
+
'
?url=
'
+
encodeURIComponent
(
this
.
_interactiveUrl
)
}
this
.
$emit
(
events
.
load
,
this
.
adData
)
}
else
{
const
errMsg
=
{
errCode
:
responseData
.
ret
,
errMsg
:
responseData
.
msg
}
this
.
errorMessage
=
errMsg
this
.
$emit
(
events
.
error
,
errMsg
)
}
},
fail
:
(
err
)
=>
{
this
.
$emit
(
events
.
error
,
{
code
:
responseData
.
ret
,
message
:
responseData
.
m
sg
errCode
:
''
,
errMsg
:
err
.
errM
sg
})
},
complete
:
()
=>
{
this
.
loading
=
false
}
},
fail
:
(
err
)
=>
{
this
.
$emit
(
events
.
error
,
{
code
:
''
,
message
:
err
.
errMsg
})
})
},
onclick
()
{
if
(
this
.
disabled
)
{
return
}
if
(
!
this
.
_interactiveUrl
)
{
return
}
})
},
onclick
()
{
if
(
this
.
openType
!==
OpenTypes
.
Interactive
||
!
this
.
_interactiveUrl
)
{
return
}
uni
.
navigateTo
({
url
:
this
.
adData
.
openUrl
})
uni
.
navigateTo
({
url
:
this
.
adData
.
openPath
})
this
.
_report
()
},
_report
()
{
uni
.
request
({
url
:
AD_REPORT_URL
,
data
:
{
adpid
:
this
.
adpid
,
t
:
'
10019
'
},
timeout
:
5000
,
dataType
:
'
json
'
})
this
.
_report
()
},
_report
()
{
uni
.
request
({
url
:
AD_REPORT_URL
,
data
:
{
adpid
:
this
.
adpid
,
t
:
'
10019
'
},
timeout
:
5000
,
dataType
:
'
json
'
})
}
}
}
}
</
script
>
<
style
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录