1 Star 1 Fork 0

hylf / spshot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
app.js 957 Bytes
一键复制 编辑 原始数据 按行查看 历史
huayunliufeng 提交于 2022-02-03 21:45 . Initial Commit
const { getRequest } = require("./config")
// app.js
App({
/**
* 生命周期回调——监听小程序初始化。
*/
onLaunch(options) {
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
getRequest("/user/user/getOpenId/"+res.code).then((resp)=>{
if(resp.data.flag){
wx.setStorageSync('openid', resp.data.data);
}else{
wx.showToast({
title: '获取openid失败!请检查网络',
icon: 'error',
duration: 2000
});
}
},(err)=>{});
}
})
},
/**
* 生命周期回调——监听小程序启动或切前台。
*/
onShow(options){
},
/**
* 生命周期回调——监听小程序切后台。
*/
onHide(){
},
/**
* 错误监听函数。
*/
onError(msg){
console.log(msg)
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hylf/spshot.git
git@gitee.com:hylf/spshot.git
hylf
spshot
spshot
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891