Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
ed612a2f
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看板
提交
ed612a2f
编写于
7月 01, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 调整部分示例页面路径
上级
ec5db453
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
40 addition
and
1185 deletion
+40
-1185
pages.json
pages.json
+7
-7
pages/API/request-payment/request-payment/order-detail.uvue
pages/API/request-payment/request-payment/order-detail.uvue
+0
-0
pages/API/request-payment/request-payment/request-payment-uni-pay.uvue
...uest-payment/request-payment/request-payment-uni-pay.uvue
+0
-0
pages/API/unicloud-call-function/unicloud-call-function.test.js
...API/unicloud-call-function/unicloud-call-function.test.js
+0
-33
pages/API/unicloud-call-function/unicloud-call-function.uvue
pages/API/unicloud-call-function/unicloud-call-function.uvue
+0
-108
pages/API/unicloud-database/unicloud-database.uvue
pages/API/unicloud-database/unicloud-database.uvue
+0
-322
pages/API/unicloud-import-object/unicloud-import-object.uvue
pages/API/unicloud-import-object/unicloud-import-object.uvue
+0
-161
pages/API/unicloud/unicloud/call-function.test.js
pages/API/unicloud/unicloud/call-function.test.js
+1
-1
pages/API/unicloud/unicloud/cloud-object.test.js
pages/API/unicloud/unicloud/cloud-object.test.js
+1
-1
pages/API/unicloud/unicloud/database.test.js
pages/API/unicloud/unicloud/database.test.js
+1
-1
pages/API/websocket/websocket-socketTask.test.js
pages/API/websocket/websocket-socketTask.test.js
+18
-0
pages/component/unicloud-db/add.uvue
pages/component/unicloud-db/add.uvue
+0
-117
pages/component/unicloud-db/detail.uvue
pages/component/unicloud-db/detail.uvue
+0
-110
pages/component/unicloud-db/edit.uvue
pages/component/unicloud-db/edit.uvue
+0
-170
pages/component/unicloud-db/types.uts
pages/component/unicloud-db/types.uts
+0
-25
pages/component/unicloud-db/unicloud-db/contacts/add.uvue
pages/component/unicloud-db/unicloud-db/contacts/add.uvue
+0
-0
pages/component/unicloud-db/unicloud-db/contacts/detail.uvue
pages/component/unicloud-db/unicloud-db/contacts/detail.uvue
+0
-0
pages/component/unicloud-db/unicloud-db/contacts/edit.uvue
pages/component/unicloud-db/unicloud-db/contacts/edit.uvue
+0
-0
pages/component/unicloud-db/unicloud-db/contacts/list.uvue
pages/component/unicloud-db/unicloud-db/contacts/list.uvue
+0
-0
pages/component/unicloud-db/unicloud-db/contacts/types.uts
pages/component/unicloud-db/unicloud-db/contacts/types.uts
+0
-0
pages/component/unicloud-db/unicloud-db/datacom.uvue
pages/component/unicloud-db/unicloud-db/datacom.uvue
+0
-70
pages/component/unicloud-db/unicloud-db/mixin-datacom.test.js
...s/component/unicloud-db/unicloud-db/mixin-datacom.test.js
+0
-20
pages/component/unicloud-db/unicloud-db/mixin-datacom.uvue
pages/component/unicloud-db/unicloud-db/mixin-datacom.uvue
+0
-27
pages/component/unicloud-db/unicloud-db/mixin-datacom/datacom.uvue
...ponent/unicloud-db/unicloud-db/mixin-datacom/datacom.uvue
+0
-0
pages/component/unicloud-db/unicloud-db/mixin-datacom/mixin-datacom.test.js
...icloud-db/unicloud-db/mixin-datacom/mixin-datacom.test.js
+0
-0
pages/component/unicloud-db/unicloud-db/mixin-datacom/mixin-datacom.uvue
.../unicloud-db/unicloud-db/mixin-datacom/mixin-datacom.uvue
+0
-0
pages/pages.test.js
pages/pages.test.js
+12
-12
未找到文件。
pages.json
浏览文件 @
ed612a2f
...
...
@@ -283,32 +283,32 @@
}
},
{
"path"
:
"pages/component/unicloud-db/unicloud-db"
,
"path"
:
"pages/component/unicloud-db/unicloud-db
/contacts/list
"
,
"style"
:
{
"navigationBarTitleText"
:
"联系人"
,
"enablePullDownRefresh"
:
true
}
},
{
"path"
:
"pages/component/unicloud-db/add"
,
"path"
:
"pages/component/unicloud-db/
unicloud-db/contacts/
add"
,
"style"
:
{
"navigationBarTitleText"
:
"新增联系人"
}
},
{
"path"
:
"pages/component/unicloud-db/edit"
,
"path"
:
"pages/component/unicloud-db/
unicloud-db/contacts/
edit"
,
"style"
:
{
"navigationBarTitleText"
:
"编辑联系人"
}
},
{
"path"
:
"pages/component/unicloud-db/detail"
,
"path"
:
"pages/component/unicloud-db/
unicloud-db/contacts/
detail"
,
"style"
:
{
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/component/unicloud-db/unicloud-db/mixin-datacom"
,
"path"
:
"pages/component/unicloud-db/unicloud-db/mixin-datacom
/mixin-datacom
"
,
"style"
:
{
"navigationBarTitleText"
:
"mixinDatacom"
}
...
...
@@ -886,14 +886,14 @@
//
#endif
//
#ifdef
APP
||
WEB
{
"path"
:
"pages/API/request-payment
-uni-pay
/request-payment-uni-pay"
,
"path"
:
"pages/API/request-payment
/request-payment
/request-payment-uni-pay"
,
"style"
:
{
"navigationBarTitleText"
:
"uni-pay示例"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/API/request-payment
-uni-pay
/order-detail"
,
"path"
:
"pages/API/request-payment
/request-payment
/order-detail"
,
"style"
:
{
"navigationBarTitleText"
:
"订单详情示例"
,
"enablePullDownRefresh"
:
false
...
...
pages/API/request-payment
-uni-pay
/order-detail.uvue
→
pages/API/request-payment
/request-payment
/order-detail.uvue
浏览文件 @
ed612a2f
文件已移动
pages/API/request-payment
-uni-pay
/request-payment-uni-pay.uvue
→
pages/API/request-payment
/request-payment
/request-payment-uni-pay.uvue
浏览文件 @
ed612a2f
文件已移动
pages/API/unicloud-call-function/unicloud-call-function.test.js
已删除
100644 → 0
浏览文件 @
ec5db453
const
PAGE_PATH
=
'
/pages/API/unicloud-call-function/unicloud-call-function
'
describe
(
'
unicloud-call-function
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
setData
({
isUniTest
:
true
})
})
it
(
'
callFunction
'
,
async
()
=>
{
await
page
.
callMethod
(
'
callFunction
'
)
const
{
callFunctionResult
,
callFunctionError
,
}
=
await
page
.
data
()
console
.
error
(
callFunctionResult
)
console
.
error
(
callFunctionError
)
expect
(
callFunctionResult
[
'
showMessage
'
]).
toBe
(
"
Hello uniCloud function
"
)
expect
(
callFunctionResult
[
'
event
'
][
'
num
'
]).
toBe
(
1
)
expect
(
callFunctionResult
[
'
event
'
][
'
str
'
]).
toBe
(
'
ABC
'
)
})
it
(
'
callFunctionWithGeneric
'
,
async
()
=>
{
await
page
.
callMethod
(
'
callFunctionWithGeneric
'
)
const
{
genericDemoShowMessage
,
}
=
await
page
.
data
()
expect
(
genericDemoShowMessage
).
toBe
(
"
Hello uniCloud function
"
)
})
})
pages/API/unicloud-call-function/unicloud-call-function.uvue
已删除
100644 → 0
浏览文件 @
ec5db453
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt">
<button type="primary" @click="callFunction">请求云函数</button>
<button type="primary" @click="callFunctionWithGeneric">请求云函数传入泛型</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: '请求云函数',
callFunctionResult: {},
callFunctionError: {},
genericDemoShowMessage: '',
isUniTest: false
}
},
onLoad() {
},
onUnload() {
if (this.isUniTest) {
uni.hideToast()
}
},
methods: {
notify(content : string, title : string) {
if (!this.isUniTest) {
uni.showModal({
title,
content,
showCancel: false
})
} else {
console.log(title, content)
}
},
async callFunctionWithGeneric() : Promise<void> {
type EchoCfResult = {
showMessage: string
}
uni.showLoading({
title: '加载中...'
})
await uniCloud.callFunction<EchoCfResult>({
name: 'echo-cf',
data: {
num: 1,
str: 'ABC'
}
}).then(res => {
const result = res.result
uni.hideLoading()
this.genericDemoShowMessage = result.showMessage
this.notify(result.showMessage, '提示')
}).catch((err : any | null) => {
const error = err as UniCloudError
this.callFunctionError = {
errCode: error.errCode,
errMsg: error.errMsg
}
uni.hideLoading()
this.notify(error.errMsg, '错误')
})
},
async callFunction() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
await uniCloud.callFunction({
name: 'echo-cf',
data: {
num: 1,
str: 'ABC'
}
}).then(res => {
const result = res.result
this.callFunctionResult = result
console.log(JSON.stringify(result))
uni.hideLoading()
this.notify(result['showMessage'] as string, '提示')
}).catch((err : any | null) => {
const error = err as UniCloudError
this.callFunctionError = {
errCode: error.errCode,
errMsg: error.errMsg
}
uni.hideLoading()
this.notify(error.errMsg, '错误')
})
}
}
}
</script>
<style>
</style>
pages/API/unicloud-database/unicloud-database.uvue
已删除
100644 → 0
浏览文件 @
ec5db453
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt">
<button type="primary" @click="dbAdd">新增单条数据</button>
<button type="primary" @click="dbBatchAdd">新增多条数据</button>
<button type="primary" @click="dbUpdate">更新数据</button>
<button type="primary" @click="dbGet">where传字符串获取数据</button>
<button type="primary" @click="dbGetWithCommand">where传对象获取数据</button>
<button type="primary" @click="dbRemove">删除数据</button>
<button type="primary" @click="dbLookupInit">初始化联表查询数据</button>
<button type="primary" @click="dbLookup">联表查询</button>
<button type="primary" @click="dbMultiSend">合并查询查询</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: 'ClientDB',
addId: '',
batchAddIds: [] as Array<string>,
batchAddinserted: 0,
updateUpdated: 0,
getData: [] as Array<UTSJSONObject>,
getWithCommandData: [] as Array<UTSJSONObject>,
removeDeleted: 0,
lookupData: [] as Array<UTSJSONObject>,
multiSendSuccessCount: 0,
isUniTest: false
}
},
computed: {
dataTag() : string {
return this.isUniTest ? 'default-tag' + Date.now() : 'default-tag'
}
},
methods: {
notify(content : string, title : string) {
if (!this.isUniTest) {
uni.showModal({
title,
content,
showCancel: false
})
} else {
console.log(title, content)
}
},
async dbAdd() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
await db.collection('type')
.add({
num: 1,
tag: this.dataTag,
date: new Date()
})
.then(res => {
uni.hideLoading()
console.log(res)
this.addId = res.id
this.notify(`新增成功,id: ${res.id}`, '提示')
})
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
async dbBatchAdd() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
await db.collection('type')
.add([{
num: 2,
tag: this.dataTag,
}, {
num: 3,
tag: this.dataTag,
}])
.then((res) => {
uni.hideLoading()
console.log(res)
console.log('JSON.stringify(res.inserted)', JSON.stringify(res.inserted))
this.batchAddIds = res.ids
this.batchAddinserted = res.inserted
this.notify(`新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`, '提示')
})
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
async dbGet() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
await db.collection('type')
.where(
`tag == "${this.dataTag}"`
)
.field('num, tag')
.orderBy('num desc')
.skip(1)
.limit(2)
.get()
.then(res => {
uni.hideLoading()
console.log(res)
this.getData = res.data
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
})
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
async dbGetWithCommand() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
await db.collection('type')
.where({
num: db.command.gt(1),
tag: this.dataTag
})
.field('num, tag')
.orderBy('num desc')
.skip(1)
.limit(2)
.get()
.then(res => {
uni.hideLoading()
console.log(res)
this.getWithCommandData = res.data
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
})
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
async dbUpdate() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
await db.collection('type')
.where(
`tag == "${this.dataTag}"`
)
.update({
num: 4
})
.then(res => {
uni.hideLoading()
console.log(res)
this.updateUpdated = res.updated
this.notify(`更新成功,更新了${res.updated}条数据`, '提示')
})
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
async dbRemove() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
await db.collection('type')
.where(
`tag == "${this.dataTag}"`
)
.remove()
.then(res => {
uni.hideLoading()
console.log(res)
this.removeDeleted = res.deleted
this.notify(`删除成功,删掉了${res.deleted}条数据`, '提示')
})
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
async dbLookupInit() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
await db.collection('local')
.where(`tag == "${this.dataTag}"`)
.remove()
.then(() : Promise<UniCloudDBRemoveResult> => {
return db.collection('foreign')
.where(`tag == "${this.dataTag}"`)
.remove()
})
.then(() : Promise<UniCloudDBBatchAddResult> => {
return db.collection('local')
.add([{
id: "local_1",
name: "local_1_name",
tag: this.dataTag,
foreign_id: "foreign_1"
}, {
id: "local_2",
name: "local_2_name",
tag: this.dataTag,
foreign_id: "foreign_2"
}])
})
.then(() : Promise<UniCloudDBBatchAddResult> => {
return db.collection('foreign')
.add([{
id: "foreign_1",
name: "foreign_1_name",
tag: this.dataTag
}, {
id: "foreign_2",
name: "foreign_2_name",
tag: this.dataTag
}])
})
.then((_) : void => {
uni.hideLoading()
this.notify('数据初始化成功', '提示')
})
.catch((err : any | null) => {
uni.hideLoading()
console.error(err)
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
async dbLookup() : Promise<void> {
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
const local = db.collection('local')
.where(`tag == "${this.dataTag}"`)
.getTemp()
const foreign = db.collection('foreign')
.where(`tag == "${this.dataTag}"`)
.getTemp()
await db.collection(local, foreign)
.get()
.then(res => {
uni.hideLoading()
console.log(res)
this.lookupData = res.data
this.notify(`联表查询成功,取到了${res.data.length}条数据`, '提示')
})
.catch((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
async dbMultiSend() : Promise<void> {
const db = uniCloud.databaseForJQL()
const temp1 = db.collection('type')
.where(
'tag == "default-tag"'
).getTemp()
const temp2 = db.collection('type')
.where(
'tag == "default-tag"'
).getTemp()
await db.multiSend(temp1, temp2)
.then<void>(res => {
uni.hideLoading()
let successCount = 0
for (let i = 0; i < res.dataList.length; i++) {
const item = res.dataList[i]
if(item.errCode == 0) {
console.log(`第${i}个请求查询到${item.data!.length}条数据`)
successCount++
} else {
console.error(`第${i}个请求查询失败,错误信息:${item.data!.length}`)
}
}
this.multiSendSuccessCount = successCount
this.notify(`合并查询成功,成功查询的语句条数为:${successCount}`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
console.error(err)
this.notify(error.errMsg, '错误')
})
}
}
}
</script>
<style>
</style>
pages/API/unicloud-import-object/unicloud-import-object.uvue
已删除
100644 → 0
浏览文件 @
ec5db453
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="addTodo">添加Todo</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="addTodoWithGeneric">添加Todo传入泛型</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="randomFail">随机触发失败重试</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="fail">云对象失败调用</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="failWithNumberErrCode">云对象数字错误码</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="success">云对象成功调用</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: '请求云对象',
todoTitle: '学习编程',
todoContent: '熟悉uts语法',
returnTodoTitle: '',
returnTodoContent: '',
genericDemoReturnTodoTitle: '',
genericDemoReturnTodoContent: '',
failErrCode: '',
failErrDetailTips: '',
failNumberErrCode: 0,
successErrCode: -1,
isUniTest: false
}
},
methods: {
notify(content : string, title : string) {
if (!this.isUniTest) {
uni.showModal({
title,
content,
showCancel: false
})
} else {
console.log(title, content)
}
},
async addTodo() : Promise<void> {
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
const title = this.todoTitle
const content = this.todoContent
await todo.add<UTSJSONObject>(title, content).then((res : UTSJSONObject) => {
this.returnTodoTitle = res['title'] as string
this.returnTodoContent = res['content'] as string
this.notify(res['showMessage'] as string, '提示')
}).catch((err : any | null) => {
console.log(err)
const error = err as UniCloudError
console.error(error)
})
},
async addTodoWithGeneric() : Promise<void> {
type AddTodoResult = {
title: string,
content: string,
showMessage: string
}
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
const title = this.todoTitle
const content = this.todoContent
await todo.add<AddTodoResult>(title, content).then((res : AddTodoResult) => {
this.genericDemoReturnTodoTitle = res.title
this.genericDemoReturnTodoContent = res.content
this.notify(res.showMessage, '提示')
}).catch((err : any | null) => {
console.log(err)
const error = err as UniCloudError
console.error(error)
})
},
async randomFail() : Promise<void> {
const todoObj = uniCloud.importObject('todo', {
errorOptions: {
retry: true
}
})
await todoObj.randomFail().then((res : UTSJSONObject) => {
this.notify(res['showMessage'] as string, '提示')
}).catch((err : any | null) => {
const error = err as UniCloudError
console.error(error)
})
},
async fail() : Promise<void> {
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
await todo.fail().then((res : UTSJSONObject) => {
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
console.log('todo.fail: ', res);
}).catch((err : any | null) => {
const error = err as UniCloudError
this.failErrCode = error.errCode as string
const detail = error.detail
if (detail != null && detail['tips'] != null) {
this.failErrDetailTips = detail['tips']
}
console.error(error)
})
},
async failWithNumberErrCode() : Promise<void> {
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
await todo.failWithNumberErrCode().then((res : UTSJSONObject) => {
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
console.log('todo.fail: ', res);
}).catch((err : any | null) => {
const error = err as UniCloudError
this.failNumberErrCode = error.errCode as number
console.error(error)
})
},
async success() : Promise<void> {
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
await todo.success().then((res : UTSJSONObject) => {
this.successErrCode = res['errCode'] as number
this.notify(res['showMessage'] as string, '提示')
}).catch((err : any | null) => {
const error = err as UniCloudError
console.error(error)
})
}
}
}
</script>
<style>
</style>
pages/API/unicloud/unicloud/call-function.test.js
浏览文件 @
ed612a2f
const
PAGE_PATH
=
'
/pages/API/
call-function
/call-function
'
const
PAGE_PATH
=
'
/pages/API/
unicloud/unicloud
/call-function
'
describe
(
'
unicloud-call-function
'
,
()
=>
{
let
page
...
...
pages/API/unicloud
-import-object/unicloud-import
-object.test.js
→
pages/API/unicloud
/unicloud/cloud
-object.test.js
浏览文件 @
ed612a2f
const
PAGE_PATH
=
'
/pages/API/unicloud
-import-object/unicloud-import
-object
'
const
PAGE_PATH
=
'
/pages/API/unicloud
/unicloud/cloud
-object
'
describe
(
'
unicloud-import-object
'
,
()
=>
{
let
page
...
...
pages/API/unicloud
-database/unicloud-
database.test.js
→
pages/API/unicloud
/unicloud/
database.test.js
浏览文件 @
ed612a2f
const
PAGE_PATH
=
'
/pages/API/unicloud
-database/unicloud-
database
'
const
PAGE_PATH
=
'
/pages/API/unicloud
/unicloud/
database
'
describe
(
'
unicloud-database
'
,
()
=>
{
let
page
...
...
pages/API/websocket/websocket-socketTask.test.js
0 → 100644
浏览文件 @
ed612a2f
const
PAGE_PATH
=
'
/pages/API/websocket/websocket-socketTask
'
describe
(
'
ExtApi-WebSocket
'
,
()
=>
{
let
page
;
let
res
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_connectSocket
'
);
await
page
.
waitFor
(
1500
);
res
=
await
page
.
data
(
'
jest_result
'
);
});
it
(
'
Check
'
,
async
()
=>
{
expect
(
res
).
toBe
(
2
);
});
});
pages/component/unicloud-db/add.uvue
已删除
100644 → 0
浏览文件 @
ec5db453
<template>
<view class="page">
<unicloud-db ref="udb" :collection="collection" loadtime="manual"></unicloud-db>
<form @submit="onFormSubmit">
<view class="form-item">
<text class="form-item-label">姓名</text>
<input class="form-item-input" placeholder="姓名" name="username" />
</view>
<view class="form-item">
<text class="form-item-label">电话</text>
<input class="form-item-input" placeholder="电话" name="mobile" />
</view>
<view class="form-item">
<text class="form-item-label">邮箱</text>
<input class="form-item-input" placeholder="邮箱地址" name="email" />
</view>
<view class="form-item">
<text class="form-item-label">备注</text>
<textarea class="form-item-input" placeholder="备注" name="comment" maxlength="-1"/>
</view>
<view class="form-item">
<text class="form-item-label">性别</text>
<radio-group class="radio-list" name="gender">
<view class="radio-item" v-for="(item, _) in genderList" :key="item.value">
<radio :value="item.value" />
<text>{{item.text}}</text>
</view>
</radio-group>
</view>
<button class="btn-add" type="primary" form-type="submit">保存</button>
</form>
</view>
</template>
<script>
import { COLLECTION_NAME, GenderType, GenderList, UNICLOUD_DB_CONTACTS_ADD } from './types.uts'
export default {
data() {
return {
collection: COLLECTION_NAME,
genderList: GenderList as GenderType[],
uniCloudElement: null as UniCloudDBElement | null
}
},
onReady() {
this.uniCloudElement = this.$refs['udb'] as UniCloudDBElement
},
methods: {
onFormSubmit: function (e : UniFormSubmitEvent) {
const formData = e.detail.value
const genderString = formData['gender'] as string
formData['gender'] = (genderString.length > 0) ? parseInt(genderString) : -1
console.log('formData', formData)
this.uniCloudElement!.add(formData, {
showToast: false,
needLoading: true,
loadingTitle: "正在保存...",
success: (_ : UniCloudDBAddResult) => {
// TODO 后续通过 EventChannel 实现
uni.$emit(UNICLOUD_DB_CONTACTS_ADD, '')
setTimeout(() => {
uni.navigateBack()
}, 500)
},
fail: (err : any | null) => {
const error = err as UniCloudError
uni.showModal({
content: error.errMsg,
showCancel: false
})
}
})
}
}
}
</script>
<style>
.page {
padding: 15px;
}
.form-item {
flex-direction: row;
margin-bottom: 15px;
align-items: center;
}
.form-item-label {
width: 45px;
margin-right: 10px;
}
.form-item-input {
flex: 1;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
padding: 8px;
}
.radio-list {
flex-direction: row;
}
.radio-item {
flex-direction: row;
margin-right: 30px;
align-items: center;
}
.btn-add {
margin-top: 50px;
}
</style>
pages/component/unicloud-db/detail.uvue
已删除
100644 → 0
浏览文件 @
ec5db453
<template>
<scroll-view class="page">
<unicloud-db ref="udb" v-slot:default="{data, loading, error}" :collection="collection" :where="where"
page-data="replace">
<view v-if="error!=null" class="error">{{error.errMsg}}</view>
<view v-if="loading" class="loading">正在加载...</view>
<view v-if="data.length>0">
<view class="form-item">
<text class="form-item-label">姓名</text>
<text class="form-item-input">{{data[0]['username']}}</text>
</view>
<view class="form-item">
<text class="form-item-label">电话</text>
<text class="form-item-input">{{data[0]['mobile']}}</text>
</view>
<view class="form-item">
<text class="form-item-label">邮箱</text>
<text class="form-item-input">{{data[0]['email']}}</text>
</view>
<view class="form-item">
<text class="form-item-label">备注</text>
<text class="form-item-input">{{data[0]['comment']}}</text>
</view>
<view class="form-item">
<text class="form-item-label">性别</text>
<text class="form-item-input">{{displayGender(data[0].getNumber('gender'))}}</text>
</view>
<button type="default" @click="gotoUpdatePage(data[0].getString('_id'))">编辑</button>
</view>
</unicloud-db>
</scroll-view>
</template>
<script>
import { COLLECTION_NAME, GenderType, GenderList, UNICLOUD_DB_CONTACTS_UPDATE } from './types.uts'
export default {
data() {
return {
collection: '',
where: '',
whereID: '',
uniCloudElement: null as UniCloudDBElement | null
}
},
onLoad(options) {
this.collection = COLLECTION_NAME;
this.whereID = options['id'] as string;
this.where = `_id=='${this.whereID}'`;
},
onShow() {
// TODO 后续通过 EventChannel 实现
uni.$off(UNICLOUD_DB_CONTACTS_UPDATE, this.onDataChange);
},
onUnload() {
// TODO 后续通过 EventChannel 实现
uni.$off(UNICLOUD_DB_CONTACTS_UPDATE, this.onDataChange);
},
onReady() {
this.uniCloudElement = this.$refs['udb'] as UniCloudDBElement
},
methods: {
displayGender(value : number | null) : string {
const str = value ?? -1
return (GenderList as GenderType[]).find((item : GenderType) : boolean => {
return item.value == str
})!.text;
},
gotoUpdatePage(id : string | null) {
// TODO 后续通过 EventChannel 实现
uni.$on(UNICLOUD_DB_CONTACTS_UPDATE, this.onDataChange);
uni.navigateTo({
url: './edit?id=' + id
})
},
onDataChange(_ : string) {
this.uniCloudElement!.loadData()
}
}
}
</script>
<style>
.page {
flex: 1;
padding: 15px;
}
.loading {
align-items: center;
}
.form-item {
flex-direction: row;
margin-bottom: 15px;
align-items: center;
padding: 8px 0;
}
.form-item-label {
width: 45px;
margin-right: 10px;
}
.form-item-input {
flex: 1;
font-size: 14px;
color: #666;
}
</style>
pages/component/unicloud-db/edit.uvue
已删除
100644 → 0
浏览文件 @
ec5db453
<template>
<scroll-view class="scroll-view">
<unicloud-db ref="udb" v-slot:default="{data, loading, error}" :collection="collection" :where="where"
page-data="replace">
<view v-if="error!=null" class="error">{{error.errMsg}}</view>
<view v-if="loading" class="loading">正在加载...</view>
<form v-if="data.length>0" @submit="onFormSubmit">
<view class="form-item">
<text class="form-item-label">姓名</text>
<input class="form-item-input" placeholder="姓名" name="username" :value="data[0].getString('username')" />
</view>
<view class="form-item">
<text class="form-item-label">电话</text>
<input class="form-item-input" placeholder="电话" name="mobile" :value="data[0].getString('mobile')" />
</view>
<view class="form-item">
<text class="form-item-label">邮箱</text>
<input class="form-item-input" placeholder="邮箱地址" name="email" :value="data[0].getString('email')" />
</view>
<view class="form-item">
<text class="form-item-label">备注</text>
<textarea class="form-item-input" placeholder="备注" name="comment" maxlength="-1" :value="data[0].getString('comment')" />
</view>
<view class="form-item">
<text class="form-item-label">性别</text>
<radio-group class="radio-list" name="gender">
<view class="radio-item" v-for="(item, _) in genderList" :key="item.value">
<radio :value="item.value" :checked="item.value == data[0].getNumber('gender')" />
<text>{{item.text}}</text>
</view>
</radio-group>
</view>
<view class="btn-group">
<button class="btn-submit" type="primary" form-type="submit">保存</button>
<button class="btn-delete" type="warn"
@click="remove(data[0].getString('_id'), data[0].getString('username'))">删除联系人</button>
</view>
</form>
</unicloud-db>
</scroll-view>
</template>
<script>
import { COLLECTION_NAME, GenderType, GenderList, UNICLOUD_DB_CONTACTS_UPDATE, UNICLOUD_DB_CONTACTS_DELETE } from './types.uts'
export default {
data() {
return {
collection: '',
where: '',
genderList: GenderList as GenderType[],
whereID: '',
uniCloudElement: null as UniCloudDBElement | null
}
},
onLoad(options) {
this.collection = COLLECTION_NAME;
this.whereID = options['id'] as string;
this.where = `_id=='${this.whereID}'`;
},
onReady() {
this.uniCloudElement = this.$refs['udb'] as UniCloudDBElement
},
methods: {
onFormSubmit: function (e : UniFormSubmitEvent) {
const formData = e.detail.value
const genderString = formData['gender'] as string
formData['gender'] = (genderString.length > 0) ? parseInt(genderString) : -1
this.uniCloudElement!.update(this.whereID, formData, {
showToast: false,
needLoading: true,
needConfirm: false,
loadingTitle: "正在保存...",
success: (_ : UniCloudDBUpdateResult) => {
// TODO 后续通过 EventChannel 实现
uni.$emit(UNICLOUD_DB_CONTACTS_UPDATE, this.whereID)
setTimeout(() => {
uni.navigateBack()
}, 500)
},
fail: (err : any | null) => {
const error = err as UniCloudError
uni.showModal({
content: error.errMsg,
showCancel: false
})
}
})
},
remove(id : string | null, name : string | null) {
this.uniCloudElement!.remove(id!, {
needConfirm: true,
needLoading: true,
loadingTitle: "正在删除...",
confirmTitle: "确定删除?",
confirmContent: name,
success: (_ : UniCloudDBRemoveResult) => {
// TODO 后续通过 EventChannel 实现
uni.$emit(UNICLOUD_DB_CONTACTS_DELETE, this.whereID)
setTimeout(() => {
uni.navigateBack({
delta: 2
})
}, 500)
},
fail: (err : any | null) => {
const error = err as UniCloudError
uni.showModal({
content: error.errMsg,
showCancel: false
})
}
})
}
}
}
</script>
<style>
.page {
flex: 1;
}
.scroll-view {
padding: 15px;
flex: 1;
}
.loading {
align-items: center;
}
.form-item {
flex-direction: row;
margin-bottom: 15px;
align-items: center;
}
.form-item-label {
width: 45px;
margin-right: 10px;
}
.form-item-input {
flex: 1;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
padding: 8px;
}
.radio-list {
flex-direction: row;
}
.radio-item {
flex-direction: row;
margin-right: 30px;
align-items: center;
}
.btn-group {
margin-top: 30px;
}
.btn-delete {
margin-top: 15px;
}
</style>
pages/component/unicloud-db/types.uts
已删除
100644 → 0
浏览文件 @
ec5db453
export const COLLECTION_NAME = 'opendb-contacts'
export type GenderType = {
text : string,
value : number,
}
export const GenderList = [
{
text: "未知",
value: 0
},
{
text: "男",
value: 1
},
{
text: "女",
value: 2
},
] as GenderType[]
export const UNICLOUD_DB_CONTACTS_ADD = 'unicloud-db-contacts-add'
export const UNICLOUD_DB_CONTACTS_UPDATE = 'unicloud-db-contacts-update'
export const UNICLOUD_DB_CONTACTS_DELETE = 'unicloud-db-contacts-delete'
pages/component/unicloud-db
-
contacts/add.uvue
→
pages/component/unicloud-db
/unicloud-db/
contacts/add.uvue
浏览文件 @
ed612a2f
文件已移动
pages/component/unicloud-db
-
contacts/detail.uvue
→
pages/component/unicloud-db
/unicloud-db/
contacts/detail.uvue
浏览文件 @
ed612a2f
文件已移动
pages/component/unicloud-db
-
contacts/edit.uvue
→
pages/component/unicloud-db
/unicloud-db/
contacts/edit.uvue
浏览文件 @
ed612a2f
文件已移动
pages/component/unicloud-db
-
contacts/list.uvue
→
pages/component/unicloud-db
/unicloud-db/
contacts/list.uvue
浏览文件 @
ed612a2f
文件已移动
pages/component/unicloud-db
-
contacts/types.uts
→
pages/component/unicloud-db
/unicloud-db/
contacts/types.uts
浏览文件 @
ed612a2f
文件已移动
pages/component/unicloud-db/unicloud-db/datacom.uvue
已删除
100644 → 0
浏览文件 @
ec5db453
<template>
<view>
<view v-if="mixinDatacomLoading">Loading...</view>
<view v-else-if="mixinDatacomError">
请求错误:{{mixinDatacomError}}
</view>
<view v-else="mixinDatacomResData.length>0">
<!-- 需要自行处理数据及相关UI展现 -->
<!-- {{mixinDatacomResData}} -->
<scroll-view class="list-view">
<view class="list-item" v-for="(item, _) in mixinDatacomResData">
<text>{{item}}</text>
</view>
</scroll-view>
</view>
<view v-if="!mixinDatacomLoading && mixinDatacomResData.length==0">
无数据
</view>
</view>
</template>
<script lang="uts">
export default {
mixins: [uniCloud.mixinDatacom],
data() {
return {
}
},
created() {
this.load()
},
methods: {
load() {
if (this.mixinDatacomLoading == true) {
return
}
this.mixinDatacomLoading = true
this.mixinDatacomGet(null).then((res: UniCloudDBGetResult) => {
const data = res.data
// const count = res.count
this.mixinDatacomResData = data
}).catch((err: any | null) => {
this.mixinDatacomError = err as UniCloudError
}).finally(() => {
this.mixinDatacomLoading = false
})
},
// 当组件属性发生变化时
onMixinDatacomPropsChange(needReset: boolean, changed: Array<string>) {
console.log(needReset, changed);
// needReset=true 需要重置已加载数据和分页信息,例如 collection,orderby
// changed,变化的属性名,类型为 Array,例如 ['collection', 'orderby']
// if (needReset) {
// // 清空已加载的数据
// this.mixinDatacomResData = []
// // 重置分页数据,如果没有分页不需要处理
// this.mixinDatacomPage.size = this.pageSize // 重置分页大小
// this.mixinDatacomPage.current = 0 // 重置当前分页
// this.mixinDatacomPage.count = 0 // 重置数据总数
// }
}
}
}
</script>
<style>
</style>
pages/component/unicloud-db/unicloud-db/mixin-datacom.test.js
已删除
100644 → 0
浏览文件 @
ec5db453
const
PAGE_PATH
=
'
/pages/component/mixin-datacom/mixin-datacom
'
describe
(
'
mixin-datacom
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
it
(
'
dummyTest
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
mixinDatacomGet
'
,
async
()
=>
{
const
datacom
=
await
page
.
$
(
'
.datacom
'
)
const
children
=
await
datacom
.
$$
(
'
.list-item
'
)
expect
(
children
.
length
>
0
).
toBe
(
true
)
})
})
pages/component/unicloud-db/unicloud-db/mixin-datacom.uvue
已删除
100644 → 0
浏览文件 @
ec5db453
<template>
<view class="content">
<datacom class="datacom" collection="unicloud-db-test"></datacom>
</view>
</template>
<script>
import datacom from './datacom.uvue';
export default {
components: {
datacom
},
data() {
return {
}
},
methods: {
}
}
</script>
<style>
.content {
flex: 1;
}
</style>
pages/component/datacom/datacom.uvue
→
pages/component/
unicloud-db/unicloud-db/mixin-
datacom/datacom.uvue
浏览文件 @
ed612a2f
文件已移动
pages/component/datacom/mixin-datacom.test.js
→
pages/component/
unicloud-db/unicloud-db/mixin-
datacom/mixin-datacom.test.js
浏览文件 @
ed612a2f
文件已移动
pages/component/datacom/mixin-datacom.uvue
→
pages/component/
unicloud-db/unicloud-db/mixin-
datacom/mixin-datacom.uvue
浏览文件 @
ed612a2f
文件已移动
pages/pages.test.js
浏览文件 @
ed612a2f
...
...
@@ -76,12 +76,12 @@ const pages = [
// '/pages/component/web-view/web-view-local',
// 动态内容
// '/pages/component/unicloud-db/unicloud-db',
'
/pages/component/unicloud-db/add
'
,
'
/pages/component/unicloud-db/
unicloud-db/contacts/
add
'
,
// 动态内容
// '/pages/component/unicloud-db/edit',
// '/pages/component/unicloud-db/
unicloud-db/contacts/
edit',
// 动态内容
// '/pages/component/unicloud-db/detail',
'
/pages/component/
datacom/
datacom
'
,
// '/pages/component/unicloud-db/
unicloud-db/contacts/
detail',
'
/pages/component/
unicloud-db/unicloud-db/mixin-datacom/mixin-
datacom
'
,
// 单独测试例截图
// '/pages/component/general-attribute/general-attribute',
'
/pages/component/general-event/general-event
'
,
...
...
@@ -144,8 +144,10 @@ const pages = [
'
/pages/API/websocket/websocket-socketTask
'
,
// 页面销毁时会关闭socket连接,所以规避
// '/pages/API/websocket/websocket',
'
/pages/API/unicloud/call-function
'
,
'
/pages/API/unicloud/import-object
'
,
'
/pages/API/unicloud/unicloud/cloud-function
'
,
'
/pages/API/unicloud/unicloud/cloud-object
'
,
'
/pages/API/unicloud/unicloud/database
'
,
'
/pages/API/unicloud/unicloud/cloud-storage
'
,
'
/pages/API/get-system-info/get-system-info
'
,
'
/pages/API/get-device-info/get-device-info
'
,
'
/pages/API/get-app-base-info/get-app-base-info
'
,
...
...
@@ -155,13 +157,11 @@ const pages = [
'
/pages/API/get-network-type/get-network-type
'
,
'
/pages/API/page-scroll-to/page-scroll-to
'
,
'
/pages/API/event-bus/event-bus
'
,
'
/pages/API/unicloud-file-api/unicloud-file-api
'
,
'
/pages/API/unicloud-database/unicloud-database
'
,
'
/pages/API/get-battery-info/get-battery-info
'
,
'
/pages/API/get-window-info/get-window-info
'
,
'
/pages/API/rpx2px/rpx2px
'
,
'
/pages/API/request-payment
-uni-pay
/request-payment-uni-pay
'
,
'
/pages/API/request-payment
-uni-pay
/order-detail
'
,
'
/pages/API/request-payment
/request-payment
/request-payment-uni-pay
'
,
'
/pages/API/request-payment
/request-payment
/order-detail
'
,
// 单独测试例截图
// '/pages/API/resize-observer/resize-observer',
// 单独测试例截图
...
...
@@ -356,8 +356,8 @@ function getWaitForTagName(pagePath) {
return
'
text
'
}
if
(
pagePath
===
'
/pages/component/unicloud-db
-
contacts/edit
'
||
pagePath
===
'
/pages/component/unicloud-db
-
contacts/detail
'
pagePath
===
'
/pages/component/unicloud-db
/unicloud-db/
contacts/edit
'
||
pagePath
===
'
/pages/component/unicloud-db
/unicloud-db/
contacts/detail
'
)
{
return
'
scroll-view
'
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录