Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
take_order
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
和慭琛
take_order
Commits
50a5e668
Commit
50a5e668
authored
Mar 22, 2021
by
李超鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
云函数 开发
parent
b5a22276
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
1780 additions
and
1478 deletions
+1780
-1478
cloud_rules.js
take-order/common/api/cloud_rules.js
+27
-4
package-lock.json
take-order/package-lock.json
+865
-0
LICENSE.md
...rder/uniCloud-tcb/cloudfunctions/common/uni-id/LICENSE.md
+201
-0
config.json
...der/uniCloud-tcb/cloudfunctions/common/uni-id/config.json
+44
-0
index.js
...-order/uniCloud-tcb/cloudfunctions/common/uni-id/index.js
+1
-0
package.json
...er/uniCloud-tcb/cloudfunctions/common/uni-id/package.json
+13
-0
index.js
...r/uniCloud-tcb/cloudfunctions/common/user-common/index.js
+11
-0
package.json
...iCloud-tcb/cloudfunctions/common/user-common/package.json
+12
-0
index.js
...r/uniCloud-tcb/cloudfunctions/getGroupStandardV2/index.js
+46
-0
package.json
...iCloud-tcb/cloudfunctions/getGroupStandardV2/package.json
+15
-0
getRelationDictionary.param.json
...ns/getRelationDictionary/getRelationDictionary.param.json
+9
-0
index.js
...niCloud-tcb/cloudfunctions/getRelationDictionary/index.js
+22
-0
getUserWatermark.param.json
...oudfunctions/getUserWatermark/getUserWatermark.param.json
+8
-0
index.js
...der/uniCloud-tcb/cloudfunctions/getUserWatermark/index.js
+21
-0
package-lock.json
...oud-tcb/cloudfunctions/getUserWatermark/package-lock.json
+11
-0
package.json
...uniCloud-tcb/cloudfunctions/getUserWatermark/package.json
+15
-0
index.js
take-order/uniCloud-tcb/cloudfunctions/saveImage/index.js
+19
-0
package.json
...-order/uniCloud-tcb/cloudfunctions/saveImage/package.json
+15
-0
index.js
...er/uniCloud-tcb/cloudfunctions/saveUserWatermark/index.js
+25
-0
package-lock.json
...ud-tcb/cloudfunctions/saveUserWatermark/package-lock.json
+11
-0
package.json
...niCloud-tcb/cloudfunctions/saveUserWatermark/package.json
+15
-0
saveUserWatermark.param.json
...dfunctions/saveUserWatermark/saveUserWatermark.param.json
+33
-0
db_init.json
take-order/uniCloud-tcb/database/db_init.json
+341
-1474
No files found.
take-order/common/api/cloud_rules.js
View file @
50a5e668
...
@@ -4,23 +4,46 @@ const db = uniCloud.database({
...
@@ -4,23 +4,46 @@ const db = uniCloud.database({
let
cloudRulesApiFun
=
function
(
vm
){
let
cloudRulesApiFun
=
function
(
vm
){
/* 查询所有产品*/
/* 查询所有产品
废弃
*/
let
getAllProduct
=
async
()
=>
await
db
.
collection
(
"product"
).
get
();
let
getAllProduct
=
async
()
=>
await
db
.
collection
(
"product"
).
get
();
/* 查询产品下的品牌 {product_code:"P0001"}*/
/* 查询产品下的品牌 {product_code:"P0001"}
废弃
*/
let
getBrand
=
async
(
params
=
{})
=>
await
db
.
collection
(
"brand"
).
where
(
params
).
get
();
let
getBrand
=
async
(
params
=
{})
=>
await
db
.
collection
(
"brand"
).
where
(
params
).
get
();
/* 查询规范项目 {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
});
let
getGroupStandard
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'getGroupStandard'
,
data
:
params
});
/* 查询类别数据 */
let
getClassifyDictionary
=
async
()
=>
await
db
.
collection
(
"dictionary"
).
where
({
"type"
:
"classify"
}).
get
()
/* 查询有数据的系统 或者 品牌 数据 {"classify_id":"","system_id":"","field":"system_id|brand_id"}*/
let
getRelationDictionary
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'getRelationDictionary'
,
data
:
params
});
/* 查询规范 根据 分类、系统、品牌 {"token":"", "classify_id":"","system_id":"","brand_id":""} */
let
getGroupStandardV2
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'getGroupStandardV2'
,
data
:
params
});
/* 保存图片 {"token":"", "standardId":"", "url":""} */
let
saveImage
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'saveImage'
,
data
:
params
});
/* 获取用户水印,首次返回默认水印 {"token":"", "systemId":""} */
let
getUserWatermark
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'getUserWatermark'
,
data
:
params
});
/* 保存用户水印配置 {"token":"", "watermark": getUserWatemark返回的数据} */
let
saveUserWatermark
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'saveUserWatermark'
,
data
:
params
});
const
rulesApi
=
{
const
rulesApi
=
{
getAllProduct
,
getAllProduct
,
getBrand
,
getBrand
,
getstandard
,
getstandard
,
getGroupStandard
,
getGroupStandard
,
// 新接口
getClassifyDictionary
,
getRelationDictionary
,
getGroupStandardV2
,
saveImage
}
}
return
rulesApi
return
rulesApi
}
}
...
...
take-order/package-lock.json
0 → 100644
View file @
50a5e668
This diff is collapsed.
Click to expand it.
take-order/uniCloud-tcb/cloudfunctions/common/uni-id/LICENSE.md
0 → 100644
View file @
50a5e668
This diff is collapsed.
Click to expand it.
take-order/uniCloud-tcb/cloudfunctions/common/uni-id/config.json
0 → 100644
View file @
50a5e668
{
"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"
:
"weixin appid"
,
"appsecret"
:
"weixin appsecret"
}
}
},
"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"
:
"your sms key"
,
"smsSecret"
:
"your sms secret"
}
}
}
take-order/uniCloud-tcb/cloudfunctions/common/uni-id/index.js
0 → 100644
View file @
50a5e668
This diff is collapsed.
Click to expand it.
take-order/uniCloud-tcb/cloudfunctions/common/uni-id/package.json
0 → 100644
View file @
50a5e668
{
"name"
:
"uni-id"
,
"version"
:
"2.0.3"
,
"description"
:
"uni-id for uniCloud"
,
"main"
:
"index.js"
,
"homepage"
:
"https://uniapp.dcloud.io/uniCloud/uni-id"
,
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git+https://gitee.com/dcloud/uni-id.git"
},
"author"
:
""
,
"license"
:
"Apache-2.0"
}
\ No newline at end of file
take-order/uniCloud-tcb/cloudfunctions/common/user-common/index.js
0 → 100644
View file @
50a5e668
async
function
getUserId
(
token
)
{
const
res
=
await
uniCloud
.
httpclient
.
request
(
"https://system.banshouhui.com/wxh-worker-rest/rest/"
+
token
+
"/myinfo/id"
,
{
method
:
'GET'
})
return
res
?
res
.
data
:
""
}
module
.
exports
=
{
getUserId
}
take-order/uniCloud-tcb/cloudfunctions/common/user-common/package.json
0 → 100644
View file @
50a5e668
{
"name"
:
"user-common"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"keywords"
:
[],
"author"
:
""
,
"license"
:
"ISC"
}
take-order/uniCloud-tcb/cloudfunctions/getGroupStandardV2/index.js
0 → 100644
View file @
50a5e668
'use strict'
;
const
{
getUserId
}
=
require
(
'user-common'
)
exports
.
main
=
async
(
event
,
context
)
=>
{
const
db
=
uniCloud
.
database
();
const
_
=
db
.
command
const
$
=
db
.
command
.
aggregate
const
user_id
=
getUserId
(
event
.
token
)
let
res
=
await
db
.
collection
(
"standardV2"
).
aggregate
().
lookup
({
from
:
'user_upload_file'
,
let
:
{
standard_id
:
'$_id'
},
pipeline
:
$
.
pipeline
()
.
match
(
_
.
expr
(
$
.
and
([
$
.
eq
([
'$standard_id'
,
'$$standard_id'
]),
$
.
eq
([
'$user_id'
,
user_id
])
]))).
sort
({
create_date
:
-
1
}).
limit
(
5
)
.
project
({
"_id"
:
0
,
"url"
:
1
,
})
.
done
(),
as
:
'imageList'
}).
end
()
let
data
=
res
.
data
const
map
=
new
Map
()
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
data
[
i
].
imageList
=
data
[
i
].
imageList
.
map
(
a
=>
a
.
url
)
let
key
=
data
[
i
].
type
if
(
map
.
has
(
key
))
{
data
[
i
].
images
=
data
[
i
].
images
.
split
(
","
)
map
.
get
(
key
).
list
.
push
(
data
[
i
])
}
else
{
data
[
i
].
images
=
data
[
i
].
images
.
split
(
","
)
map
.
set
(
key
,
{
type
:
key
,
list
:
[
data
[
i
]]
})
}
}
return
[...
map
.
values
()]
};
take-order/uniCloud-tcb/cloudfunctions/getGroupStandardV2/package.json
0 → 100644
View file @
50a5e668
{
"name"
:
"getGroupStandardV2"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"keywords"
:
[],
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"user-common"
:
"file:../common/user-common"
}
}
take-order/uniCloud-tcb/cloudfunctions/getRelationDictionary/getRelationDictionary.param.json
0 → 100644
View file @
50a5e668
//
本文件中的json内容将在云函数【运行】时作为参数传给云函数。
//
配置教程参考:https
:
//uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"classify_id"
:
"79550af260555cc20afb34146966a2c4"
,
"system_id"
:
"79550af260555cc20afb34156c94b32c"
,
"field"
:
"brand_id"
}
take-order/uniCloud-tcb/cloudfunctions/getRelationDictionary/index.js
0 → 100644
View file @
50a5e668
'use strict'
;
exports
.
main
=
async
(
event
,
context
)
=>
{
const
field_name
=
event
.
field
const
param
=
{
"classify_id"
:
event
.
classify_id
,
"system_id"
:
event
.
system_id
,
"brand_id"
:
event
.
brand_id
}
const
db
=
uniCloud
.
database
()
let
res
=
await
db
.
collection
(
"standardV2"
).
aggregate
().
match
(
param
).
group
({
_id
:
"$"
+
event
.
field
}).
end
();
res
=
await
db
.
collection
(
'dictionary'
).
field
({
"_id"
:
true
,
"name"
:
true
}).
where
({
_id
:
db
.
command
.
in
(
Array
.
from
(
res
.
data
,
item
=>
item
.
_id
))
}).
get
()
return
res
.
data
};
take-order/uniCloud-tcb/cloudfunctions/getUserWatermark/getUserWatermark.param.json
0 → 100644
View file @
50a5e668
//
本文件中的json内容将在云函数【运行】时作为参数传给云函数。
//
配置教程参考:https
:
//uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"token"
:
""
"system_id"
:
"79550af260555cc20afb34156c94b32c"
}
take-order/uniCloud-tcb/cloudfunctions/getUserWatermark/index.js
0 → 100644
View file @
50a5e668
'use strict'
;
const
{
getUserId
}
=
require
(
'user-common'
)
exports
.
main
=
async
(
event
,
context
)
=>
{
//event为客户端上传的参数
const
user_id
=
getUserId
(
event
.
token
)
const
collection
=
uniCloud
.
database
().
collection
(
"user_watermark"
).
field
({
'_id'
:
false
})
let
res
=
await
collection
.
where
({
user_id
:
user_id
,
system_id
:
event
.
system_id
}).
get
()
if
(
!
res
.
data
||
res
.
data
.
length
<=
0
)
{
// 用户没有 获取模板
res
=
await
collection
.
where
({
system_id
:
event
.
system_id
}).
get
()
}
return
res
.
data
[
0
]
};
take-order/uniCloud-tcb/cloudfunctions/getUserWatermark/package-lock.json
0 → 100644
View file @
50a5e668
{
"name"
:
"getUserWatermark"
,
"version"
:
"1.0.0"
,
"lockfileVersion"
:
1
,
"requires"
:
true
,
"dependencies"
:
{
"user-common"
:
{
"version"
:
"file:../common/user-common"
}
}
}
take-order/uniCloud-tcb/cloudfunctions/getUserWatermark/package.json
0 → 100644
View file @
50a5e668
{
"name"
:
"getUserWatermark"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"keywords"
:
[],
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"user-common"
:
"file:../common/user-common"
}
}
take-order/uniCloud-tcb/cloudfunctions/saveImage/index.js
0 → 100644
View file @
50a5e668
'use strict'
;
const
{
getUserId
}
=
require
(
'user-common'
)
exports
.
main
=
async
(
event
,
context
)
=>
{
//event为客户端上传的参数
let
workerId
=
getUserId
(
event
.
token
)
if
(
workerId
)
{
await
uniCloud
.
database
().
collection
(
"user_upload_file"
).
add
({
"user_id"
:
workerId
,
"standard_id"
:
event
.
standardId
,
url
:
event
.
url
,
create_date
:
new
Date
()
})
return
true
}
return
false
};
take-order/uniCloud-tcb/cloudfunctions/saveImage/package.json
0 → 100644
View file @
50a5e668
{
"name"
:
"saveImage"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"keywords"
:
[],
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"user-common"
:
"file:../common/user-common"
}
}
take-order/uniCloud-tcb/cloudfunctions/saveUserWatermark/index.js
0 → 100644
View file @
50a5e668
'use strict'
;
const
{
getUserId
}
=
require
(
'user-common'
)
exports
.
main
=
async
(
event
,
context
)
=>
{
let
user_id
=
getUserId
(
event
.
token
)
const
watermark
=
event
.
watermark
user_id
=
'12312313'
if
(
user_id
)
{
watermark
.
user_id
=
user_id
const
collection
=
uniCloud
.
database
().
collection
(
"user_watermark"
);
const
res
=
await
collection
.
where
({
user_id
:
user_id
,
system_id
:
watermark
.
system_id
}).
get
()
if
(
res
.
data
&&
res
.
data
.
length
>
0
)
{
collection
.
doc
(
res
.
data
[
0
].
_id
).
update
(
watermark
)
}
else
{
collection
.
add
(
watermark
)
}
}
//返回数据给客户端
return
true
};
take-order/uniCloud-tcb/cloudfunctions/saveUserWatermark/package-lock.json
0 → 100644
View file @
50a5e668
{
"name"
:
"saveUserWatermark"
,
"version"
:
"1.0.0"
,
"lockfileVersion"
:
1
,
"requires"
:
true
,
"dependencies"
:
{
"user-common"
:
{
"version"
:
"file:../common/user-common"
}
}
}
take-order/uniCloud-tcb/cloudfunctions/saveUserWatermark/package.json
0 → 100644
View file @
50a5e668
{
"name"
:
"saveUserWatermark"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"keywords"
:
[],
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"user-common"
:
"file:../common/user-common"
}
}
take-order/uniCloud-tcb/cloudfunctions/saveUserWatermark/saveUserWatermark.param.json
0 → 100644
View file @
50a5e668
//
本文件中的json内容将在云函数【运行】时作为参数传给云函数。
//
配置教程参考:https
:
//uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"token"
:
"12312313"
,
"watermark"
:
{
"has_origin"
:
true
,
"lower_right"
:
{
"body"
:
[{
"watemark_text"
:
"时间"
,
"watemark_type"
:
"时间"
,
"watemark_value"
:
""
},
{
"watemark_text"
:
"地址"
,
"watemark_type"
:
"地址"
,
"watemark_value"
:
""
},
{
"watemark_text"
:
"经度"
,
"watemark_type"
:
"经度"
,
"watemark_value"
:
""
},
{
"watemark_text"
:
"纬度"
,
"watemark_type"
:
"纬度"
,
"watemark_value"
:
""
}],
"title_text"
:
"OR000000001111"
},
"mid_text"
:
"现场拍照"
,
"system_id"
:
"79550af260555cc20afb34156c94b32c"
,
"user_id"
:
""
}
}
take-order/uniCloud-tcb/database/db_init.json
View file @
50a5e668
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment