xjc 3 rokov pred
rodič
commit
84c2f99098
1 zmenil súbory, kde vykonal 4 pridanie a 8 odobranie
  1. 4 8
      pages/message/message.js

+ 4 - 8
pages/message/message.js

@@ -2,15 +2,14 @@
 const app = getApp()
 var host = app.globalData.host;
 const $api = require('../../utils/api.js').API;
-// var timer;
+var timer;
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-        focus:false,
-        timer:null
+        focus:false
     },
 
     /**
@@ -22,10 +21,7 @@ Page({
     getData(){
         var _this=this;
         f()
-        timer=setInterval(f,1000)
-        this.setData({
-          timer:timer
-        })
+        timer=setInterval(f,10000)
         function f(){
           $api.getconsult().then(res=>{
             _this.setData({
@@ -79,7 +75,7 @@ Page({
      * 生命周期函数--监听页面卸载
      */
     onUnload: function () {
-      clearInterval(this.data.timer)
+      clearInterval(timer)
     },
 
     /**