tanyanfei 3 سال پیش
والد
کامیت
7fe9b53fe8
3فایلهای تغییر یافته به همراه17 افزوده شده و 4 حذف شده
  1. 15 3
      pages/index/index.js
  2. 1 1
      pages/index/index.wxml
  3. 1 0
      utils/api.js

+ 15 - 3
pages/index/index.js

@@ -4,13 +4,14 @@ const app = getApp()
 const $api = require('../../utils/api.js').API;
 Page({
   data: {
-    notices:[{}],
+    notices:[],
     tabs:['关注','热门股票','胜率榜','防守榜','冠军心得'],
     cur:0,
     date:'2021-11-09',
     followList:[],
     page:1,
-    total:0
+    total:0,
+    error:0
   },
   onLoad() {
     var y = new Date().getFullYear(), m = (new Date().getMonth() + 1), d = new Date().getDate();
@@ -51,6 +52,12 @@ Page({
         total:res.data.data.total
       })
     })
+    .catch(err=>{
+      this.setData({
+        error:1
+      })
+      // console.log(err)
+    })
   },
   getData(){
     //胜率
@@ -113,5 +120,10 @@ Page({
       date:e.detail.value
     })
     this.getHot()
-  }
+  },
+  onShow: function () {
+    if (this.data.error) {
+      this.onLoad()
+    }
+  },
 })

+ 1 - 1
pages/index/index.wxml

@@ -1,5 +1,5 @@
 <!--index.wxml-->
-<view   class="marquee_container" 
+<view   class="marquee_container"  wx:if='{{notices.length>0}}'
   style="{{'--marqueeWidth--:'+-12*notices.length+'em'}}">
     <view class="zd"></view>
     <image src="../../images/tttz.png" mode="widthFix"></image>

+ 1 - 0
utils/api.js

@@ -34,6 +34,7 @@ function request(method, url, data) {
               resolve(res);
             } else if (res.data.code == 403) {
               //未登录
+              reject(403)
               wx.switchTab({
                 url: '../user/user',
               })