代码拉取完成,页面将自动刷新
//app.js
import Util from "utils/util";
import Config from "config";
App({
globalData: {
systemInfo: null,
userInfo: null,
openId: 1,
code: null,
sessionKey: null,
},
"Util": Util,
"Config": Config,
// 小程序初始化
onLaunch() {
const that = this;
// 获取系统信息
wx.getSystemInfo({
success(res) {
that.globalData.systemInfo = res;
},
});
that.inIt();
},
// 小程序初始化
inIt: function () {
const that = this;
that.Util.login() // 登录
.then((res) => {
// console.log(res);
that.globalData.code = res.code;
return that.Util.getUserInfo(); // 获取用户信息
})
.then((res) => {
// console.log(res);
that.globalData.userInfo = res.userInfo;
return that.Util.getOpenIdAndKey(that.globalData.code); // 获取openId 和 access_key
})
.then((res) => {
// console.log(res.data.data.openId); // 后台需要改!
that.globalData.openId = res.data.data.openId;
})
.catch((res) => {
that.globalData.userRefuse = true;
})
},
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。