You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const cloud = require('wx-server-sdk')
|
|
|
|
|
|
|
|
cloud.init()
|
|
|
|
|
|
|
|
|
|
|
|
exports.main = async (event, context) => {
|
|
|
|
let {name, data} = event;
|
|
|
|
const wxContext = cloud.getWXContext();
|
|
|
|
let db = cloud.database();
|
|
|
|
switch (name) {
|
|
|
|
case 'getOpenData': {
|
|
|
|
return cloud.getOpenData(data);
|
|
|
|
}
|
|
|
|
case "login":{
|
|
|
|
return {
|
|
|
|
openid: wxContext.OPENID,
|
|
|
|
appid: wxContext.APPID,
|
|
|
|
unionid: wxContext.UNIONID,
|
|
|
|
env: wxContext.ENV,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "reportPageHistory":{
|
|
|
|
db.collection("pageHistory").add({
|
|
|
|
data:{
|
|
|
|
...data,
|
|
|
|
time: new Date(),
|
|
|
|
timestamp: Date.now(),
|
|
|
|
openid: wxContext.OPENID
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|