大数据平台的小程序版本

welcome.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // pages/welcome/welcome.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. 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'],
  9. indicatorDots: true,
  10. vertical: false,
  11. autoplay: false,
  12. interval: 2000,
  13. duration: 500
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. console.log('welcome',options)
  20. var _this = this;
  21. // 查看是否授权
  22. wx.getSetting({
  23. success: function(res){
  24. if (res.authSetting['scope.userInfo']) {
  25. // 已经授权,可以直接调用 getUserInfo 获取头像昵称
  26. wx.getUserInfo({
  27. success:function (e){
  28. wx.setStorageSync('encryptedData',e.encryptedData)
  29. wx.setStorageSync('iv',e.iv)
  30. // 当判断微信未过期后 判断是否授权
  31. if(!wx.getStorageSync('hasWxLogin')&&!wx.getStorageSync('noneLogin')) {
  32. var data=app.checkSession()
  33. console.log(data)
  34. if(!data) {
  35. _this.setData({
  36. canIUse: false
  37. })
  38. }
  39. }else {
  40. }
  41. },
  42. fail:function(err) {
  43. console.log("获取头像失败")
  44. }
  45. })
  46. }else{
  47. //未授权
  48. console.log("未授权")
  49. }
  50. }
  51. })
  52. },
  53. // 微信登录
  54. bindGetUserInfo: function(e) {
  55. var _this = this;
  56. wx.getUserInfo({
  57. success: function(res) {
  58. console.log(res)
  59. if(res.iv){//获取授权成功
  60. wx.setStorageSync('encryptedData',res.encryptedData)//用户加密数据
  61. wx.setStorageSync('iv',res.iv)//加密算法的初始向量
  62. wx.showLoading({
  63. title: '加载中',
  64. })
  65. app.login()
  66. }
  67. }
  68. })
  69. },
  70. /**
  71. * 用户点击右上角分享
  72. */
  73. onShareAppMessage: function () {
  74. }
  75. })