parent
78d1d8c247
commit
1b0bdcf27e
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
const path = require('path')
|
||||||
|
const yargs = require('yargs')
|
||||||
|
|
||||||
|
yargs
|
||||||
|
.usage('Usage: $0 -c [config] -o [output]')
|
||||||
|
.example('$0 -c ./svrkit.config.js -o ./svrkit-utils.js')
|
||||||
|
.alias('c', 'config')
|
||||||
|
.describe('c', 'svrkit config js file path')
|
||||||
|
.alias('o', 'output')
|
||||||
|
.describe('o', 'svrkit-utils output file path, defaults to svrkit-utils.js under the same folder of svrkit config file')
|
||||||
|
.describe('--keep-case', 'keeps field casing instead of converting to camcel case')
|
||||||
|
.demandOption(['c'])
|
||||||
|
.help('h')
|
||||||
|
.alias('h', 'help')
|
||||||
|
.argv
|
||||||
|
|
||||||
|
const cli = require(path.join(__dirname, '../cli/svrkit-utils.js'))
|
||||||
|
const ret = cli.main(process.argv.slice(2))
|
||||||
|
|
||||||
|
if (typeof ret === 'number') {
|
||||||
|
process.exit(ret)
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
|
||||||
|
function generate(options) {
|
||||||
|
if (!options) {
|
||||||
|
throw new Error('options must be provided')
|
||||||
|
}
|
||||||
|
|
||||||
|
const { serviceName, funcName, data } = options
|
||||||
|
|
||||||
|
const serviceConfig = config.find(c => c.serviceName === serviceName)
|
||||||
|
if (!serviceConfig) {
|
||||||
|
throw new Error('service not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!serviceConfig.functions[funcName]) {
|
||||||
|
throw new Error('function not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoName = serviceConfig.functions[funcName].req
|
||||||
|
const reqProto = proto[reqProtoName]
|
||||||
|
|
||||||
|
if (!reqProto) {
|
||||||
|
throw new Error('request proto not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const resProtoName = serviceConfig.functions[funcName].res
|
||||||
|
const resProto = resProtoName && proto[resProtoName]
|
||||||
|
|
||||||
|
const reqProtoVerifyErr = reqProto.verify(data)
|
||||||
|
if (reqProtoVerifyErr) {
|
||||||
|
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoJSON = protoJSON.nested[reqProtoName]
|
||||||
|
|
||||||
|
if (reqProtoJSON && reqProtoJSON.fields) {
|
||||||
|
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
|
||||||
|
for (const key in data) {
|
||||||
|
if (!reqProtoJSON.fields[key]) {
|
||||||
|
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('data must be object')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
serviceName,
|
||||||
|
funcName,
|
||||||
|
magic: serviceConfig.magic,
|
||||||
|
cmdid: serviceConfig.functions[funcName].cmdid,
|
||||||
|
existResp: Boolean(resProto),
|
||||||
|
reqBodyBuffer: reqProto.encode(data).finish(),
|
||||||
|
},
|
||||||
|
reqProto,
|
||||||
|
resProto,
|
||||||
|
decode: buf => resProto && resProto.decode(buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateV2(options) {
|
||||||
|
if (!options) {
|
||||||
|
throw new Error('options must be provided')
|
||||||
|
}
|
||||||
|
|
||||||
|
const { apiName, data } = options
|
||||||
|
|
||||||
|
const apiConfig = config.find(c => c.apiName === apiName)
|
||||||
|
|
||||||
|
const reqProtoName = apiConfig.req
|
||||||
|
const reqProto = proto[reqProtoName]
|
||||||
|
|
||||||
|
if (!reqProto) {
|
||||||
|
throw new Error('request proto not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const resProtoName = apiConfig.res
|
||||||
|
const resProto = proto[resProtoName]
|
||||||
|
|
||||||
|
const reqProtoVerifyErr = reqProto.verify(data)
|
||||||
|
if (reqProtoVerifyErr) {
|
||||||
|
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoJSON = protoJSON.nested[reqProtoName]
|
||||||
|
|
||||||
|
if (reqProtoJSON && reqProtoJSON.fields) {
|
||||||
|
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
|
||||||
|
for (const key in data) {
|
||||||
|
if (!reqProtoJSON.fields[key]) {
|
||||||
|
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('data must be object')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
apiName,
|
||||||
|
reqBodyBuffer: reqProto.encode(data).finish(),
|
||||||
|
},
|
||||||
|
reqProto,
|
||||||
|
resProto,
|
||||||
|
decode: buf => resProto && resProto.decode(buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
generate,
|
||||||
|
generateV2,
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const yargs = require('yargs')
|
||||||
|
const chalk = require('chalk')
|
||||||
|
const debug = require('debug')('cli')
|
||||||
|
const pbjs = require("protobufjs/cli/pbjs")
|
||||||
|
|
||||||
|
const log = (...msg) => {
|
||||||
|
console.log(chalk.blue('svrkit-utils'), ...msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
debug('process.cwd', process.cwd())
|
||||||
|
debug('yargs.argv', yargs.argv)
|
||||||
|
|
||||||
|
if (yargs.argv.config) {
|
||||||
|
const configPath = path.resolve(process.cwd(), yargs.argv.config)
|
||||||
|
const config = require(configPath)
|
||||||
|
|
||||||
|
const protos = config.map(c => path.resolve(path.dirname(configPath), c.proto))
|
||||||
|
|
||||||
|
if (yargs.argv.output) {
|
||||||
|
if (!yargs.argv.output.endsWith('.js')) {
|
||||||
|
throw new Error('output file name must ends with .js')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputDest = yargs.argv.output || path.resolve(path.dirname(configPath), 'svrkit-utils.js')
|
||||||
|
const outputFileName = path.basename(outputDest)
|
||||||
|
const outputFilePath = path.resolve(process.cwd(), outputDest)
|
||||||
|
|
||||||
|
debug('outputDest', outputDest)
|
||||||
|
debug('outputFilePath', outputFilePath)
|
||||||
|
|
||||||
|
const staticModuleFileName = `${outputFileName.slice(0, -3)}.static.js`
|
||||||
|
const staticModuleFilePath = path.resolve(path.dirname(outputFilePath), staticModuleFileName)
|
||||||
|
|
||||||
|
const staticJsonFileName = `${outputFileName.slice(0, -3)}.static.json`
|
||||||
|
const staticJsonFilePath = path.resolve(path.dirname(outputFilePath), staticJsonFileName)
|
||||||
|
|
||||||
|
log('generating static module')
|
||||||
|
const pbjsArgs = ['-t', 'static-module', '-w', 'commonjs', '-l', 'eslint-disable', '-o', staticModuleFilePath, ...protos]
|
||||||
|
|
||||||
|
if (yargs.argv.keepCase) {
|
||||||
|
pbjsArgs.unshift('--keep-case')
|
||||||
|
}
|
||||||
|
|
||||||
|
pbjs.main(pbjsArgs, (err, out) => {
|
||||||
|
if (err) {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
|
||||||
|
let staticModuleContent = fs.readFileSync(staticModuleFilePath, 'utf8')
|
||||||
|
fs.writeFileSync(staticModuleFilePath, `// #lizard forgives
|
||||||
|
${staticModuleContent}`, 'utf8')
|
||||||
|
|
||||||
|
log('static module generated')
|
||||||
|
|
||||||
|
log('generating json descriptors')
|
||||||
|
pbjs.main(['-t', 'json', '-o', staticJsonFilePath, ...protos], (err, out) => {
|
||||||
|
if (err) {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
|
||||||
|
log('json descriptors generated')
|
||||||
|
|
||||||
|
try {
|
||||||
|
const protoUtils = fs.readFileSync(path.join(__dirname, './svrkit-utils-template.js'), 'utf8')
|
||||||
|
|
||||||
|
let svrkitConfigRelativePath = path.relative(path.dirname(outputDest), configPath)
|
||||||
|
if (!svrkitConfigRelativePath.startsWith('.')) {
|
||||||
|
svrkitConfigRelativePath = `./${svrkitConfigRelativePath}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = `
|
||||||
|
const config = require('${svrkitConfigRelativePath}')
|
||||||
|
const proto = require('./${staticModuleFileName}')
|
||||||
|
const protoJSON = require('./${staticJsonFileName}')
|
||||||
|
${protoUtils}
|
||||||
|
`
|
||||||
|
|
||||||
|
fs.writeFileSync(outputFilePath, output, 'utf8')
|
||||||
|
|
||||||
|
log(`${outputFileName} generated`)
|
||||||
|
} catch (err) {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
throw new Error('config file must be provided')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
main,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "@tencent/cloud-functions-tools",
|
||||||
|
"version": "1.5.1",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "alankldeng",
|
||||||
|
"license": "ISC",
|
||||||
|
"bin": {
|
||||||
|
"svrkit-utils": "bin/svrkit-utils"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"chalk": "^2.4.1",
|
||||||
|
"debug": "^4.1.0",
|
||||||
|
"protobufjs": "^6.8.8",
|
||||||
|
"yargs": "^12.0.5"
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
|
|||||||
|
const config = require('./svrkit.config.js')
|
||||||
|
const proto = require('./bundle.js')
|
||||||
|
|
||||||
|
function generate(options) {
|
||||||
|
if (!options) {
|
||||||
|
throw new Error('options must be provided')
|
||||||
|
}
|
||||||
|
|
||||||
|
const { serviceName, funcName, data } = options
|
||||||
|
|
||||||
|
const serviceConfig = config.find(c => c.serviceName === serviceName)
|
||||||
|
if (!serviceConfig) {
|
||||||
|
throw new Error('service not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!serviceConfig.functions[funcName]) {
|
||||||
|
throw new Error('function not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProto = proto[serviceConfig.functions[funcName].req]
|
||||||
|
const resProto = proto[serviceConfig.functions[funcName].res]
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
serviceName,
|
||||||
|
funcName,
|
||||||
|
magic: serviceConfig.magic,
|
||||||
|
cmdid: serviceConfig.functions[funcName].cmdid,
|
||||||
|
existResp: serviceConfig.functions[funcName].existResp,
|
||||||
|
reqBodyBuffer: reqProto.encode(data),
|
||||||
|
},
|
||||||
|
decode: buf => resProto.decode(resProto)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
generate,
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
message ApiDemoReq
|
||||||
|
{
|
||||||
|
optional string str = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ApiDemoResp
|
||||||
|
{
|
||||||
|
optional string str = 2;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
message GetWeAppMemberByUserReq
|
||||||
|
{
|
||||||
|
optional uint32 useruin = 1;
|
||||||
|
optional uint32 type = 2; //1:管理员 2:运营者 3:开发人员 4:体验者
|
||||||
|
optional uint32 status = 3; //SAFECENTER_WEAPP_STATUS_XXX
|
||||||
|
}
|
||||||
|
message WeAppMemberInfo
|
||||||
|
{
|
||||||
|
optional uint32 type = 1;
|
||||||
|
optional uint32 weappuin = 2;
|
||||||
|
optional uint32 useruin = 3;
|
||||||
|
optional uint32 status = 4;
|
||||||
|
optional uint32 createtime = 5;
|
||||||
|
optional uint32 updatetime = 6;
|
||||||
|
optional string ticket = 7;
|
||||||
|
}
|
||||||
|
message WeAppMemberInfoList
|
||||||
|
{
|
||||||
|
repeated WeAppMemberInfo infos = 1;
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
message GenWxaCloudTmpCodeReq
|
||||||
|
{
|
||||||
|
optional uint32 CloudPlatform = 1;
|
||||||
|
optional uint32 AppUin = 2;
|
||||||
|
optional uint32 UserUin = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GenWxaCloudTmpCodeResp
|
||||||
|
{
|
||||||
|
optional string TmpCode = 1;
|
||||||
|
}
|
@ -0,0 +1,119 @@
|
|||||||
|
|
||||||
|
const config = require('./svrkit.config.js')
|
||||||
|
const proto = require('./svrkit-utils.static.js')
|
||||||
|
const protoJSON = require('./svrkit-utils.static.json')
|
||||||
|
|
||||||
|
function generate(options) {
|
||||||
|
if (!options) {
|
||||||
|
throw new Error('options must be provided')
|
||||||
|
}
|
||||||
|
|
||||||
|
const { serviceName, funcName, data } = options
|
||||||
|
|
||||||
|
const serviceConfig = config.find(c => c.serviceName === serviceName)
|
||||||
|
if (!serviceConfig) {
|
||||||
|
throw new Error('service not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!serviceConfig.functions[funcName]) {
|
||||||
|
throw new Error('function not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoName = serviceConfig.functions[funcName].req
|
||||||
|
const reqProto = proto[reqProtoName]
|
||||||
|
|
||||||
|
if (!reqProto) {
|
||||||
|
throw new Error('request proto not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const resProtoName = serviceConfig.functions[funcName].res
|
||||||
|
const resProto = resProtoName && proto[resProtoName]
|
||||||
|
|
||||||
|
const reqProtoVerifyErr = reqProto.verify(data)
|
||||||
|
if (reqProtoVerifyErr) {
|
||||||
|
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoJSON = protoJSON.nested[reqProtoName]
|
||||||
|
|
||||||
|
if (reqProtoJSON && reqProtoJSON.fields) {
|
||||||
|
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
|
||||||
|
for (const key in data) {
|
||||||
|
if (!reqProtoJSON.fields[key]) {
|
||||||
|
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('data must be object')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
serviceName,
|
||||||
|
funcName,
|
||||||
|
magic: serviceConfig.magic,
|
||||||
|
cmdid: serviceConfig.functions[funcName].cmdid,
|
||||||
|
existResp: Boolean(resProto),
|
||||||
|
reqBodyBuffer: reqProto.encode(data).finish(),
|
||||||
|
},
|
||||||
|
reqProto,
|
||||||
|
resProto,
|
||||||
|
decode: buf => resProto && resProto.decode(buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateV2(options) {
|
||||||
|
if (!options) {
|
||||||
|
throw new Error('options must be provided')
|
||||||
|
}
|
||||||
|
|
||||||
|
const { apiName, data } = options
|
||||||
|
|
||||||
|
const apiConfig = config.find(c => c.apiName === apiName)
|
||||||
|
|
||||||
|
const reqProtoName = apiConfig.req
|
||||||
|
const reqProto = proto[reqProtoName]
|
||||||
|
|
||||||
|
if (!reqProto) {
|
||||||
|
throw new Error('request proto not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const resProtoName = apiConfig.res
|
||||||
|
const resProto = proto[resProtoName]
|
||||||
|
|
||||||
|
const reqProtoVerifyErr = reqProto.verify(data)
|
||||||
|
if (reqProtoVerifyErr) {
|
||||||
|
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoJSON = protoJSON.nested[reqProtoName]
|
||||||
|
|
||||||
|
if (reqProtoJSON && reqProtoJSON.fields) {
|
||||||
|
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
|
||||||
|
for (const key in data) {
|
||||||
|
if (!reqProtoJSON.fields[key]) {
|
||||||
|
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('data must be object')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
apiName,
|
||||||
|
reqBodyBuffer: reqProto.encode(data).finish(),
|
||||||
|
},
|
||||||
|
reqProto,
|
||||||
|
resProto,
|
||||||
|
decode: buf => resProto && resProto.decode(buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
generate,
|
||||||
|
generateV2,
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,101 @@
|
|||||||
|
{
|
||||||
|
"nested": {
|
||||||
|
"ApiDemoReq": {
|
||||||
|
"fields": {
|
||||||
|
"str": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ApiDemoResp": {
|
||||||
|
"fields": {
|
||||||
|
"str": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenWxaCloudTmpCodeReq": {
|
||||||
|
"fields": {
|
||||||
|
"CloudPlatform": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"AppUin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"UserUin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenWxaCloudTmpCodeResp": {
|
||||||
|
"fields": {
|
||||||
|
"TmpCode": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GetWeAppMemberByUserReq": {
|
||||||
|
"fields": {
|
||||||
|
"useruin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WeAppMemberInfo": {
|
||||||
|
"fields": {
|
||||||
|
"type": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"weappuin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"useruin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 3
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 4
|
||||||
|
},
|
||||||
|
"createtime": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 5
|
||||||
|
},
|
||||||
|
"updatetime": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 6
|
||||||
|
},
|
||||||
|
"ticket": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WeAppMemberInfoList": {
|
||||||
|
"fields": {
|
||||||
|
"infos": {
|
||||||
|
"rule": "repeated",
|
||||||
|
"type": "WeAppMemberInfo",
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
proto: './proto/demo.proto',
|
||||||
|
apiName: 'demo',
|
||||||
|
req: 'ApiDemoReq',
|
||||||
|
res: 'ApiDemoResp'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
proto: './proto/mmbizwxatmpcode.proto',
|
||||||
|
serviceName: 'MMBizWxaCloud',
|
||||||
|
magic: 13299,
|
||||||
|
functions: {
|
||||||
|
GenWxaCloudTmpCode: {
|
||||||
|
cmdid: 3,
|
||||||
|
req: 'GenWxaCloudTmpCodeReq',
|
||||||
|
res: 'GenWxaCloudTmpCodeResp',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
proto: './proto/mmbizsafecenter.proto',
|
||||||
|
serviceName: 'mmbizsafecenter',
|
||||||
|
magic: 12085,
|
||||||
|
functions: {
|
||||||
|
GetWeAppMemberByUser: {
|
||||||
|
cmdid: 73,
|
||||||
|
req: 'GetWeAppMemberByUserReq',
|
||||||
|
res: 'WeAppMemberInfoList',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"openapi": [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
// 云函数入口文件
|
||||||
|
const cloud = require('wx-server-sdk')
|
||||||
|
const wxgService = require('./wx-server-sdk-wxg-service')
|
||||||
|
const svrkitUtils = require('./svrkit-utils.js')
|
||||||
|
|
||||||
|
cloud.registerService(wxgService)
|
||||||
|
cloud.init()
|
||||||
|
|
||||||
|
// 云函数入口函数
|
||||||
|
exports.main = async (event, context) => {
|
||||||
|
const wxContext = cloud.getWXContext()
|
||||||
|
const bizuin = wxContext.APPUIN
|
||||||
|
switch (event.type) {
|
||||||
|
case "GenerateARModel":
|
||||||
|
return await cloud.callWXSvrkit({
|
||||||
|
pbInstance: svrkitUtils.generate({
|
||||||
|
serviceName: "Mmbizwxaintpar",
|
||||||
|
funcName: "GenerateARModel",
|
||||||
|
data: {
|
||||||
|
bizuin: bizuin,
|
||||||
|
name: event.name,
|
||||||
|
url: event.url,
|
||||||
|
algoType: event.algoType,
|
||||||
|
getmesh: event.getMesh,
|
||||||
|
gettexture: event.getTexture
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
timeout: 30000,
|
||||||
|
});
|
||||||
|
case "GetARModel":
|
||||||
|
return await cloud.callWXSvrkit({
|
||||||
|
pbInstance: svrkitUtils.generate({
|
||||||
|
serviceName: "Mmbizwxaintpar",
|
||||||
|
funcName: "GetARModel",
|
||||||
|
data: {
|
||||||
|
bizuin: bizuin,
|
||||||
|
cosid: event.cosid,
|
||||||
|
modelType: event.modelType,
|
||||||
|
needData: event.needData,
|
||||||
|
useIntranet: event.useIntranet,
|
||||||
|
expireTime: event.expireTime
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
timeout: 30000,
|
||||||
|
});
|
||||||
|
// GetARModelList 废弃,完全依赖本地缓存
|
||||||
|
// case "GetARModelList":
|
||||||
|
// return await cloud.callWXSvrkit({
|
||||||
|
// pbInstance: svrkitUtils.generate({
|
||||||
|
// serviceName: "Mmbizwxaintpar",
|
||||||
|
// funcName: "GetARModelList",
|
||||||
|
// data: {
|
||||||
|
// bizuin: bizuin,
|
||||||
|
// modelStatus: event.modelStatus,
|
||||||
|
// algoType: event.algoType
|
||||||
|
// },
|
||||||
|
// }),
|
||||||
|
// timeout: 30000,
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "ARDemo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"svrkit": "svrkit-utils --config ./svrkit.config.js --output ./svrkit-utils.js"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"wx-server-sdk": "^2.6.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tencent/cloud-functions-tools": "^1.7.0"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
enum enARModelStatus
|
||||||
|
{
|
||||||
|
ARModel_Status_Default = 0;
|
||||||
|
ARModel_Status_Init = 1;
|
||||||
|
ARModel_Status_Sparse_Finished = 2;
|
||||||
|
ARModel_Status_3d_Finished = 3;
|
||||||
|
ARModel_Status_Object_Finished = 4;
|
||||||
|
ARModel_Status_Marker_Finished = 5;
|
||||||
|
ARModel_Status_Fail = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum enARAlgorithmType
|
||||||
|
{
|
||||||
|
Algorithm_Type_3D_Object = 1;
|
||||||
|
Algorithm_Type_3D_Marker = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum enARModelType
|
||||||
|
{
|
||||||
|
ARModel_Type_Sparse = 1;
|
||||||
|
ARModel_Type_3D = 2;
|
||||||
|
ARModel_Type_Marker = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ModelCos
|
||||||
|
{
|
||||||
|
message ModelCosId
|
||||||
|
{
|
||||||
|
optional enARModelType model_type = 1;
|
||||||
|
optional string model_cosid = 2;
|
||||||
|
optional string errmsg = 3;
|
||||||
|
}
|
||||||
|
repeated ModelCosId model_list = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ARModel
|
||||||
|
{
|
||||||
|
//option(mmbizintpkv.KvTableID) = 493;
|
||||||
|
option(mmbizintpkv.KvTableTestID) = 916;
|
||||||
|
optional string cosid = 1; // 原始文件的cosid
|
||||||
|
optional uint32 bizuin = 2;
|
||||||
|
optional string name = 3; // 原始文件的名称
|
||||||
|
optional uint32 upload_time = 4;
|
||||||
|
optional enARModelStatus model_status = 5;
|
||||||
|
optional enARAlgorithmType algo_type = 6;
|
||||||
|
optional ModelCos model_cos = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetARModelListReq
|
||||||
|
{
|
||||||
|
optional uint32 bizuin = 1;
|
||||||
|
optional uint32 model_status = 2; // enARModelStatus
|
||||||
|
optional uint32 start_time = 3;
|
||||||
|
optional uint32 end_time = 4;
|
||||||
|
optional uint32 offset = 5;
|
||||||
|
optional uint32 limit = 6;
|
||||||
|
optional uint32 algo_type = 7; // enARAlgorithmType
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetARModelListResp
|
||||||
|
{
|
||||||
|
repeated ARModel model_list = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message GenerateARModelReq
|
||||||
|
{
|
||||||
|
optional uint32 bizuin = 1;
|
||||||
|
optional string name = 2;
|
||||||
|
optional bytes buffer = 3;
|
||||||
|
optional string url = 4;
|
||||||
|
optional enARAlgorithmType algo_type = 5;
|
||||||
|
optional uint32 lod = 6[default=0]; // 重建模型精度, 最高精度为0, 取1,2,3时精度依次下降
|
||||||
|
optional bool getmesh = 7[default=false];
|
||||||
|
optional bool gettexture = 8[default=false];
|
||||||
|
}
|
||||||
|
|
||||||
|
message GenerateARModelResp
|
||||||
|
{
|
||||||
|
optional string url = 1;
|
||||||
|
optional string host = 2;
|
||||||
|
optional string cosid = 3;
|
||||||
|
optional uint32 lod = 4[default=0];
|
||||||
|
optional bool getmesh = 5[default=false];
|
||||||
|
optional bool gettexture = 6[default=false];
|
||||||
|
}
|
||||||
|
|
||||||
|
message ARModelData
|
||||||
|
{
|
||||||
|
optional bytes mesh_model = 1; // 文本(点面信息)
|
||||||
|
optional bytes texture_model = 2; // 图像png
|
||||||
|
optional bytes preview = 3;
|
||||||
|
optional bytes mesh_blob = 4; // obj二进制, getmesh = true时返回
|
||||||
|
optional bytes texture_blob = 5; // 纹理二进制, gettexture = true时返回
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetARModelReq
|
||||||
|
{
|
||||||
|
optional uint32 bizuin = 1;
|
||||||
|
optional string cosid = 2;
|
||||||
|
optional uint32 model_type = 3; // 1:稀疏点云 2:3d模型
|
||||||
|
optional uint32 need_data = 4[default=1]; // 0:不需要数据 1:需要数据
|
||||||
|
optional uint32 use_intranet = 5[default=0]; // 当need_data为0时生效 0:生成外网链接 1:内网链接
|
||||||
|
optional uint32 expire_time = 6; // url过期时间,默认5分钟,单位为秒
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetARModelResp
|
||||||
|
{
|
||||||
|
optional ARModelData model_data = 1;
|
||||||
|
optional string url = 2;
|
||||||
|
optional string host = 3;
|
||||||
|
optional string errMsg = 4;
|
||||||
|
optional uint32 expire_time = 5;
|
||||||
|
optional uint32 status = 6; // 0 创建中 1 成功 2 失败
|
||||||
|
}
|
@ -0,0 +1,136 @@
|
|||||||
|
|
||||||
|
const config = require('./svrkit.config.js')
|
||||||
|
const proto = require('./svrkit-utils.static.js')
|
||||||
|
const protoJSON = require('./svrkit-utils.static.json')
|
||||||
|
function getProto(proto, serviceName, protoName) {
|
||||||
|
if (proto[protoName]) {
|
||||||
|
return proto[protoName];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proto[serviceName] && proto[serviceName][protoName]) {
|
||||||
|
return proto[serviceName][protoName];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理 mmpayolcirclemodel.QueryActivityReq 的形式*/
|
||||||
|
const [realServiceName, realProtoName] = protoName.split('.')
|
||||||
|
if (proto[realServiceName]) {
|
||||||
|
return proto[realServiceName][realProtoName]
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate(options) {
|
||||||
|
if (!options) {
|
||||||
|
throw new Error('options must be provided')
|
||||||
|
}
|
||||||
|
|
||||||
|
const { serviceName, funcName, data } = options
|
||||||
|
|
||||||
|
const serviceConfig = config.find(c => c.serviceName === serviceName)
|
||||||
|
if (!serviceConfig) {
|
||||||
|
throw new Error('service not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!serviceConfig.functions[funcName]) {
|
||||||
|
throw new Error('function not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoName = serviceConfig.functions[funcName].req
|
||||||
|
const reqProto = getProto(proto, serviceName, reqProtoName);
|
||||||
|
|
||||||
|
if (!reqProto) {
|
||||||
|
throw new Error('request proto not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const resProtoName = serviceConfig.functions[funcName].res
|
||||||
|
const resProto = resProtoName && getProto(proto, serviceName, resProtoName);
|
||||||
|
|
||||||
|
const reqProtoVerifyErr = reqProto.verify(data)
|
||||||
|
if (reqProtoVerifyErr) {
|
||||||
|
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoJSON = protoJSON.nested[reqProtoName]
|
||||||
|
|
||||||
|
if (reqProtoJSON && reqProtoJSON.fields) {
|
||||||
|
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
|
||||||
|
for (const key in data) {
|
||||||
|
if (!reqProtoJSON.fields[key]) {
|
||||||
|
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('data must be object')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
serviceName,
|
||||||
|
funcName,
|
||||||
|
magic: serviceConfig.magic,
|
||||||
|
cmdid: serviceConfig.functions[funcName].cmdid,
|
||||||
|
existResp: Boolean(resProto),
|
||||||
|
reqBodyBuffer: reqProto.encode(data).finish(),
|
||||||
|
},
|
||||||
|
reqProto,
|
||||||
|
resProto,
|
||||||
|
decode: buf => resProto && resProto.decode(buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateV2(options) {
|
||||||
|
if (!options) {
|
||||||
|
throw new Error('options must be provided')
|
||||||
|
}
|
||||||
|
|
||||||
|
const { apiName, data } = options
|
||||||
|
|
||||||
|
const apiConfig = config.find(c => c.apiName === apiName)
|
||||||
|
|
||||||
|
const reqProtoName = apiConfig.req
|
||||||
|
const reqProto = proto[reqProtoName]
|
||||||
|
|
||||||
|
if (!reqProto) {
|
||||||
|
throw new Error('request proto not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
const resProtoName = apiConfig.res
|
||||||
|
const resProto = proto[resProtoName]
|
||||||
|
|
||||||
|
const reqProtoVerifyErr = reqProto.verify(data)
|
||||||
|
if (reqProtoVerifyErr) {
|
||||||
|
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const reqProtoJSON = protoJSON.nested[reqProtoName]
|
||||||
|
|
||||||
|
if (reqProtoJSON && reqProtoJSON.fields) {
|
||||||
|
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
|
||||||
|
for (const key in data) {
|
||||||
|
if (!reqProtoJSON.fields[key]) {
|
||||||
|
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('data must be object')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
apiName,
|
||||||
|
reqBodyBuffer: reqProto.encode(data).finish(),
|
||||||
|
},
|
||||||
|
reqProto,
|
||||||
|
resProto,
|
||||||
|
decode: buf => resProto && resProto.decode(buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
generate,
|
||||||
|
generateV2,
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,299 @@
|
|||||||
|
{
|
||||||
|
"nested": {
|
||||||
|
"enARModelStatus": {
|
||||||
|
"values": {
|
||||||
|
"ARModel_Status_Default": 0,
|
||||||
|
"ARModel_Status_Init": 1,
|
||||||
|
"ARModel_Status_Sparse_Finished": 2,
|
||||||
|
"ARModel_Status_3d_Finished": 3,
|
||||||
|
"ARModel_Status_Object_Finished": 4,
|
||||||
|
"ARModel_Status_Marker_Finished": 5,
|
||||||
|
"ARModel_Status_Fail": 100
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"enARAlgorithmType": {
|
||||||
|
"values": {
|
||||||
|
"Algorithm_Type_3D_Object": 1,
|
||||||
|
"Algorithm_Type_3D_Marker": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"enARModelType": {
|
||||||
|
"values": {
|
||||||
|
"ARModel_Type_Sparse": 1,
|
||||||
|
"ARModel_Type_3D": 2,
|
||||||
|
"ARModel_Type_Marker": 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ModelCos": {
|
||||||
|
"fields": {
|
||||||
|
"modelList": {
|
||||||
|
"rule": "repeated",
|
||||||
|
"type": "ModelCosId",
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nested": {
|
||||||
|
"ModelCosId": {
|
||||||
|
"fields": {
|
||||||
|
"modelType": {
|
||||||
|
"type": "enARModelType",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"modelCosid": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"errmsg": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ARModel": {
|
||||||
|
"options": {
|
||||||
|
"(mmbizintpkv.KvTableTestID)": 916
|
||||||
|
},
|
||||||
|
"fields": {
|
||||||
|
"cosid": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"bizuin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 3
|
||||||
|
},
|
||||||
|
"uploadTime": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 4
|
||||||
|
},
|
||||||
|
"modelStatus": {
|
||||||
|
"type": "enARModelStatus",
|
||||||
|
"id": 5
|
||||||
|
},
|
||||||
|
"algoType": {
|
||||||
|
"type": "enARAlgorithmType",
|
||||||
|
"id": 6
|
||||||
|
},
|
||||||
|
"modelCos": {
|
||||||
|
"type": "ModelCos",
|
||||||
|
"id": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GetARModelListReq": {
|
||||||
|
"fields": {
|
||||||
|
"bizuin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"modelStatus": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"startTime": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 3
|
||||||
|
},
|
||||||
|
"endTime": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 4
|
||||||
|
},
|
||||||
|
"offset": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 5
|
||||||
|
},
|
||||||
|
"limit": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 6
|
||||||
|
},
|
||||||
|
"algoType": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GetARModelListResp": {
|
||||||
|
"fields": {
|
||||||
|
"modelList": {
|
||||||
|
"rule": "repeated",
|
||||||
|
"type": "ARModel",
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenerateARModelReq": {
|
||||||
|
"fields": {
|
||||||
|
"bizuin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"buffer": {
|
||||||
|
"type": "bytes",
|
||||||
|
"id": 3
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 4
|
||||||
|
},
|
||||||
|
"algoType": {
|
||||||
|
"type": "enARAlgorithmType",
|
||||||
|
"id": 5
|
||||||
|
},
|
||||||
|
"lod": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 6,
|
||||||
|
"options": {
|
||||||
|
"default": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"getmesh": {
|
||||||
|
"type": "bool",
|
||||||
|
"id": 7,
|
||||||
|
"options": {
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gettexture": {
|
||||||
|
"type": "bool",
|
||||||
|
"id": 8,
|
||||||
|
"options": {
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenerateARModelResp": {
|
||||||
|
"fields": {
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"cosid": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 3
|
||||||
|
},
|
||||||
|
"lod": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 4,
|
||||||
|
"options": {
|
||||||
|
"default": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"getmesh": {
|
||||||
|
"type": "bool",
|
||||||
|
"id": 5,
|
||||||
|
"options": {
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gettexture": {
|
||||||
|
"type": "bool",
|
||||||
|
"id": 6,
|
||||||
|
"options": {
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ARModelData": {
|
||||||
|
"fields": {
|
||||||
|
"meshModel": {
|
||||||
|
"type": "bytes",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"textureModel": {
|
||||||
|
"type": "bytes",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
"type": "bytes",
|
||||||
|
"id": 3
|
||||||
|
},
|
||||||
|
"meshBlob": {
|
||||||
|
"type": "bytes",
|
||||||
|
"id": 4
|
||||||
|
},
|
||||||
|
"textureBlob": {
|
||||||
|
"type": "bytes",
|
||||||
|
"id": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GetARModelReq": {
|
||||||
|
"fields": {
|
||||||
|
"bizuin": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"cosid": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"modelType": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 3
|
||||||
|
},
|
||||||
|
"needData": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 4,
|
||||||
|
"options": {
|
||||||
|
"default": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"useIntranet": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 5,
|
||||||
|
"options": {
|
||||||
|
"default": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expireTime": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GetARModelResp": {
|
||||||
|
"fields": {
|
||||||
|
"modelData": {
|
||||||
|
"type": "ARModelData",
|
||||||
|
"id": 1
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 3
|
||||||
|
},
|
||||||
|
"errMsg": {
|
||||||
|
"type": "string",
|
||||||
|
"id": 4
|
||||||
|
},
|
||||||
|
"expireTime": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 5
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "uint32",
|
||||||
|
"id": 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
// 模块导出一个数组,每个元素是一个模块配置项
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
// 模块对应的 proto 文件相对于该文件的路径
|
||||||
|
proto: './proto/mmbizwxaintparDemo.proto',
|
||||||
|
// 模块 service name
|
||||||
|
serviceName: 'Mmbizwxaintpar',
|
||||||
|
// 模块 magic 数字
|
||||||
|
magic: 11081,
|
||||||
|
// 模块导出的接口方法
|
||||||
|
functions: {
|
||||||
|
// 接口名字及其对应的接口调用信息
|
||||||
|
GenerateARModel: {
|
||||||
|
// 接口的 cmdid
|
||||||
|
cmdid: 1,
|
||||||
|
// 接口的 request 对应的 protobuf message 名字,需在 proto 文件中定义
|
||||||
|
req: 'GenerateARModelReq',
|
||||||
|
// 接口的 response 对应的 protobuf message 名字,需在 proto 文件中定义
|
||||||
|
res: 'GenerateARModelResp',
|
||||||
|
},
|
||||||
|
// 接口的名字及其对应的接口调用信息
|
||||||
|
GetARModelList: {
|
||||||
|
cmdid: 3,
|
||||||
|
req: 'GetARModelListReq',
|
||||||
|
res: 'GetARModelListResp',
|
||||||
|
},
|
||||||
|
GetARModel: {
|
||||||
|
cmdid: 4,
|
||||||
|
req: 'GetARModelReq',
|
||||||
|
res: 'GetARModelResp',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,12 @@
|
|||||||
|
## 0.6.0
|
||||||
|
|
||||||
|
1. `A` 新增 `callWXSvrkit` 支持传入 `headuin` 和 `routeMethod`
|
||||||
|
|
||||||
|
## 0.2.0
|
||||||
|
|
||||||
|
1. `A` 新增 `callTencentInnerAPI` 内部接口
|
||||||
|
|
||||||
|
## 0.1.0
|
||||||
|
|
||||||
|
1. `A` 新增 `callWXSvrkit` 内部接口
|
||||||
|
2. `A` 新增 `callWXInnerAPI` 内部接口
|
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 wechat-miniprogram
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "@tencent/wx-server-sdk-wxg-service",
|
||||||
|
"version": "0.7.0",
|
||||||
|
"description": "wxg service plugin for mini program cloud server sdk",
|
||||||
|
"main": "index.js",
|
||||||
|
"author": "wechat mini program team",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^1.9.3"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
// 云函数入口文件
|
||||||
|
const cloud = require('wx-server-sdk')
|
||||||
|
|
||||||
|
// 云函数入口函数
|
||||||
|
exports.main = async () => {
|
||||||
|
cloud.init({
|
||||||
|
env: process.env.TCB_ENV,
|
||||||
|
})
|
||||||
|
const db = cloud.database()
|
||||||
|
return db.collection('perm4').where({
|
||||||
|
_openid: 'server'
|
||||||
|
}).limit(1).get()
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "getServerDataDemo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"wx-server-sdk": "latest"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
// 云函数入口文件
|
||||||
|
const cloud = require('wx-server-sdk')
|
||||||
|
|
||||||
|
// 云函数入口函数
|
||||||
|
exports.main = async (event) => {
|
||||||
|
cloud.init({
|
||||||
|
env: process.env.TCB_ENV,
|
||||||
|
})
|
||||||
|
const fileList = event.fileIdList
|
||||||
|
const result = await cloud.getTempFileURL({
|
||||||
|
fileList,
|
||||||
|
})
|
||||||
|
return result.fileList
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "getTempFileURL",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"wx-server-sdk": "latest"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
exports.main = (event) => ({
|
||||||
|
openid: event.userInfo.openId,
|
||||||
|
})
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "login",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"wx-server-sdk": "latest"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
// 云函数入口文件
|
||||||
|
const cloud = require('wx-server-sdk')
|
||||||
|
|
||||||
|
|
||||||
|
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
|
||||||
|
|
||||||
|
// 云函数入口函数
|
||||||
|
exports.main = async (event, context) => {
|
||||||
|
const wxContext = cloud.getWXContext()
|
||||||
|
|
||||||
|
if (event.op == "")
|
||||||
|
|
||||||
|
return {
|
||||||
|
event,
|
||||||
|
openid: wxContext.OPENID,
|
||||||
|
appid: wxContext.APPID,
|
||||||
|
unionid: wxContext.UNIONID,
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"openapi": [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
// 云函数入口文件
|
||||||
|
const cloud = require('wx-server-sdk')
|
||||||
|
|
||||||
|
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
|
||||||
|
const db = wx.cloud.database().collection("orders")
|
||||||
|
const wxContext = cloud.getWXContext()
|
||||||
|
|
||||||
|
// 云函数入口函数
|
||||||
|
exports.main = async () => {
|
||||||
|
|
||||||
|
const result;
|
||||||
|
db.where({
|
||||||
|
_openid: wxContext.OPENID
|
||||||
|
}).get({
|
||||||
|
success: function (res) {
|
||||||
|
result = res
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
// 云函数入口文件
|
||||||
|
// const cloud = require('wx-server-sdk')
|
||||||
|
const get = require("./get")
|
||||||
|
const add = require("./add")
|
||||||
|
|
||||||
|
// cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
|
||||||
|
|
||||||
|
// 云函数入口函数
|
||||||
|
exports.main = async (event, context) => {
|
||||||
|
// const wxContext = cloud.getWXContext()
|
||||||
|
|
||||||
|
if (event.op == "get") {
|
||||||
|
return await get.main();
|
||||||
|
} else if(event.op == "add") {
|
||||||
|
add()
|
||||||
|
//TODO add paramas
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "orders",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"wx-server-sdk": "~2.6.3"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
// components/grid-tile/index.js
|
||||||
|
Component({
|
||||||
|
/**
|
||||||
|
* 组件的属性列表
|
||||||
|
*/
|
||||||
|
properties: {
|
||||||
|
height: {
|
||||||
|
type: Number,
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
index: {
|
||||||
|
type: Number,
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的方法列表
|
||||||
|
*/
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<view class="center" style="width: 100%; height: {{height}}px; background-color: #6bbc7a;">
|
||||||
|
<view class="center" style="width: 60px; height: 60px; border-radius: 30px; background-color: white; color: black;">
|
||||||
|
{{index}}
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,10 @@
|
|||||||
|
/* components/grid-tile/index.wxss */
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
text-align: center;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<view class="navigation-bar">
|
||||||
|
<view class="navigation-bar__inner {{ios ? 'ios' : 'android'}}" style="margin-top: {{statusBarHeight}}px; color: {{color}};background: {{background}}">
|
||||||
|
<view class='navigation-bar__left' style="width: {{sideWidth}}px;">
|
||||||
|
<block wx:if="{{back}}">
|
||||||
|
<view class="navigation-bar__buttons" bindtap="back" >
|
||||||
|
<image class="navigation-bar__button navigation-bar__btn_goback" hover-class="active" src="../../images/back-arrow.png"></image>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
<block wx:else>
|
||||||
|
<slot name="left"></slot>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
<view class="navigation-bar__center {{title ? 'title' : ''}}">
|
||||||
|
<view wx:if="{{loading}}" class="navigation-bar__loading">
|
||||||
|
<view class="loading"></view>
|
||||||
|
</view>
|
||||||
|
<block wx:if="{{title}}">{{title}}</block>
|
||||||
|
<block wx:else>
|
||||||
|
<slot name="center"></slot>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
<view class='navigation-bar__right' style="width: {{sideWidth}}px;">
|
||||||
|
<slot name="right"></slot>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,75 @@
|
|||||||
|
.navigation-bar {
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar .android {
|
||||||
|
height: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner {
|
||||||
|
height: 44px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__left {
|
||||||
|
position: relative;
|
||||||
|
padding-left: 16px;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__left .navigation-bar__buttons {
|
||||||
|
height: 100%;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__left .navigation-bar__btn {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
height: 100%;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__left .navigation-bar__btn_goback {
|
||||||
|
width: 8px;
|
||||||
|
height: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__center {
|
||||||
|
font-size: 17px;
|
||||||
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__center.title {
|
||||||
|
display: inline-block;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__loading {
|
||||||
|
margin-right: 4px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__loading .loading {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation-bar__inner .navigation-bar__right {
|
||||||
|
padding-right: 16px;
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
var globalThis = this, self = this;
|
||||||
|
module.exports =
|
||||||
|
require("../../_commons/0.js")([
|
||||||
|
{
|
||||||
|
"ids": [6],
|
||||||
|
"modules":{
|
||||||
|
|
||||||
|
/***/ "./node_modules/@mpflow/webpack-plugin/lib/loaders/page-loader.js?appContext=src&outputPath=components%2Fpage-scroll%2Findex!./src/components/page-scroll/index.ts":
|
||||||
|
/*!*************************************************************************************************************************************************************************!*\
|
||||||
|
!*** ./node_modules/@mpflow/webpack-plugin/lib/loaders/page-loader.js?appContext=src&outputPath=components%2Fpage-scroll%2Findex!./src/components/page-scroll/index.ts ***!
|
||||||
|
\*************************************************************************************************************************************************************************/
|
||||||
|
/*! no static exports found */
|
||||||
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
module.exports = __webpack_require__(/*! ./index.ts */ "./src/components/page-scroll/index.ts")
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ "./src/components/page-scroll/index.ts":
|
||||||
|
/*!*********************************************!*\
|
||||||
|
!*** ./src/components/page-scroll/index.ts ***!
|
||||||
|
\*********************************************/
|
||||||
|
/*! no static exports found */
|
||||||
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
|
Component({
|
||||||
|
options: {
|
||||||
|
virtualHost: true
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
refresherEnabled: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false
|
||||||
|
},
|
||||||
|
refresherThreshold: {
|
||||||
|
type: Number,
|
||||||
|
value: 45
|
||||||
|
},
|
||||||
|
refresherDefaultStyle: {
|
||||||
|
type: String,
|
||||||
|
value: 'black'
|
||||||
|
},
|
||||||
|
refresherBackground: {
|
||||||
|
type: String,
|
||||||
|
value: '#FFF'
|
||||||
|
},
|
||||||
|
refresherTriggered: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false
|
||||||
|
},
|
||||||
|
lowerThreshold: {
|
||||||
|
type: Number,
|
||||||
|
value: 50
|
||||||
|
},
|
||||||
|
scrollIntoView: {
|
||||||
|
type: String,
|
||||||
|
value: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onScroll: function onScroll(e) {
|
||||||
|
this.triggerEvent('scroll', e.detail);
|
||||||
|
},
|
||||||
|
onScrollToLower: function onScrollToLower(e) {
|
||||||
|
this.triggerEvent('scrollToLower', e.detail);
|
||||||
|
},
|
||||||
|
onPulling: function onPulling(e) {
|
||||||
|
this.triggerEvent('pulling', e.detail);
|
||||||
|
},
|
||||||
|
onRefresh: function onRefresh(e) {
|
||||||
|
this.triggerEvent('refresh', e.detail);
|
||||||
|
},
|
||||||
|
onRestore: function onRestore(e) {
|
||||||
|
this.triggerEvent('restore', e.detail);
|
||||||
|
},
|
||||||
|
onAbort: function onAbort(e) {
|
||||||
|
this.triggerEvent('abort', e.detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
},
|
||||||
|
"entries": [["./node_modules/@mpflow/webpack-plugin/lib/loaders/page-loader.js?appContext=src&outputPath=components%2Fpage-scroll%2Findex!./src/components/page-scroll/index.ts",0]]
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
// # sourceMappingURL=index.js.map
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {},
|
||||||
|
"componentFramework": "glass-easel",
|
||||||
|
"renderer": "skyline"
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<scroll-view style="flex: 1; overflow: auto; width: 100%;" scroll-y scroll-anchoring enable-back-to-top enhanced scroll-into-view="{{ scrollIntoView }}" refresher-enabled="{{ refresherEnabled }}" refresher-threshold="{{ refresherThreshold }}" refresher-default-style="{{ refresherDefaultStyle }}" refresher-background="{{ refresherBackground }}" refresher-triggered="{{ refresherTriggered }}" bindscroll="onScroll" lower-threshold="{{ lowerThreshold }}" bindscrolltolower="onScrollToLower" bindrefresherpulling="onPulling" bindrefresherrefresh="onRefresh" bindrefresherrestore="onRestore" bindrefresherabort="onAbort" type="list">
|
||||||
|
<view>
|
||||||
|
<slot/>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* # sourceMappingURL=index.wxss.map */
|
@ -0,0 +1,38 @@
|
|||||||
|
Component({
|
||||||
|
properties: {
|
||||||
|
maskClosable: {
|
||||||
|
type: Boolean,
|
||||||
|
value: true,
|
||||||
|
},
|
||||||
|
mask: {
|
||||||
|
// 是否需要 遮罩层
|
||||||
|
type: Boolean,
|
||||||
|
value: true,
|
||||||
|
},
|
||||||
|
maskStyle: {
|
||||||
|
// 遮罩层的样式
|
||||||
|
type: String,
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
show: {
|
||||||
|
// 是否开启弹窗
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
enable: true,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
close() {
|
||||||
|
const { data } = this;
|
||||||
|
console.log('@@@ close', data.maskClosable)
|
||||||
|
if (!data.maskClosable) return;
|
||||||
|
this.setData({
|
||||||
|
enable: !this.data.enable
|
||||||
|
});
|
||||||
|
this.triggerEvent('close', {}, {});
|
||||||
|
},
|
||||||
|
// stopEvent() {},
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<root-portal wx:if="{{show}}" enable="{{enable}}">
|
||||||
|
<view class="popup" bindtap="close">
|
||||||
|
<slot></slot>
|
||||||
|
</view>
|
||||||
|
</root-portal>
|
@ -0,0 +1,22 @@
|
|||||||
|
root-portal {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 5000;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 100vw;
|
||||||
|
height: 200px;
|
||||||
|
background: rgba(51, 51, 51, 0.65);
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale3d(1, 1, 1);
|
||||||
|
transition: all .2s ease-in;
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.6 KiB |
@ -1,30 +0,0 @@
|
|||||||
Page({
|
|
||||||
data:{
|
|
||||||
date:"",
|
|
||||||
region:"",
|
|
||||||
},
|
|
||||||
submit:function(e){
|
|
||||||
wx.cloud.database()
|
|
||||||
.collection("homeworks")
|
|
||||||
.add({
|
|
||||||
data: e.detail.value,
|
|
||||||
|
|
||||||
success: (res) =>{
|
|
||||||
console.log(res)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
dateChange:function(e){
|
|
||||||
this.setData({
|
|
||||||
date:e.detail.value,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
regionChange:function(e){
|
|
||||||
this.setData({
|
|
||||||
region:e.detail.value,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
|
|
||||||
"usingComponents": {
|
|
||||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
<view class="container">
|
|
||||||
<form bindsubmit="submit">
|
|
||||||
|
|
||||||
<view class="form-group">
|
|
||||||
<text>任务标题:</text>
|
|
||||||
<input type="text" name="title" placeholder="请输入任务标题" />
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="form-group">
|
|
||||||
<text>任务内容:</text>
|
|
||||||
<textarea name="details" placeholder="请输入任务内容"></textarea>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="form-group">
|
|
||||||
<text>截止时间:</text>
|
|
||||||
<input name="deadLine" type="datetime-local" />
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="form-group">
|
|
||||||
<text>附件:</text>
|
|
||||||
<button class="btn-attachment">上传附件</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<button form-type="submit" class="btn-submit">提交</button>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</view>
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
.container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.input {
|
|
||||||
flex: 1;
|
|
||||||
border: none;
|
|
||||||
border-bottom: 2rpx solid #ccc;
|
|
||||||
padding: 10rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
outline: none;
|
|
||||||
-webkit-appearance: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-submit {
|
|
||||||
height: 80rpx;
|
|
||||||
background-color: #2677ff;
|
|
||||||
color: #fff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6rpx;
|
|
||||||
padding: 12rpx 24rpx;
|
|
||||||
font-size: 30rpx;
|
|
||||||
}
|
|
Loading…
Reference in new issue