提交 6aa1a7b8 编写于 作者: 芊里

Merge branch 'master' of https://gitee.com/dcloud/base-app

......@@ -6,7 +6,7 @@
3.2 处理因token过期等问题自动更新本地token,或token无效跳转至登陆页面
*/
const debug = true;//开启后,会alert错误信息
export default function request(name,params,callback,{showLoading=false,loadText='',fail=()=>{}}={}){
export default function request(name,params,callback=false,{showLoading=false,loadText='',fail=()=>{}}={}){
console.log('request');
showLoading||loadText? uni.showLoading({title:loadText}):'';
......@@ -16,21 +16,26 @@ export default function request(name,params,callback,{showLoading=false,loadText
name = routers[0]
action = routers[1]
}
console.log({name,data: {action,params}})
return uniCloud.callFunction({name,data: {action,params},
success(e){
console.log(e);
if(showLoading || loadText) uni.hideLoading()
const res = e.result
if (res.code === 0 ) {
return callback(res.data, e.result, e)
// console.log({name,data: {action,params}})
return new Promise((resolve,reject)=>{
uniCloud.callFunction({name,data: {action,params},
success(e){
// console.log(e);
if(showLoading || loadText) uni.hideLoading()
const {result:{data,code}} = e
console.log(data,code);
if (code === 0 ) {
resolve(e)
return callback(data,e.result,e)
}
debug? uni.showModal({content: JSON.stringify(e)}) :'';
},
fail(err){
reject(err)
console.log(err);
debug? uni.showModal({content: JSON.stringify(err)}) :'';
fail(err)
}
debug? uni.showModal({content: JSON.stringify(e)}) :'';
},
fail(err){
console.log(err);
debug? uni.showModal({content: JSON.stringify(err)}) :'';
fail(err)
}
})
})
}
\ No newline at end of file
{
"name" : "base-app",
"appid" : "__UNI__BC54A00",
"appid" : "__UNI__03B096E",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
......@@ -64,7 +64,8 @@
"entitlements" : {
"com.apple.developer.associated-domains" : [
"applinks:uniapp.dcloud.io",
"applinks:static-7827e38b-7f40-4421-bca7-58331dcddc00.bspapp.com"
"applinks:static-7827e38b-7f40-4421-bca7-58331dcddc00.bspapp.com",
"applinks:static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com"
]
}
},
......@@ -78,20 +79,20 @@
"weixin" : {
"appid" : "wx0411fa6a39d61297",
"appsecret" : "",
"UniversalLinks" : "https://static-7827e38b-7f40-4421-bca7-58331dcddc00.bspapp.com/uni-universallinks/__UNI__BC54A00"
"UniversalLinks" : "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com/uni-universallinks/__UNI__03B096E"
},
"univerify" : {}
},
"share" : {
"weixin" : {
"appid" : "wx0411fa6a39d61297",
"UniversalLinks" : "https://static-7827e38b-7f40-4421-bca7-58331dcddc00.bspapp.com/uni-universallinks/__UNI__BC54A00",
"_spaceID" : "7827e38b-7f40-4421-bca7-58331dcddc00"
"UniversalLinks" : "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com/uni-universallinks/__UNI__03B096E",
"_spaceID" : "76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e"
}
},
"payment" : {
"weixin" : {
"UniversalLinks" : "https://static-7827e38b-7f40-4421-bca7-58331dcddc00.bspapp.com/uni-universallinks/__UNI__BC54A00"
"UniversalLinks" : "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com/uni-universallinks/__UNI__03B096E"
}
},
"ad" : {}
......@@ -100,7 +101,7 @@
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "",
"appid" : "wx999bf02c8e05dfc9",
"setting" : {
"urlCheck" : false
},
......
......@@ -207,17 +207,17 @@
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#F8F8F8"
},
"condition": {
"list": [
{
"path": "uni_modules/uni-login-page/pages/index/index"
},
{
"path": "pages/test/test"
}
],
"current":0
},
// "condition": {
// "list": [
// {
// "path": "uni_modules/uni-login-page/pages/index/index"
// },
// {
// "path": "pages/test/test"
// }
// ],
// "current":0
// },
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#007AFF",
......
<template>
<view>
test
<button type="default" @click="fn1">1</button>
<button type="default" @click="fn2">2</button>
</view>
</template>
......@@ -12,12 +14,19 @@
}
},
onLoad() {
this.request('user-center/login_by_',{},e=>{
console.log(e);
})
},
methods: {
fn1(){
let res = this.request('user-center/login_by_').then(e=>{
console.log('then--1',e);
})
},
fn2(){
this.request('user-center/login_by_',{},e=>{
console.log('222',e);
})
}
}
}
</script>
......
......@@ -50,11 +50,12 @@
this.uploadUserInfo({avatar:url});
})
let options = {
width:uni.upx2px(700),
height:uni.upx2px(700)
width:600,
height:600
}
uni.navigateTo({
url:'./uploadCutImageToUnicloud?path=' + res.tempFilePaths[0] + `&options=${JSON.stringify(options)}`,
animationType:"fade-in"
});
}
})
......@@ -65,9 +66,11 @@
* value 更新后的用户字段值
*/
uploadUserInfo(data){
console.log(this.userInfo._id)
userTable.doc(this.userInfo._id)
.update(data)
.then(res=>{
console.log(data)
this.login(data)
})
.catch(err=>{
......
<template>
<view class="content" >
<limeClipper :width="options.width" :scale-ratio="2" :isLockWidth="true" :isLockHeight="true" :height="options.height" :image-url="path"
<limeClipper :width="options.width" :scale-ratio="2" :is-lock-width="true" :is-lock-height="true" :height="options.height" :image-url="path"
@success="successFn" @cancel="cancel" />
</view>
</template>
......
{
"bsonType": "object",
"required": ["appid", "platform", "version", "url", "contents", "type"],
"permission": {
"read": false,
"create": false,
"update": false,
"delete": false
},
"properties": {
"_id": {
"description": "记录id,自动生成"
},
"appid": {
"bsonType": "string",
"trim": "both",
"description": "应用的AppID",
"label": "AppID",
"componentForEdit": {
"name": "uni-easyinput",
"props": {
"disabled": true
}
}
},
"name": {
"bsonType": "string",
"trim": "both",
"description": "应用名称",
"label": "应用名称",
"componentForEdit": {
"name": "uni-easyinput",
"props": {
"disabled": true
}
}
},
"title": {
"bsonType": "string",
"description": "更新标题",
"label": "更新标题"
},
"contents": {
"bsonType": "string",
"description": "更新内容",
"label": "更新内容",
"componentForEdit": {
"name": "textarea"
},
"componentForShow": {
"name": "textarea",
"props": {
"disabled": true
}
}
},
"platform": {
"bsonType": "array",
"enum": [{
"value": "Android",
"text": "安卓"
}, {
"value": "iOS",
"text": "苹果"
}],
"description": "更新平台,Android || iOS || [Android, iOS]",
"label": "平台"
},
"type": {
"bsonType": "string",
"enum": [{
"value": "native_app",
"text": "原生App安装包"
}, {
"value": "wgt",
"text": "Wgt资源包"
}],
"description": "安装包类型,native_app || wgt",
"label": "安装包类型"
},
"version": {
"bsonType": "string",
"description": "当前包版本号,必须大于当前线上发行版本号",
"label": "版本号"
},
"min_uni_version": {
"bsonType": "string",
"description": "原生App最低版本",
"label": "原生App最低版本"
},
"url": {
"bsonType": "string",
"description": "可下载安装包地址",
"label": "包地址"
},
"stable_publish": {
"bsonType": "bool",
"description": "是否上线发行",
"label": "上线发行"
},
"is_silently": {
"bsonType": "bool",
"description": "是否静默更新",
"label": "静默更新",
"defaultValue": false
},
"is_mandatory": {
"bsonType": "bool",
"description": "是否强制更新",
"label": "强制更新",
"defaultValue": false
},
"create_date": {
"bsonType": "timestamp",
"label": "上传时间",
"forceDefaultValue": {
"$env": "now"
},
"componentForEdit": {
"name": "uni-dateformat"
}
}
}
{
"bsonType": "object",
"required": ["appid", "platform", "version", "url", "contents", "type"],
"permission": {
"read": false,
"create": false,
"update": false,
"delete": false
},
"properties": {
"_id": {
"description": "记录id,自动生成"
},
"appid": {
"bsonType": "string",
"trim": "both",
"description": "应用的AppID",
"label": "AppID",
"componentForEdit": {
"name": "uni-easyinput",
"props": {
"disabled": true
}
}
},
"name": {
"bsonType": "string",
"trim": "both",
"description": "应用名称",
"label": "应用名称",
"componentForEdit": {
"name": "uni-easyinput",
"props": {
"disabled": true
}
}
},
"title": {
"bsonType": "string",
"description": "更新标题",
"label": "更新标题"
},
"contents": {
"bsonType": "string",
"description": "更新内容",
"label": "更新内容",
"componentForEdit": {
"name": "textarea"
},
"componentForShow": {
"name": "textarea",
"props": {
"disabled": true
}
}
},
"platform": {
"bsonType": "array",
"enum": [{
"value": "Android",
"text": "安卓"
}, {
"value": "iOS",
"text": "苹果"
}],
"description": "更新平台,Android || iOS || [Android, iOS]",
"label": "平台"
},
"type": {
"bsonType": "string",
"enum": [{
"value": "native_app",
"text": "原生App安装包"
}, {
"value": "wgt",
"text": "Wgt资源包"
}],
"description": "安装包类型,native_app || wgt",
"label": "安装包类型"
},
"version": {
"bsonType": "string",
"description": "当前包版本号,必须大于当前线上发行版本号",
"label": "版本号"
},
"min_uni_version": {
"bsonType": "string",
"description": "原生App最低版本",
"label": "原生App最低版本"
},
"url": {
"bsonType": "string",
"description": "可下载安装包地址",
"label": "包地址"
},
"stable_publish": {
"bsonType": "bool",
"description": "是否上线发行",
"label": "上线发行"
},
"is_silently": {
"bsonType": "bool",
"description": "是否静默更新",
"label": "静默更新",
"defaultValue": false
},
"is_mandatory": {
"bsonType": "bool",
"description": "是否强制更新",
"label": "强制更新",
"defaultValue": false
},
"create_date": {
"bsonType": "timestamp",
"label": "上传时间",
"forceDefaultValue": {
"$env": "now"
},
"componentForEdit": {
"name": "uni-dateformat"
}
}
}
}
{
"bsonType": "object",
"required": ["bannerfile"],
"permission": {
"read": true
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"bannerfile": {
"bsonType": "file",
"fileMediaType": "image",
"title": "图片文件",
"description": "图片文件信息,包括文件名、url等"
},
"open_url": {
"bsonType": "string",
"description": "点击跳转目标地址。如果是web地址则使用内置web-view打开;如果是本地页面则跳转本地页面;如果是schema地址则打开本地的app",
"title": "点击目标地址",
"format": "url",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"trim": "both"
},
"title": {
"bsonType": "string",
"description": "注意标题文字颜色和背景图靠色导致看不清的问题",
"maxLength": 20,
"title": "标题",
"trim": "both"
},
"sort": {
"bsonType": "int",
"description": "数字越小,排序越前",
"title": "排序"
},
"category_id": {
"bsonType": "string",
"description": "多个栏目的banner都存在一个表里时可用这个字段区分",
"title": "分类id"
},
"status": {
"bsonType": "bool",
"defaultValue": true,
"title": "生效状态"
},
"description": {
"bsonType": "string",
"description": "维护者自用描述",
"title": "备注",
"trim": "both"
}
}
{
"bsonType": "object",
"required": ["bannerfile"],
"permission": {
"read": true
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"bannerfile": {
"bsonType": "file",
"fileMediaType": "image",
"title": "图片文件",
"description": "图片文件信息,包括文件名、url等"
},
"open_url": {
"bsonType": "string",
"description": "点击跳转目标地址。如果是web地址则使用内置web-view打开;如果是本地页面则跳转本地页面;如果是schema地址则打开本地的app",
"title": "点击目标地址",
"format": "url",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"trim": "both"
},
"title": {
"bsonType": "string",
"description": "注意标题文字颜色和背景图靠色导致看不清的问题",
"maxLength": 20,
"title": "标题",
"trim": "both"
},
"sort": {
"bsonType": "int",
"description": "数字越小,排序越前",
"title": "排序"
},
"category_id": {
"bsonType": "string",
"description": "多个栏目的banner都存在一个表里时可用这个字段区分",
"title": "分类id"
},
"status": {
"bsonType": "bool",
"defaultValue": true,
"title": "生效状态"
},
"description": {
"bsonType": "string",
"description": "维护者自用描述",
"title": "备注",
"trim": "both"
}
}
}
{
"bsonType": "object",
"permission": {
"create": false,
"delete": false,
"read": "doc.is_on_sale == true",
"update": false
},
"properties": {
"_id": {
"description": "存储文档 ID(商品 ID),系统自动生成"
},
"add_date": {
"bsonType": "timestamp",
"defaultValue": {
"$env": "now"
},
"description": "上架时间"
},
"category_id": {
"bsonType": "string",
"description": "分类 id,参考`opendb-mall-categories`表",
"foreignKey": "opendb-mall-categories._id"
},
"comment_count": {
"bsonType": "int",
"description": "累计评论数"
},
"goods_banner_imgs": {
"bsonType": "array",
"description": "商品详情页的banner图地址"
},
"goods_desc": {
"bsonType": "string",
"description": "商品详细描述",
"title": "详细描述",
"trim": "both"
},
"goods_sn": {
"bsonType": "string",
"description": "商品的唯一货号",
"title": "货号",
"trim": "both"
},
"goods_thumb": {
"bsonType": "string",
"description": "商品缩略图,用于在列表或搜索结果中预览显示",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"title": "缩略图地址",
"trim": "both"
},
"is_alone_sale": {
"bsonType": "bool",
"description": "是否能单独销售;如果不能单独销售,则只能作为某商品的配件或者赠品销售"
},
"is_best": {
"bsonType": "bool",
"description": "是否精品"
},
"is_hot": {
"bsonType": "bool",
"description": "是否热销"
},
"is_new": {
"bsonType": "bool",
"description": "是否新品",
"title": "是否新品"
},
"is_on_sale": {
"bsonType": "bool",
"description": "是否上架销售",
"title": "是否上架"
},
"is_real": {
"bsonType": "bool",
"description": "是否实物",
"title": "是否为实物"
},
"keywords": {
"bsonType": "string",
"description": "商品关键字,为搜索引擎收录使用",
"title": "关键字",
"trim": "both"
},
"last_modify_date": {
"bsonType": "timestamp",
"defaultValue": {
"$env": "now"
},
"description": "最后修改时间"
},
"month_sell_count": {
"bsonType": "int",
"description": "月销量"
},
"name": {
"bsonType": "string",
"description": "商品名称",
"title": "名称",
"trim": "both"
},
"remain_count": {
"bsonType": "int",
"description": "库存数量",
"title": "库存数量"
},
"seller_note": {
"bsonType": "string",
"description": "商家备注,仅商家可见",
"permission": {
"read": false
},
"trim": "both"
},
"total_sell_count": {
"bsonType": "int",
"description": "总销量"
}
},
"required": ["goods_sn", "name", "remain_count", "month_sell_count", "total_sell_count", "comment_count", "is_real",
"is_on_sale", "is_alone_sale", "is_best", "is_new", "is_hot"
]
{
"bsonType": "object",
"permission": {
"create": false,
"delete": false,
"read": "doc.is_on_sale == true",
"update": false
},
"properties": {
"_id": {
"description": "存储文档 ID(商品 ID),系统自动生成"
},
"add_date": {
"bsonType": "timestamp",
"defaultValue": {
"$env": "now"
},
"description": "上架时间"
},
"category_id": {
"bsonType": "string",
"description": "分类 id,参考`opendb-mall-categories`表",
"foreignKey": "opendb-mall-categories._id"
},
"comment_count": {
"bsonType": "int",
"description": "累计评论数"
},
"goods_banner_imgs": {
"bsonType": "array",
"description": "商品详情页的banner图地址"
},
"goods_desc": {
"bsonType": "string",
"description": "商品详细描述",
"title": "详细描述",
"trim": "both"
},
"goods_sn": {
"bsonType": "string",
"description": "商品的唯一货号",
"title": "货号",
"trim": "both"
},
"goods_thumb": {
"bsonType": "string",
"description": "商品缩略图,用于在列表或搜索结果中预览显示",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"title": "缩略图地址",
"trim": "both"
},
"is_alone_sale": {
"bsonType": "bool",
"description": "是否能单独销售;如果不能单独销售,则只能作为某商品的配件或者赠品销售"
},
"is_best": {
"bsonType": "bool",
"description": "是否精品"
},
"is_hot": {
"bsonType": "bool",
"description": "是否热销"
},
"is_new": {
"bsonType": "bool",
"description": "是否新品",
"title": "是否新品"
},
"is_on_sale": {
"bsonType": "bool",
"description": "是否上架销售",
"title": "是否上架"
},
"is_real": {
"bsonType": "bool",
"description": "是否实物",
"title": "是否为实物"
},
"keywords": {
"bsonType": "string",
"description": "商品关键字,为搜索引擎收录使用",
"title": "关键字",
"trim": "both"
},
"last_modify_date": {
"bsonType": "timestamp",
"defaultValue": {
"$env": "now"
},
"description": "最后修改时间"
},
"month_sell_count": {
"bsonType": "int",
"description": "月销量"
},
"name": {
"bsonType": "string",
"description": "商品名称",
"title": "名称",
"trim": "both"
},
"remain_count": {
"bsonType": "int",
"description": "库存数量",
"title": "库存数量"
},
"seller_note": {
"bsonType": "string",
"description": "商家备注,仅商家可见",
"permission": {
"read": false
},
"trim": "both"
},
"total_sell_count": {
"bsonType": "int",
"description": "总销量"
}
},
"required": ["goods_sn", "name", "remain_count", "month_sell_count", "total_sell_count", "comment_count", "is_real",
"is_on_sale", "is_alone_sale", "is_best", "is_new", "is_hot"
]
}
{
"bsonType": "object",
"permission": {
"create": "auth.uid != null",
"delete": "doc.uid == auth.uid",
"read": true,
"update": "doc.uid == auth.uid"
},
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
"article_status": {
"bsonType": "int",
"description": "文章状态:0 草稿箱 1 已发布",
"maximum": 1,
"minimum": 0
},
"avatar": {
"bsonType": "string",
"description": "缩略图地址",
"label": "封面大图"
},
"category_id": {
"bsonType": "string",
"description": "分类 id,参考`uni-news-categories`表"
},
"comment_count": {
"bsonType": "int",
"description": "评论数量",
"permission": {
"write": false
}
},
"comment_status": {
"bsonType": "int",
"description": "评论状态:0 关闭 1 开放",
"maximum": 1,
"minimum": 0
},
"content": {
"bsonType": "string",
"description": "文章内容",
"label": "文章内容"
},
"excerpt": {
"bsonType": "string",
"description": "文章摘录",
"label": "摘要"
},
"is_essence": {
"bsonType": "bool",
"description": "阅读加精",
"permission": {
"write": false
}
},
"is_sticky": {
"bsonType": "bool",
"description": "是否置顶",
"permission": {
"write": false
}
},
"last_comment_user_id": {
"bsonType": "string",
"description": "最后回复用户 id,参考`uni-id-users` 表"
},
"last_modify_date": {
"bsonType": "timestamp",
"description": "最后修改时间"
},
"last_modify_ip": {
"bsonType": "string",
"description": "最后修改时 IP 地址"
},
"like_count": {
"bsonType": "int",
"description": "喜欢数、点赞数",
"permission": {
"write": false
}
},
"mode": {
"bsonType": "number",
"description": "排版显示模式"
},
"publish_date": {
"bsonType": "timestamp",
"defaultValue": {
"$env": "now"
},
"description": "发表时间"
},
"publish_ip": {
"bsonType": "string",
"description": "发表时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
},
"title": {
"bsonType": "string",
"description": "标题",
"label": "标题"
},
"user_id": {
"bsonType": "string",
"description": "文章作者ID, 参考`uni-id-users` 表"
},
"view_count": {
"bsonType": "int",
"description": "阅读数量",
"permission": {
"write": false
}
}
},
"required": ["user_id", "title", "content", "article_status", "view_count", "like_count", "is_sticky", "is_essence",
"comment_status", "comment_count", "mode"
]
}
{
"bsonType": "object",
"required": ["user_id", "title", "content"],
"permission": {
"read": "doc.uid == auth.uid && doc.article_status == 0 || doc.article_status == 1",
"create": "auth.uid != null",
"update": "doc.uid == auth.uid",
"delete": "doc.uid == auth.uid"
},
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
"user_id": {
"bsonType": "string",
"description": "文章作者ID, 参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id",
"defaultValue": {
"$env": "uid"
}
},
"author": {
"bsonType": "string",
"title": "作者信息",
"description": "冗余字段,用于保存联表查询结果,参考`uni-id-users`表",
"foreignKey": "uni-id-users._id",
"enum": {
"collection": "uni-id-users",
"field": "username, _id as text, _id as value"
}
},
"category_id": {
"bsonType": "string",
"title": "分类",
"description": "分类 id,参考`uni-news-categories`表",
"foreignKey": "opendb-news-categories._id",
"enum": {
"collection": "opendb-news-categories",
"field": "name as text, _id as value"
}
},
"title": {
"bsonType": "string",
"title": "标题",
"description": "标题",
"label": "标题",
"trim": "both"
},
"content": {
"bsonType": "string",
"title": "文章内容",
"description": "文章内容",
"label": "文章内容",
"trim": "right"
},
"excerpt": {
"bsonType": "string",
"title": "文章摘录",
"description": "文章摘录",
"label": "摘要",
"trim": "both"
},
"article_status": {
"bsonType": "int",
"title": "文章状态",
"description": "文章状态:0 草稿箱 1 已发布",
"defaultValue": 0,
"enum": [{
"value": 0,
"text": "草稿箱"
}, {
"value": 1,
"text": "已发布"
}]
},
"view_count": {
"bsonType": "int",
"title": "阅读数量",
"description": "阅读数量",
"permission": {
"write": false
}
},
"like_count": {
"bsonType": "int",
"description": "喜欢数、点赞数",
"permission": {
"write": false
}
},
"is_sticky": {
"bsonType": "bool",
"title": "是否置顶",
"description": "是否置顶",
"permission": {
"write": false
}
},
"is_essence": {
"bsonType": "bool",
"title": "阅读加精",
"description": "阅读加精",
"permission": {
"write": false
}
},
"comment_status": {
"bsonType": "int",
"title": "开放评论",
"description": "评论状态:0 关闭 1 开放",
"enum": [{
"value": 0,
"text": "关闭"
}, {
"value": 1,
"text": "开放"
}]
},
"comment_count": {
"bsonType": "int",
"description": "评论数量",
"permission": {
"write": false
}
},
"last_comment_user_id": {
"bsonType": "string",
"description": "最后回复用户 id,参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id"
},
"avatar": {
"bsonType": "string",
"title": "封面大图",
"description": "缩略图地址",
"label": "封面大图",
"trim": "both"
},
"publish_date": {
"bsonType": "timestamp",
"title": "发表时间",
"description": "发表时间",
"defaultValue": {
"$env": "now"
}
},
"publish_ip": {
"bsonType": "string",
"title": "发布文章时IP地址",
"description": "发表时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
},
"last_modify_date": {
"bsonType": "timestamp",
"title": "最后修改时间",
"description": "最后修改时间",
"defaultValue": {
"$env": "now"
}
},
"last_modify_ip": {
"bsonType": "string",
"description": "最后修改时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
},
"mode": {
"bsonType": "number",
"title": "排版显示模式",
"description": "排版显示模式,如左图右文、上图下文等"
}
}
{
"bsonType": "object",
"required": ["user_id", "title", "content"],
"permission": {
"read": "doc.uid == auth.uid && doc.article_status == 0 || doc.article_status == 1",
"create": "auth.uid != null",
"update": "doc.uid == auth.uid",
"delete": "doc.uid == auth.uid"
},
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
"user_id": {
"bsonType": "string",
"description": "文章作者ID, 参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id",
"defaultValue": {
"$env": "uid"
}
},
"author": {
"bsonType": "string",
"title": "作者信息",
"description": "冗余字段,用于保存联表查询结果,参考`uni-id-users`表",
"foreignKey": "uni-id-users._id",
"enum": {
"collection": "uni-id-users",
"field": "username, _id as text, _id as value"
}
},
"category_id": {
"bsonType": "string",
"title": "分类",
"description": "分类 id,参考`uni-news-categories`表",
"foreignKey": "opendb-news-categories._id",
"enum": {
"collection": "opendb-news-categories",
"field": "name as text, _id as value"
}
},
"title": {
"bsonType": "string",
"title": "标题",
"description": "标题",
"label": "标题",
"trim": "both"
},
"content": {
"bsonType": "string",
"title": "文章内容",
"description": "文章内容",
"label": "文章内容",
"trim": "right"
},
"excerpt": {
"bsonType": "string",
"title": "文章摘录",
"description": "文章摘录",
"label": "摘要",
"trim": "both"
},
"article_status": {
"bsonType": "int",
"title": "文章状态",
"description": "文章状态:0 草稿箱 1 已发布",
"defaultValue": 0,
"enum": [{
"value": 0,
"text": "草稿箱"
}, {
"value": 1,
"text": "已发布"
}]
},
"view_count": {
"bsonType": "int",
"title": "阅读数量",
"description": "阅读数量",
"permission": {
"write": false
}
},
"like_count": {
"bsonType": "int",
"description": "喜欢数、点赞数",
"permission": {
"write": false
}
},
"is_sticky": {
"bsonType": "bool",
"title": "是否置顶",
"description": "是否置顶",
"permission": {
"write": false
}
},
"is_essence": {
"bsonType": "bool",
"title": "阅读加精",
"description": "阅读加精",
"permission": {
"write": false
}
},
"comment_status": {
"bsonType": "int",
"title": "开放评论",
"description": "评论状态:0 关闭 1 开放",
"enum": [{
"value": 0,
"text": "关闭"
}, {
"value": 1,
"text": "开放"
}]
},
"comment_count": {
"bsonType": "int",
"description": "评论数量",
"permission": {
"write": false
}
},
"last_comment_user_id": {
"bsonType": "string",
"description": "最后回复用户 id,参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id"
},
"avatar": {
"bsonType": "string",
"title": "封面大图",
"description": "缩略图地址",
"label": "封面大图",
"trim": "both"
},
"publish_date": {
"bsonType": "timestamp",
"title": "发表时间",
"description": "发表时间",
"defaultValue": {
"$env": "now"
}
},
"publish_ip": {
"bsonType": "string",
"title": "发布文章时IP地址",
"description": "发表时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
},
"last_modify_date": {
"bsonType": "timestamp",
"title": "最后修改时间",
"description": "最后修改时间",
"defaultValue": {
"$env": "now"
}
},
"last_modify_ip": {
"bsonType": "string",
"description": "最后修改时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
},
"mode": {
"bsonType": "number",
"title": "排版显示模式",
"description": "排版显示模式,如左图右文、上图下文等"
}
}
}
{
"bsonType": "object",
"required": ["name"],
"permission": {
"read": true,
"create": false,
"update": false,
"delete": false
},
"properties": {
"_id": {
"description": "存储文档 ID(文章 ID),系统自动生成"
},
"name": {
"bsonType": "string",
"description": "类别名称",
"label": "名称",
"trim": "both"
},
"description": {
"bsonType": "string",
"description": "类别描述",
"label": "描述",
"trim": "both"
},
"icon": {
"bsonType": "string",
"description": "类别图标地址",
"label": "图标地址",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"trim": "both"
},
"sort": {
"bsonType": "int",
"description": "类别显示顺序",
"label": "排序"
},
"article_count": {
"bsonType": "int",
"description": "该类别下文章数量"
},
"create_date": {
"bsonType": "timestamp",
"description": "创建时间",
"forceDefaultValue": {
"$env": "now"
}
}
}
{
"bsonType": "object",
"required": ["name"],
"permission": {
"read": true,
"create": false,
"update": false,
"delete": false
},
"properties": {
"_id": {
"description": "存储文档 ID(文章 ID),系统自动生成"
},
"name": {
"bsonType": "string",
"description": "类别名称",
"label": "名称",
"trim": "both"
},
"description": {
"bsonType": "string",
"description": "类别描述",
"label": "描述",
"trim": "both"
},
"icon": {
"bsonType": "string",
"description": "类别图标地址",
"label": "图标地址",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"trim": "both"
},
"sort": {
"bsonType": "int",
"description": "类别显示顺序",
"label": "排序"
},
"article_count": {
"bsonType": "int",
"description": "该类别下文章数量"
},
"create_date": {
"bsonType": "timestamp",
"description": "创建时间",
"forceDefaultValue": {
"$env": "now"
}
}
}
}
{
"bsonType": "object",
"required": ["article_id", "user_id", "comment_content", "like_count", "comment_type", "reply_user_id",
"reply_comment_id"
],
"permission": {
"read": true,
"create": "auth.uid != null && get(`database.opendb-news-article.${doc.article_id}`).comment_status == 1",
"update": "doc.uid == auth.uid",
"delete": "doc.uid == auth.uid"
},
"properties": {
"_id": {
"description": "存储文档 ID(文章 ID),系统自动生成"
},
"article_id": {
"bsonType": "string",
"description": "文章ID,opendb-news-posts 表中的`_id`字段",
"foreignKey": "opendb-news-articles._id"
},
"user_id": {
"bsonType": "string",
"description": "评论者ID,参考`uni-id-users` 表",
"forceDefaultValue": {
"$env": "uid"
},
"foreignKey": "uni-id-users._id"
},
"comment_content": {
"bsonType": "string",
"description": "评论内容",
"title": "评论内容",
"trim": "right"
},
"like_count": {
"bsonType": "int",
"description": "评论喜欢数、点赞数"
},
"comment_type": {
"bsonType": "int",
"description": "回复类型: 0 针对文章的回复 1 针对评论的回复"
},
"reply_user_id": {
"bsonType": "string",
"description": "被回复的评论用户ID,comment_type为1时有效",
"foreignKey": "uni-id-users._id"
},
"reply_comment_id": {
"bsonType": "string",
"description": "被回复的评论ID,comment_type为1时有效",
"foreignKey": "opendb-news-comments._id"
},
"comment_date": {
"bsonType": "timestamp",
"description": "评论发表时间",
"forceDefaultValue": {
"$env": "now"
}
},
"comment_ip": {
"bsonType": "string",
"description": "评论发表时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
}
}
{
"bsonType": "object",
"required": ["article_id", "user_id", "comment_content", "like_count", "comment_type", "reply_user_id",
"reply_comment_id"
],
"permission": {
"read": true,
"create": "auth.uid != null && get(`database.opendb-news-article.${doc.article_id}`).comment_status == 1",
"update": "doc.uid == auth.uid",
"delete": "doc.uid == auth.uid"
},
"properties": {
"_id": {
"description": "存储文档 ID(文章 ID),系统自动生成"
},
"article_id": {
"bsonType": "string",
"description": "文章ID,opendb-news-posts 表中的`_id`字段",
"foreignKey": "opendb-news-articles._id"
},
"user_id": {
"bsonType": "string",
"description": "评论者ID,参考`uni-id-users` 表",
"forceDefaultValue": {
"$env": "uid"
},
"foreignKey": "uni-id-users._id"
},
"comment_content": {
"bsonType": "string",
"description": "评论内容",
"title": "评论内容",
"trim": "right"
},
"like_count": {
"bsonType": "int",
"description": "评论喜欢数、点赞数"
},
"comment_type": {
"bsonType": "int",
"description": "回复类型: 0 针对文章的回复 1 针对评论的回复"
},
"reply_user_id": {
"bsonType": "string",
"description": "被回复的评论用户ID,comment_type为1时有效",
"foreignKey": "uni-id-users._id"
},
"reply_comment_id": {
"bsonType": "string",
"description": "被回复的评论ID,comment_type为1时有效",
"foreignKey": "opendb-news-comments._id"
},
"comment_date": {
"bsonType": "timestamp",
"description": "评论发表时间",
"forceDefaultValue": {
"$env": "now"
}
},
"comment_ip": {
"bsonType": "string",
"description": "评论发表时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
}
}
}
{
"bsonType": "object",
"required": ["user_id", "article_id"],
"permission": {
"read": true,
"create": "auth.uid != null",
"update": false,
"delete": "doc.uid == auth.uid"
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"article_id": {
"bsonType": "string",
"description": "文章id,参考opendb-news-articles表",
"foreignKey": "opendb-news-articles._id"
},
"user_id": {
"bsonType": "string",
"description": "收藏者id,参考uni-id-users表",
"forceDefaultValue": {
"$env": "uid"
},
"foreignKey": "uni-id-users._id"
},
"create_date": {
"bsonType": "timestamp",
"description": "收藏时间",
"forceDefaultValue": {
"$env": "now"
}
}
}
{
"bsonType": "object",
"required": ["user_id", "article_id"],
"permission": {
"read": true,
"create": "auth.uid != null",
"update": false,
"delete": "doc.uid == auth.uid"
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"article_id": {
"bsonType": "string",
"description": "文章id,参考opendb-news-articles表",
"foreignKey": "opendb-news-articles._id"
},
"user_id": {
"bsonType": "string",
"description": "收藏者id,参考uni-id-users表",
"forceDefaultValue": {
"$env": "uid"
},
"foreignKey": "uni-id-users._id"
},
"create_date": {
"bsonType": "timestamp",
"description": "收藏时间",
"forceDefaultValue": {
"$env": "now"
}
}
}
}
{
"bsonType": "object",
"permission": {
"create": false,
"delete": false,
"read": true,
"update": false
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"content": {
"bsonType": "string",
"description": "搜索内容"
},
"count": {
"bsonType": "long",
"description": "搜索次数"
},
"create_date": {
"bsonType": "timestamp",
"description": "统计时间"
}
},
"required": ["content", "count"]
{
"bsonType": "object",
"permission": {
"create": false,
"delete": false,
"read": true,
"update": false
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"content": {
"bsonType": "string",
"description": "搜索内容"
},
"count": {
"bsonType": "long",
"description": "搜索次数"
},
"create_date": {
"bsonType": "timestamp",
"description": "统计时间"
}
},
"required": ["content", "count"]
}
{
"bsonType": "object",
"permission": {
"create": true,
"delete": false,
"read": false,
"update": false
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"content": {
"bsonType": "string",
"description": "搜索内容"
},
"create_date": {
"bsonType": "timestamp",
"description": "统计时间"
},
"device_id": {
"bsonType": "string",
"description": "设备id"
},
"user_id": {
"bsonType": "string",
"description": "收藏者id,参考uni-id-users表"
}
},
"required": ["content"]
{
"bsonType": "object",
"permission": {
"create": true,
"delete": false,
"read": false,
"update": false
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"content": {
"bsonType": "string",
"description": "搜索内容"
},
"create_date": {
"bsonType": "timestamp",
"description": "统计时间"
},
"device_id": {
"bsonType": "string",
"description": "设备id"
},
"user_id": {
"bsonType": "string",
"description": "收藏者id,参考uni-id-users表"
}
},
"required": ["content"]
}
{
"bsonType": "object",
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"code": {
"bsonType": "string",
"description": "验证码"
},
"create_date": {
"bsonType": "timestamp",
"description": "创建时间"
},
"device_uuid": {
"bsonType": "string",
"description": "设备UUID,常用于图片验证码"
},
"email": {
"bsonType": "string",
"description": "邮箱"
},
"expired_date": {
"bsonType": "timestamp",
"description": "过期时间"
},
"ip": {
"bsonType": "string",
"description": "请求时客户端IP地址"
},
"mobile": {
"bsonType": "string",
"description": "手机号码"
},
"scene": {
"bsonType": "string",
"description": "使用验证码的场景,如:login, bind, unbind, pay"
},
"state": {
"bsonType": "int",
"description": "验证状态:0 未验证、1 已验证、2 已作废"
}
},
"required": []
{
"bsonType": "object",
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"code": {
"bsonType": "string",
"description": "验证码"
},
"create_date": {
"bsonType": "timestamp",
"description": "创建时间"
},
"device_uuid": {
"bsonType": "string",
"description": "设备UUID,常用于图片验证码"
},
"email": {
"bsonType": "string",
"description": "邮箱"
},
"expired_date": {
"bsonType": "timestamp",
"description": "过期时间"
},
"ip": {
"bsonType": "string",
"description": "请求时客户端IP地址"
},
"mobile": {
"bsonType": "string",
"description": "手机号码"
},
"scene": {
"bsonType": "string",
"description": "使用验证码的场景,如:login, bind, unbind, pay"
},
"state": {
"bsonType": "int",
"description": "验证状态:0 未验证、1 已验证、2 已作废"
}
},
"required": []
}
{
"bsonType": "object",
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"create_date": {
"bsonType": "timestamp",
"description": "创建时间",
"forceDefaultValue": {
"$env": "now"
}
},
"device_uuid": {
"bsonType": "string",
"description": "设备唯一标识"
},
"ip": {
"bsonType": "string",
"description": "ip地址"
},
"state": {
"bsonType": "int",
"description": "结果:0 失败、1 成功"
},
"type": {
"bsonType": "string",
"description": "登录类型",
"enum": ["login", "logout"]
},
"ua": {
"bsonType": "string",
"description": "userAgent"
},
"user_id": {
"bsonType": "string",
"description": "用户id,参考uni-id-users表"
}
},
"required": []
{
"bsonType": "object",
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"create_date": {
"bsonType": "timestamp",
"description": "创建时间",
"forceDefaultValue": {
"$env": "now"
}
},
"device_uuid": {
"bsonType": "string",
"description": "设备唯一标识"
},
"ip": {
"bsonType": "string",
"description": "ip地址"
},
"state": {
"bsonType": "int",
"description": "结果:0 失败、1 成功"
},
"type": {
"bsonType": "string",
"description": "登录类型",
"enum": ["login", "logout"]
},
"ua": {
"bsonType": "string",
"description": "userAgent"
},
"user_id": {
"bsonType": "string",
"description": "用户id,参考uni-id-users表"
}
},
"required": []
}
{
"bsonType": "object",
"permission": {
"read": "'read' in auth.permission",
"create": false,
"update": "doc._id == auth.uid",
"delete": false
},
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
"ali_openid": {
"bsonType": "string",
"description": "支付宝平台openid"
},
"apple_openid": {
"bsonType": "string",
"description": "苹果登录openid"
},
"avatar": {
"bsonType": "string",
"description": "头像地址",
"title": "头像地址",
"trim": "both"
},
"comment": {
"bsonType": "string",
"description": "备注",
"title": "备注",
"trim": "both"
},
"department_id": {
"bsonType": "array",
"description": "部门ID",
"enum": {
"collection": "opendb-department",
"field": "_id as value, name as text",
"orderby": "name asc"
},
"enumType": "tree",
"title": "部门"
},
"email": {
"bsonType": "string",
"description": "邮箱地址",
"format": "email",
"title": "邮箱",
"trim": "both"
},
"email_confirmed": {
"bsonType": "int",
"defaultValue": 0,
"description": "邮箱验证状态:0 未验证 1 已验证",
"enum": [{
"text": "未验证",
"value": 0
}, {
"text": "已验证",
"value": 1
}],
"title": "邮箱验证状态"
},
"gender": {
"bsonType": "int",
"defaultValue": 0,
"description": "用户性别:0 未知 1 男性 2 女性",
"enum": [{
"text": "未知",
"value": 0
}, {
"text": "男",
"value": 1
}, {
"text": "女",
"value": 2
}],
"title": "性别"
},
"inviter_uid": {
"bsonType": "array",
"description": "用户全部上级邀请者",
"trim": "both"
},
"last_login_date": {
"bsonType": "timestamp",
"description": "最后登录时间"
},
"last_login_ip": {
"bsonType": "string",
"description": "最后登录时 IP 地址"
},
"mobile": {
"bsonType": "string",
"description": "手机号码",
"pattern": "^\\+?[0-9-]{3,20}$",
"title": "手机号码",
"trim": "both"
},
"mobile_confirmed": {
"bsonType": "int",
"defaultValue": 0,
"description": "手机号验证状态:0 未验证 1 已验证",
"enum": [{
"text": "未验证",
"value": 0
}, {
"text": "已验证",
"value": 1
}],
"title": "手机号验证状态"
},
"my_invite_code": {
"bsonType": "string",
"description": "用户自身邀请码"
},
"nickname": {
"bsonType": "string",
"description": "用户昵称",
"title": "昵称",
"trim": "both"
},
"password": {
"bsonType": "password",
"description": "密码,加密存储",
"title": "密码",
"trim": "both"
},
"password_secret_version": {
"bsonType": "int",
"description": "密码使用的passwordSecret版本",
"title": "passwordSecret"
},
"realname_auth": {
"bsonType": "object",
"description": "实名认证信息",
"properties": {
"auth_date": {
"bsonType": "timestamp",
"description": "认证通过时间"
},
"auth_status": {
"bsonType": "int",
"description": "认证状态:0 未认证 1 等待认证 2 认证通过 3 认证失败",
"maximum": 3,
"minimum": 0
},
"contact_email": {
"bsonType": "string",
"description": "联系人邮箱"
},
"contact_mobile": {
"bsonType": "string",
"description": "联系人手机号码"
},
"contact_person": {
"bsonType": "string",
"description": "联系人姓名"
},
"id_card_back": {
"bsonType": "string",
"description": "身份证反面照 URL"
},
"id_card_front": {
"bsonType": "string",
"description": "身份证正面照 URL"
},
"identity": {
"bsonType": "string",
"description": "身份证号码\/营业执照号码"
},
"in_hand": {
"bsonType": "string",
"description": "手持身份证照片 URL"
},
"license": {
"bsonType": "string",
"description": "营业执照 URL"
},
"real_name": {
"bsonType": "string",
"description": "真实姓名\/企业名称"
},
"type": {
"bsonType": "int",
"description": "用户类型:0 个人用户 1 企业用户",
"maximum": 1,
"minimum": 0
}
},
"required": ["type", "auth_status"]
},
"register_date": {
"bsonType": "timestamp",
"description": "注册时间",
"forceDefaultValue": {
"$env": "now"
}
},
"register_ip": {
"bsonType": "string",
"description": "注册时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
},
"role": {
"bsonType": "array",
"description": "用户角色",
"enum": {
"collection": "uni-id-roles",
"field": "role_id as value, role_name as text"
},
"foreignKey": "uni-id-roles.role_id",
"permission": {
"write": false
},
"title": "角色"
},
"status": {
"bsonType": "int",
"defaultValue": 0,
"description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝",
"enum": [{
"text": "正常",
"value": 0
}, {
"text": "禁用",
"value": 1
}, {
"text": "审核中",
"value": 2
}, {
"text": "审核拒绝",
"value": 3
}],
"title": "用户状态"
},
"token": {
"bsonType": "array",
"description": "用户token"
},
"username": {
"bsonType": "string",
"description": "用户名,不允许重复",
"title": "用户名",
"trim": "both"
},
"wx_openid": {
"bsonType": "object",
"description": "微信各个平台openid",
"properties": {
"app-plus": {
"bsonType": "string",
"description": "app平台微信openid"
},
"mp-weixin": {
"bsonType": "string",
"description": "微信小程序平台openid"
}
}
},
"wx_unionid": {
"bsonType": "string",
"description": "微信unionid"
}
},
"required": []
{
"bsonType": "object",
"permission": {
"read": true,
"create": false,
"update": "doc._id == auth.uid",
"delete": false
},
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
"ali_openid": {
"bsonType": "string",
"description": "支付宝平台openid"
},
"apple_openid": {
"bsonType": "string",
"description": "苹果登录openid"
},
"avatar": {
"bsonType": "string",
"description": "头像地址",
"title": "头像地址",
"trim": "both"
},
"comment": {
"bsonType": "string",
"description": "备注",
"title": "备注",
"trim": "both"
},
"department_id": {
"bsonType": "array",
"description": "部门ID",
"enum": {
"collection": "opendb-department",
"field": "_id as value, name as text",
"orderby": "name asc"
},
"enumType": "tree",
"title": "部门"
},
"email": {
"bsonType": "string",
"description": "邮箱地址",
"format": "email",
"title": "邮箱",
"trim": "both"
},
"email_confirmed": {
"bsonType": "int",
"defaultValue": 0,
"description": "邮箱验证状态:0 未验证 1 已验证",
"enum": [{
"text": "未验证",
"value": 0
}, {
"text": "已验证",
"value": 1
}],
"title": "邮箱验证状态"
},
"gender": {
"bsonType": "int",
"defaultValue": 0,
"description": "用户性别:0 未知 1 男性 2 女性",
"enum": [{
"text": "未知",
"value": 0
}, {
"text": "男",
"value": 1
}, {
"text": "女",
"value": 2
}],
"title": "性别"
},
"inviter_uid": {
"bsonType": "array",
"description": "用户全部上级邀请者",
"trim": "both"
},
"last_login_date": {
"bsonType": "timestamp",
"description": "最后登录时间"
},
"last_login_ip": {
"bsonType": "string",
"description": "最后登录时 IP 地址"
},
"mobile": {
"bsonType": "string",
"description": "手机号码",
"pattern": "^\\+?[0-9-]{3,20}$",
"title": "手机号码",
"trim": "both"
},
"mobile_confirmed": {
"bsonType": "int",
"defaultValue": 0,
"description": "手机号验证状态:0 未验证 1 已验证",
"enum": [{
"text": "未验证",
"value": 0
}, {
"text": "已验证",
"value": 1
}],
"title": "手机号验证状态"
},
"my_invite_code": {
"bsonType": "string",
"description": "用户自身邀请码"
},
"nickname": {
"bsonType": "string",
"description": "用户昵称",
"title": "昵称",
"trim": "both"
},
"password": {
"bsonType": "password",
"description": "密码,加密存储",
"title": "密码",
"trim": "both"
},
"password_secret_version": {
"bsonType": "int",
"description": "密码使用的passwordSecret版本",
"title": "passwordSecret"
},
"realname_auth": {
"bsonType": "object",
"description": "实名认证信息",
"properties": {
"auth_date": {
"bsonType": "timestamp",
"description": "认证通过时间"
},
"auth_status": {
"bsonType": "int",
"description": "认证状态:0 未认证 1 等待认证 2 认证通过 3 认证失败",
"maximum": 3,
"minimum": 0
},
"contact_email": {
"bsonType": "string",
"description": "联系人邮箱"
},
"contact_mobile": {
"bsonType": "string",
"description": "联系人手机号码"
},
"contact_person": {
"bsonType": "string",
"description": "联系人姓名"
},
"id_card_back": {
"bsonType": "string",
"description": "身份证反面照 URL"
},
"id_card_front": {
"bsonType": "string",
"description": "身份证正面照 URL"
},
"identity": {
"bsonType": "string",
"description": "身份证号码\/营业执照号码"
},
"in_hand": {
"bsonType": "string",
"description": "手持身份证照片 URL"
},
"license": {
"bsonType": "string",
"description": "营业执照 URL"
},
"real_name": {
"bsonType": "string",
"description": "真实姓名\/企业名称"
},
"type": {
"bsonType": "int",
"description": "用户类型:0 个人用户 1 企业用户",
"maximum": 1,
"minimum": 0
}
},
"required": ["type", "auth_status"]
},
"register_date": {
"bsonType": "timestamp",
"description": "注册时间",
"forceDefaultValue": {
"$env": "now"
}
},
"register_ip": {
"bsonType": "string",
"description": "注册时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
},
"role": {
"bsonType": "array",
"description": "用户角色",
"enum": {
"collection": "uni-id-roles",
"field": "role_id as value, role_name as text"
},
"foreignKey": "uni-id-roles.role_id",
"permission": {
"write": false
},
"title": "角色"
},
"status": {
"bsonType": "int",
"defaultValue": 0,
"description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝",
"enum": [{
"text": "正常",
"value": 0
}, {
"text": "禁用",
"value": 1
}, {
"text": "审核中",
"value": 2
}, {
"text": "审核拒绝",
"value": 3
}],
"title": "用户状态"
},
"token": {
"bsonType": "array",
"description": "用户token"
},
"username": {
"bsonType": "string",
"description": "用户名,不允许重复",
"title": "用户名",
"trim": "both"
},
"wx_openid": {
"bsonType": "object",
"description": "微信各个平台openid",
"properties": {
"app-plus": {
"bsonType": "string",
"description": "app平台微信openid"
},
"mp-weixin": {
"bsonType": "string",
"description": "微信小程序平台openid"
}
}
},
"wx_unionid": {
"bsonType": "string",
"description": "微信unionid"
}
},
"required": []
}
{
"bsonType": "object",
"permission": {
"read": "auth.uid && doc.uid == auth.uid",
"create": true,
"update": false,
"delete": false
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"user_id": {
"bsonType": "string",
"description": "留言反馈用户ID/回复留言用户ID,参考uni-id-users表",
"foreignKey": "uni-id-users._id"
},
"create_date": {
"bsonType": "timestamp",
"description": "留言时间/回复留言时间"
},
"content": {
"bsonType": "string",
"description": "留言内容/回复内容",
"trim": "right"
},
"imgs": {
"bsonType": "array",
"description": "图片列表"
},
"is_reply": {
"bsonType": "bool",
"description": "是否是回复类型"
},
"feedback_id": {
"bsonType": "string",
"description": "被回复留言ID"
},
"contact": {
"bsonType": "string",
"description": "联系人",
"trim": "both"
},
"mobile": {
"bsonType": "string",
"description": "联系电话",
"trim": "both"
},
"reply_count": {
"bsonType": "int",
"description": "被回复条数"
}
}
}
\ No newline at end of file
{
"bsonType": "object",
"permission": {
"read": "auth.uid && doc.uid == auth.uid",
"create": true,
"update": false,
"delete": false
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"user_id": {
"bsonType": "string",
"description": "留言反馈用户ID\/回复留言用户ID,参考uni-id-users表",
"foreignKey": "uni-id-users._id",
"forceDefaultValue": {
"$env": "uid"
}
},
"ip": {
"forceDefaultValue": {
"$env": "clientIP"
}
},
"create_date": {
"bsonType": "timestamp",
"description": "留言时间\/回复留言时间",
"forceDefaultValue": {
"$env": "now"
}
},
"content": {
"bsonType": "string",
"description": "留言内容\/回复内容",
"trim": "right"
},
"imgs": {
"bsonType": "array",
"description": "图片列表"
},
"is_reply": {
"bsonType": "bool",
"description": "是否是回复类型"
},
"feedback_id": {
"bsonType": "string",
"description": "被回复留言ID"
},
"contact": {
"bsonType": "string",
"description": "联系人",
"trim": "both"
},
"mobile": {
"bsonType": "string",
"description": "联系电话",
"trim": "both"
},
"reply_count": {
"bsonType": "int",
"description": "被回复条数"
}
}
}
# clientDB使用许可协议
本协议是数字天堂(北京)网络技术有限公司(以下称“DCloud”)与您之间达成的关于clientDB框架(以下简称本框架)的协议。
本协议签订地点为中华人民共和国北京市海淀区。
您使用本框架即视为您已阅读并同意受本协议的约束。
## 知识产权及使用授权
您可以自由下载、使用、复制本框架而不需要向DCloud付费。
DCloud所拥有的知识产权,包括但不限于商标、专利、著作权、商业秘密、专有数据、源码,并不发生转移或共享。
您使用本框架开发的代码及输出物,包括但不限于网站、移动应用,其知识产权归属您所有。
本框架未包含第三方软件或技术,不涉及额外遵循第三方软件的授权协议问题。
## 您的义务
您不得破解、反编译、逆向工程本框架,不得破解或劫持本框架网络请求,不得对DCloud服务进行网络攻击,不得利用DCloud系统漏洞谋利或侵害DCloud利益,不得替换、删改本框架自带的非用户自定义文件。
未经书面许可您不可利用DCloud产品的全部或部分文件、模块、组件来制作与DCloud争夺用户的产品(通过DCloud插件市场服务开发者不属于此范围)。
如果您违反您的义务,DCloud将有权停止您使用本框架,造成的损失由您自行承担。
如果您给DCloud造成重大损失,或者在接收到DCloud的停止违约通知后拒不改正,DCloud将有权停止对您的DCloud所有产品和服务的使用授权,冻结您在DCloud所有产品服务中的预付款项和应收款项,因此造成的损失由您自行承担。
如果您的行为产生法律问题,DCloud有权追责您的法律责任。
## 隐私条款
本框架未进行任何数据采集、发送等涉及数据隐私的行为。
## 安全
您理解并同意,本框架同其他软件一样,无法承诺绝对的安全性。
当DCloud发现本框架的任何安全漏洞时,将及时在[社区](https://ask.dcloud.net.cn/explore/)发送公告,并将及时发布紧急更新补丁和升级推送通知。
## 免责声明
DCloud不因开发者使用本框架而承担任何法律责任。
## 协议修订
根据发展,DCloud可能会对本协议进行修改。修改时,DCloud会在产品或者网页中显著的位置发布相关信息以便及时通知到用户。如果您选择继续使用本框架,即表示您同意接受这些修改。
{
"id": "unicloud-db", // 必选 插件标识,需要保证唯一性
"name": "unicloud-db", // 必选 插件名称
"version": "1.0.8", // 必选 插件版本
"description": "写法更灵活的客户端访问云端数据方案", // 插件描述
"author": "DCloud", // 插件作者
"license": "MIT",
"homepage": "https://ext.dcloud.net.cn/plugin?id=2314", // 插件地址
"files": [ // 必选 插件自身文件列表(支持通配,规范:https://docs.npmjs.com/files/package.json#files)
],
"bundledFiles": [ // 插件依赖的文件列表,通常是依赖的三方插件的 files 合并
"cloudfunctions/unicloud-db",
"cloudfunctions/common/uni-id",
"js_sdk"
]
}
## 简介
每个查询业务,都要写一个云函数,很麻烦,也占用云函数的总数量。
本插件提供了一个通用的数据库查询云函数,由前端向云函数传递要查询的条件,比如查询哪个表、查询哪些字段、where条件和排序是什么。
> 举例:在前端的list.vue列表页面,可以调用本云函数,传入列表查询条件。然后写content.vue详情页面时,无需再新建一个云函数,可以直接在content.vue页面继续调用相同的本云函数,传入详情的查询条件。
客户端的查询条件语法,与云函数里查询数据库的语法是相同的。[查询api手册](https://uniapp.dcloud.io/uniCloud/cf-database?id=%e6%9f%a5%e8%af%a2%e6%96%87%e6%a1%a3)
与某些小程序云的客户端直接操作数据库不同,本方案有2个明显优势:
- 安全:查询权限是在云函数里控制台的,能查什么表、什么字段,在云端控制。如果全部放在前端,由于前端的不可信任,相当于无法控制权限了。而某些小程序云提供的客户端权限,并不可编程,无法满足开发者的实际业务权限需求
- 包体积:某些小程序云的客户端操作数据库是一个数M大小的js sdk,如果迁移到H5和App,对应用的启动速度、性能、体积影响非常大
综上,本插件的优势在于:
1. 提高开发效率
2. 减少云函数数量
3. 安全,可控制权限
4. 性能好
本项目包括云函数和客户端两部分,需要搭配使用,具体请参考下面文档。
**示例项目使用须知**
1. 下载示例项目后选择服务空间
2. 在db_init.json上右键初始化数据库
3. 上传公共模块及云函数,公共模块用法参考[使用公共模块](https://uniapp.dcloud.net.cn/uniCloud/cf-common)
4. 运行项目即可
示例项目文件介绍:
<pre v-pre="" data-lang="">
<code class="lang-" style="padding:0">
┌─cloudfunctions 云函数
│ ├─common 公共模块
| │ └─uni-curd 数据库查询通用公共模块
| ├─unicloud-db 在云函数中控制权限,并调用uni-curd完成查询
| └─db_init.json 初始化数据库
├─js_sdk 前端公共js目录
| └─unicloud-db 前端的js库,封装了查询语法
├─pages 业务页面文件存放的目录
│ ├─index
│ │ └─index.vue index示例页面
├─main.js Vue初始化入口文件
├─App.vue 应用配置,用来配置App全局样式以及监听 <a href="/frame?id=应用生命周期">应用生命周期</a>
├─manifest.json 配置应用名称、appid、logo、版本等打包信息,<a href="/collocation/manifest">详见</a>
└─pages.json 配置页面路由、导航条、选项卡等页面类信息,<a href="/collocation/pages">详见</a>
</code>
</pre>
- 云函数里包括一个公共模块`uni-curd`和一个云函数`unicloud-db`
- 前端包括一个js sdk`unicloud-db`,然后就是index.vue里的示例调用
- index示例页面,里面包含两个示例一个简单查询一个分页查询
## 客户端公共模块
客户端js-sdk主要负责组装查询逻辑
**示例代码**
```js
// 引入公共模块
import db from '@/js_sdk/unicloud-db/index.js'
const dbCmd = db.command
// 使用unicloud-db
uniCloud.callFunction({
name: 'unicloud-db',
data: {
command: db.collection('list').where({
name: new RegExp('','g'),
time: dbCmd.gt(1105885393581)
}).field({
extra: false
}).get()
},
success(res) {
// ...
},
fail(err) {
// ...
}
})
```
**使用说明**
语法与云函数写查询数据库一致,目前有以下限制:
- 不可使用db.serverDate、db.Geo、db.RegExp
- 上传时会对query进行序列化,除Date类型、RegExp之外的所有不可序列化的参数类型均不支持(例如:undefined)
- 为方便控制禁止前端使用set方法,一般情况下也不需要前端使用set
## 云函数公共模块
云函数公共模块`uni-curd`主要负责解析客户端查询逻辑,对客户端行为做简单的限制
**使用示例**
```js
'use strict';
const uniCurd = require('uni-curd')
const db = uniCloud.database()
const dbCmd = db.command
exports.main = async (event, context) => {
// 这里可以判断用户身份给予不同权限,例如:可以从event里拿到uni-id的token,根据token和客户端参数决定查询权限限制
try {
const res = await uniCurd({
command: event.command,
pagination: event.pagination,
rules: {
list: { // 数据表名
// CRUD权限
create: false,
read: true,
update: false,
delete: false,
// 是否允许使用聚合
aggregate: false,
// 是否允许使用联表查询,联表查询时blockedField不会对被连接的数据表生效
lookup: false,
// 使用聚合时blockField不会覆盖客户端的project,而是在聚合第一阶段插入project,不使用聚合时会在最后阶段插入一个field(会覆盖客户端的field方法)
blockedField: ['extra'],
// 不使用聚合时mixinCondition会在没有where的时候在collection方法之后插入where,有where时会跟where条件进行合并,取原条件且mixinCondition。使用聚合时会在第一阶段插入match使用混入的条件,如果有blockedField会插入在blockedField对应的project之前
mixinCondition: {
time: dbCmd.gt(1000000000000)
},
// 更多用法请参考下方参数说明文档
}
}
})
return res
} catch (e) {
return {
code: 10001,
msg: e.message
}
}
};
```
**参数说明**
|参数名 |类型 |是否必填 |默认值 |说明 |
|:-: |:-: |:-: |:-: |:-: |
|command |Object |是 |- |客户端上传的查询条件 |
|pagination |Object |否 |- |如需分页,请在此字段内配置 |
|rules |Object |是 |- |权限规则 |
**pagination参数说明**
|参数名 |类型 |是否必填 |默认值 |说明 |
|:-: |:-: |:-: |:-: |:-: |
|pageSize |Object |是 |- |每页数量 |
|current |Object |是 |- |当前页码 |
**rules参数说明**
rules下可以对不同的数据表配置不同的权限,比如以下规则代表”数据表list允许插入,数据表goods允许更新“
```js
{
list: {
create: true,
},
goods: {
update: true
}
}
```
|参数名 |类型 |是否必填 |默认值 |说明 |
|:-: |:-: |:-: |:-: |:-: |
|create |Boolean|否 |false |是否开启插入权限 |
|read |Boolean|否 |true |是否开启读权限 |
|update |Boolean|否 |false |是否开启更新权限 |
|delete |Boolean|否 |false |是否开启删除权限 |
|aggregate |Boolean|否 |false |是否允许聚合 |
|lookup |Boolean|否 |false |是否允许联表查询 |
|blockedField |Array |否 |- |屏蔽的数据库字段,请阅读注意事项 |
|mixinCondition |Object |否 |- |混入条件,请阅读注意事项 |
|hooks |Object |否 |- |回调方法 |
**hooks参数说明**
|参数名 |类型 |是否必填 |默认值 |说明 |
|:-: |:-: |:-: |:-: |:-: |
|beforeStageAppend |Function |否 |- |每个阶段被添加之前执行 |
|afterStageAppend |Function |否 |- |每个阶段被添加之后执行 |
|beforeSend |Function |否 |- |最终阶段'get', 'end', 'count', 'add', 'remove', 'update'添加之前执行,在beforeStageAppend之后 |
**回调方法的使用**
回调参数如下:
```js
{
state: {
useAggregate, // 是否使用了聚合
useLookup, // 是否使用了联表查询
type, // 操作类型,可能的值为create、read、update、delete
collection, // 当前数据表名
methodList // 使用到的方法列表
},
stage: {
method, // 当前阶段方法名
args // 当前阶段方法参数
},
exec // 已经组装的查询指令
}
```
回调方法中可以通过返回结果修改数据库指令,例如以下示例在skip之后插入一个limit
```js
afterStageAppend: function({
state,
stage,
exec
}) {
if(stage.method === 'skip') {
return exec.limit(1)
}
},
```
**注意事项**
- 关于blockedField
+ 使用聚合时blockField不会覆盖客户端的project,而是在聚合第一阶段插入project
+ 不使用聚合时会在最后阶段插入一个field(会覆盖客户端的field方法)
+ blockedField仅对读操作生效
- 关于mixinCondition
+ mixinCondition内可以使用数据库操作符
+ 不使用聚合时mixinCondition会在没有where的时候在collection方法之后插入where,有where时会跟where条件进行合并,取原条件且mixinCondition。
+ 使用聚合时会在第一阶段插入match使用混入的条件,如果有blockedField会插入在blockedField对应的project之前
+ mixinCondition会对除插入以外的所有操作生效
+ 使用mixinCondition时客户端不可使用`collection('xxx').doc('xxx')`方法(1.0.8版本起即使有mixinCondition客户端也可以使用doc方法)
- 关于联表查询
+ 连接的数据表也会受所配置的权限规则中对应数据表规则限制,主要是read,目前连接的数据表不会受blockedField限制
**参考**
在线通讯录项目,完整的演示了如何基于clientDB在客户端代码里实现数据的增删改查,是学习clientDB的重要示例项目。该项目插件地址:[https://ext.dcloud.net.cn/plugin?id=2574](https://ext.dcloud.net.cn/plugin?id=2574)
\ No newline at end of file
{
"passwordSecret": "passwordSecret-demo",
"tokenSecret": "tokenSecret-demo",
"tokenExpiresIn": 7200,
"tokenExpiresThreshold": 600,
"passwordErrorLimit": 6,
"bindTokenToDevice": true,
"passwordErrorRetryTime": 3600,
"autoSetInviteCode": false,
"forceInviteCode": false,
"app-plus": {
"tokenExpiresIn": 2592000,
"oauth" : {
"weixin" : {
"appid": "wx0411fa6a39d61297",
"appsecret": "fdc6251421d3d688a563b4f00dd540e7"
},
"apple": {
"bundleId": "io.dcloud.game.cat"
}
}
},
"mp-weixin": {
"oauth" : {
"weixin" : {
"appid" : "weixin appid",
"appsecret" : "weixin appsecret"
}
}
},
"mp-alipay": {
"oauth" : {
"alipay" : {
"appid" : "alipay appid",
"privateKey" : "alipay privateKey"
}
}
},
"service": {
"sms": {
"name": "DCloud",
"codeExpiresIn": 300,
"smsKey": "71a19f38c954f7d768d68a050486bf15",
"smsSecret": "d6c424b702d73baa3b6e1a1452469213"
},
"univerify":{
"appid": "__UNI__BC54A00",
"apiKey":"d1e36bcd497b3795434d900dcfdd44dc",
"apiSecret":"2feb378ff1114362b20ac179b572293e"
}
}
{
"passwordSecret": "passwordSecret-demo",
"tokenSecret": "tokenSecret-demo",
"tokenExpiresIn": 7200,
"tokenExpiresThreshold": 600,
"passwordErrorLimit": 6,
"bindTokenToDevice": true,
"passwordErrorRetryTime": 3600,
"autoSetInviteCode": false,
"forceInviteCode": false,
"app-plus": {
"tokenExpiresIn": 2592000,
"oauth": {
"weixin": {
"appid": "wx0411fa6a39d61297",
"appsecret": "6c9119430d7be0a147bcbbb73ef33acf"
},
"apple": {
"bundleId": "io.dcloud.game.cat"
}
}
},
"mp-weixin": {
"oauth": {
"weixin": {
"appid": "wx999bf02c8e05dfc9",
"appsecret": "b5f608afd332b2c0ded7e6b98ca4ccd3"
}
}
},
"mp-alipay": {
"oauth": {
"alipay": {
"appid": "alipay appid",
"privateKey": "alipay privateKey"
}
}
},
"service": {
"sms": {
"name": "DCloud",
"codeExpiresIn": 300,
"smsKey": "71a19f38c954f7d768d68a050486bf15",
"smsSecret": "d6c424b702d73baa3b6e1a1452469213"
},
"univerify": {
"appid": "__UNI__BC54A00",
"apiKey": "d1e36bcd497b3795434d900dcfdd44dc",
"apiSecret": "2feb378ff1114362b20ac179b572293e"
}
}
}
......@@ -370,7 +370,7 @@ $list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg;
/* #endif */
height: $uni-img-size-base;
width: $uni-img-size-base;
marin-right: 10px;
margin-right: 10px;
}
.uni-icon-wrapper {
......
......@@ -64,36 +64,52 @@
if(!reg_phone.test(this.phone))return uni.showToast({
title: '手机号格式错误',
icon: 'none'
});
uniCloud.callFunction({
"name": "user-center",
"data": {
"action": "sendSmsCode",
"params": {
"mobile": this.phone,
"type": "login"
}
},
success: (e) => {
uni.showToast({
title: "短信验证码发送成功",
icon: 'none'
});
this.request('user-center/sendSmsCode',
{
"mobile": this.phone,
"type": "login"
},(data,result)=>{
console.log(data,result);
uni.showToast({
title: "短信验证码发送成功",
icon: 'none'
});
this.reverseNumber = Number(this.count);
this.getCode();
this.$emit('getCode');
},
fail: (err) => {
console.log(err);
uni.showToast({
title: '短信验证码发送失败',
icon: 'none'
});
},
complete: () => {
uni.hideLoading()
}
})
this.getCode();
this.$emit('getCode');
})
// uniCloud.callFunction({
// "name": "user-center",
// "data": {
// "action": "sendSmsCode",
// "params": {
// "mobile": this.phone,
// "type": "login"
// }
// },
// success: (e) => {
// uni.showToast({
// title: "短信验证码发送成功",
// icon: 'none'
// });
// this.reverseNumber = Number(this.count);
// this.getCode();
// this.$emit('getCode');
// },
// fail: (err) => {
// console.log(err);
// uni.showToast({
// title: '短信验证码发送失败',
// icon: 'none'
// });
// },
// complete: () => {
// uni.hideLoading()
// }
// })
},
getCode() {
if (this.reverseNumber == 0) {
......
......@@ -139,7 +139,7 @@
uni.setStorageSync('uni_id_uid', result.uid)
uni.setStorageSync('uni_id_token', result.token)
uni.setStorageSync('uni_id_token_expired', result.tokenExpired)
delete result.userInfo.token
this.setUserInfo(result.userInfo)
if(type=='univerify'){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册