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.
project/pages/my/my.ts

77 lines
2.2 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// logs.ts
// const util = require('../../utils/util.js')
// import { formatTime } from '../../utils/util'
Page({
data: {
userInfo: {},
key:{},
},
atLogin() {
wx.getUserProfile({
desc: '展示用户信息',
success: (res) => {
this.setData({
userInfo: res.userInfo,
})
// wx.setStorageSync("userInfo", res.userInfo);
wx.setStorage({
key:"userInfo",
data:this.data.userInfo,
// userInfo:res.userInfo,
encrypt: true, // 若开启加密存储setStorage 和 getStorage 需要同时声明 encrypt 的值为 true
success() {
wx.getStorage({
key: "key",
encrypt: true, // 若开启加密存储setStorage 和 getStorage 需要同时声明 encrypt 的值为 true
success(res) {
console.log(res.data)
}
})
}
})
 wx.login({
      success: function(login_res){
        if(login_res.code){
          wx.request({
            url:'http://192.168.58.210:81/atlogin',
            method:'GET',
            data:{
              code:login_res.code,
            },
success:function(res :any){
console.log(res)
let skey=res.data.skey
console.log(skey)
wx.setStorageSync('skey',skey)
}
          })
        }else{
          console.log('登录失败!'+login_res.errMsg)
        }
      }
    })   
}
})
},   
onShow() {
const userInfo = wx.getStorageSync("userInfo");
if (userInfo!=null) return;
this.setData({
userInfo: userInfo,
})
  
},
onLoad() {
const userInfo = wx.getStorageSync("userInfo");
if (userInfo!=null) return;
this.setData({
userInfo: userInfo,
})
},
})