38 Star 656 Fork 231

小肥羊 / 在线答题小程序

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
小肥羊 提交于 2019-09-18 20:05 . 模拟考试助手
//app.js
App({
onLaunch: function () {
var _this = this;
// wx.showModal({
// showCancel: false,
// title: '温馨提醒',
// content: '需要授权使用您的昵称等个人信息',
// success (res) {
// if (res.confirm) {
// console.log('用户点击确定')
// _this._getUserInfo();
// } else if (res.cancel) {
// console.log('用户点击取消')
// }
// }
// })
},
_getUserInfo: function(){
// 获取用户信息
var _this = this;
wx.getSetting({
success: res => {
console.log(res);
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
console.log(res)
// 可以将 res 发送给后台解码出 unionId
_this.globalData.userInfo = res.userInfo;
_this._gotoMyinfo();
}
})
}else if(!res.authSetting['scope.userInfo']) {
wx.authorize({
scope: 'scope.getUserInfo',
success() {
wx.getUserInfo({
success(result) {
console.log(res)
// 可以将 res 发送给后台解码出 unionId
_this.globalData.userInfo = res.userInfo;
_this._gotoMyinfo();
}
})
}
})
}
}
})
},
_gotoMyinfo: function(){
wx.navigateTo({
url: '/pages/myinfo/index',
success: res => {
console.log(res);
},
fail: err => {
console.log(err);
}
})
},
globalData: {
userInfo: {
avatarUrl: '/images/20190727180127.jpg',
nickName: '未命名'
}
}
})
JavaScript
1
https://gitee.com/xiaofeiyang3369/myexamapp.git
git@gitee.com:xiaofeiyang3369/myexamapp.git
xiaofeiyang3369
myexamapp
在线答题小程序
master

搜索帮助