提交 14d1d150 编写于 作者: L linju

2

{ {
"name" : "base-app", "name" : "base-app",
"appid" : "__UNI__BC54A00", "appid" : "__UNI__03B096E",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",
...@@ -64,7 +64,8 @@ ...@@ -64,7 +64,8 @@
"entitlements" : { "entitlements" : {
"com.apple.developer.associated-domains" : [ "com.apple.developer.associated-domains" : [
"applinks:uniapp.dcloud.io", "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 @@ ...@@ -78,20 +79,20 @@
"weixin" : { "weixin" : {
"appid" : "wx0411fa6a39d61297", "appid" : "wx0411fa6a39d61297",
"appsecret" : "", "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" : {} "univerify" : {}
}, },
"share" : { "share" : {
"weixin" : { "weixin" : {
"appid" : "wx0411fa6a39d61297", "appid" : "wx0411fa6a39d61297",
"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",
"_spaceID" : "7827e38b-7f40-4421-bca7-58331dcddc00" "_spaceID" : "76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e"
} }
}, },
"payment" : { "payment" : {
"weixin" : { "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" : {} "ad" : {}
...@@ -100,7 +101,7 @@ ...@@ -100,7 +101,7 @@
}, },
"quickapp" : {}, "quickapp" : {},
"mp-weixin" : { "mp-weixin" : {
"appid" : "", "appid" : "wx999bf02c8e05dfc9",
"setting" : { "setting" : {
"urlCheck" : false "urlCheck" : false
}, },
......
...@@ -50,11 +50,12 @@ ...@@ -50,11 +50,12 @@
this.uploadUserInfo({avatar:url}); this.uploadUserInfo({avatar:url});
}) })
let options = { let options = {
width:uni.upx2px(700), width:600,
height:uni.upx2px(700) height:600
} }
uni.navigateTo({ uni.navigateTo({
url:'./uploadCutImageToUnicloud?path=' + res.tempFilePaths[0] + `&options=${JSON.stringify(options)}`, url:'./uploadCutImageToUnicloud?path=' + res.tempFilePaths[0] + `&options=${JSON.stringify(options)}`,
animationType:"fade-in"
}); });
} }
}) })
...@@ -65,9 +66,11 @@ ...@@ -65,9 +66,11 @@
* value 更新后的用户字段值 * value 更新后的用户字段值
*/ */
uploadUserInfo(data){ uploadUserInfo(data){
console.log(this.userInfo._id)
userTable.doc(this.userInfo._id) userTable.doc(this.userInfo._id)
.update(data) .update(data)
.then(res=>{ .then(res=>{
console.log(data)
this.login(data) this.login(data)
}) })
.catch(err=>{ .catch(err=>{
......
{ {
"bsonType": "object", "bsonType": "object",
"required": ["appid", "platform", "version", "url", "contents", "type"], "required": ["appid", "platform", "version", "url", "contents", "type"],
"permission": { "permission": {
"read": false, "read": false,
"create": false, "create": false,
"update": false, "update": false,
"delete": false "delete": false
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "记录id,自动生成" "description": "记录id,自动生成"
}, },
"appid": { "appid": {
"bsonType": "string", "bsonType": "string",
"trim": "both", "trim": "both",
"description": "应用的AppID", "description": "应用的AppID",
"label": "AppID", "label": "AppID",
"componentForEdit": { "componentForEdit": {
"name": "uni-easyinput", "name": "uni-easyinput",
"props": { "props": {
"disabled": true "disabled": true
} }
} }
}, },
"name": { "name": {
"bsonType": "string", "bsonType": "string",
"trim": "both", "trim": "both",
"description": "应用名称", "description": "应用名称",
"label": "应用名称", "label": "应用名称",
"componentForEdit": { "componentForEdit": {
"name": "uni-easyinput", "name": "uni-easyinput",
"props": { "props": {
"disabled": true "disabled": true
} }
} }
}, },
"title": { "title": {
"bsonType": "string", "bsonType": "string",
"description": "更新标题", "description": "更新标题",
"label": "更新标题" "label": "更新标题"
}, },
"contents": { "contents": {
"bsonType": "string", "bsonType": "string",
"description": "更新内容", "description": "更新内容",
"label": "更新内容", "label": "更新内容",
"componentForEdit": { "componentForEdit": {
"name": "textarea" "name": "textarea"
}, },
"componentForShow": { "componentForShow": {
"name": "textarea", "name": "textarea",
"props": { "props": {
"disabled": true "disabled": true
} }
} }
}, },
"platform": { "platform": {
"bsonType": "array", "bsonType": "array",
"enum": [{ "enum": [{
"value": "Android", "value": "Android",
"text": "安卓" "text": "安卓"
}, { }, {
"value": "iOS", "value": "iOS",
"text": "苹果" "text": "苹果"
}], }],
"description": "更新平台,Android || iOS || [Android, iOS]", "description": "更新平台,Android || iOS || [Android, iOS]",
"label": "平台" "label": "平台"
}, },
"type": { "type": {
"bsonType": "string", "bsonType": "string",
"enum": [{ "enum": [{
"value": "native_app", "value": "native_app",
"text": "原生App安装包" "text": "原生App安装包"
}, { }, {
"value": "wgt", "value": "wgt",
"text": "Wgt资源包" "text": "Wgt资源包"
}], }],
"description": "安装包类型,native_app || wgt", "description": "安装包类型,native_app || wgt",
"label": "安装包类型" "label": "安装包类型"
}, },
"version": { "version": {
"bsonType": "string", "bsonType": "string",
"description": "当前包版本号,必须大于当前线上发行版本号", "description": "当前包版本号,必须大于当前线上发行版本号",
"label": "版本号" "label": "版本号"
}, },
"min_uni_version": { "min_uni_version": {
"bsonType": "string", "bsonType": "string",
"description": "原生App最低版本", "description": "原生App最低版本",
"label": "原生App最低版本" "label": "原生App最低版本"
}, },
"url": { "url": {
"bsonType": "string", "bsonType": "string",
"description": "可下载安装包地址", "description": "可下载安装包地址",
"label": "包地址" "label": "包地址"
}, },
"stable_publish": { "stable_publish": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否上线发行", "description": "是否上线发行",
"label": "上线发行" "label": "上线发行"
}, },
"is_silently": { "is_silently": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否静默更新", "description": "是否静默更新",
"label": "静默更新", "label": "静默更新",
"defaultValue": false "defaultValue": false
}, },
"is_mandatory": { "is_mandatory": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否强制更新", "description": "是否强制更新",
"label": "强制更新", "label": "强制更新",
"defaultValue": false "defaultValue": false
}, },
"create_date": { "create_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"label": "上传时间", "label": "上传时间",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "now" "$env": "now"
}, },
"componentForEdit": { "componentForEdit": {
"name": "uni-dateformat" "name": "uni-dateformat"
} }
} }
} }
} }
{ {
"bsonType": "object", "bsonType": "object",
"required": ["bannerfile"], "required": ["bannerfile"],
"permission": { "permission": {
"read": true "read": true
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "ID,系统自动生成" "description": "ID,系统自动生成"
}, },
"bannerfile": { "bannerfile": {
"bsonType": "file", "bsonType": "file",
"fileMediaType": "image", "fileMediaType": "image",
"title": "图片文件", "title": "图片文件",
"description": "图片文件信息,包括文件名、url等" "description": "图片文件信息,包括文件名、url等"
}, },
"open_url": { "open_url": {
"bsonType": "string", "bsonType": "string",
"description": "点击跳转目标地址。如果是web地址则使用内置web-view打开;如果是本地页面则跳转本地页面;如果是schema地址则打开本地的app", "description": "点击跳转目标地址。如果是web地址则使用内置web-view打开;如果是本地页面则跳转本地页面;如果是schema地址则打开本地的app",
"title": "点击目标地址", "title": "点击目标地址",
"format": "url", "format": "url",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S", "pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"trim": "both" "trim": "both"
}, },
"title": { "title": {
"bsonType": "string", "bsonType": "string",
"description": "注意标题文字颜色和背景图靠色导致看不清的问题", "description": "注意标题文字颜色和背景图靠色导致看不清的问题",
"maxLength": 20, "maxLength": 20,
"title": "标题", "title": "标题",
"trim": "both" "trim": "both"
}, },
"sort": { "sort": {
"bsonType": "int", "bsonType": "int",
"description": "数字越小,排序越前", "description": "数字越小,排序越前",
"title": "排序" "title": "排序"
}, },
"category_id": { "category_id": {
"bsonType": "string", "bsonType": "string",
"description": "多个栏目的banner都存在一个表里时可用这个字段区分", "description": "多个栏目的banner都存在一个表里时可用这个字段区分",
"title": "分类id" "title": "分类id"
}, },
"status": { "status": {
"bsonType": "bool", "bsonType": "bool",
"defaultValue": true, "defaultValue": true,
"title": "生效状态" "title": "生效状态"
}, },
"description": { "description": {
"bsonType": "string", "bsonType": "string",
"description": "维护者自用描述", "description": "维护者自用描述",
"title": "备注", "title": "备注",
"trim": "both" "trim": "both"
} }
} }
} }
{ {
"bsonType": "object", "bsonType": "object",
"permission": { "permission": {
"create": false, "create": false,
"delete": false, "delete": false,
"read": "doc.is_on_sale == true", "read": "doc.is_on_sale == true",
"update": false "update": false
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "存储文档 ID(商品 ID),系统自动生成" "description": "存储文档 ID(商品 ID),系统自动生成"
}, },
"add_date": { "add_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"defaultValue": { "defaultValue": {
"$env": "now" "$env": "now"
}, },
"description": "上架时间" "description": "上架时间"
}, },
"category_id": { "category_id": {
"bsonType": "string", "bsonType": "string",
"description": "分类 id,参考`opendb-mall-categories`表", "description": "分类 id,参考`opendb-mall-categories`表",
"foreignKey": "opendb-mall-categories._id" "foreignKey": "opendb-mall-categories._id"
}, },
"comment_count": { "comment_count": {
"bsonType": "int", "bsonType": "int",
"description": "累计评论数" "description": "累计评论数"
}, },
"goods_banner_imgs": { "goods_banner_imgs": {
"bsonType": "array", "bsonType": "array",
"description": "商品详情页的banner图地址" "description": "商品详情页的banner图地址"
}, },
"goods_desc": { "goods_desc": {
"bsonType": "string", "bsonType": "string",
"description": "商品详细描述", "description": "商品详细描述",
"title": "详细描述", "title": "详细描述",
"trim": "both" "trim": "both"
}, },
"goods_sn": { "goods_sn": {
"bsonType": "string", "bsonType": "string",
"description": "商品的唯一货号", "description": "商品的唯一货号",
"title": "货号", "title": "货号",
"trim": "both" "trim": "both"
}, },
"goods_thumb": { "goods_thumb": {
"bsonType": "string", "bsonType": "string",
"description": "商品缩略图,用于在列表或搜索结果中预览显示", "description": "商品缩略图,用于在列表或搜索结果中预览显示",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S", "pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"title": "缩略图地址", "title": "缩略图地址",
"trim": "both" "trim": "both"
}, },
"is_alone_sale": { "is_alone_sale": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否能单独销售;如果不能单独销售,则只能作为某商品的配件或者赠品销售" "description": "是否能单独销售;如果不能单独销售,则只能作为某商品的配件或者赠品销售"
}, },
"is_best": { "is_best": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否精品" "description": "是否精品"
}, },
"is_hot": { "is_hot": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否热销" "description": "是否热销"
}, },
"is_new": { "is_new": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否新品", "description": "是否新品",
"title": "是否新品" "title": "是否新品"
}, },
"is_on_sale": { "is_on_sale": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否上架销售", "description": "是否上架销售",
"title": "是否上架" "title": "是否上架"
}, },
"is_real": { "is_real": {
"bsonType": "bool", "bsonType": "bool",
"description": "是否实物", "description": "是否实物",
"title": "是否为实物" "title": "是否为实物"
}, },
"keywords": { "keywords": {
"bsonType": "string", "bsonType": "string",
"description": "商品关键字,为搜索引擎收录使用", "description": "商品关键字,为搜索引擎收录使用",
"title": "关键字", "title": "关键字",
"trim": "both" "trim": "both"
}, },
"last_modify_date": { "last_modify_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"defaultValue": { "defaultValue": {
"$env": "now" "$env": "now"
}, },
"description": "最后修改时间" "description": "最后修改时间"
}, },
"month_sell_count": { "month_sell_count": {
"bsonType": "int", "bsonType": "int",
"description": "月销量" "description": "月销量"
}, },
"name": { "name": {
"bsonType": "string", "bsonType": "string",
"description": "商品名称", "description": "商品名称",
"title": "名称", "title": "名称",
"trim": "both" "trim": "both"
}, },
"remain_count": { "remain_count": {
"bsonType": "int", "bsonType": "int",
"description": "库存数量", "description": "库存数量",
"title": "库存数量" "title": "库存数量"
}, },
"seller_note": { "seller_note": {
"bsonType": "string", "bsonType": "string",
"description": "商家备注,仅商家可见", "description": "商家备注,仅商家可见",
"permission": { "permission": {
"read": false "read": false
}, },
"trim": "both" "trim": "both"
}, },
"total_sell_count": { "total_sell_count": {
"bsonType": "int", "bsonType": "int",
"description": "总销量" "description": "总销量"
} }
}, },
"required": ["goods_sn", "name", "remain_count", "month_sell_count", "total_sell_count", "comment_count", "is_real", "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" "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", "bsonType": "object",
"required": ["user_id", "title", "content"], "required": ["user_id", "title", "content"],
"permission": { "permission": {
"read": "doc.uid == auth.uid && doc.article_status == 0 || doc.article_status == 1", "read": "doc.uid == auth.uid && doc.article_status == 0 || doc.article_status == 1",
"create": "auth.uid != null", "create": "auth.uid != null",
"update": "doc.uid == auth.uid", "update": "doc.uid == auth.uid",
"delete": "doc.uid == auth.uid" "delete": "doc.uid == auth.uid"
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "存储文档 ID(用户 ID),系统自动生成" "description": "存储文档 ID(用户 ID),系统自动生成"
}, },
"user_id": { "user_id": {
"bsonType": "string", "bsonType": "string",
"description": "文章作者ID, 参考`uni-id-users` 表", "description": "文章作者ID, 参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id", "foreignKey": "uni-id-users._id",
"defaultValue": { "defaultValue": {
"$env": "uid" "$env": "uid"
} }
}, },
"author": { "author": {
"bsonType": "string", "bsonType": "string",
"title": "作者信息", "title": "作者信息",
"description": "冗余字段,用于保存联表查询结果,参考`uni-id-users`表", "description": "冗余字段,用于保存联表查询结果,参考`uni-id-users`表",
"foreignKey": "uni-id-users._id", "foreignKey": "uni-id-users._id",
"enum": { "enum": {
"collection": "uni-id-users", "collection": "uni-id-users",
"field": "username, _id as text, _id as value" "field": "username, _id as text, _id as value"
} }
}, },
"category_id": { "category_id": {
"bsonType": "string", "bsonType": "string",
"title": "分类", "title": "分类",
"description": "分类 id,参考`uni-news-categories`表", "description": "分类 id,参考`uni-news-categories`表",
"foreignKey": "opendb-news-categories._id", "foreignKey": "opendb-news-categories._id",
"enum": { "enum": {
"collection": "opendb-news-categories", "collection": "opendb-news-categories",
"field": "name as text, _id as value" "field": "name as text, _id as value"
} }
}, },
"title": { "title": {
"bsonType": "string", "bsonType": "string",
"title": "标题", "title": "标题",
"description": "标题", "description": "标题",
"label": "标题", "label": "标题",
"trim": "both" "trim": "both"
}, },
"content": { "content": {
"bsonType": "string", "bsonType": "string",
"title": "文章内容", "title": "文章内容",
"description": "文章内容", "description": "文章内容",
"label": "文章内容", "label": "文章内容",
"trim": "right" "trim": "right"
}, },
"excerpt": { "excerpt": {
"bsonType": "string", "bsonType": "string",
"title": "文章摘录", "title": "文章摘录",
"description": "文章摘录", "description": "文章摘录",
"label": "摘要", "label": "摘要",
"trim": "both" "trim": "both"
}, },
"article_status": { "article_status": {
"bsonType": "int", "bsonType": "int",
"title": "文章状态", "title": "文章状态",
"description": "文章状态:0 草稿箱 1 已发布", "description": "文章状态:0 草稿箱 1 已发布",
"defaultValue": 0, "defaultValue": 0,
"enum": [{ "enum": [{
"value": 0, "value": 0,
"text": "草稿箱" "text": "草稿箱"
}, { }, {
"value": 1, "value": 1,
"text": "已发布" "text": "已发布"
}] }]
}, },
"view_count": { "view_count": {
"bsonType": "int", "bsonType": "int",
"title": "阅读数量", "title": "阅读数量",
"description": "阅读数量", "description": "阅读数量",
"permission": { "permission": {
"write": false "write": false
} }
}, },
"like_count": { "like_count": {
"bsonType": "int", "bsonType": "int",
"description": "喜欢数、点赞数", "description": "喜欢数、点赞数",
"permission": { "permission": {
"write": false "write": false
} }
}, },
"is_sticky": { "is_sticky": {
"bsonType": "bool", "bsonType": "bool",
"title": "是否置顶", "title": "是否置顶",
"description": "是否置顶", "description": "是否置顶",
"permission": { "permission": {
"write": false "write": false
} }
}, },
"is_essence": { "is_essence": {
"bsonType": "bool", "bsonType": "bool",
"title": "阅读加精", "title": "阅读加精",
"description": "阅读加精", "description": "阅读加精",
"permission": { "permission": {
"write": false "write": false
} }
}, },
"comment_status": { "comment_status": {
"bsonType": "int", "bsonType": "int",
"title": "开放评论", "title": "开放评论",
"description": "评论状态:0 关闭 1 开放", "description": "评论状态:0 关闭 1 开放",
"enum": [{ "enum": [{
"value": 0, "value": 0,
"text": "关闭" "text": "关闭"
}, { }, {
"value": 1, "value": 1,
"text": "开放" "text": "开放"
}] }]
}, },
"comment_count": { "comment_count": {
"bsonType": "int", "bsonType": "int",
"description": "评论数量", "description": "评论数量",
"permission": { "permission": {
"write": false "write": false
} }
}, },
"last_comment_user_id": { "last_comment_user_id": {
"bsonType": "string", "bsonType": "string",
"description": "最后回复用户 id,参考`uni-id-users` 表", "description": "最后回复用户 id,参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id" "foreignKey": "uni-id-users._id"
}, },
"avatar": { "avatar": {
"bsonType": "string", "bsonType": "string",
"title": "封面大图", "title": "封面大图",
"description": "缩略图地址", "description": "缩略图地址",
"label": "封面大图", "label": "封面大图",
"trim": "both" "trim": "both"
}, },
"publish_date": { "publish_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"title": "发表时间", "title": "发表时间",
"description": "发表时间", "description": "发表时间",
"defaultValue": { "defaultValue": {
"$env": "now" "$env": "now"
} }
}, },
"publish_ip": { "publish_ip": {
"bsonType": "string", "bsonType": "string",
"title": "发布文章时IP地址", "title": "发布文章时IP地址",
"description": "发表时 IP 地址", "description": "发表时 IP 地址",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "clientIP" "$env": "clientIP"
} }
}, },
"last_modify_date": { "last_modify_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"title": "最后修改时间", "title": "最后修改时间",
"description": "最后修改时间", "description": "最后修改时间",
"defaultValue": { "defaultValue": {
"$env": "now" "$env": "now"
} }
}, },
"last_modify_ip": { "last_modify_ip": {
"bsonType": "string", "bsonType": "string",
"description": "最后修改时 IP 地址", "description": "最后修改时 IP 地址",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "clientIP" "$env": "clientIP"
} }
}, },
"mode": { "mode": {
"bsonType": "number", "bsonType": "number",
"title": "排版显示模式", "title": "排版显示模式",
"description": "排版显示模式,如左图右文、上图下文等" "description": "排版显示模式,如左图右文、上图下文等"
} }
} }
} }
{ {
"bsonType": "object", "bsonType": "object",
"required": ["name"], "required": ["name"],
"permission": { "permission": {
"read": true, "read": true,
"create": false, "create": false,
"update": false, "update": false,
"delete": false "delete": false
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "存储文档 ID(文章 ID),系统自动生成" "description": "存储文档 ID(文章 ID),系统自动生成"
}, },
"name": { "name": {
"bsonType": "string", "bsonType": "string",
"description": "类别名称", "description": "类别名称",
"label": "名称", "label": "名称",
"trim": "both" "trim": "both"
}, },
"description": { "description": {
"bsonType": "string", "bsonType": "string",
"description": "类别描述", "description": "类别描述",
"label": "描述", "label": "描述",
"trim": "both" "trim": "both"
}, },
"icon": { "icon": {
"bsonType": "string", "bsonType": "string",
"description": "类别图标地址", "description": "类别图标地址",
"label": "图标地址", "label": "图标地址",
"pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S", "pattern": "^(http:\/\/|https:\/\/|\/|.\/|@\/)\\S",
"trim": "both" "trim": "both"
}, },
"sort": { "sort": {
"bsonType": "int", "bsonType": "int",
"description": "类别显示顺序", "description": "类别显示顺序",
"label": "排序" "label": "排序"
}, },
"article_count": { "article_count": {
"bsonType": "int", "bsonType": "int",
"description": "该类别下文章数量" "description": "该类别下文章数量"
}, },
"create_date": { "create_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "创建时间", "description": "创建时间",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "now" "$env": "now"
} }
} }
} }
} }
{ {
"bsonType": "object", "bsonType": "object",
"required": ["article_id", "user_id", "comment_content", "like_count", "comment_type", "reply_user_id", "required": ["article_id", "user_id", "comment_content", "like_count", "comment_type", "reply_user_id",
"reply_comment_id" "reply_comment_id"
], ],
"permission": { "permission": {
"read": true, "read": true,
"create": "auth.uid != null && get(`database.opendb-news-article.${doc.article_id}`).comment_status == 1", "create": "auth.uid != null && get(`database.opendb-news-article.${doc.article_id}`).comment_status == 1",
"update": "doc.uid == auth.uid", "update": "doc.uid == auth.uid",
"delete": "doc.uid == auth.uid" "delete": "doc.uid == auth.uid"
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "存储文档 ID(文章 ID),系统自动生成" "description": "存储文档 ID(文章 ID),系统自动生成"
}, },
"article_id": { "article_id": {
"bsonType": "string", "bsonType": "string",
"description": "文章ID,opendb-news-posts 表中的`_id`字段", "description": "文章ID,opendb-news-posts 表中的`_id`字段",
"foreignKey": "opendb-news-articles._id" "foreignKey": "opendb-news-articles._id"
}, },
"user_id": { "user_id": {
"bsonType": "string", "bsonType": "string",
"description": "评论者ID,参考`uni-id-users` 表", "description": "评论者ID,参考`uni-id-users` 表",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "uid" "$env": "uid"
}, },
"foreignKey": "uni-id-users._id" "foreignKey": "uni-id-users._id"
}, },
"comment_content": { "comment_content": {
"bsonType": "string", "bsonType": "string",
"description": "评论内容", "description": "评论内容",
"title": "评论内容", "title": "评论内容",
"trim": "right" "trim": "right"
}, },
"like_count": { "like_count": {
"bsonType": "int", "bsonType": "int",
"description": "评论喜欢数、点赞数" "description": "评论喜欢数、点赞数"
}, },
"comment_type": { "comment_type": {
"bsonType": "int", "bsonType": "int",
"description": "回复类型: 0 针对文章的回复 1 针对评论的回复" "description": "回复类型: 0 针对文章的回复 1 针对评论的回复"
}, },
"reply_user_id": { "reply_user_id": {
"bsonType": "string", "bsonType": "string",
"description": "被回复的评论用户ID,comment_type为1时有效", "description": "被回复的评论用户ID,comment_type为1时有效",
"foreignKey": "uni-id-users._id" "foreignKey": "uni-id-users._id"
}, },
"reply_comment_id": { "reply_comment_id": {
"bsonType": "string", "bsonType": "string",
"description": "被回复的评论ID,comment_type为1时有效", "description": "被回复的评论ID,comment_type为1时有效",
"foreignKey": "opendb-news-comments._id" "foreignKey": "opendb-news-comments._id"
}, },
"comment_date": { "comment_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "评论发表时间", "description": "评论发表时间",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "now" "$env": "now"
} }
}, },
"comment_ip": { "comment_ip": {
"bsonType": "string", "bsonType": "string",
"description": "评论发表时 IP 地址", "description": "评论发表时 IP 地址",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "clientIP" "$env": "clientIP"
} }
} }
} }
} }
{ {
"bsonType": "object", "bsonType": "object",
"required": ["user_id", "article_id"], "required": ["user_id", "article_id"],
"permission": { "permission": {
"read": true, "read": true,
"create": "auth.uid != null", "create": "auth.uid != null",
"update": false, "update": false,
"delete": "doc.uid == auth.uid" "delete": "doc.uid == auth.uid"
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "ID,系统自动生成" "description": "ID,系统自动生成"
}, },
"article_id": { "article_id": {
"bsonType": "string", "bsonType": "string",
"description": "文章id,参考opendb-news-articles表", "description": "文章id,参考opendb-news-articles表",
"foreignKey": "opendb-news-articles._id" "foreignKey": "opendb-news-articles._id"
}, },
"user_id": { "user_id": {
"bsonType": "string", "bsonType": "string",
"description": "收藏者id,参考uni-id-users表", "description": "收藏者id,参考uni-id-users表",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "uid" "$env": "uid"
}, },
"foreignKey": "uni-id-users._id" "foreignKey": "uni-id-users._id"
}, },
"create_date": { "create_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "收藏时间", "description": "收藏时间",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "now" "$env": "now"
} }
} }
} }
} }
{ {
"bsonType": "object", "bsonType": "object",
"permission": { "permission": {
"create": false, "create": false,
"delete": false, "delete": false,
"read": true, "read": true,
"update": false "update": false
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "ID,系统自动生成" "description": "ID,系统自动生成"
}, },
"content": { "content": {
"bsonType": "string", "bsonType": "string",
"description": "搜索内容" "description": "搜索内容"
}, },
"count": { "count": {
"bsonType": "long", "bsonType": "long",
"description": "搜索次数" "description": "搜索次数"
}, },
"create_date": { "create_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "统计时间" "description": "统计时间"
} }
}, },
"required": ["content", "count"] "required": ["content", "count"]
} }
{ {
"bsonType": "object", "bsonType": "object",
"permission": { "permission": {
"create": true, "create": true,
"delete": false, "delete": false,
"read": false, "read": false,
"update": false "update": false
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "ID,系统自动生成" "description": "ID,系统自动生成"
}, },
"content": { "content": {
"bsonType": "string", "bsonType": "string",
"description": "搜索内容" "description": "搜索内容"
}, },
"create_date": { "create_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "统计时间" "description": "统计时间"
}, },
"device_id": { "device_id": {
"bsonType": "string", "bsonType": "string",
"description": "设备id" "description": "设备id"
}, },
"user_id": { "user_id": {
"bsonType": "string", "bsonType": "string",
"description": "收藏者id,参考uni-id-users表" "description": "收藏者id,参考uni-id-users表"
} }
}, },
"required": ["content"] "required": ["content"]
} }
{ {
"bsonType": "object", "bsonType": "object",
"properties": { "properties": {
"_id": { "_id": {
"description": "ID,系统自动生成" "description": "ID,系统自动生成"
}, },
"code": { "code": {
"bsonType": "string", "bsonType": "string",
"description": "验证码" "description": "验证码"
}, },
"create_date": { "create_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "创建时间" "description": "创建时间"
}, },
"device_uuid": { "device_uuid": {
"bsonType": "string", "bsonType": "string",
"description": "设备UUID,常用于图片验证码" "description": "设备UUID,常用于图片验证码"
}, },
"email": { "email": {
"bsonType": "string", "bsonType": "string",
"description": "邮箱" "description": "邮箱"
}, },
"expired_date": { "expired_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "过期时间" "description": "过期时间"
}, },
"ip": { "ip": {
"bsonType": "string", "bsonType": "string",
"description": "请求时客户端IP地址" "description": "请求时客户端IP地址"
}, },
"mobile": { "mobile": {
"bsonType": "string", "bsonType": "string",
"description": "手机号码" "description": "手机号码"
}, },
"scene": { "scene": {
"bsonType": "string", "bsonType": "string",
"description": "使用验证码的场景,如:login, bind, unbind, pay" "description": "使用验证码的场景,如:login, bind, unbind, pay"
}, },
"state": { "state": {
"bsonType": "int", "bsonType": "int",
"description": "验证状态:0 未验证、1 已验证、2 已作废" "description": "验证状态:0 未验证、1 已验证、2 已作废"
} }
}, },
"required": [] "required": []
} }
{ {
"bsonType": "object", "bsonType": "object",
"properties": { "properties": {
"_id": { "_id": {
"description": "ID,系统自动生成" "description": "ID,系统自动生成"
}, },
"create_date": { "create_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "创建时间", "description": "创建时间",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "now" "$env": "now"
} }
}, },
"device_uuid": { "device_uuid": {
"bsonType": "string", "bsonType": "string",
"description": "设备唯一标识" "description": "设备唯一标识"
}, },
"ip": { "ip": {
"bsonType": "string", "bsonType": "string",
"description": "ip地址" "description": "ip地址"
}, },
"state": { "state": {
"bsonType": "int", "bsonType": "int",
"description": "结果:0 失败、1 成功" "description": "结果:0 失败、1 成功"
}, },
"type": { "type": {
"bsonType": "string", "bsonType": "string",
"description": "登录类型", "description": "登录类型",
"enum": ["login", "logout"] "enum": ["login", "logout"]
}, },
"ua": { "ua": {
"bsonType": "string", "bsonType": "string",
"description": "userAgent" "description": "userAgent"
}, },
"user_id": { "user_id": {
"bsonType": "string", "bsonType": "string",
"description": "用户id,参考uni-id-users表" "description": "用户id,参考uni-id-users表"
} }
}, },
"required": [] "required": []
} }
{ {
"bsonType": "object", "bsonType": "object",
"permission": { "permission": {
"read": "'read' in auth.permission", "read": true,
"create": false, "create": false,
"update": "doc._id == auth.uid", "update": "doc._id == auth.uid",
"delete": false "delete": false
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "存储文档 ID(用户 ID),系统自动生成" "description": "存储文档 ID(用户 ID),系统自动生成"
}, },
"ali_openid": { "ali_openid": {
"bsonType": "string", "bsonType": "string",
"description": "支付宝平台openid" "description": "支付宝平台openid"
}, },
"apple_openid": { "apple_openid": {
"bsonType": "string", "bsonType": "string",
"description": "苹果登录openid" "description": "苹果登录openid"
}, },
"avatar": { "avatar": {
"bsonType": "string", "bsonType": "string",
"description": "头像地址", "description": "头像地址",
"title": "头像地址", "title": "头像地址",
"trim": "both" "trim": "both"
}, },
"comment": { "comment": {
"bsonType": "string", "bsonType": "string",
"description": "备注", "description": "备注",
"title": "备注", "title": "备注",
"trim": "both" "trim": "both"
}, },
"department_id": { "department_id": {
"bsonType": "array", "bsonType": "array",
"description": "部门ID", "description": "部门ID",
"enum": { "enum": {
"collection": "opendb-department", "collection": "opendb-department",
"field": "_id as value, name as text", "field": "_id as value, name as text",
"orderby": "name asc" "orderby": "name asc"
}, },
"enumType": "tree", "enumType": "tree",
"title": "部门" "title": "部门"
}, },
"email": { "email": {
"bsonType": "string", "bsonType": "string",
"description": "邮箱地址", "description": "邮箱地址",
"format": "email", "format": "email",
"title": "邮箱", "title": "邮箱",
"trim": "both" "trim": "both"
}, },
"email_confirmed": { "email_confirmed": {
"bsonType": "int", "bsonType": "int",
"defaultValue": 0, "defaultValue": 0,
"description": "邮箱验证状态:0 未验证 1 已验证", "description": "邮箱验证状态:0 未验证 1 已验证",
"enum": [{ "enum": [{
"text": "未验证", "text": "未验证",
"value": 0 "value": 0
}, { }, {
"text": "已验证", "text": "已验证",
"value": 1 "value": 1
}], }],
"title": "邮箱验证状态" "title": "邮箱验证状态"
}, },
"gender": { "gender": {
"bsonType": "int", "bsonType": "int",
"defaultValue": 0, "defaultValue": 0,
"description": "用户性别:0 未知 1 男性 2 女性", "description": "用户性别:0 未知 1 男性 2 女性",
"enum": [{ "enum": [{
"text": "未知", "text": "未知",
"value": 0 "value": 0
}, { }, {
"text": "男", "text": "男",
"value": 1 "value": 1
}, { }, {
"text": "女", "text": "女",
"value": 2 "value": 2
}], }],
"title": "性别" "title": "性别"
}, },
"inviter_uid": { "inviter_uid": {
"bsonType": "array", "bsonType": "array",
"description": "用户全部上级邀请者", "description": "用户全部上级邀请者",
"trim": "both" "trim": "both"
}, },
"last_login_date": { "last_login_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "最后登录时间" "description": "最后登录时间"
}, },
"last_login_ip": { "last_login_ip": {
"bsonType": "string", "bsonType": "string",
"description": "最后登录时 IP 地址" "description": "最后登录时 IP 地址"
}, },
"mobile": { "mobile": {
"bsonType": "string", "bsonType": "string",
"description": "手机号码", "description": "手机号码",
"pattern": "^\\+?[0-9-]{3,20}$", "pattern": "^\\+?[0-9-]{3,20}$",
"title": "手机号码", "title": "手机号码",
"trim": "both" "trim": "both"
}, },
"mobile_confirmed": { "mobile_confirmed": {
"bsonType": "int", "bsonType": "int",
"defaultValue": 0, "defaultValue": 0,
"description": "手机号验证状态:0 未验证 1 已验证", "description": "手机号验证状态:0 未验证 1 已验证",
"enum": [{ "enum": [{
"text": "未验证", "text": "未验证",
"value": 0 "value": 0
}, { }, {
"text": "已验证", "text": "已验证",
"value": 1 "value": 1
}], }],
"title": "手机号验证状态" "title": "手机号验证状态"
}, },
"my_invite_code": { "my_invite_code": {
"bsonType": "string", "bsonType": "string",
"description": "用户自身邀请码" "description": "用户自身邀请码"
}, },
"nickname": { "nickname": {
"bsonType": "string", "bsonType": "string",
"description": "用户昵称", "description": "用户昵称",
"title": "昵称", "title": "昵称",
"trim": "both" "trim": "both"
}, },
"password": { "password": {
"bsonType": "password", "bsonType": "password",
"description": "密码,加密存储", "description": "密码,加密存储",
"title": "密码", "title": "密码",
"trim": "both" "trim": "both"
}, },
"password_secret_version": { "password_secret_version": {
"bsonType": "int", "bsonType": "int",
"description": "密码使用的passwordSecret版本", "description": "密码使用的passwordSecret版本",
"title": "passwordSecret" "title": "passwordSecret"
}, },
"realname_auth": { "realname_auth": {
"bsonType": "object", "bsonType": "object",
"description": "实名认证信息", "description": "实名认证信息",
"properties": { "properties": {
"auth_date": { "auth_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "认证通过时间" "description": "认证通过时间"
}, },
"auth_status": { "auth_status": {
"bsonType": "int", "bsonType": "int",
"description": "认证状态:0 未认证 1 等待认证 2 认证通过 3 认证失败", "description": "认证状态:0 未认证 1 等待认证 2 认证通过 3 认证失败",
"maximum": 3, "maximum": 3,
"minimum": 0 "minimum": 0
}, },
"contact_email": { "contact_email": {
"bsonType": "string", "bsonType": "string",
"description": "联系人邮箱" "description": "联系人邮箱"
}, },
"contact_mobile": { "contact_mobile": {
"bsonType": "string", "bsonType": "string",
"description": "联系人手机号码" "description": "联系人手机号码"
}, },
"contact_person": { "contact_person": {
"bsonType": "string", "bsonType": "string",
"description": "联系人姓名" "description": "联系人姓名"
}, },
"id_card_back": { "id_card_back": {
"bsonType": "string", "bsonType": "string",
"description": "身份证反面照 URL" "description": "身份证反面照 URL"
}, },
"id_card_front": { "id_card_front": {
"bsonType": "string", "bsonType": "string",
"description": "身份证正面照 URL" "description": "身份证正面照 URL"
}, },
"identity": { "identity": {
"bsonType": "string", "bsonType": "string",
"description": "身份证号码\/营业执照号码" "description": "身份证号码\/营业执照号码"
}, },
"in_hand": { "in_hand": {
"bsonType": "string", "bsonType": "string",
"description": "手持身份证照片 URL" "description": "手持身份证照片 URL"
}, },
"license": { "license": {
"bsonType": "string", "bsonType": "string",
"description": "营业执照 URL" "description": "营业执照 URL"
}, },
"real_name": { "real_name": {
"bsonType": "string", "bsonType": "string",
"description": "真实姓名\/企业名称" "description": "真实姓名\/企业名称"
}, },
"type": { "type": {
"bsonType": "int", "bsonType": "int",
"description": "用户类型:0 个人用户 1 企业用户", "description": "用户类型:0 个人用户 1 企业用户",
"maximum": 1, "maximum": 1,
"minimum": 0 "minimum": 0
} }
}, },
"required": ["type", "auth_status"] "required": ["type", "auth_status"]
}, },
"register_date": { "register_date": {
"bsonType": "timestamp", "bsonType": "timestamp",
"description": "注册时间", "description": "注册时间",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "now" "$env": "now"
} }
}, },
"register_ip": { "register_ip": {
"bsonType": "string", "bsonType": "string",
"description": "注册时 IP 地址", "description": "注册时 IP 地址",
"forceDefaultValue": { "forceDefaultValue": {
"$env": "clientIP" "$env": "clientIP"
} }
}, },
"role": { "role": {
"bsonType": "array", "bsonType": "array",
"description": "用户角色", "description": "用户角色",
"enum": { "enum": {
"collection": "uni-id-roles", "collection": "uni-id-roles",
"field": "role_id as value, role_name as text" "field": "role_id as value, role_name as text"
}, },
"foreignKey": "uni-id-roles.role_id", "foreignKey": "uni-id-roles.role_id",
"permission": { "permission": {
"write": false "write": false
}, },
"title": "角色" "title": "角色"
}, },
"status": { "status": {
"bsonType": "int", "bsonType": "int",
"defaultValue": 0, "defaultValue": 0,
"description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝", "description": "用户状态:0 正常 1 禁用 2 审核中 3 审核拒绝",
"enum": [{ "enum": [{
"text": "正常", "text": "正常",
"value": 0 "value": 0
}, { }, {
"text": "禁用", "text": "禁用",
"value": 1 "value": 1
}, { }, {
"text": "审核中", "text": "审核中",
"value": 2 "value": 2
}, { }, {
"text": "审核拒绝", "text": "审核拒绝",
"value": 3 "value": 3
}], }],
"title": "用户状态" "title": "用户状态"
}, },
"token": { "token": {
"bsonType": "array", "bsonType": "array",
"description": "用户token" "description": "用户token"
}, },
"username": { "username": {
"bsonType": "string", "bsonType": "string",
"description": "用户名,不允许重复", "description": "用户名,不允许重复",
"title": "用户名", "title": "用户名",
"trim": "both" "trim": "both"
}, },
"wx_openid": { "wx_openid": {
"bsonType": "object", "bsonType": "object",
"description": "微信各个平台openid", "description": "微信各个平台openid",
"properties": { "properties": {
"app-plus": { "app-plus": {
"bsonType": "string", "bsonType": "string",
"description": "app平台微信openid" "description": "app平台微信openid"
}, },
"mp-weixin": { "mp-weixin": {
"bsonType": "string", "bsonType": "string",
"description": "微信小程序平台openid" "description": "微信小程序平台openid"
} }
} }
}, },
"wx_unionid": { "wx_unionid": {
"bsonType": "string", "bsonType": "string",
"description": "微信unionid" "description": "微信unionid"
} }
}, },
"required": [] "required": []
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
isChoose:{ isChoose:{
type:Boolean, type:Boolean,
default:false default:false
} },
}, },
methods:{ methods:{
/** /**
......
...@@ -123,13 +123,13 @@ ...@@ -123,13 +123,13 @@
db.collection(dbCollectionName).add(value).then((res) => { db.collection(dbCollectionName).add(value).then((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)
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
content: err.message || '请求服务失败', content: err.message || '反馈失败',
showCancel: false showCancel: false
}) })
}).finally(() => { }).finally(() => {
......
{ {
"bsonType": "object", "bsonType": "object",
"permission": { "permission": {
"read": "auth.uid && doc.uid == auth.uid", "read": "auth.uid && doc.uid == auth.uid",
"create": true, "create": true,
"update": false, "update": false,
"delete": false "delete": false
}, },
"properties": { "properties": {
"_id": { "_id": {
"description": "ID,系统自动生成" "description": "ID,系统自动生成"
}, },
"user_id": { "user_id": {
"bsonType": "string", "bsonType": "string",
"description": "留言反馈用户ID/回复留言用户ID,参考uni-id-users表", "description": "留言反馈用户ID\/回复留言用户ID,参考uni-id-users表",
"foreignKey": "uni-id-users._id" "foreignKey": "uni-id-users._id",
}, "forceDefaultValue": {
"create_date": { "$env": "uid"
"bsonType": "timestamp", }
"description": "留言时间/回复留言时间" },
}, "ip": {
"content": { "forceDefaultValue": {
"bsonType": "string", "$env": "clientIP"
"description": "留言内容/回复内容", }
"trim": "right" },
}, "create_date": {
"imgs": { "bsonType": "timestamp",
"bsonType": "array", "description": "留言时间\/回复留言时间",
"description": "图片列表" "forceDefaultValue": {
}, "$env": "now"
"is_reply": { }
"bsonType": "bool", },
"description": "是否是回复类型" "content": {
}, "bsonType": "string",
"feedback_id": { "description": "留言内容\/回复内容",
"bsonType": "string", "trim": "right"
"description": "被回复留言ID" },
}, "imgs": {
"contact": { "bsonType": "array",
"bsonType": "string", "description": "图片列表"
"description": "联系人", },
"trim": "both" "is_reply": {
}, "bsonType": "bool",
"mobile": { "description": "是否是回复类型"
"bsonType": "string", },
"description": "联系电话", "feedback_id": {
"trim": "both" "bsonType": "string",
}, "description": "被回复留言ID"
"reply_count": { },
"bsonType": "int", "contact": {
"description": "被回复条数" "bsonType": "string",
} "description": "联系人",
} "trim": "both"
} },
\ No newline at end of file "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", "passwordSecret": "passwordSecret-demo",
"tokenSecret": "tokenSecret-demo", "tokenSecret": "tokenSecret-demo",
"tokenExpiresIn": 7200, "tokenExpiresIn": 7200,
"tokenExpiresThreshold": 600, "tokenExpiresThreshold": 600,
"passwordErrorLimit": 6, "passwordErrorLimit": 6,
"bindTokenToDevice": true, "bindTokenToDevice": true,
"passwordErrorRetryTime": 3600, "passwordErrorRetryTime": 3600,
"autoSetInviteCode": false, "autoSetInviteCode": false,
"forceInviteCode": false, "forceInviteCode": false,
"app-plus": { "app-plus": {
"tokenExpiresIn": 2592000, "tokenExpiresIn": 2592000,
"oauth" : { "oauth": {
"weixin" : { "weixin": {
"appid": "wx0411fa6a39d61297", "appid": "wx0411fa6a39d61297",
"appsecret": "fdc6251421d3d688a563b4f00dd540e7" "appsecret": "6c9119430d7be0a147bcbbb73ef33acf"
}, },
"apple": { "apple": {
"bundleId": "io.dcloud.game.cat" "bundleId": "io.dcloud.game.cat"
} }
} }
}, },
"mp-weixin": { "mp-weixin": {
"oauth" : { "oauth": {
"weixin" : { "weixin": {
"appid" : "weixin appid", "appid": "wx999bf02c8e05dfc9",
"appsecret" : "weixin appsecret" "appsecret": "b5f608afd332b2c0ded7e6b98ca4ccd3"
} }
} }
}, },
"mp-alipay": { "mp-alipay": {
"oauth" : { "oauth": {
"alipay" : { "alipay": {
"appid" : "alipay appid", "appid": "alipay appid",
"privateKey" : "alipay privateKey" "privateKey": "alipay privateKey"
} }
} }
}, },
"service": { "service": {
"sms": { "sms": {
"name": "DCloud", "name": "DCloud",
"codeExpiresIn": 300, "codeExpiresIn": 300,
"smsKey": "71a19f38c954f7d768d68a050486bf15", "smsKey": "71a19f38c954f7d768d68a050486bf15",
"smsSecret": "d6c424b702d73baa3b6e1a1452469213" "smsSecret": "d6c424b702d73baa3b6e1a1452469213"
}, },
"univerify":{ "univerify": {
"appid": "Du9ZOTSzHO9vutboF6UYa3", "appid": "__UNI__BC54A00",
"apiKey":"d1e36bcd497b3795434d900dcfdd44dc", "apiKey": "d1e36bcd497b3795434d900dcfdd44dc",
"apiSecret":"2feb378ff1114362b20ac179b572293e" "apiSecret": "2feb378ff1114362b20ac179b572293e"
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册