Ver código fonte

文件浏览列表及详情页功能对接

xyg 3 anos atrás
pai
commit
058e177e05

+ 6 - 0
light-application-server/src/main/java/com/jd/lightapplication/controller/NoticeInfoController.java

@@ -57,4 +57,10 @@ public class NoticeInfoController {
         return R.success();
     }
 
+    @GetMapping("/getById")
+    @ApiOperation(value = "5、根据ID查询详情")
+    public R getById(Long id) {
+        return R.success(noticeInfoService.getById(id));
+    }
+
 }

+ 2 - 1
light-application-wx/app.js

@@ -15,7 +15,8 @@ App({
   },
   globalData: {
     imgPath: 'http://192.168.0.46/image',
-    path: 'https://192.168.1.218',
+    // path: 'https://192.168.1.218',
+    path: 'http://192.168.0.46:8081',
     Authorization: '',
     userInfo: {},
     roleInfo: {}

+ 29 - 16
light-application-wx/pages/file-browse/file-browse.js

@@ -1,4 +1,5 @@
 // pages/file-browse/file-browse.js
+const util = require('../../utils/util.js');
 Page({
 
     /**
@@ -8,17 +9,7 @@ Page({
         current: 1,
         size: 10,
         total: 0,
-        list: [{
-            id: 1,
-            fileName: '上调300元 4月1日起 重庆执行两档最低工资标准',
-            fileDesc: '4月1日起,重庆执行新的最低工资标准,具体为两档,分别为2100元/月、2000元/月,比原标准提高了300元。',
-            publishTime: '2022-03-24'
-        }, {
-            id: 2,
-            fileName: '市委办公厅、市政府办公厅印发《实施意见》要求铸魂育人倾情关爱 做好新时代关心下一代工作',
-            fileDesc: '4月1日起,重庆执行新的最低工资标准,具体为两档,分别为2100元/月、2000元/月,比原标准提高了300元,比原标准提高了300元,比原标准提高了300元。',
-            publishTime: '2022-03-24'
-        }]
+        list: []
     },
 
     /**
@@ -41,9 +32,15 @@ Page({
                 if (res.data.code != 200) {
                     util.toast(res.data.msg);
                 } else {
+                    let records = res.data.data.records;
+                    for (let i in records) {
+                        let content = records[i].content;
+                        content = content.match(/[\u4e00-\u9fa5]/g).join("");
+                        records[i].desc = content;
+                    }
                     that.setData({
                         total: res.data.data.total,
-                        list: res.data.data.records
+                        list: records
                     });
                 }
             }
@@ -100,9 +97,15 @@ Page({
                 if (res.data.code != 200) {
                     util.toast(res.data.msg);
                 } else {
+                    let records = res.data.data.records;
+                    for (let i in records) {
+                        let content = records[i].content;
+                        content = content.match(/[\u4e00-\u9fa5]/g).join("");
+                        records[i].desc = content;
+                    }
                     that.setData({
                         total: res.data.data.total,
-                        list: res.data.data.records
+                        list: records
                     });
                 }
             }
@@ -136,9 +139,14 @@ Page({
                 if (res.data.code != 200) {
                     util.toast(res.data.msg);
                 } else {
-                    let list = res.data.data.records;
+                    let records = res.data.data.records;
+                    for (let i in records) {
+                        let content = records[i].content;
+                        content = content.match(/[\u4e00-\u9fa5]/g).join("");
+                        records[i].desc = content;
+                    }
                     that.setData({
-                        list: arr.concat(list)
+                        list: arr.concat(records)
                     });
                 }
             }
@@ -151,10 +159,15 @@ Page({
     onShareAppMessage: function () {
 
     },
+
+    /**
+     * 查看文件详情
+     * @param {*} e 
+     */
     fileDetail: function (e) {
         let id = e.currentTarget.dataset.id;
         wx.navigateTo({
             url: '../file-detail/file-detail?id=' + id,
-        })
+        });
     }
 })

+ 5 - 5
light-application-wx/pages/file-browse/file-browse.wxml

@@ -1,9 +1,9 @@
 <!--pages/file-browse/file-browse.wxml-->
 <scroll-view class="list">
-    <view class="item" scroll-y="true" wx:for="{{list}}" wx:for-item="item" wx:key="i" data-id="{{item.id}}" bindtap="fileDetail">
-        <view class="file-name">{{item.fileName}}</view>
-        <view class="file-desc">{{item.fileDesc}}</view>
+    <view class="item" scroll-y="true" wx:for="{{list}}" wx:key="i" data-id="{{item.id}}" bindtap="fileDetail">
+        <view class="file-name">{{item.title}}</view>
+        <view class="file-desc">{{item.desc}}</view>
         <text class="detailBtn">详情></text>
-        <view class="publish-time">{{item.publishTime}}</view>
+        <view class="publish-time">{{item.createTime}}</view>
     </view>
-</scroll-view>
+</scroll-view>

+ 13 - 8
light-application-wx/pages/file-browse/file-browse.wxss

@@ -1,13 +1,18 @@
 /* pages/file-browse/file-browse.wxss */
+page {
+    background-color: #F0F4F7;
+}
+
 .list {
     padding: 30rpx;
     background: none;
+    box-sizing: border-box;
 }
 
 .item {
-    padding: 20rpx;
-    width: 86%;
-    background-color: #eeeeee;
+    padding: 30rpx;
+    box-sizing: border-box;
+    background-color: #FFFFFF;
     border-radius: 20rpx;
     margin-bottom: 15rpx;
 }
@@ -16,7 +21,7 @@
     font-size: 1.2em;
     line-height: 50rpx;
     border-bottom: solid 1rpx #dddddd;
-    padding-bottom: 9rpx;
+    padding-bottom: 20rpx;
     display: -webkit-box;
     word-break: break-all;
     text-overflow: ellipsis;
@@ -28,8 +33,8 @@
 
 .file-desc {
     font-size: .8em;
-    margin-top: 12rpx;
-    margin-bottom: 12rpx;
+    margin-top: 20rpx;
+    margin-bottom: 20rpx;
     display: -webkit-box;
     word-break: break-all;
     text-overflow: ellipsis;
@@ -47,6 +52,6 @@
     font-size: .8em;
     color: #2463b4;
     position: absolute;
-    right: 90rpx;
-    margin-top: -8rpx;
+    right: 60rpx;
+    margin-top: -5rpx;
 }

+ 26 - 4
light-application-wx/pages/file-detail/file-detail.js

@@ -1,20 +1,42 @@
 // pages/file-detail/file-detail.js
+const util = require('../../utils/util.js');
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-        title:'上调300元4月1日起重庆执行两档最低工资标准',
-        publishTime:'2022-03-24',
-        content:'4月1日起,重庆执行新的最低工资标准,具体为两档,分别为2100元/月、2000元/月,比原标准提高了300元,比原标准提高了300元,比原标准提高了300元。'
+
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
-
+        let that = this;
+        util.get({
+            url: '/api/notice/getById',
+            header: {
+                'content-type': 'application/x-www-form-urlencoded'
+            },
+            data: {
+                id: options.id
+            },
+            success: (res) => {
+                wx.hideLoading();
+                console.info(res);
+                if (res.data.code != 200) {
+                    util.toast(res.data.msg);
+                } else {
+                    that.setData({
+                        title: res.data.data.title,
+                        createTime: util.formatDate(res.data.data.createTime, 'yyyy-MM-dd'),
+                        content: res.data.data.content
+                    });
+                }
+
+            }
+        });
     },
 
     /**

+ 3 - 2
light-application-wx/pages/file-detail/file-detail.wxml

@@ -1,7 +1,8 @@
 <!--pages/file-detail/file-detail.wxml-->
 <scroll-view class="detail">
     <view class="title">{{title}}</view>
-    <view class="publish-time">{{publishTime}}</view>
+    <view class="publish-time">{{createTime}}</view>
     <view class="line"></view>
-    <view class="content">{{content}}</view>
+    <!-- <view class="content">{{content}}</view> -->
+    <rich-text class="content" nodes="{{content}}"></rich-text>
 </scroll-view>

+ 4 - 9
light-application-wx/pages/file-detail/file-detail.wxss

@@ -1,35 +1,30 @@
 /* pages/file-detail/file-detail.wxss */
 .detail {
     padding: 30rpx;
+    box-sizing: border-box;
 }
 
 .title {
     font-size: 1.2em;
     text-align: center;
-    width: 94%;
 }
 
 .publish-time {
-    font-size: .8em;
-    color: #b9b9b9;
+    font-size: .7em;
+    color: #999999;
     text-align: center;
     margin-top: 10rpx;
 }
 
 .line {
-    width: 90%;
     height: 2rpx;
     color: #fff;
     text-align: center;
-    background-color: #dddddd;
+    background-color: #EBE8E3;
     margin-top: 40rpx;
     margin-bottom: 40rpx;
 }
 
 .content {
     color: #747474;
-    width: 94%;
-    font-size: 1.1em;
-    text-indent: 2em;
-    line-height: 1.5em;
 }