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.
|
|
|
// pages/auth/auth.js
|
|
|
|
const $api = require('../../utils/api').API;
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
agree: false
|
|
|
|
},
|
|
|
|
|
|
|
|
setAgree() {
|
|
|
|
let {
|
|
|
|
agree
|
|
|
|
} = this.data;
|
|
|
|
this.setData({
|
|
|
|
agree: !agree
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
bindGetUserInfo: function (e) {
|
|
|
|
let {
|
|
|
|
agree
|
|
|
|
} = this.data;
|
|
|
|
if (agree===false) {
|
|
|
|
wx.showToast({
|
|
|
|
title: '请勾选隐私政策',
|
|
|
|
icon: 'none',
|
|
|
|
duration: 2000
|
|
|
|
})
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (e.detail.userInfo) {
|
|
|
|
wx.switchTab({
|
|
|
|
url: '/pages/index/index'
|
|
|
|
})
|
|
|
|
//用户按了允许授权按钮
|
|
|
|
// var that = this;
|
|
|
|
// let info = e.detail.userInfo;
|
|
|
|
// that.queryUsreInfo();
|
|
|
|
} else {
|
|
|
|
//用户按了拒绝按钮
|
|
|
|
wx.showModal({
|
|
|
|
title: '警告',
|
|
|
|
content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!!!',
|
|
|
|
showCancel: false,
|
|
|
|
confirmText: '返回授权',
|
|
|
|
success: function (res) {
|
|
|
|
if (res.confirm) {
|
|
|
|
console.log('用户点击了“返回授权”')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
var that = this;
|
|
|
|
// 查看是否授权
|
|
|
|
wx.getSetting({
|
|
|
|
success: function (res) {
|
|
|
|
if (res.authSetting['scope.userInfo']) {
|
|
|
|
wx.getUserInfo({
|
|
|
|
success: function (res) {
|
|
|
|
//从数据库获取用户信息
|
|
|
|
that.queryUsreInfo();
|
|
|
|
//用户已经授权过
|
|
|
|
// wx.switchTab({
|
|
|
|
// url: '/pages/index/index'
|
|
|
|
// })
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
queryUsreInfo() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|