Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uniCloud
提交
4b81da44
H
hello-uniCloud
项目概览
DCloud
/
hello-uniCloud
通知
294
Star
3
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uniCloud
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4b81da44
编写于
11月 18, 2022
作者:
study夏羽
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复部分示例弹框不显示问题
上级
46ebd587
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
97 addition
and
222 deletion
+97
-222
changelog.md
changelog.md
+5
-0
components/alertCode/alertCode.vue
components/alertCode/alertCode.vue
+1
-1
components/set-permission/set-permission.vue
components/set-permission/set-permission.vue
+1
-1
manifest.json
manifest.json
+7
-4
package.json
package.json
+4
-7
pages/clientDB/clientDB-api/clientDB-api.vue
pages/clientDB/clientDB-api/clientDB-api.vue
+17
-38
pages/clientDB/demo/demo.vue
pages/clientDB/demo/demo.vue
+11
-29
pages/clientDB/permission-demo/permission-demo.vue
pages/clientDB/permission-demo/permission-demo.vue
+9
-13
pages/clientDB/permission-demo/readme.vue
pages/clientDB/permission-demo/readme.vue
+10
-29
pages/clientDB/permission-field-simple/permission-field-simple.vue
...entDB/permission-field-simple/permission-field-simple.vue
+3
-10
pages/clientDB/permission-table-compound/permission-table-compound.vue
...B/permission-table-compound/permission-table-compound.vue
+2
-6
pages/clientDB/permission-table-simple/permission-table-simple.vue
...entDB/permission-table-simple/permission-table-simple.vue
+2
-10
pages/clientDB/unicloud-db-demo/unicloud-db-demo.vue
pages/clientDB/unicloud-db-demo/unicloud-db-demo.vue
+6
-8
pages/clientDB/validate/validate.test.js
pages/clientDB/validate/validate.test.js
+0
-37
pages/cloudFunction/cloudFunction.vue
pages/cloudFunction/cloudFunction.vue
+10
-15
pages/cloudObject/cloudObject.vue
pages/cloudObject/cloudObject.vue
+0
-1
pages/validate-demo/add.vue
pages/validate-demo/add.vue
+8
-12
uniCloud-aliyun/database/permission-test.schema.json
uniCloud-aliyun/database/permission-test.schema.json
+1
-1
未找到文件。
changelog.md
浏览文件 @
4b81da44
## 1.3.6(2022-11-18)
1.
默认开启云端一体安全网络
2.
修复部分示例弹框不显示问题
## 1.3.5(2022-10-28)
-
新增安全网络示例,
[
详见
](
https://uniapp.dcloud.net.cn/uniCloud/secure-network.html
)
## 1.3.4(2022-06-29)
## 1.3.4(2022-06-29)
新增:支持 ios 安全区
新增:支持 ios 安全区
## 1.3.2(2022-06-28)
## 1.3.2(2022-06-28)
...
...
components/alertCode/alertCode.vue
浏览文件 @
4b81da44
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
}
}
function
purifyCodes
(
codes
)
{
function
purifyCodes
(
codes
)
{
codes
=
JSON
.
parse
(
JSON
.
stringify
(
codes
))
const
codesType
=
getType
(
codes
)
const
codesType
=
getType
(
codes
)
switch
(
codesType
)
{
switch
(
codesType
)
{
case
'
object
'
:
case
'
object
'
:
...
@@ -54,7 +55,6 @@
...
@@ -54,7 +55,6 @@
e
.
stopPropagation
()
e
.
stopPropagation
()
},
},
closeMe
(
e
)
{
closeMe
(
e
)
{
console
.
log
(
'
closeMe
'
,
e
);
this
.
isShow
=
false
this
.
isShow
=
false
}
}
}
}
...
...
components/set-permission/set-permission.vue
浏览文件 @
4b81da44
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
});
});
if
(
!
activeIndex
)
{
if
(
!
activeIndex
)
{
let
res
=
await
this
.
logout
()
let
res
=
await
this
.
logout
()
console
.
log
(
res
.
result
.
msg
);
console
.
log
(
res
);
uni
.
setStorageSync
(
'
role_index
'
,
activeIndex
)
uni
.
setStorageSync
(
'
role_index
'
,
activeIndex
)
uni
.
setStorageSync
(
'
uni_id_token
'
,
false
)
uni
.
setStorageSync
(
'
uni_id_token
'
,
false
)
uni
.
setStorageSync
(
'
uni_id_uid
'
,
false
)
uni
.
setStorageSync
(
'
uni_id_uid
'
,
false
)
...
...
manifest.json
浏览文件 @
4b81da44
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
"name"
:
"hello uniCloud"
,
"name"
:
"hello uniCloud"
,
"appid"
:
""
,
"appid"
:
""
,
"description"
:
"为开发者提供的基于 serverless 模式和 js 编程的云开发平台。示例代码"
,
"description"
:
"为开发者提供的基于 serverless 模式和 js 编程的云开发平台。示例代码"
,
"versionName"
:
"1.0.
0
"
,
"versionName"
:
"1.0.
2
"
,
"versionCode"
:
10
0
,
"versionCode"
:
10
2
,
"transformPx"
:
false
,
"transformPx"
:
false
,
"app-plus"
:
{
"app-plus"
:
{
"usingComponents"
:
true
,
"usingComponents"
:
true
,
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
"delay"
:
0
"delay"
:
0
},
},
"modules"
:
{
"modules"
:
{
"VideoPlayer"
:
{}
"VideoPlayer"
:
{},
"SecureNetwork"
:
{}
},
},
"distribute"
:
{
"distribute"
:
{
"android"
:
{
"android"
:
{
...
@@ -40,7 +41,9 @@
...
@@ -40,7 +41,9 @@
],
],
"abiFilters"
:
[
"armeabi-v7a"
,
"arm64-v8a"
,
"x86"
]
"abiFilters"
:
[
"armeabi-v7a"
,
"arm64-v8a"
,
"x86"
]
},
},
"ios"
:
{},
"ios"
:
{
"dSYMs"
:
false
},
"sdkConfigs"
:
{
"sdkConfigs"
:
{
"maps"
:
{},
"maps"
:
{},
"ad"
:
{},
"ad"
:
{},
...
...
package.json
浏览文件 @
4b81da44
{
{
"id"
:
"uni-cloud"
,
"id"
:
"uni-cloud"
,
"displayName"
:
"hello uniCloud"
,
"displayName"
:
"hello uniCloud"
,
"version"
:
"1.3.
4
"
,
"version"
:
"1.3.
6
"
,
"description"
:
"为开发者提供的基于 serverless 模式和 js 编程的云开发平台。示例代码"
,
"description"
:
"为开发者提供的基于 serverless 模式和 js 编程的云开发平台。示例代码"
,
"keywords"
:
[
"keywords"
:
[
"uniCloud示例"
"uniCloud示例"
],
],
"repository"
:
"https://git
ee.com/dcloud/hello-uniC
loud"
,
"repository"
:
"https://git
code.net/dcloud/hellounic
loud"
,
"engines"
:
{
"engines"
:
{
"HBuilderX"
:
"^3.3.12"
"HBuilderX"
:
"^3.3.12"
},
},
"dcloudext"
:
{
"dcloudext"
:
{
"category"
:
[
"uniCloud"
,
"云端一体项目模板"
],
"sale"
:
{
"sale"
:
{
"regular"
:
{
"regular"
:
{
"price"
:
"0.00"
"price"
:
"0.00"
...
@@ -31,7 +27,8 @@
...
@@ -31,7 +27,8 @@
"data"
:
"无"
,
"data"
:
"无"
,
"permissions"
:
"无"
"permissions"
:
"无"
},
},
"npmurl"
:
""
"npmurl"
:
""
,
"type"
:
"unicloud-template-project"
},
},
"uni_modules"
:
{
"uni_modules"
:
{
"platforms"
:
{
"platforms"
:
{
...
...
pages/clientDB/clientDB-api/clientDB-api.vue
浏览文件 @
4b81da44
...
@@ -222,24 +222,20 @@
...
@@ -222,24 +222,20 @@
uni
.
hideLoading
()
uni
.
hideLoading
()
}
}
},
},
async
getData
(
tableName
)
{
getData
(
tableName
)
{
console
.
log
(
tableName
);
console
.
log
(
tableName
);
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
// 客户端联表查询
// 客户端联表查询
return
await
db
.
collection
(
tableName
)
db
.
collection
(
tableName
)
.
get
()
.
get
()
.
then
(
res
=>
{
.
then
(
res
=>
{
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
console
.
log
(
res
.
result
.
data
,
"
111
"
);
return
res
.
result
.
data
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
err
)
console
.
error
(
err
)
return
err
})
})
.
finally
((
e
)
=>
{
.
finally
((
e
)
=>
{
console
.
log
(
e
,
9527
);
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
...
@@ -251,138 +247,122 @@
...
@@ -251,138 +247,122 @@
const
res
=
await
db
.
collection
(
orderQuery
,
bookQuery
).
field
(
'
book_id as books_info,quantity
'
).
get
()
const
res
=
await
db
.
collection
(
orderQuery
,
bookQuery
).
field
(
'
book_id as books_info,quantity
'
).
get
()
uni
.
hideLoading
()
uni
.
hideLoading
()
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
console
.
log
(
res
.
result
.
data
,
"
111
"
);
},
},
async
getOrder
()
{
getOrder
()
{
//直接关联多个表为虚拟表再进行查询。仅数据表字段内容较少时使用,否者将查询超时
//直接关联多个表为虚拟表再进行查询。仅数据表字段内容较少时使用,否者将查询超时
uni
.
showLoading
({
mask
:
true
});
uni
.
showLoading
({
mask
:
true
});
// 客户端联表查询
// 客户端联表查询
return
await
db
.
collection
(
'
order,book
'
)
// 注意collection方法内需要传入所有用到的表名,用逗号分隔,主表需要放在第一位
db
.
collection
(
'
order,book
'
)
// 注意collection方法内需要传入所有用到的表名,用逗号分隔,主表需要放在第一位
//.where('book_id.title == "三国演义"') // 查询order表内书名为“三国演义”的订单
//.where('book_id.title == "三国演义"') // 查询order表内书名为“三国演义”的订单
.
field
(
'
book_id{title,author} as books_info,quantity
'
)
// 这里联表查询book表返回book表内的title、book表内的author、order表内的quantity
.
field
(
'
book_id{title,author} as books_info,quantity
'
)
// 这里联表查询book表返回book表内的title、book表内的author、order表内的quantity
.
get
()
.
get
()
.
then
(
res
=>
{
.
then
(
res
=>
{
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
console
.
log
(
res
.
result
.
data
,
"
111
"
);
return
res
.
result
.
data
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
err
)
console
.
error
(
err
)
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
getOneBook
()
{
getOneBook
()
{
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
// 客户端联表查询
// 客户端联表查询
return
await
db
.
collection
(
'
book
'
)
db
.
collection
(
'
book
'
)
.
get
({
.
get
({
getOne
:
true
getOne
:
true
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
return
res
.
result
.
data
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
err
)
console
.
error
(
err
)
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
getBookTitle
()
{
getBookTitle
()
{
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
// 客户端联表查询
// 客户端联表查询
return
await
db
.
collection
(
'
book
'
)
db
.
collection
(
'
book
'
)
.
field
(
'
title
'
)
.
field
(
'
title
'
)
.
get
()
.
get
()
.
then
(
res
=>
{
.
then
(
res
=>
{
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
return
res
.
result
.
data
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
err
)
console
.
error
(
err
)
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
getBookAs
()
{
getBookAs
()
{
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
// 客户端联表查询
// 客户端联表查询
return
await
db
.
collection
(
'
book
'
)
db
.
collection
(
'
book
'
)
.
field
(
'
title,author as book_author
'
)
.
field
(
'
title,author as book_author
'
)
.
get
()
.
get
()
.
then
(
res
=>
{
.
then
(
res
=>
{
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
return
res
.
result
.
data
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
err
)
console
.
error
(
err
)
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
getOrderOrderBy
(
str
)
{
getOrderOrderBy
(
str
)
{
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
return
await
db
.
collection
(
'
order
'
)
db
.
collection
(
'
order
'
)
.
orderBy
(
str
)
.
orderBy
(
str
)
.
get
()
.
get
()
.
then
(
res
=>
{
.
then
(
res
=>
{
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
return
res
.
result
.
data
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
err
)
console
.
error
(
err
)
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
getBookHasCount
()
{
getBookHasCount
()
{
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
return
await
db
.
collection
(
'
book
'
)
db
.
collection
(
'
book
'
)
.
get
({
.
get
({
"
getCount
"
:
true
"
getCount
"
:
true
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
return
res
.
result
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
err
)
console
.
error
(
err
)
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
getTreeFn
()
{
getTreeFn
()
{
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
return
await
db
.
collection
(
"
department
"
).
get
({
db
.
collection
(
"
department
"
).
get
({
getTree
:
{
getTree
:
{
limitLevel
:
10
,
// 最大查询层级(不包含当前层级),可以省略默认10级,最大15,最小1
limitLevel
:
10
,
// 最大查询层级(不包含当前层级),可以省略默认10级,最大15,最小1
// startWith: "parent_code==''" // 第一层级条件,此初始条件可以省略,不传startWith时默认从最顶级开始查询
// startWith: "parent_code==''" // 第一层级条件,此初始条件可以省略,不传startWith时默认从最顶级开始查询
}
}
})
})
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
console
.
log
(
"
res:
"
,
res
);
const
resdata
=
res
.
result
.
data
const
resdata
=
res
.
result
.
data
console
.
log
(
"
resdata
"
,
);
this
.
$refs
.
alertCode
.
open
(
resdata
)
this
.
$refs
.
alertCode
.
open
(
resdata
)
return
resdata
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
showModal
({
uni
.
showModal
({
content
:
err
.
message
||
'
请求服务失败
'
,
content
:
err
.
message
||
'
请求服务失败
'
,
showCancel
:
false
showCancel
:
false
})
})
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
...
@@ -398,7 +378,6 @@
...
@@ -398,7 +378,6 @@
console
.
log
(
res
);
console
.
log
(
res
);
this
.
$refs
.
alertCode
.
open
(
res
.
result
.
data
)
this
.
$refs
.
alertCode
.
open
(
res
.
result
.
data
)
uni
.
hideLoading
()
uni
.
hideLoading
()
return
res
.
result
.
data
}
}
}
}
}
}
...
...
pages/clientDB/demo/demo.vue
浏览文件 @
4b81da44
...
@@ -128,53 +128,45 @@
...
@@ -128,53 +128,45 @@
console
.
log
(
"
this.currentRole:
"
,
this
.
currentRole
);
console
.
log
(
"
this.currentRole:
"
,
this
.
currentRole
);
},
},
async
getNoticeData
()
{
async
getNoticeData
()
{
console
.
log
(
'
111111111111
'
);
let
res
=
await
db
.
action
(
'
add_view_count
'
)
let
res
=
await
db
.
action
(
'
add_view_count
'
)
.
collection
(
'
notice
'
)
.
collection
(
'
notice
'
)
.
field
(
'
data,_id,update_time,view_count
'
)
.
field
(
'
data,_id,update_time,view_count
'
)
.
get
();
.
get
();
console
.
log
(
"
res:
"
,
res
);
this
.
noticeData
=
res
.
result
.
data
[
0
]
this
.
noticeData
=
res
.
result
.
data
[
0
]
},
},
async
clickIcon
(
e
,
item
)
{
async
clickIcon
(
e
,
item
)
{
if
(
e
)
{
if
(
e
)
{
let
res
=
await
this
.
$refs
.
udb
.
remove
(
item
.
_id
);
await
this
.
$refs
.
udb
.
remove
(
item
.
_id
);
return
res
}
else
{
}
else
{
this
.
defaultText
=
item
.
text
this
.
defaultText
=
item
.
text
this
.
activeNoticeId
=
item
.
_id
this
.
activeNoticeId
=
item
.
_id
this
.
$refs
.
upDataDialog
.
open
()
this
.
$refs
.
upDataDialog
.
open
()
}
}
},
},
async
updateState
(
e
,
_id
)
{
updateState
(
e
,
_id
)
{
console
.
log
(
e
.
detail
.
value
,
_id
);
console
.
log
(
e
.
detail
.
value
,
_id
);
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
return
await
db
.
collection
(
'
comment
'
)
db
.
collection
(
'
comment
'
)
.
doc
(
_id
)
.
doc
(
_id
)
.
update
({
.
update
({
"
state
"
:
e
.
detail
.
value
/
1
"
state
"
:
e
.
detail
.
value
/
1
})
})
.
then
(({
.
then
(({
code
,
message
})
=>
{
code
,
message
})
=>
{
uni
.
showToast
({
uni
.
showToast
({
title
:
'
已切换为:
'
+
(
e
.
detail
.
value
?
'
审核通过
'
:
'
审核中
'
),
title
:
'
已切换为:
'
+
(
e
.
detail
.
value
?
'
审核通过
'
:
'
审核中
'
),
icon
:
'
none
'
,
icon
:
'
none
'
,
duration
:
3000
duration
:
3000
});
});
console
.
log
(
code
,
message
);
console
.
log
(
code
,
message
);
return
message
}).
catch
(({
code
,
message
})
=>
{
}).
catch
(({
code
,
message
})
=>
{
console
.
log
(
code
,
message
);
console
.
log
(
code
,
message
);
return
message
}).
finally
(
e
=>
{
}).
finally
(
e
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
this
.
$refs
.
upDataDialog
.
close
()
this
.
$refs
.
upDataDialog
.
close
()
return
e
})
})
},
},
async
updateComment
(
text
)
{
async
updateComment
(
text
)
{
...
@@ -192,9 +184,7 @@
...
@@ -192,9 +184,7 @@
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
});
});
return
await
this
.
$refs
.
udb
.
update
(
this
.
activeNoticeId
,
{
await
this
.
$refs
.
udb
.
update
(
this
.
activeNoticeId
,
{
text
},
{
text
},
{
action
:
"
up_comment
"
,
action
:
"
up_comment
"
,
toastTitle
:
'
修改成功
'
,
// toast提示语
toastTitle
:
'
修改成功
'
,
// toast提示语
success
:
(
res
)
=>
{
// 更新成功后的回调
success
:
(
res
)
=>
{
// 更新成功后的回调
...
@@ -212,14 +202,10 @@
...
@@ -212,14 +202,10 @@
}
}
}
}
})
})
return
message
},
},
fail
:
(
err
)
=>
{
// 更新失败后的回调
fail
:
(
err
)
=>
{
// 更新失败后的回调
const
{
console
.
log
(
"
err:
"
,
err
);
message
const
{
message
}
=
err
}
=
err
return
message
},
},
complete
:
()
=>
{
// 完成后的回调
complete
:
()
=>
{
// 完成后的回调
uni
.
hideLoading
()
uni
.
hideLoading
()
...
@@ -237,13 +223,11 @@
...
@@ -237,13 +223,11 @@
return
false
return
false
}
}
this
.
$refs
.
dialog
.
close
()
this
.
$refs
.
dialog
.
close
()
await
db
.
collection
(
'
comment
'
).
add
({
return
await
db
.
collection
(
'
comment
'
).
add
({
text
text
}).
then
(
res
=>
{
}).
then
(
res
=>
{
console
.
log
(
res
);
console
.
log
(
res
);
this
.
getNewData
()
this
.
getNewData
()
return
res
.
result
}).
catch
(({
}).
catch
(({
code
,
code
,
message
message
...
@@ -261,11 +245,9 @@
...
@@ -261,11 +245,9 @@
});
});
}
}
console
.
log
(
code
,
message
);
console
.
log
(
code
,
message
);
return
message
})
})
},
},
getNewData
()
{
getNewData
()
{
//console.log(this.$refs.udb);
this
.
$refs
.
udb
.
refresh
()
//{clear:true}
this
.
$refs
.
udb
.
refresh
()
//{clear:true}
},
},
getUserImg
(
e
)
{
getUserImg
(
e
)
{
...
...
pages/clientDB/permission-demo/permission-demo.vue
浏览文件 @
4b81da44
...
@@ -84,7 +84,8 @@
...
@@ -84,7 +84,8 @@
value
:
-
1
value
:
-
1
}
}
],
],
rulo_index
:
0
rulo_index
:
0
,
role
:
''
}
}
},
},
mounted
()
{
mounted
()
{
...
@@ -118,17 +119,17 @@
...
@@ -118,17 +119,17 @@
},
},
methods
:
{
methods
:
{
setState
(
e
){
setState
(
e
){
console
.
log
(
e
.
detail
.
value
);
console
.
log
(
e
.
detail
.
value
,
dbCollectionName
);
db
.
collection
(
dbCollectionName
).
update
({
db
.
collection
(
dbCollectionName
).
update
({
state
:
e
.
detail
.
value
state
:
e
.
detail
.
value
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
console
.
log
(
"
res:
"
,
res
);
this
.
formData
.
state
=
e
.
detail
.
value
this
.
formData
.
state
=
e
.
detail
.
value
uni
.
showToast
({
uni
.
showToast
({
icon
:
'
none
'
,
icon
:
'
none
'
,
title
:
'
更新成功
'
title
:
'
更新成功
'
})
})
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
err
);
console
.
log
(
JSON
.
stringify
(
err
));
console
.
log
(
JSON
.
stringify
(
err
));
uni
.
showModal
({
uni
.
showModal
({
content
:
err
.
message
||
'
请求服务失败
'
,
content
:
err
.
message
||
'
请求服务失败
'
,
...
@@ -147,6 +148,7 @@
...
@@ -147,6 +148,7 @@
changePermission
({
role
,
index
}){
changePermission
({
role
,
index
}){
console
.
log
(
'
index
'
,
index
);
console
.
log
(
'
index
'
,
index
);
console
.
log
(
'
role
'
,
role
);
console
.
log
(
'
role
'
,
role
);
this
.
role
=
role
this
.
rulo_index
=
index
this
.
rulo_index
=
index
let
field
=
"
_id,username,nickname,state
"
;
let
field
=
"
_id,username,nickname,state
"
;
let
where
=
{}
let
where
=
{}
...
@@ -159,7 +161,7 @@
...
@@ -159,7 +161,7 @@
db
.
collection
(
'
permission-test
'
)
db
.
collection
(
'
permission-test
'
)
.
where
(
where
)
.
where
(
where
)
.
field
(
field
).
get
().
then
(
e
=>
{
.
field
(
field
).
get
().
then
(
e
=>
{
console
.
log
(
e
.
result
.
data
);
console
.
log
(
e
);
if
(
e
.
result
.
data
[
0
]){
if
(
e
.
result
.
data
[
0
]){
this
.
formData
=
e
.
result
.
data
[
0
]
this
.
formData
=
e
.
result
.
data
[
0
]
}
else
{
}
else
{
...
@@ -183,18 +185,18 @@
...
@@ -183,18 +185,18 @@
})
})
this
.
$refs
.
form
.
submit
().
then
((
res
)
=>
{
this
.
$refs
.
form
.
submit
().
then
((
res
)
=>
{
this
.
submitForm
(
res
)
this
.
submitForm
(
res
)
}).
catch
((
e
rrors
)
=>
{
}).
catch
((
e
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
addDefaultData
()
{
addDefaultData
()
{
console
.
log
(
'
addDefaultData
'
);
console
.
log
(
"
dbCollectionName:
"
,
dbCollectionName
);
db
.
collection
(
dbCollectionName
).
add
({
db
.
collection
(
dbCollectionName
).
add
({
"
nickname
"
:
"
默认昵称
"
,
"
nickname
"
:
"
默认昵称
"
,
"
username
"
:
"
默认姓名
"
,
"
username
"
:
"
默认姓名
"
,
"
phone
"
:
"
1888888888
"
"
phone
"
:
"
1888888888
"
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
console
.
log
(
res
.
result
.
id
);
console
.
log
(
res
);
this
.
formData
.
_id
=
res
.
result
.
id
this
.
formData
.
_id
=
res
.
result
.
id
uni
.
showToast
({
uni
.
showToast
({
icon
:
'
none
'
,
icon
:
'
none
'
,
...
@@ -213,7 +215,6 @@
...
@@ -213,7 +215,6 @@
},
},
submitForm
(
value
)
{
submitForm
(
value
)
{
// 使用 uni-clientDB 提交数据
// 使用 uni-clientDB 提交数据
console
.
log
(
'
value._id------------------------------------------------------
'
,
this
.
formData
.
_id
);
if
(
this
.
formData
.
_id
)
{
if
(
this
.
formData
.
_id
)
{
console
.
log
(
this
.
formData
.
state
);
console
.
log
(
this
.
formData
.
state
);
if
(
this
.
formData
.
state
===
0
){
if
(
this
.
formData
.
state
===
0
){
...
@@ -236,22 +237,17 @@
...
@@ -236,22 +237,17 @@
icon
:
'
none
'
,
icon
:
'
none
'
,
title
:
'
更新成功
'
title
:
'
更新成功
'
})
})
console
.
log
(
"
33333333333:
"
,
33333333333
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
err
.
message
);
console
.
log
(
JSON
.
stringify
(
err
));
console
.
log
(
JSON
.
stringify
(
err
));
uni
.
showModal
({
uni
.
showModal
({
content
:
err
.
message
||
'
请求服务失败
'
,
content
:
err
.
message
||
'
请求服务失败
'
,
showCancel
:
false
showCancel
:
false
})
})
console
.
log
(
"
44444444:
"
,
33333333333
);
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
console
.
log
(
"
5555555555:
"
,
33333333333
);
})
})
}
else
{
}
else
{
console
.
log
(
'
err 9527
'
);
console
.
log
(
'
err 9527
'
);
console
.
log
(
"
6666666666:
"
,
33333333333
);
}
}
}
}
...
...
pages/clientDB/permission-demo/readme.vue
浏览文件 @
4b81da44
...
@@ -220,9 +220,9 @@
...
@@ -220,9 +220,9 @@
urls
:[
url
]
urls
:[
url
]
})
})
},
},
a
sync
a
ddFn
(){
addFn
(){
uni
.
showLoading
({
mask
:
true
})
uni
.
showLoading
({
mask
:
true
})
return
await
ptDb
.
add
({
ptDb
.
add
({
nickname
:
"
默认昵称
"
,
nickname
:
"
默认昵称
"
,
username
:
"
默认姓名
"
,
username
:
"
默认姓名
"
,
phone
:
"
18888888888
"
phone
:
"
18888888888
"
...
@@ -233,7 +233,6 @@
...
@@ -233,7 +233,6 @@
showCancel
:
false
,
showCancel
:
false
,
confirmText
:
"
知道了
"
confirmText
:
"
知道了
"
});
});
return
e
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
log
(
err
);
console
.
log
(
err
);
uni
.
showModal
({
uni
.
showModal
({
...
@@ -242,21 +241,19 @@
...
@@ -242,21 +241,19 @@
showCancel
:
false
,
showCancel
:
false
,
confirmText
:
"
知道了
"
confirmText
:
"
知道了
"
});
});
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
removeFn
(){
removeFn
(){
uni
.
showLoading
({
mask
:
true
})
uni
.
showLoading
({
mask
:
true
})
return
await
ptDb
.
remove
().
then
(
e
=>
{
ptDb
.
remove
().
then
(
e
=>
{
console
.
log
(
e
,
"
123
"
);
console
.
log
(
e
,
"
123
"
);
uni
.
showModal
({
uni
.
showModal
({
content
:
JSON
.
stringify
(
e
.
result
),
content
:
JSON
.
stringify
(
e
.
result
),
showCancel
:
false
,
showCancel
:
false
,
confirmText
:
"
知道了
"
confirmText
:
"
知道了
"
});
});
return
e
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
log
(
JSON
.
stringify
(
err
));
console
.
log
(
JSON
.
stringify
(
err
));
uni
.
showModal
({
uni
.
showModal
({
...
@@ -265,7 +262,6 @@
...
@@ -265,7 +262,6 @@
showCancel
:
false
,
showCancel
:
false
,
confirmText
:
"
知道了
"
confirmText
:
"
知道了
"
});
});
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
...
@@ -273,13 +269,10 @@
...
@@ -273,13 +269,10 @@
updateNickname
(
self
){
updateNickname
(
self
){
},
},
async
updateFn
(
data
,
where
=
{}){
updateFn
(
data
,
where
=
{}){
console
.
log
(
"
data
"
);
console
.
log
(
data
);
console
.
log
(
data
);
uni
.
showLoading
({
mask
:
true
})
uni
.
showLoading
({
mask
:
true
})
return
await
ptDb
ptDb
.
where
(
where
).
update
(
data
)
.
where
(
where
)
.
update
(
data
)
.
then
(
e
=>
{
.
then
(
e
=>
{
console
.
log
(
e
);
console
.
log
(
e
);
uni
.
showModal
({
uni
.
showModal
({
...
@@ -287,9 +280,7 @@
...
@@ -287,9 +280,7 @@
showCancel
:
false
,
showCancel
:
false
,
confirmText
:
"
知道了
"
confirmText
:
"
知道了
"
});
});
return
e
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
if
(
'
nickname
'
in
data
){
if
(
'
nickname
'
in
data
){
uni
.
showModal
({
uni
.
showModal
({
title
:
"
被拒绝,普通用户角色,只能更新自己创建的数据。
"
,
title
:
"
被拒绝,普通用户角色,只能更新自己创建的数据。
"
,
...
@@ -328,12 +319,7 @@
...
@@ -328,12 +319,7 @@
});
});
}
}
console
.
log
(
"
错误------
"
,
err
);
console
.
log
(
"
错误------
"
,
err
);
console
.
log
(
"
错误------
"
,
err
.
message
);
/* uni.showModal({
return
err
//console.log(err);
/*
*/
/* uni.showModal({
title:"执行更新操作失败!",
title:"执行更新操作失败!",
content: "schema配置了,更新该字段限:\n 1、数据创建者,2、审核员,3、当然还有无任何权限限制的管理员",
content: "schema配置了,更新该字段限:\n 1、数据创建者,2、审核员,3、当然还有无任何权限限制的管理员",
showCancel: false,
showCancel: false,
...
@@ -343,16 +329,14 @@
...
@@ -343,16 +329,14 @@
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
getFn
(
field
=
'
uid,username,nickname,state
'
){
getFn
(
field
=
'
uid,username,nickname,state
'
){
// console.time('getFn');
// console.time('getFn');
uni
.
showLoading
({
mask
:
true
})
uni
.
showLoading
({
mask
:
true
})
return
await
ptDb
.
field
(
field
).
get
()
ptDb
.
field
(
field
).
get
()
.
then
(
e
=>
{
.
then
(
e
=>
{
// console.timeEnd('getFn');
// console.timeEnd('getFn');
console
.
log
(
e
,
"
1111
"
);
console
.
log
(
e
);
if
(
e
.
result
.
data
.
length
){
if
(
e
.
result
.
data
.
length
){
console
.
log
(
e
.
result
.
data
.
length
);
//console.log(this.$refs.alertCode);
this
.
$refs
.
alertCode
.
open
(
e
.
result
.
data
)
this
.
$refs
.
alertCode
.
open
(
e
.
result
.
data
)
}
else
{
}
else
{
uni
.
showModal
({
uni
.
showModal
({
...
@@ -362,7 +346,6 @@
...
@@ -362,7 +346,6 @@
confirmText
:
"
知道了
"
confirmText
:
"
知道了
"
});
});
}
}
return
e
.
result
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
// console.timeEnd('getFn');
// console.timeEnd('getFn');
console
.
log
(
err
,
"
err---
"
);
console
.
log
(
err
,
"
err---
"
);
...
@@ -372,7 +355,6 @@
...
@@ -372,7 +355,6 @@
showCancel
:
false
,
showCancel
:
false
,
confirmText
:
"
知道了
"
confirmText
:
"
知道了
"
});
});
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
...
@@ -380,7 +362,6 @@
...
@@ -380,7 +362,6 @@
changePermission
(
e
){
changePermission
(
e
){
console
.
log
(
e
,
'
切换完成
'
);
console
.
log
(
e
,
'
切换完成
'
);
this
.
currentRole
=
e
.
role
this
.
currentRole
=
e
.
role
console
.
log
(
"
this.currentRole
"
,
this
.
currentRole
);
}
}
}
}
}
}
...
...
pages/clientDB/permission-field-simple/permission-field-simple.vue
浏览文件 @
4b81da44
...
@@ -144,15 +144,13 @@
...
@@ -144,15 +144,13 @@
"
text
"
:
"
数据
"
+
Date
.
now
(),
"
text
"
:
"
数据
"
+
Date
.
now
(),
...
hasIp
...
hasIp
}),
}),
);
);
let
res
;
let
res
;
try
{
try
{
switch
(
e
.
type
)
{
switch
(
e
.
type
)
{
case
'
read
'
:
case
'
read
'
:
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
field
(
e
.
field
).
where
(
e
.
where
).
get
()
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
).
field
(
e
.
field
).
get
()
return
res
break
;
break
;
case
'
create
'
:
case
'
create
'
:
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
)
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
)
...
@@ -160,7 +158,6 @@
...
@@ -160,7 +158,6 @@
"
text
"
:
"
默认写入的数据
"
+
Date
.
now
(),
"
text
"
:
"
默认写入的数据
"
+
Date
.
now
(),
...
hasIp
...
hasIp
})
})
return
res
break
;
break
;
case
'
update
'
:
case
'
update
'
:
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
)
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
)
...
@@ -168,16 +165,16 @@
...
@@ -168,16 +165,16 @@
"
text
"
:
"
更新后的数据
"
+
Date
.
now
(),
"
text
"
:
"
更新后的数据
"
+
Date
.
now
(),
...
hasIp
...
hasIp
})
})
return
res
break
;
break
;
case
'
delete
'
:
case
'
delete
'
:
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
).
remove
()
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
).
remove
()
return
res
break
;
break
;
default
:
default
:
console
.
log
(
'
err 未定义事件类型
'
);
console
.
log
(
'
err 未定义事件类型
'
);
break
;
break
;
}
}
console
.
log
(
"
res:
"
,
res
);
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
TODO handle the exception
'
,
err
);
console
.
log
(
'
TODO handle the exception
'
,
err
);
uni
.
showModal
({
uni
.
showModal
({
...
@@ -185,18 +182,14 @@
...
@@ -185,18 +182,14 @@
content
:
item
.
explain
+
'
【
'
+
this
.
typeText
+
'
字段
'
+
item
.
field
+
'
】
'
+
(
item
.
explain_end
?
item
.
explain_end
:
''
),
content
:
item
.
explain
+
'
【
'
+
this
.
typeText
+
'
字段
'
+
item
.
field
+
'
】
'
+
(
item
.
explain_end
?
item
.
explain_end
:
''
),
showCancel
:
false
showCancel
:
false
});
});
//return false
return
err
.
message
}
finally
{
}
finally
{
uni
.
hideLoading
()
uni
.
hideLoading
()
}
}
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
},
},
changePermission
(
e
)
{
changePermission
(
e
)
{
console
.
log
(
e
,
'
切换完成
'
);
console
.
log
(
e
,
'
切换完成
'
);
console
.
log
(
"
this.typeIndex:
"
,
this
.
typeIndex
);
console
.
log
(
"
this.typeIndex:
"
,
this
.
typeIndex
);
this
.
currentRole
=
e
.
role
this
.
currentRole
=
e
.
role
console
.
log
(
"
this.currentRole
"
,
this
.
currentRole
);
}
}
}
}
}
}
...
...
pages/clientDB/permission-table-compound/permission-table-compound.vue
浏览文件 @
4b81da44
...
@@ -137,7 +137,6 @@
...
@@ -137,7 +137,6 @@
});
});
return
false
return
false
}
}
return
res
break
;
break
;
case
'
create
'
:
case
'
create
'
:
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
add
({
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
add
({
...
@@ -156,6 +155,8 @@
...
@@ -156,6 +155,8 @@
console
.
log
(
'
err 未定义事件类型
'
);
console
.
log
(
'
err 未定义事件类型
'
);
break
;
break
;
}
}
console
.
log
(
"
res:
"
,
res
);
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
TODO handle the exception
'
,
err
);
console
.
log
(
'
TODO handle the exception
'
,
err
);
uni
.
showModal
({
uni
.
showModal
({
...
@@ -163,19 +164,14 @@
...
@@ -163,19 +164,14 @@
content
:
item
.
explain
+
'
【
'
+
this
.
typeText
+
'
数据】
'
+
(
item
.
explain_end
?
item
.
explain_end
:
''
),
content
:
item
.
explain
+
'
【
'
+
this
.
typeText
+
'
数据】
'
+
(
item
.
explain_end
?
item
.
explain_end
:
''
),
showCancel
:
false
showCancel
:
false
});
});
//return false
return
err
.
message
}
finally
{
}
finally
{
uni
.
hideLoading
()
uni
.
hideLoading
()
}
}
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
},
},
changePermission
(
e
)
{
changePermission
(
e
)
{
console
.
log
(
e
,
'
切换完成
'
);
console
.
log
(
e
,
'
切换完成
'
);
console
.
log
(
"
this.typeIndex:
"
,
this
.
typeIndex
);
console
.
log
(
"
this.typeIndex:
"
,
this
.
typeIndex
);
this
.
currentRole
=
e
.
role
this
.
currentRole
=
e
.
role
console
.
log
(
"
this.currentRole
"
,
this
.
currentRole
);
}
}
}
}
}
}
...
...
pages/clientDB/permission-table-simple/permission-table-simple.vue
浏览文件 @
4b81da44
...
@@ -139,7 +139,6 @@
...
@@ -139,7 +139,6 @@
created
()
{
created
()
{
for
(
var
j
=
0
;
j
<
this
.
types
.
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
this
.
types
.
length
;
j
++
)
{
let
type
=
this
.
types
[
j
].
value
let
type
=
this
.
types
[
j
].
value
console
.
log
(
type
);
for
(
let
i
=
0
;
i
<
this
.
permissionList
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
permissionList
.
length
;
i
++
)
{
let
jsonString
=
`{
let
jsonString
=
`{
"permission":{
"permission":{
...
@@ -179,28 +178,26 @@
...
@@ -179,28 +178,26 @@
});
});
return
false
return
false
}
}
return
res
break
;
break
;
case
'
create
'
:
case
'
create
'
:
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
add
({
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
add
({
"
text
"
:
"
默认写入的数据
"
+
Date
.
now
()
"
text
"
:
"
默认写入的数据
"
+
Date
.
now
()
})
})
return
res
break
;
break
;
case
'
update
'
:
case
'
update
'
:
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
).
update
({
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
).
update
({
"
text
"
:
"
更新后的数据
"
+
Date
.
now
()
"
text
"
:
"
更新后的数据
"
+
Date
.
now
()
})
})
return
res
break
;
break
;
case
'
delete
'
:
case
'
delete
'
:
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
).
remove
()
res
=
await
db
.
action
(
e
.
action
).
collection
(
tableName
).
where
(
e
.
where
).
remove
()
return
res
break
;
break
;
default
:
default
:
console
.
log
(
'
err 未定义事件类型
'
);
console
.
log
(
'
err 未定义事件类型
'
);
break
;
break
;
}
}
console
.
log
(
"
res:
"
,
res
);
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
TODO handle the exception
'
,
err
);
console
.
log
(
'
TODO handle the exception
'
,
err
);
uni
.
showModal
({
uni
.
showModal
({
...
@@ -208,20 +205,15 @@
...
@@ -208,20 +205,15 @@
content
:
item
.
explain
+
'
【
'
+
this
.
typeText
+
'
数据】
'
+
(
item
.
explain_end
?
item
.
explain_end
:
''
),
content
:
item
.
explain
+
'
【
'
+
this
.
typeText
+
'
数据】
'
+
(
item
.
explain_end
?
item
.
explain_end
:
''
),
showCancel
:
false
showCancel
:
false
});
});
//return false
return
err
.
message
}
finally
{
}
finally
{
uni
.
hideLoading
()
uni
.
hideLoading
()
}
}
this
.
$refs
.
alertCode
.
open
(
res
.
result
)
},
},
changePermission
(
e
)
{
changePermission
(
e
)
{
console
.
log
(
e
,
'
切换完成
'
);
console
.
log
(
e
,
'
切换完成
'
);
console
.
log
(
"
role:
"
,
e
.
role
);
console
.
log
(
"
role:
"
,
e
.
role
);
console
.
log
(
"
typeIndex:
"
,
this
.
typeIndex
);
console
.
log
(
"
typeIndex:
"
,
this
.
typeIndex
);
this
.
currentRole
=
e
.
role
this
.
currentRole
=
e
.
role
console
.
log
(
this
.
currentRole
);
}
}
}
}
}
}
...
...
pages/clientDB/unicloud-db-demo/unicloud-db-demo.vue
浏览文件 @
4b81da44
...
@@ -117,7 +117,6 @@
...
@@ -117,7 +117,6 @@
},
},
onLoad
()
{
onLoad
()
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
console
.
log
(
this
.
$refs
.
udb
,
12121111
);
this
.
dataList
=
this
.
$refs
.
udb
.
dataList
this
.
dataList
=
this
.
$refs
.
udb
.
dataList
},
2000
);
},
2000
);
},
},
...
@@ -155,7 +154,6 @@
...
@@ -155,7 +154,6 @@
}
}
},
},
async
setOrderby
({
detail
:{
value
}})
{
async
setOrderby
({
detail
:{
value
}})
{
console
.
log
(
"
value:
"
,
value
);
let
arr
=
Object
.
keys
(
this
.
orderbyObj
)
let
arr
=
Object
.
keys
(
this
.
orderbyObj
)
if
(
arr
.
length
>
value
.
length
){
if
(
arr
.
length
>
value
.
length
){
for
(
let
key
in
this
.
orderbyObj
)
{
for
(
let
key
in
this
.
orderbyObj
)
{
...
@@ -171,10 +169,10 @@
...
@@ -171,10 +169,10 @@
uni
.
showActionSheet
({
uni
.
showActionSheet
({
itemList
,
itemList
,
success
:
({
tapIndex
})
=>
{
success
:
({
tapIndex
})
=>
{
console
.
log
(
tapIndex
);
this
.
orderbyObj
[
key
]
=
itemList
[
tapIndex
];
this
.
orderbyObj
[
key
]
=
itemList
[
tapIndex
];
},
},
fail
:
(
err
)
=>
{
fail
:
(
err
)
=>
{
console
.
log
(
err
);
this
.
orderbyArr
=
arr
this
.
orderbyArr
=
arr
},
},
complete
()
{
complete
()
{
...
@@ -201,7 +199,7 @@
...
@@ -201,7 +199,7 @@
return
arrJson
return
arrJson
},
},
async
add
(){
async
add
(){
return
await
udb
.
add
({
await
udb
.
add
({
book_id
:
"
add-test
"
,
book_id
:
"
add-test
"
,
quantity
:
Date
.
now
()
quantity
:
Date
.
now
()
},{
},{
...
@@ -212,13 +210,13 @@
...
@@ -212,13 +210,13 @@
}
}
})
})
},
},
async
remove
(){
remove
(){
const
_id
=
udb
.
dataList
[
0
].
_id
const
_id
=
udb
.
dataList
[
0
].
_id
return
await
udb
.
remove
(
_id
)
udb
.
remove
(
_id
)
},
},
async
update
(){
update
(){
const
_id
=
udb
.
dataList
[
0
].
_id
const
_id
=
udb
.
dataList
[
0
].
_id
return
await
udb
.
update
(
_id
,{
book_id
:
"
这条数据被改
"
},
udb
.
update
(
_id
,{
book_id
:
"
这条数据被改
"
},
{
{
success
:
(
res
)
=>
{
// 新增成功后的回调
success
:
(
res
)
=>
{
// 新增成功后的回调
this
.
getFn
()
this
.
getFn
()
...
...
pages/clientDB/validate/validate.test.js
已删除
100644 → 0
浏览文件 @
46ebd587
describe
(
'
pages/clientDB/validate/validate.vue
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page
=
await
program
.
reLaunch
(
'
/pages/clientDB/validate/validate
'
)
if
(
process
.
env
.
UNI_PLATFORM
===
"
h5
"
||
process
.
env
.
UNI_PLATFORM
===
"
app-plus
"
)
{
await
page
.
waitFor
(
1000
)
}
if
(
process
.
env
.
UNI_PLATFORM
===
"
mp-weixin
"
)
{
await
page
.
waitFor
(
1000
);
//微信等待
}
page
=
await
program
.
currentPage
()
})
beforeEach
(
async
()
=>
{
jest
.
setTimeout
(
5000
)
return
false
})
it
(
'
点击切换navBar
'
,
async
()
=>
{
//expect.assertions(1);
const
segmentedControl
=
await
page
.
$
(
'
.segmented-control
'
)
const
seControl
=
await
segmentedControl
.
$$
(
'
.segmented-control__item
'
)
// console.log(await seControl[0].text());
expect
(
await
seControl
[
0
].
text
()).
toBe
(
'
实例demo
'
)
await
seControl
[
1
].
tap
()
await
page
.
waitFor
(
300
)
await
seControl
[
2
].
tap
()
await
page
.
waitFor
(
300
)
})
})
pages/cloudFunction/cloudFunction.vue
浏览文件 @
4b81da44
...
@@ -30,11 +30,11 @@
...
@@ -30,11 +30,11 @@
return
{}
return
{}
},
},
methods
:
{
methods
:
{
a
sync
a
dd
()
{
add
()
{
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'
处理中...
'
title
:
'
处理中...
'
})
})
return
await
uniCloud
.
callFunction
({
uniCloud
.
callFunction
({
name
:
'
add
'
,
name
:
'
add
'
,
data
:
{
data
:
{
name
:
'
DCloud
'
,
name
:
'
DCloud
'
,
...
@@ -48,7 +48,6 @@
...
@@ -48,7 +48,6 @@
showCancel
:
false
showCancel
:
false
})
})
console
.
log
(
res
)
console
.
log
(
res
)
return
res
.
result
.
id
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showModal
({
uni
.
showModal
({
...
@@ -58,11 +57,11 @@
...
@@ -58,11 +57,11 @@
console
.
error
(
err
)
console
.
error
(
err
)
})
})
},
},
async
remove
()
{
remove
()
{
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'
处理中...
'
title
:
'
处理中...
'
})
})
return
await
uniCloud
.
callFunction
({
uniCloud
.
callFunction
({
name
:
'
remove
'
name
:
'
remove
'
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
...
@@ -71,7 +70,6 @@
...
@@ -71,7 +70,6 @@
showCancel
:
false
showCancel
:
false
})
})
console
.
log
(
res
)
console
.
log
(
res
)
return
res
.
result
.
msg
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showModal
({
uni
.
showModal
({
...
@@ -81,11 +79,11 @@
...
@@ -81,11 +79,11 @@
console
.
error
(
err
)
console
.
error
(
err
)
})
})
},
},
async
update
()
{
update
()
{
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'
处理中...
'
title
:
'
处理中...
'
})
})
return
await
uniCloud
.
callFunction
({
uniCloud
.
callFunction
({
name
:
'
update
'
,
name
:
'
update
'
,
data
:
{
data
:
{
name
:
'
DCloud
'
,
name
:
'
DCloud
'
,
...
@@ -99,7 +97,6 @@
...
@@ -99,7 +97,6 @@
showCancel
:
false
showCancel
:
false
})
})
console
.
log
(
res
)
console
.
log
(
res
)
return
res
.
result
.
msg
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showModal
({
uni
.
showModal
({
...
@@ -109,11 +106,11 @@
...
@@ -109,11 +106,11 @@
console
.
error
(
err
)
console
.
error
(
err
)
})
})
},
},
async
get
()
{
get
()
{
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'
处理中...
'
title
:
'
处理中...
'
})
})
return
await
uniCloud
.
callFunction
({
uniCloud
.
callFunction
({
name
:
'
get
'
name
:
'
get
'
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
...
@@ -122,7 +119,6 @@
...
@@ -122,7 +119,6 @@
showCancel
:
false
showCancel
:
false
})
})
console
.
log
(
res
)
console
.
log
(
res
)
return
res
.
result
.
data
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showModal
({
uni
.
showModal
({
...
@@ -132,9 +128,9 @@
...
@@ -132,9 +128,9 @@
console
.
error
(
err
)
console
.
error
(
err
)
})
})
},
},
async
useCommon
()
{
useCommon
()
{
console
.
log
(
'
请确保自己已经阅读并按照公用模块文档操作 https://uniapp.dcloud.io/uniCloud/cf-common
'
)
console
.
log
(
'
请确保自己已经阅读并按照公用模块文档操作 https://uniapp.dcloud.io/uniCloud/cf-common
'
)
return
await
uniCloud
.
callFunction
({
uniCloud
.
callFunction
({
name
:
'
use-common
'
name
:
'
use-common
'
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
...
@@ -143,7 +139,6 @@
...
@@ -143,7 +139,6 @@
showCancel
:
false
showCancel
:
false
})
})
console
.
log
(
res
)
console
.
log
(
res
)
return
res
.
result
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showModal
({
uni
.
showModal
({
...
...
pages/cloudObject/cloudObject.vue
浏览文件 @
4b81da44
...
@@ -104,7 +104,6 @@
...
@@ -104,7 +104,6 @@
showCancel
:
false
showCancel
:
false
})
})
console
.
log
(
res
)
console
.
log
(
res
)
return
res
.
msg
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showModal
({
uni
.
showModal
({
...
...
pages/validate-demo/add.vue
浏览文件 @
4b81da44
...
@@ -119,37 +119,33 @@
...
@@ -119,37 +119,33 @@
/**
/**
* 触发表单提交
* 触发表单提交
*/
*/
async
submit
()
{
submit
()
{
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
mask
:
true
})
})
return
this
.
$refs
.
form
.
submit
().
then
(
async
(
res
)
=>
{
this
.
$refs
.
form
.
submit
().
then
(
(
res
)
=>
{
console
.
log
(
res
,
"
000
"
);
console
.
log
(
res
,
"
000
"
);
let
msg
=
await
this
.
submitForm
(
res
)
this
.
submitForm
(
res
)
console
.
log
(
msg
,
121399999
);
return
res
}).
catch
((
errors
)
=>
{
}).
catch
((
errors
)
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
},
},
async
submitForm
(
value
)
{
submitForm
(
value
)
{
// 使用 clientDB 提交数据
// 使用 clientDB 提交数据
return
await
db
.
collection
(
dbCollectionName
).
add
(
value
).
then
((
res
)
=>
{
db
.
collection
(
dbCollectionName
).
add
(
value
).
then
((
res
)
=>
{
console
.
log
(
"
res:----
"
,
res
);
uni
.
showToast
({
uni
.
showToast
({
icon
:
'
none
'
,
icon
:
'
none
'
,
title
:
'
新增成功
'
title
:
'
新增成功
'
})
})
//this.getOpenerEventChannel().emit('refreshData')
// this.getOpenerEventChannel().emit('refreshData')
//setTimeout(() => uni.navigateBack(), 500)
// setTimeout(() => uni.navigateBack(), 500)
return
res
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
uni
.
showModal
({
uni
.
showModal
({
content
:
err
.
message
||
'
请求服务失败
'
,
content
:
err
.
message
||
'
请求服务失败
'
,
showCancel
:
false
showCancel
:
false
})
})
return
err
}).
finally
(()
=>
{
}).
finally
(()
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
})
})
...
...
uniCloud-aliyun/database/permission-test.schema.json
浏览文件 @
4b81da44
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
"username"
:{
"username"
:{
"bsonType"
:
"string"
,
"bsonType"
:
"string"
,
"permission"
:{
"permission"
:{
"
wri
te"
:
"doc.state != 0 || auth.uid != doc.uid"
"
upda
te"
:
"doc.state != 0 || auth.uid != doc.uid"
}
}
},
},
"state"
:{
"state"
:{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录