Compare commits
No commits in common. 'master' and 'kongweiyu_branch' have entirely different histories.
master
...
kongweiyu_
Before Width: | Height: | Size: 1.3 MiB |
@ -1,23 +0,0 @@
|
||||
#!/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)
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
|
||||
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,
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
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,
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
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,
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
message ApiDemoReq
|
||||
{
|
||||
optional string str = 2;
|
||||
}
|
||||
|
||||
message ApiDemoResp
|
||||
{
|
||||
optional string str = 2;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
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;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
message GenWxaCloudTmpCodeReq
|
||||
{
|
||||
optional uint32 CloudPlatform = 1;
|
||||
optional uint32 AppUin = 2;
|
||||
optional uint32 UserUin = 3;
|
||||
}
|
||||
|
||||
message GenWxaCloudTmpCodeResp
|
||||
{
|
||||
optional string TmpCode = 1;
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
|
||||
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,
|
||||
}
|
||||
|
@ -1,101 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
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',
|
||||
},
|
||||
}
|
||||
},
|
||||
]
|
@ -1,62 +0,0 @@
|
||||
// 云函数入口文件
|
||||
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,
|
||||
// });
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
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 失败
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
|
||||
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,
|
||||
}
|
||||
|
@ -1,299 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
// 模块导出一个数组,每个元素是一个模块配置项
|
||||
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',
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
@ -1,12 +0,0 @@
|
||||
## 0.6.0
|
||||
|
||||
1. `A` 新增 `callWXSvrkit` 支持传入 `headuin` 和 `routeMethod`
|
||||
|
||||
## 0.2.0
|
||||
|
||||
1. `A` 新增 `callTencentInnerAPI` 内部接口
|
||||
|
||||
## 0.1.0
|
||||
|
||||
1. `A` 新增 `callWXSvrkit` 内部接口
|
||||
2. `A` 新增 `callWXInnerAPI` 内部接口
|
@ -1,22 +0,0 @@
|
||||
|
||||
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.
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"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,17 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
|
||||
// 获取openId云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 获取基础信息
|
||||
const wxContext = cloud.getWXContext();
|
||||
|
||||
return {
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
unionid: wxContext.UNIONID,
|
||||
};
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "orders",
|
||||
"name": "getOpenId",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
@ -1,13 +0,0 @@
|
||||
// 云函数入口文件
|
||||
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()
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
// 云函数入口文件
|
||||
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
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
exports.main = (event) => ({
|
||||
openid: event.userInfo.openId,
|
||||
})
|
@ -1,19 +0,0 @@
|
||||
// 云函数入口文件
|
||||
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,
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
// 云函数入口文件
|
||||
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
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
// 云函数入口文件
|
||||
// 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
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// components/grid-tile/index.js
|
||||
Component({
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
height: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
|
||||
}
|
||||
})
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<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>
|
@ -1,10 +0,0 @@
|
||||
/* components/grid-tile/index.wxss */
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<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>
|
@ -1,75 +0,0 @@
|
||||
.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;
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
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
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {},
|
||||
"componentFramework": "glass-easel",
|
||||
"renderer": "skyline"
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<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>
|
@ -1,4 +0,0 @@
|
||||
|
||||
|
||||
|
||||
/* # sourceMappingURL=index.wxss.map */
|
@ -1,38 +0,0 @@
|
||||
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() {},
|
||||
},
|
||||
});
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<root-portal wx:if="{{show}}" enable="{{enable}}">
|
||||
<view class="popup" bindtap="close">
|
||||
<slot></slot>
|
||||
</view>
|
||||
</root-portal>
|
@ -1,22 +0,0 @@
|
||||
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: 906 B |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.6 KiB |
@ -1,110 +1,158 @@
|
||||
/* pages/Detailed/detailed.wxss */
|
||||
/* 评论-回复-回复评论显示区域 */
|
||||
.container {
|
||||
width: 718rpx;
|
||||
margin-top: 39rpx;
|
||||
padding-left: 32rpx;
|
||||
}
|
||||
|
||||
.divLine{
|
||||
background: #E0E3DA;
|
||||
width: 90%;
|
||||
height: 5rpx;
|
||||
.total {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
margin-left: 1rpx;
|
||||
}
|
||||
|
||||
.container_inp {
|
||||
width: 661rpx;
|
||||
height: 32rpx;
|
||||
background-color: #F2F2F2;
|
||||
border-radius: 8rpx;
|
||||
padding: 17rpx 0rpx 15rpx 25rpx;
|
||||
margin-top: 24rpx;
|
||||
margin-bottom: 47rpx;
|
||||
}
|
||||
|
||||
.container_place {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.container-item {
|
||||
display: flex;
|
||||
margin-bottom: 34rpx;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.item_img {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
margin-right: 17rpx;
|
||||
}
|
||||
|
||||
.item_right {
|
||||
display: inline-block;
|
||||
width: 636rpx;
|
||||
border-bottom: 2rpx solid #E5E5E5;
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.right_name {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.right_content {
|
||||
width: 603rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.right_content_txt {
|
||||
font-size: 26rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.right_content_txt2 {
|
||||
font-size: 24rpx;
|
||||
color: #CCCCCC;
|
||||
margin-left: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
/* 留言部分 */
|
||||
.comment-box {
|
||||
background-color: white;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.comment-one {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin: 0 20rpx 40rpx 20rpx;
|
||||
}
|
||||
|
||||
.comment-face {
|
||||
width: 70rpx;
|
||||
height: 70rpx;
|
||||
border-radius: 50rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.nickname-time {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
width: 600rpx;
|
||||
}
|
||||
|
||||
.comment-nickname {
|
||||
color: #586B94;
|
||||
font-weight: 550;
|
||||
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.comment-time {
|
||||
color: #7F7F7F;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.comment-text {
|
||||
margin-top: 14rpx;
|
||||
|
||||
font-size: 28rpx;
|
||||
width: 606rpx;
|
||||
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
|
||||
letter-spacing: 2rpx;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.comment-obj {
|
||||
color: #586B94;
|
||||
font-weight: 550;
|
||||
}
|
||||
|
||||
/* 发布评论 */
|
||||
.pub-comment {
|
||||
background-color: white;
|
||||
padding: 20rpx 40rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
border-top: solid 1rpx #E0E3DA;
|
||||
}
|
||||
|
||||
.pub-left {
|
||||
background-color: #fff;
|
||||
color: #7F7F7F;
|
||||
border-radius: 10rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.pub-input {
|
||||
padding: 10rpx 20rpx;
|
||||
width: 490rpx;
|
||||
background-color: #F1F1F1;
|
||||
border-color: #AAAAAA;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
.pub-button {
|
||||
background-color: #1AAD19;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
border: solid 1rpx #7F7F7F;
|
||||
border-radius: 10rpx;
|
||||
padding: 10rpx 18rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.comment-right{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.reply {
|
||||
display: flex;
|
||||
margin-top: 32rpx;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.reply_img {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-right: 17rpx;
|
||||
}
|
||||
|
||||
.reply_right {
|
||||
display: inline-block;
|
||||
width: 546rpx;
|
||||
}
|
||||
|
||||
/* 结束 */
|
||||
.end {
|
||||
margin-top: 47rpx;
|
||||
margin-bottom: 48rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.end_txt {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
/* 底部评论 */
|
||||
.foot {
|
||||
width: 686rpx;
|
||||
padding: 17rpx 32rpx;
|
||||
background-color: #FFFFFF;
|
||||
box-shadow: 0rpx -1rpx 4rpx 0rpx rgba(0, 0, 0, 0.08);
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.say {
|
||||
display: inline-block;
|
||||
width: 360rpx;
|
||||
padding: 20rpx 0rpx 10rpx 24rpx;
|
||||
background-color: #F2F2F2;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.say_img {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 13rpx;
|
||||
/* vertical-align: 10rpx; */
|
||||
}
|
||||
|
||||
.say_inp {
|
||||
display: inline-block;
|
||||
width: 300rpx;
|
||||
height: 33rpx;
|
||||
}
|
||||
|
||||
.say_place {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.foot_img {
|
||||
width: 45rpx;
|
||||
height: 40rpx;
|
||||
margin-left: 50rpx;
|
||||
margin-right: 17rpx;
|
||||
}
|
||||
|
||||
.foot_num {
|
||||
font-size: 24rpx;
|
||||
vertical-align: 10rpx;
|
||||
}
|
||||
|
||||
.foot_img2 {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-left: 30rpx;
|
||||
margin-right: 17rpx;
|
||||
}
|
||||
|
||||
|
@ -1,111 +0,0 @@
|
||||
// pages/Detailed/detailed.js
|
||||
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data:{
|
||||
avatarUrl: defaultAvatarUrl,
|
||||
teacher: null
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
const eventChannel = this.getOpenerEventChannel()
|
||||
eventChannel.on('acceptDataFromOpenerPage', (data) => {
|
||||
//对发送过来的数据进行处理
|
||||
console.log("[DETAILS]",data)
|
||||
this.setData({
|
||||
teacher: data.data,
|
||||
avatarUrl: data.data.headPhoto
|
||||
})
|
||||
})
|
||||
// 使用索引在教师数组中获取对应的教师信息
|
||||
// var teacherInfo = this.data.teacher[index];
|
||||
// 继续处理教师信息
|
||||
// 调用云函数获取教师信息
|
||||
// wx.cloud.callFunction({
|
||||
// name: "detailed",
|
||||
// success: (res) => {
|
||||
// this.setData({
|
||||
// teacher: res.result.data
|
||||
// })
|
||||
// // console.log(this.data.teacher[1]);
|
||||
// }
|
||||
// })
|
||||
},
|
||||
|
||||
changeTab(e) {
|
||||
const index = e.currentTarget.dataset.index;
|
||||
this.setData({
|
||||
currentTab: parseInt(index)
|
||||
});
|
||||
},
|
||||
onAddButtonTap: function() {
|
||||
this.setData({
|
||||
showPopup: true
|
||||
});
|
||||
},
|
||||
onBackButtonTap: function() {
|
||||
this.setData({
|
||||
showPopup: false
|
||||
});
|
||||
},
|
||||
|
||||
handleSubmit: function() {
|
||||
// 处理....
|
||||
// 提交成功后隐藏弹窗
|
||||
this.setData({
|
||||
showPopup: false
|
||||
});
|
||||
},
|
||||
|
||||
navToComments: () => {
|
||||
wx.navigateTo({
|
||||
url: '/pages/Comments/Comments',
|
||||
})
|
||||
},
|
||||
inputChange(e) {
|
||||
this.setData({
|
||||
inputValue: e.detail.value
|
||||
});
|
||||
},
|
||||
reserve(e){
|
||||
wx.showModal({
|
||||
title: '预约',
|
||||
content: '确定预约该老师吗?',
|
||||
complete: (res) => {
|
||||
if (res.cancel) {
|
||||
|
||||
}
|
||||
|
||||
if (res.confirm) {
|
||||
var tmp = this.data.teacher
|
||||
var state = 0
|
||||
console.log("[MAIN] reserve",tmp);
|
||||
try {
|
||||
state = wx.getStorageSync(tmp._id)
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
if (state == 1) {
|
||||
wx.showToast({
|
||||
title: '您已经预约!',
|
||||
icon: "error",
|
||||
})
|
||||
} else {
|
||||
wx.setStorageSync(tmp._id, 1)
|
||||
wx.showToast({
|
||||
title: '请等待老师确认',
|
||||
})
|
||||
}
|
||||
// wx.clearStorageSync(tmp._id)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1,70 @@
|
||||
// pages/Detailed/detailed.js
|
||||
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data:{
|
||||
avatarUrl: defaultAvatarUrl,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
var index = options.index; // 第一个页面传递过来的教师索引
|
||||
var teacherInfo = this.data.teacher[index];
|
||||
// 使用索引在教师数组中获取对应的教师信息
|
||||
// var teacherInfo = this.data.teacher[index];
|
||||
// 继续处理教师信息
|
||||
// 调用云函数获取教师信息
|
||||
wx.cloud.callFunction({
|
||||
name: "detailed",
|
||||
success: (res) => {
|
||||
this.setData({
|
||||
teacher: res.result.data
|
||||
})
|
||||
// console.log(this.data.teacher[1]);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
changeTab(e) {
|
||||
const index = e.currentTarget.dataset.index;
|
||||
this.setData({
|
||||
currentTab: parseInt(index)
|
||||
});
|
||||
},
|
||||
onAddButtonTap: function() {
|
||||
this.setData({
|
||||
showPopup: true
|
||||
});
|
||||
},
|
||||
onBackButtonTap: function() {
|
||||
this.setData({
|
||||
showPopup: false
|
||||
});
|
||||
},
|
||||
|
||||
handleSubmit: function() {
|
||||
// 处理....
|
||||
// 提交成功后隐藏弹窗
|
||||
this.setData({
|
||||
showPopup: false
|
||||
});
|
||||
},
|
||||
|
||||
navToComments: () => {
|
||||
wx.navigateTo({
|
||||
url: '/pages/Comments/Comments',
|
||||
})
|
||||
},
|
||||
inputChange(e) {
|
||||
this.setData({
|
||||
inputValue: e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
})
|
@ -0,0 +1,15 @@
|
||||
<!--pages/Detailed/detailed.wxml-->
|
||||
<view style="background-color: #FFFFFF; margin: 15rpx; border-radius: 25rpx;">
|
||||
<view class="avatar-wrapper">
|
||||
<image class="avatar" src="{{avatarUrl}}"></image>
|
||||
<text>
|
||||
姓名: 老师
|
||||
科目: NULL
|
||||
空闲时间: NULL
|
||||
学历: NULL
|
||||
时薪: NULL
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view style="margin: 20rpx;">综合评分: 10.0</view>
|
||||
</view>
|
@ -1,15 +1,15 @@
|
||||
/* pages/detail/detail.wxss *//* pages/Detailed/detailed.wxss */
|
||||
.avatar-wrapper {
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
}
|
||||
|
||||
/* 子元素选择器 */
|
||||
.avatar-wrapper > image {
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
border-style: solid;
|
||||
border-color: #000;
|
||||
border-width: 1px;
|
||||
margin: 20px;
|
||||
/* pages/Detailed/detailed.wxss */
|
||||
.avatar-wrapper {
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
}
|
||||
|
||||
/* 子元素选择器 */
|
||||
.avatar-wrapper > image {
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
border-style: solid;
|
||||
border-color: #000;
|
||||
border-width: 1px;
|
||||
margin: 20px;
|
||||
}
|