const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database()
exports.main = async(event,context) => {
if(event.account != null && event.password != null){
db.collection('constenv').doc('login2tokenkey').get({
success: res=>{
var login2tokenkey = res.data.value
db.collection('login').where({
data: {
account: event.account,
password: event.password
},
success: res=>{
if(res.data.length > 0){
return{
token: event.account + login2tokenkey + event.password
}
}
},
fail: err=>{
return{
token: false
}
}
})
},
fail: err=>{
return{
token: false
}
}
})
}
}
const res = await db.collection('constenv').doc('login2tokenkey').get();
学学async await吧