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.
|
|
|
|
// 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',
|
|
|
|
|
env:"cloud1-8g5wmepxce8a3b8a",
|
|
|
|
|
traceUser: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.globalData = {};
|
|
|
|
|
// 获取用户openid
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'get',
|
|
|
|
|
data: {},
|
|
|
|
|
success: res => {
|
|
|
|
|
this.globalData.openid = res.result.openid
|
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
|
|
|
|
console.error('[云函数] [login] 调用失败', err)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
console.log(this.globalData)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
getOpenid() {
|
|
|
|
|
let that = this;
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'get',
|
|
|
|
|
complete: res => {
|
|
|
|
|
|
|
|
|
|
console.log('openid: ', res.result.openid)
|
|
|
|
|
console.log('appid: ', res.result.appid)
|
|
|
|
|
// var openid = res.result.openId;
|
|
|
|
|
// that.setData({
|
|
|
|
|
// openid: openid
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|