|
- // app.js
- import {IsOnlive} from './api/login.js'
- App({
- onLaunch() {
- // 展示本地存储能力
- const logs = wx.getStorageSync('logs') || []
- logs.unshift(Date.now())
- wx.setStorageSync('logs', logs)
-
- // 心跳更新在线状态
- setInterval(()=> {
- const {times} = this.globalData
- const openid = wx.getStorageSync('openId')
- const positionParams = wx.getStorageSync('positionParams')
- const {nickname, headimgurl} = wx.getStorageSync('userInfo')
- const params = {
- openid,
- // nickname: nickname,
- // headimgurl: headimgurl,
- provinceCode: positionParams.provinceCode,
- cityCode: positionParams.cityCode,
- districtCode: positionParams.districtCode
- }
- if(openid) {
- /* 更新用户省市区,一分钟一次 */
- if(times%60 === 0){
- IsOnlive(params)
- }
- }
- }, 5000)
- },
- globalData: {
- times: 0,
- userInfo: null
- }
- })
|