瀏覽代碼

新增 海事公告

wzg 2 年之前
父節點
當前提交
6205bd8cba

+ 132 - 0
miniprogram/app.wxss

@@ -31,4 +31,136 @@ view {
 
 .aic {
   align-items: center;
+}
+
+.m10 {
+  margin: 10rpx !important;
+}
+
+.m20 {
+  margin: 20rpx !important;
+}
+
+.m30 {
+  margin: 30rpx !important;
+}
+
+.m40 {
+  margin: 40rpx !important;
+}
+
+.m50 {
+  margin: 50rpx !important;
+}
+
+.m10a {
+  margin: 10rpx auto !important;
+}
+
+.m20a {
+  margin: 20rpx auto !important;
+}
+
+.m30a {
+  margin: 30rpx auto !important;
+}
+
+.m40a {
+  margin: 40rpx auto !important;
+}
+
+.m50a {
+  margin: 50rpx auto !important;
+}
+
+.mt10 {
+  margin-top: 10rpx !important;
+}
+
+.mt20 {
+  margin-top: 20rpx !important;
+}
+
+.mt30 {
+  margin-top: 30rpx !important;
+}
+
+.mt40 {
+  margin-top: 40rpx !important;
+}
+
+.mt50 {
+  margin-top: 50rpx !important;
+}
+
+.mt60 {
+  margin-top: 60rpx !important;
+}
+
+.mt80 {
+  margin-top: 80rpx !important;
+}
+
+.mt100 {
+  margin-top: 100rpx !important;
+}
+
+.mr10 {
+  margin-right: 10rpx !important;
+}
+
+.mr20 {
+  margin-right: 20rpx !important;
+}
+
+.mr30 {
+  margin-right: 30rpx !important;
+}
+
+.mr40 {
+  margin-right: 40rpx !important;
+}
+
+.mr50 {
+  margin-right: 50rpx !important;
+}
+
+.mb10 {
+  margin-bottom: 10rpx !important;
+}
+
+.mb20 {
+  margin-bottom: 20rpx !important;
+}
+
+.mb30 {
+  margin-bottom: 30rpx !important;
+}
+
+.mb40 {
+  margin-bottom: 40rpx !important;
+}
+
+.mb50 {
+  margin-bottom: 50rpx !important;
+}
+
+.ml10 {
+  margin-left: 10rpx !important;
+}
+
+.ml20 {
+  margin-left: 20rpx !important;
+}
+
+.ml30 {
+  margin-left: 30rpx !important;
+}
+
+.ml40 {
+  margin-left: 40rpx !important;
+}
+
+.ml50 {
+  margin-left: 50rpx !important;
 }

+ 69 - 30
miniprogram/pages/maritime/maritime.js

@@ -1,56 +1,95 @@
 // pages/maritime/maritime.js
-import {
-  postApi
-} from "../../apis/api"
+import { postApi } from "../../apis/api";
 Page({
   data: {
     list: [],
-    total: '',
+    total: "",
     currentPage: 1,
-    size: 10
+    size: 10,
   },
   async getList(isScroll) {
-    let {
-      list,
-      currentPage,
-      size
-    } = this.data
-    let {
-      data
-    } = await postApi('/maritime/notice/getFileList', {
+    let { list, currentPage, size } = this.data;
+    let { data } = await postApi("/maritime/notice/getFileList", {
       currentPage,
-      size
-    })
-    let {
-      total,
-      status
-    } = data
+      size,
+      shipId: wx.getStorageSync("shipId"),
+      userId: wx.getStorageSync("userId"),
+    });
+    let { total, status } = data;
     if (status == 0) {
       if (isScroll) {
-        list = [...list, ...data.result]
+        list = [...list, ...data.result];
       } else {
-        list = data.result
+        list = data.result;
       }
     } else {
       if (!isScroll) {
-        list = []
+        list = [];
       }
     }
     this.setData({
       list,
-      total
-    })
+      total,
+    });
+  },
+  async openFile(e) {
+    try {
+      wx.showLoading({
+        title: "正在加载...",
+      });
+      let { downloadUrl: url, suffixName } = e.currentTarget.dataset.item;
+      wx.downloadFile({
+        url,
+        success: ({ tempFilePath: filePath }) => {
+          wx.hideLoading();
+          wx.openDocument({
+            filePath,
+            fileType: suffixName.toLowerCase(),
+          });
+        },
+      });
+    } catch (error) {
+      wx.showToast({
+        title: "系统繁忙",
+        icon: "error",
+      });
+      wx.hideLoading();
+    }
   },
 
   onPullDownRefresh() {
     this.setData({
       list: [],
       currentPage: 1,
-      total: 0
-    })
-    this.getList()
+      total: 0,
+    });
+    this.getList();
+  },
+  scrollList() {
+    if (
+      this.data.total == 0 ||
+      this.data.total <= this.data.size * this.data.currentPage
+    )
+      return;
+    this.data.currentPage += 1;
+    this.getList(true);
+  },
+  scrollDownList() {
+    this.setData({
+      total: 0,
+      currentPage: 1,
+      list: [],
+    });
+    this.getList();
   },
-  onLoad(options) {
-    this.getList()
+  onLoad(options) {},
+  onShow() {
+    console.log("show");
+    this.setData({
+      list: [],
+      currentPage: 1,
+      size: 10,
+    });
+    this.getList();
   },
-})
+});

+ 3 - 2
miniprogram/pages/maritime/maritime.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
-}
+  "usingComponents": {},
+  "navigationBarTitleText": "海事公告"
+}

+ 6 - 3
miniprogram/pages/maritime/maritime.wxml

@@ -1,3 +1,6 @@
-<view class="mb10" wx:for="{{list}}">
-  {{item.fileName}}
-</view>
+<view class="title">海事公告</view>
+<scroll-view class="container" bindrefresherrefresh="scrollDownList" refresher-triggered="{{isFreshing}}" refresher-enabled="{{true}}" scroll-y="true" bindscrolltolower="scrollList" style="height:calc(100vh - 120rpx)">
+  <view class="mb20 item" wx:for="{{list}}" wx:key="index" bind:tap="openFile" data-item="{{item}}">
+    {{index+1}}. {{item.fileName}}
+  </view>
+</scroll-view>

+ 18 - 1
miniprogram/pages/maritime/maritime.wxss

@@ -1 +1,18 @@
-/* pages/maritime/maritime.wxss */
+/* pages/maritime/maritime.wxss */
+.title {
+  background: #2e6cb7;
+  text-align: center;
+  color: #fff;
+  padding: 20rpx;
+}
+
+.container {
+  margin: 20rpx 30rpx;
+}
+
+.item {
+  width: 95vw;
+  padding: 10rpx 20rpx;
+  border-bottom: 1px solid #ddd;
+  font-size: 28rpx;
+}

+ 3 - 1
project.config.json

@@ -39,7 +39,9 @@
     "showES6CompileOption": false,
     "useCompilerPlugins": false,
     "ignoreUploadUnusedFiles": true,
-    "localPlugins": false
+    "localPlugins": false,
+    "condition": false,
+    "skylineRenderEnable": false
   },
   "appid": "wxf22759845920b6f3",
   "projectname": "船东小程序",

+ 7 - 0
project.private.config.json

@@ -9,6 +9,13 @@
           "launchMode": "default",
           "scene": null
         },
+        {
+          "name": "",
+          "pathName": "pages/maritime/maritime",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
         {
           "name": "",
           "pathName": "pages/maritime/maritime",