1 Star 2 Fork 0

星期八 / 知识答题小程序

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
app.js 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
星期八 提交于 2022-11-06 14:14 . 第一次提交
// app.js
App({
onLaunch: function () {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力');
} else {
wx.cloud.init({
// env 参数说明:
// env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
// env: 'my-env-id',
traceUser: true,
});
}
//系统参数
wx.getSystemInfo({
success: res => {
this.globalData.StatusBar = res.statusBarHeight;
let capsule = wx.getMenuButtonBoundingClientRect();
if (capsule) {
this.globalData.Custom = capsule;
this.globalData.CustomBar = capsule.bottom + capsule.top - res.statusBarHeight;
} else {
this.globalData.CustomBar = res.statusBarHeight + 50;
}
}
})
},
//配置
config() {
// 登录
return new Promise((resolve, reject) => {
//自己的业务,可能是 异步请求服务端的,如果是异步请求的就请求成功后 resolve(res)
const db = wx.cloud.database(); // 云数据库初始化
//加载config
db.collection('config').limit(1).get().then(res => {
//赋值
resolve(res);
}).catch(err => {
console.log(err);
})
})
},
//执行
appInt() {
return this.config().then(obj => {
return obj
});
},
//公共变量
globalData: {}
});
JavaScript
1
https://gitee.com/zj780/dati.git
git@gitee.com:zj780/dati.git
zj780
dati
知识答题小程序
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891