Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
e0a41a90
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e0a41a90
编写于
11月 09, 2023
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 部分页面回调改为箭头函数方式
上级
56ec9a7b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
98 addition
and
98 deletion
+98
-98
pages/API/download-file/download-file.uvue
pages/API/download-file/download-file.uvue
+74
-74
pages/API/request/request.uvue
pages/API/request/request.uvue
+6
-6
pages/API/websocket-global/websocket-global.uvue
pages/API/websocket-global/websocket-global.uvue
+8
-8
pages/API/websocket-socketTask/websocket-socketTask.uvue
pages/API/websocket-socketTask/websocket-socketTask.uvue
+10
-10
未找到文件。
pages/API/download-file/download-file.uvue
浏览文件 @
e0a41a90
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
...
...
@@ -16,85 +16,85 @@
</view>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: 'downloadFile',
imageSrc: '',
task: null as DownloadTask | null,
pageVisible: false,
//自动化测试例专用
jest_result: false
}
},
onLoad() {
this.pageVisible = true;
},
onUnload() {
this.imageSrc = '';
this.pageVisible = false;
uni.hideLoading();
this.task?.abort();
},
methods: {
downloadImage: function() {
uni.showLoading({
title: '下载中'
})
var self = this
this.task = uni.downloadFile({
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
success(res) {
if (this.pageVisible) {
console.log('downloadFile success, res is', res)
self.imageSrc = res.tempFilePath;
uni.hideLoading();
}
},
fail: (err) => {
if (this.pageVisible) {
console.log('downloadFile fail, err is:', err)
uni.hideLoading();
}
}
});
this.task?.onProgressUpdate((update) => {
if (this.pageVisible) {
console.log("progress : ", update.progress);
}
})
},
//自动化测试例专用
jest_downloadFile(){
uni.downloadFile({
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
success() {
this.jest_result = true
},
fail: () => {
this.jest_result = false
}
});
export default {
data() {
return {
title: 'downloadFile',
imageSrc: '',
task: null as DownloadTask | null,
pageVisible: false,
//自动化测试例专用
jest_result: false
}
},
onLoad() {
this.pageVisible = true;
},
onUnload() {
this.imageSrc = '';
this.pageVisible = false;
uni.hideLoading();
this.task?.abort();
},
methods: {
downloadImage: function () {
uni.showLoading({
title: '下载中'
})
var self = this
this.task = uni.downloadFile({
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
success: (res) => {
if (this.pageVisible) {
console.log('downloadFile success, res is', res)
self.imageSrc = res.tempFilePath;
uni.hideLoading();
}
},
fail: (err) => {
if (this.pageVisible) {
console.log('downloadFile fail, err is:', err)
uni.hideLoading();
}
}
});
this.task?.onProgressUpdate((update) => {
if (this.pageVisible) {
console.log("progress : ", update.progress);
}
})
},
//自动化测试例专用
jest_downloadFile() {
uni.downloadFile({
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
success: () => {
this.jest_result = true
},
fail: () => {
this.jest_result = false
}
});
}
}
}
}
}
</script>
<style>
.img {
width: 500rpx;
height: 500rpx;
margin: 0 auto;
}
.img {
width: 500rpx;
height: 500rpx;
margin: 0 auto;
}
.image-container {
display: flex;
justify-content: center;
align-items: center;
}
</style>
.image-container {
display: flex;
justify-content: center;
align-items: center;
}
</style>
\ No newline at end of file
pages/API/request/request.uvue
浏览文件 @
e0a41a90
...
...
@@ -190,7 +190,7 @@
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success
(res)
{
success
: (res) =>
{
if (this.pageVisible) {
console.log('request success', JSON.stringify(res.data))
uni.showToast({
...
...
@@ -202,7 +202,7 @@
this.res = '请求结果 : ' + JSON.stringify(res);
}
},
fail
(err)
{
fail
: (err) =>
{
if (this.pageVisible) {
console.log('request fail', err);
uni.showModal({
...
...
@@ -211,7 +211,7 @@
});
}
},
complete
()
{
complete
: () =>
{
uni.hideLoading()
},
});
...
...
@@ -229,14 +229,14 @@
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success
()
{
success
: () =>
{
this.jest_result = true;
},
fail
()
{
fail
: () =>
{
this.jest_result = false;
},
});
}
}
}
</script>
</script>
\ No newline at end of file
pages/API/websocket-global/websocket-global.uvue
浏览文件 @
e0a41a90
...
...
@@ -60,10 +60,10 @@ export default {
uni.closeSocket({
code: 1000,
reason: 'close reason from client',
success
(res: any)
{
success
:(res: any) =>
{
console.log('uni.closeSocket success', res)
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log('uni.closeSocket fail', err)
},
} as CloseSocketOptions)
...
...
@@ -84,11 +84,11 @@ export default {
})
uni.connectSocket({
url: 'ws://websocket.dcloud.net.cn',
success
(res: any)
{
success
:(res: any) =>
{
// 这里是接口调用成功的回调,不是连接成功的回调,请注意
console.log('uni.connectSocket success', res)
},
fail
(err: any)
{
fail
:(err: any) =>
{
// 这里是接口调用失败的回调,不是连接失败的回调,请注意
console.log('uni.connectSocket fail', err)
},
...
...
@@ -140,10 +140,10 @@ export default {
this.platform +
' : ' +
parseInt((Math.random() * 10000).toString()).toString(),
success
(res: any)
{
success
:(res: any) =>
{
console.log(res)
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log(err)
},
} as SendSocketMessageOptions)
...
...
@@ -152,10 +152,10 @@ export default {
uni.closeSocket({
code: 1000,
reason: 'close reason from client',
success
(res: any)
{
success
:(res: any) =>
{
console.log('uni.closeSocket success', res)
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log('uni.closeSocket fail', err)
},
} as CloseSocketOptions)
...
...
pages/API/websocket-socketTask/websocket-socketTask.uvue
浏览文件 @
e0a41a90
...
...
@@ -65,10 +65,10 @@ export default {
task.close({
code: 1000,
reason: 'close reason from client',
success
(res: any)
{
success
:(res: any) =>
{
console.log('uni.closeSocket success', res)
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log('uni.closeSocket fail', err)
},
} as CloseSocketOptions)
...
...
@@ -89,11 +89,11 @@ export default {
})
this.socketTask = uni.connectSocket({
url: 'ws://websocket.dcloud.net.cn',
success
(res: any)
{
success
:(res: any) =>
{
// 这里是接口调用成功的回调,不是连接成功的回调,请注意
console.log('uni.connectSocket success', res)
},
fail
(err: any)
{
fail
:(err: any) =>
{
// 这里是接口调用失败的回调,不是连接失败的回调,请注意
console.log('uni.connectSocket fail', err)
},
...
...
@@ -145,10 +145,10 @@ export default {
parseInt(Math.random() * 10000 + '').toString()
this.socketTask?.send({
data,
success
(res: any)
{
success
:(res: any) =>
{
console.log(res)
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log(err)
},
} as SendSocketMessageOptions)
...
...
@@ -157,10 +157,10 @@ export default {
this.socketTask?.close({
code: 1000,
reason: 'close reason from client',
success
(res: any)
{
success
:(res: any) =>
{
console.log('uni.closeSocket success', res)
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log('uni.closeSocket fail', err)
},
} as CloseSocketOptions)
...
...
@@ -184,10 +184,10 @@ export default {
parseInt(Math.random() * 10000 + '').toString()
this.socketTask?.send({
data,
success
(_)
{
success
:(_) =>
{
this.jest_result++
},
fail
(_)
{
fail
:(_) =>
{
this.jest_result = 0
},
} as SendSocketMessageOptions)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录