Commit 8c8010f8 authored by 李超鹏's avatar 李超鹏

添加云函数

parent 8ad2fcb0
This diff is collapsed.
'use strict';
exports.main = async (event, context) => {
const db = uniCloud.database();
let res = await db.collection("standard").where(event).get();
let data = res.data
const map = new Map()
for(let i = 0; i < data.length; i++){
let key = data[i].type
if(map.has(key)){
map.get(key).list.push(data[i])
}else{
map.set(key,{type:key, list:[data[i]]})
}
}
return [...map.values()]
};
...@@ -12,11 +12,15 @@ const db = uniCloud.database({ ...@@ -12,11 +12,15 @@ const db = uniCloud.database({
/* 查询规范项目 {product_code:"P0001"}*/ /* 查询规范项目 {product_code:"P0001"}*/
let getstandard = async (params = {}) => await db.collection("standard").where(params).get(); let getstandard = async (params = {}) => await db.collection("standard").where(params).get();
/* 查询分组规范项目 */
let getGroupStandard = async (params = {}) => await uniCloud.callFunction({name: 'getGroupStandard', data: params});
const rulesApi = { const rulesApi = {
getAllProduct, getAllProduct,
getBrand, getBrand,
getstandard, getstandard,
getGroupStandard,
} }
return rulesApi return rulesApi
} }
......
{ {
"name" : "take-order", "name" : "take-order",
"appid" : "", "appid" : "__UNI__BA775F5",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
"quickapp" : {}, "quickapp" : {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin" : {
"appid" : "", "appid" : "wxd1d6eede324b0465",
"setting" : { "setting" : {
"urlCheck" : false "urlCheck" : false
}, },
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
console.log(res,"品牌") console.log(res,"品牌")
} }
) )
this.$u.cloudApi.getstandard({brand_code:"B0001"}).then(res =>{ this.$u.cloudApi.getGroupStandard({product_code:"P0001",brand_code:"B0001"}).then(res =>{
console.log(res,"规范标准") console.log(res,"规范标准")
} }
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment