Silent 6 years ago
parent
commit
26832703ba

+ 7 - 0
app/Http/Controllers/WeChat/ApiController.php

xqd
@@ -171,6 +171,13 @@ class ApiController extends Controller
         return response()->json(['status' => 'success', 'list' => $list]);
     }
 
+    public function getAnnounces(Request $request)
+    {
+        $offset = $request->input('offset', 0);
+        $list = Content::whereIn('type', [1])->orderBy('sort')->offset($offset)->limit(15)->get();
+        return response()->json(['status' => 'success', 'list' => $list]);
+    }
+
     public function getCourseInfo(Request $request)
     {
         if(empty($request->input('student_id')) || empty($student = Student::find($request->input('student_id')))) {

+ 2 - 1
routes/wechat.php

xqd
@@ -12,4 +12,5 @@ Route::get('getMyLearnInfo', 'ApiController@getMyLearnInfo');
 Route::get('applyLeave', 'ApiController@applyLeave');
 Route::get('getRemarkTitles', 'ApiController@getRemarkTitles');
 Route::get('remarkTeacher', 'ApiController@remarkTeacher');
-Route::get('getArticleContent', 'ApiController@getArticleContent');
+Route::get('getArticleContent', 'ApiController@getArticleContent');
+Route::get('getAnnounces', 'ApiController@getAnnounces');

+ 33 - 3
wechat/pages/announce/announce.js

xqd
@@ -1,8 +1,38 @@
-
+var api = require('../../utils/api.js');
 var app = getApp()
 Page({
-  
+  data: {
+    list: []
+  },
   onLoad: function () {
-    console.log('onLoad')
+    this.loadMoreAnnouncesList();
+  },
+  onReachBottom: function () {
+    this.loadMoreAnnouncesList();
+    // is_no_more || this.loadMoreGoodsList();
+  },
+  loadMoreAnnouncesList: function() {
+    var that = this;
+    wx.request({
+      url: api.getAnnouncesUrl,
+      method: 'GET',
+      data: {
+        'offset': that.data.list.length
+      },
+      success: res => {
+        if (res.data.list.length > 0) {
+          var new_list = that.data.list.concat(res.data.list);
+          that.setData({
+            list: new_list
+          });
+        } else {
+          wx.showToast({
+            title: '到底了',
+            icon: 'none',
+            duration: 800
+          })
+        }
+      }
+    })
   }
 })

+ 6 - 2
wechat/pages/announce/announce.wxml

xqd
@@ -1,3 +1,7 @@
-<view>
-  已实现页面
+<view class='sg-container'>
+  <view wx:for='{{ list }}' class='info-content'>
+    <view class='info-bg'>
+      <view class="info-label">{{ item.title||'未命名' }}</view>
+    </view>
+  </view>
 </view>

+ 24 - 0
wechat/pages/announce/announce.wxss

xqd
@@ -0,0 +1,24 @@
+.info-content {
+    padding: 0 10rpx;
+    width: 100%;
+    display: inline-block;
+    margin-bottom: 20rpx;
+}
+
+.info-content .info-bg {
+    background-color: #fff;
+    position: relative;
+    width: 100%;
+    height: 100%;
+}
+
+.info-content .info-label {
+    width: 100%;
+    height: 100rpx;
+    line-height: 100rpx;
+    padding: 0 24rpx;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+    overflow: hidden;
+    font-weight: bold;
+}

+ 1 - 0
wechat/utils/api.js

xqd
@@ -14,4 +14,5 @@ module.exports = {
   getRemarkTitlesUrl: headUrl + 'getRemarkTitles',
   remarkTeacherUrl: headUrl + 'remarkTeacher',
   getArticleContentUrl: headUrl + 'getArticleContent',
+  getAnnouncesUrl: headUrl + 'getAnnounces',
 }