123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- // pages/welcome/welcome.js
- var app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- background: ['https://kx-bigdata.oss-cn-beijing.aliyuncs.com/Applet/step1.png', 'https://kx-bigdata.oss-cn-beijing.aliyuncs.com/Applet/step2.png', 'https://kx-bigdata.oss-cn-beijing.aliyuncs.com/Applet/step3.png?v=1.0.1'],
- indicatorDots: true,
- vertical: false,
- autoplay: false,
- interval: 2000,
- duration: 500
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log('welcome',options)
- var _this = this;
- // 查看是否授权
- wx.getSetting({
- success: function(res){
- if (res.authSetting['scope.userInfo']) {
- // 已经授权,可以直接调用 getUserInfo 获取头像昵称
- wx.getUserInfo({
- success:function (e){
- wx.setStorageSync('encryptedData',e.encryptedData)
- wx.setStorageSync('iv',e.iv)
- // 当判断微信未过期后 判断是否授权
- if(!wx.getStorageSync('hasWxLogin')&&!wx.getStorageSync('noneLogin')) {
- var data=app.checkSession()
- console.log(data)
- if(!data) {
- _this.setData({
- canIUse: false
- })
- }
- }else {
- }
- },
- fail:function(err) {
- console.log("获取头像失败")
- }
- })
- }else{
- //未授权
- console.log("未授权")
- }
- }
- })
- },
- // 微信登录
- bindGetUserInfo: function(e) {
- var _this = this;
- wx.getUserInfo({
- success: function(res) {
- console.log(res)
- if(res.iv){//获取授权成功
- wx.setStorageSync('encryptedData',res.encryptedData)//用户加密数据
- wx.setStorageSync('iv',res.iv)//加密算法的初始向量
- wx.showLoading({
- title: '加载中',
- })
- app.login()
- }
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|