Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
a64e10aa
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
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看板
提交
a64e10aa
编写于
7月 01, 2023
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改问题
上级
600823ad
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
462 addition
and
287 deletion
+462
-287
pages.json
pages.json
+27
-18
pages/API/download-file/download-file.uvue
pages/API/download-file/download-file.uvue
+46
-29
pages/API/request/request.uvue
pages/API/request/request.uvue
+54
-39
pages/API/upload-file/upload-file.uvue
pages/API/upload-file/upload-file.uvue
+33
-15
pages/API/websocket-global/websocket-global.uvue
pages/API/websocket-global/websocket-global.uvue
+164
-151
pages/API/websocket-socketTask/websocket-socketTask.uvue
pages/API/websocket-socketTask/websocket-socketTask.uvue
+43
-32
pages/component/list/list.uvue
pages/component/list/list.uvue
+87
-0
pages/component/scroll-view/scroll-view-refresher.uvue
pages/component/scroll-view/scroll-view-refresher.uvue
+3
-2
pages/tabBar/component/component.uvue
pages/tabBar/component/component.uvue
+5
-1
未找到文件。
pages.json
浏览文件 @
a64e10aa
...
...
@@ -529,6 +529,15 @@
"enablePullDownRefresh"
:
false
}
}
,{
"path"
:
"pages/component/list/list"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
}
],
"globalStyle"
:
{
...
...
pages/API/download-file/download-file.uvue
浏览文件 @
a64e10aa
...
...
@@ -17,35 +17,51 @@
</view>
</template>
<script>
import DownloadTask from 'uts.sdk.modules.DCloudUniNetwork.DownloadTask';
export default {
data() {
return {
title: 'downloadFile',
imageSrc: ''
imageSrc: '',
task: null as DownloadTask | null,
pageVisible: false
}
},
onLoad() {
this.pageVisible = true;
},
onUnload() {
this.imageSrc = '';
this.pageVisible = false;
uni.hideLoading();
this.task?.abort();
},
methods: {
downloadImage: function
() {
downloadImage: function() {
uni.showLoading({
title:'下载中'
title:
'下载中'
})
var self = this
let task = uni.downloadFile({
url: "http
://192.168.12.106:8080/downloadfile",
this.task = uni.downloadFile({
url: "http
s://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();
}
}
});
task!.onProgressUpdate((update) => {
this.task?.onProgressUpdate((update) => {
if (this.pageVisible) {
console.log("progress : ", update.progress);
}
})
}
}
...
...
@@ -53,14 +69,15 @@
</script>
<style>
.img {
.img {
width: 500rpx;
height: 500rpx;
margin: 0 auto;
}
.image-container {
}
.image-container {
display: flex;
justify-content: center;
align-items: center;
}
}
</style>
\ No newline at end of file
pages/API/request/request.uvue
浏览文件 @
a64e10aa
...
...
@@ -15,20 +15,31 @@
</view>
</template>
<script>
import RequestTask from 'uts.sdk.modules.DCloudUniNetwork.RequestTask';
const duration = 2000
export default {
data() {
return {
title: 'request',
loading: false,
res: ''
res: '',
task: null as RequestTask | null,
pageVisible: false
}
},
onLoad() {
this.pageVisible = true;
},
onUnload() {
this.pageVisible = false;
uni.hideLoading();
this.task?.abort();
},
methods: {
sendRequest() {
this.loading = true;
uni.request({
url: "http
://192.168.12.106:8080/postHalo",
this.task = uni.request({
url: "http
s://unidemo.dcloud.net.cn/ajax/echo/text?name=uni-app",
dataType: "json",
responseType: "json",
method: "POST",
...
...
@@ -43,6 +54,7 @@
withCredentials: false,
firstIpv4: false,
success(res) {
if (this.pageVisible) {
console.log('request success', res)
uni.showToast({
title: '请求成功',
...
...
@@ -51,13 +63,16 @@
duration: duration
});
this.res = '请求结果 : ' + JSON.stringify(res);
}
},
fail(err) {
if (this.pageVisible) {
console.log('request fail', err);
uni.showModal({
content: err.errMsg,
showCancel: false
});
}
},
complete() {
this.loading = false;
...
...
pages/API/upload-file/upload-file.uvue
浏览文件 @
a64e10aa
...
...
@@ -10,15 +10,24 @@
</view>
</template>
<script>
import UploadTask from 'uts.sdk.modules.DCloudUniNetwork.UploadTask';
export default {
data() {
return {
title: 'uploadFile',
imageSrc: ''
imageSrc: '',
task: null as UploadTask | null,
pageVisible: false
}
},
onLoad() {
this.pageVisible = true;
},
onUnload() {
this.imageSrc = '';
this.pageVisible = false;
uni.hideLoading();
this.task?.abort();
},
methods: {
chooseImage: function() {
...
...
@@ -29,28 +38,37 @@
success: (res) => {
console.log('chooseImage success, temp path is', res.tempFilePaths[0])
var imageSrc = res.tempFilePaths[0]
uni.uploadFile({
url: 'http://192.168.12.106:8080/uploadFile', //仅为示例,非真实的接口地址
uni.showLoading({
title: '上传中'
})
this.task = uni.uploadFile({
url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址
filePath: imageSrc,
name: 'file',
formData: {
'user': 'test'
},
success: (res) => {
if (this.pageVisible) {
console.log('uploadImage success, res is:', res)
uni.hideLoading();
uni.showToast({
title: '上传成功',
icon: 'success',
duration: 1000
})
this.imageSrc = imageSrc
}
},
fail: (err) => {
if (this.pageVisible) {
console.log('uploadImage fail', err);
uni.hideLoading();
uni.showModal({
content: err.errMsg,
showCancel: false
});
}
},
});
},
...
...
pages/API/websocket-global/websocket-global.uvue
浏览文件 @
a64e10aa
...
...
@@ -14,7 +14,7 @@
</template>
<script>
import CloseSocketOptions from 'uts.sdk.modules.DCloudUniWebsocket.CloseSocketOptions';
import CloseSocketOptions from 'uts.sdk.modules.DCloudUniWebsocket.CloseSocketOptions';
export default {
data() {
return {
...
...
@@ -22,11 +22,12 @@ import CloseSocketOptions from 'uts.sdk.modules.DCloudUniWebsocket.CloseSocketOp
connecting: false,
msg: "",
roomId: '',
platform :"",
platform: "",
pageVisible: false
}
},
computed: {
showMsg():
string {
showMsg():
string {
if (this.connected) {
if (this.msg.length > 0) {
return '收到消息:' + this.msg
...
...
@@ -40,8 +41,10 @@ import CloseSocketOptions from 'uts.sdk.modules.DCloudUniWebsocket.CloseSocketOp
},
onLoad() {
this.platform = uni.getSystemInfoSync().platform;
this.pageVisible = true;
},
onUnload() {
this.pageVisible = false;
const closeOptions = new CloseSocketOptions();
uni.closeSocket(closeOptions);
uni.hideLoading()
...
...
@@ -69,33 +72,43 @@ import CloseSocketOptions from 'uts.sdk.modules.DCloudUniWebsocket.CloseSocketOp
}
})
uni.onSocketOpen((res) => {
if (this.pageVisible) {
this.connecting = false
this.connected = true
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '连接成功'
})
console.log('onOpen', res);
}
})
uni.onSocketError((err) => {
if (this.pageVisible) {
this.connecting = false
this.connected = false
uni.hideLoading()
uni.showModal({
content: '连接失败,可能是websocket服务不可用,请稍后再试',
showCancel: false
})
console.log('onError', err);
}
})
uni.onSocketMessage((res) => {
if (this.pageVisible) {
this.msg = res.data as string
console.log('onMessage', res)
}
})
uni.onSocketClose((res) => {
if (this.pageVisible) {
this.connected = false
this.msg = ""
console.log('onClose', res)
}
})
},
send() {
...
...
@@ -142,7 +155,7 @@ import CloseSocketOptions from 'uts.sdk.modules.DCloudUniWebsocket.CloseSocketOp
color: #666666;
}
.websocket-tips{
.websocket-tips {
padding: 40px 0px;
text-align: center;
font-size: 14px;
...
...
pages/API/websocket-socketTask/websocket-socketTask.uvue
浏览文件 @
a64e10aa
...
...
@@ -25,7 +25,8 @@
connecting: false,
socketTask: null as SocketTask | null,
msg: "",
platform :"",
platform: "",
pageVisible: false
}
},
computed: {
...
...
@@ -41,10 +42,12 @@
}
}
},
on
Ready() {
on
Load() {
this.platform = uni.getSystemInfoSync().platform;
this.pageVisible = true;
},
onUnload() {
this.pageVisible = false;
uni.hideLoading()
let task = this.socketTask;
if (task != null) {
...
...
@@ -75,6 +78,7 @@
}
})
this.socketTask?.onOpen((res) => {
if (this.pageVisible) {
this.connecting = false
this.connected = true
uni.hideLoading()
...
...
@@ -83,8 +87,10 @@
title: '连接成功'
})
console.log('onOpen', res);
}
})
this.socketTask?.onError((err) => {
if (this.pageVisible) {
this.connecting = false
this.connected = false
uni.hideLoading()
...
...
@@ -93,16 +99,21 @@
showCancel: false
})
console.log('onError', err);
}
})
this.socketTask?.onMessage((res) => {
if (this.pageVisible) {
this.msg = res.data as string
console.log('onMessage', res)
}
})
this.socketTask?.onClose((res) => {
if (this.pageVisible) {
this.connected = false
this.socketTask = null
this.msg = ""
console.log('onClose', res)
}
})
},
send() {
...
...
pages/component/list/list.uvue
0 → 100644
浏览文件 @
a64e10aa
<template>
<view style="height: 100%;width: 100%;">
<page-head :title="title"></page-head>
<view class="container">
<list class="uni-list" :refresher-enabled="true" @refresherrefresh="onRefresherrefresh"
:refresher-triggered="refresherTriggered">
<cell class="list_cell" v-for="(item, index) in dataList" :key="item.id">
<view class="list-item">
<text class="list-item-title" :value="item.name"></text>
</view>
</cell>
</list>
</view>
</view>
</template>
<script lang="ts">
import RefresherEvent from 'io.dcloud.uniapp.runtime.RefresherEvent';
type Item = {
id : string,
name : string
}
export default {
data() {
return {
title: 'list',
refresherTriggered: false,
dataList: [] as Item[],
}
},
onLoad() {
for (var i = 0; i < 25; i++) {
const item : Item = { id: i + "", name: "item " + i }
this.dataList.push(item)
}
},
methods: {
onRefresherrefresh(e : RefresherEvent) {
this.refresherTriggered = true
setTimeout(function () {
this.refresherTriggered = false
}, 1000)
}
}
}
</script>
<style>
.uni-list {
background-color: #eee;
position: relative;
width: 100%;
flex: 1;
display: flex;
flex-direction: column;
border-color: red;
}
.container {
display: flex;
flex-direction: column;
border: dashed;
height: 100%;
width: 100%;
}
.list_cell{
display: flex;
justify-content: center;
align-items: center;
}
.list-item {
margin-left: 12px;
margin-right: 12px;
margin-top: 12px;
padding: 20px;
background-color: #fff;
border-radius: 5px;
}
.list-item-title {
font-size: 30px;
font-weight: bold;
color: #444;
width: 100%;
}
</style>
\ No newline at end of file
pages/component/scroll-view/scroll-view-refresher.uvue
浏览文件 @
a64e10aa
...
...
@@ -11,6 +11,7 @@
</view>
</template>
<script>
import RefresherEvent from 'io.dcloud.uniapp.runtime.RefresherEvent';
export default {
data() {
...
...
pages/tabBar/component/component.uvue
浏览文件 @
a64e10aa
...
...
@@ -69,6 +69,10 @@
enable: false
},
// #endif
{
name:'list',
enable:false
}
] as Page[]
}, {
id: 'content',
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录