123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //index.js
- //获取应用实例
- const app = getApp()
- const host = app.globalData.host;
- Page({
- data: {
- act:6,
- openid:'',
- show:1,
- data:[],
- news: ['国家安全生产监督管理总局30号令'],
- animationData:{}
- },
- //事件处理函数
- bindViewTap: function() {
- wx.navigateTo({
- url: '../logs/logs'
- })
- },
- tabchange:function(e){
- this.setData({
- act: e.target.dataset.id
- })
- },
- onLoad: function () {
- this.getData()
- this.setData({
- openid: app.globalData.openid
- })
- wx.getStorage({
- key: 'userInfo',
- success: res=> {
- if(res.data){
- this.setData({show:0})
- }
- },
- })
- var animation = wx.createAnimation({
- duration: 1000,
- timingFunction: 'ease',
- })
- this.animation = animation
- animation.translateX(100).step()
- this.setData({
- animationData: animation.export()
- })
- },
- onGotUserInfo: function (e) {
- wx.setStorage({
- key: 'userInfo',
- data: e.detail.userInfo,
- })
- wx.request({
- url: host+'/api/wx/authinfo',
- method:'POST',
- data:{
- nickname: e.detail.userInfo.nickName,
- avatar: e.detail.userInfo.avatarUrl,
- openid: this.data.openid,
- },
- success:res=>{
- console.log(res)
- this.setData({
- show:0
- })
- }
- })
- },
- getData:function(){
- wx.request({
- url: host +'/api/wx/index',
- method:'GET',
- success:res=>{
- console.log(res.data)
- this.setData({
- data:res.data.data
- })
- }
- })
- }
- })
|