2 Star 1 Fork 2

ganshisheng/94_手账小程序模板

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 2.23 KB
一键复制 编辑 原始数据 按行查看 历史
ganshisheng 提交于 2020-05-30 16:14 . first commit
App({
onLaunch: function () {
console.log('App Launch')
this.getopenId()
this.getVcode()
},
onShow: function (option) {
},
onHide: function () {
},
getUserInfo: function (cb) {
var that = this
if (this.globalData.userInfo) {
typeof cb == "function" && cb(this.globalData.userInfo)
} else {
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(that.globalData.userInfo)
console.log(res.userInfo,'app.js')
},
fail: res => {
console.log(res)
}
})
}
},
getopenId:function(){
var that = this
if (this.globalData.userId) {
} else {
//调用登录接口
wx.login({
success: function (res) {
console.log(res)
wx.request({
url: "https://mp.orancat.com/puser/getOpenId",
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST",
data: { code: res.code },
complete: function (res) {
typeof cb == "function" && cb(that.globalData.userId)
that.globalData.userId = res.data.data.openid
wx.setStorageSync('userId', res.data.data.openid)
console.log(res,23)
if (res == null || res.data == null) {
console.error('网络请求失败');
return;
}
}
});
}
})
}
},
getVcode() {
let self = this;
wx.request({
url: "https://mp.orancat.com/puser/getvcode",
method: "GET",
complete: function (res) {
if (res.data.status == 0) {
self.globalData.vcode = res.data.vcode
console.log(res, 23345)
} else {
wx.showModal({
title: '提示',
content: '请求失败,请联系管理员',
showCancel: false
})
}
console.log(self.globalData.vcode, 2545)
}
});
},
globalData: {
userInfo: null,
userId:'',
checkedProArr:[],
sortBysListArr:[],
account:0,
vcode: 0
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
微信
1
https://gitee.com/ganshisheng/wxapp_94.git
git@gitee.com:ganshisheng/wxapp_94.git
ganshisheng
wxapp_94
94_手账小程序模板
master

搜索帮助