Browse Source

新增 航次列表组件

wzh 3 năm trước cách đây
mục cha
commit
b6a61c41e1

+ 42 - 0
miniprogram/components/voyages/voyages.js

@@ -0,0 +1,42 @@
+// components/voyages/Voyages.js
+import {
+  postApi
+} from "../../apis/api"
+Component({
+  properties: {
+
+  },
+  data: {
+    term: '',
+    status: 1,
+    currentPage: 1,
+    size: 10,
+    list: []
+  },
+  methods: {
+    async getVoyageList() {
+      let res = await postApi('/voyage/list', {
+        cargoOwnerId: wx.getStorageSync('cargoOwnerId'),
+        term: this.data.term,
+        status: this.data.status,
+        currentPage: this.data.currentPage,
+        size: this.data.size
+      })
+      this.setData({
+        list: [...res.data.result,...res.data.result,...res.data.result]
+      })
+      console.log(res)
+    },
+    changeStatus(e) {
+      let {
+        status
+      } = e.currentTarget.dataset
+      this.setData({
+        status,
+        currentPage: 1,
+        size: 10
+      })
+      this.getVoyageList()
+    },
+  }
+})

+ 4 - 0
miniprogram/components/voyages/voyages.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 13 - 0
miniprogram/components/voyages/voyages.wxml

@@ -0,0 +1,13 @@
+<input model:value="{{term}}" class="p10 m30a search" type="text" placeholder="搜索船舶信息" />
+<view class="df aic jcsa tabs">
+  <view class="tabsview" bindtap="changeStatus" data-status="{{1}}" style="color:{{status==1?'blue':''}};border-bottom:{{status==1?'4rpx solid blue':''}}">运输中</view>
+  <view class="tabsview" bindtap="changeStatus" data-status="{{2}}" style="color:{{status==2?'blue':''}};border-bottom:{{status==2?'4rpx solid blue':''}}">卸货中</view>
+</view>
+<scroll-view scroll-y="true" style="height:calc(100vh - 620rpx);background: #fff;">
+  <view class="df aic jcsb list" wx:for="{{list}}" wx:key="index">
+    <view class="col-1">{{item.shipName}}</view>
+    <view class="col-2">{{item.loadPort}}-{{item.dischargeProt}}</view>
+    <view class="col-3">{{item.cargo}}</view>
+    <view class="col-4">{{item.tons}}</view>
+  </view>
+</scroll-view>

+ 73 - 0
miniprogram/components/voyages/voyages.wxss

@@ -0,0 +1,73 @@
+/* components/voyages/Voyages.wxss */
+
+.df {
+  display: flex;
+}
+
+.jcsb {
+  justify-content: space-between;
+}
+
+.jcc {
+  justify-content: center;
+}
+
+.jcfe {
+  justify-content: flex-end;
+}
+
+.jcsa {
+  justify-content: space-around;
+}
+
+.aic {
+  align-items: center;
+}
+
+.search {
+  border: 1rpx solid grey;
+  width: 80%;
+  background: #fff;
+}
+
+.tabs {
+  width: 100%;
+  height: 100rpx;
+  background: #fff;
+  box-shadow: rgb(209, 206, 206) 5rpx 5rpx 10rpx
+}
+
+.tabsview {
+  width: 100rpx;
+  height: 60rpx;
+}
+
+.p10 {
+  padding: 10rpx;
+}
+
+.m30a {
+  margin: 30rpx auto;
+}
+
+.list {
+  padding: 20rpx;
+  font-size: 28rpx;
+}
+
+.col-1 {
+  width: 30vw;
+}
+
+.col-2 {
+  width: 30vw;
+}
+
+
+.col-3 {
+  width: 10vw;
+}
+
+.col-4 {
+  width: 10vw;
+}

+ 7 - 2
miniprogram/pages/index/index.js

@@ -6,17 +6,22 @@ import {
 import cloudApi from "../../apis/cloudApi"
 Page({
   data: {
-    indexInfo:{}
+    indexInfo: {},
   },
   async getIndexInfo() {
     let res = await postApi('/voyage/index', {
       cargoOwnerId: wx.getStorageSync('cargoOwnerId')
     })
     this.setData({
-      indexInfo:res.data.result
+      indexInfo: res.data.result
     })
+  },
+  forbidTouchMove() {
+
   },
   onLoad() {
     this.getIndexInfo()
+    const child = this.selectComponent('.voyages');
+    child.getVoyageList()
   }
 })

+ 3 - 1
miniprogram/pages/index/index.json

@@ -1,3 +1,5 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "Voyages": "/components/voyages/voyages"
+  }
 }

+ 21 - 23
miniprogram/pages/index/index.wxml

@@ -1,27 +1,25 @@
-<view>
-  <view class="block-line df aic">
-    <view>
-      <view>运输中船舶数量</view>
-      <view>{{indexInfo.transShipCount}}</view>
+<view catchtouchmove="forbidTouchMove">
+  <view>
+    <view class="block-line df aic">
+      <view>
+        <view>运输中船舶数量</view>
+        <view>{{indexInfo.transShipCount}}</view>
+      </view>
+      <view>
+        <view>卸货中船舶数量</view>
+        <view>{{indexInfo.dischargeShipCount}}</view>
+      </view>
     </view>
-    <view>
-      <view>卸货中船舶数量</view>
-      <view>{{indexInfo.dischargeShipCount}}</view>
+    <view class="block-line df aic">
+      <view>
+        <view>在卸吨位</view>
+        <view>{{indexInfo.dischargeTons}}/{{indexInfo.totalDischargeTons}}</view>
+      </view>
+      <view>
+        <view>已完成卸货吨位</view>
+        <view>{{indexInfo.finshDischargeTons}}</view>
+      </view>
     </view>
   </view>
-  <view class="block-line df aic">
-    <view>
-      <view>在卸吨位</view>
-      <view>{{indexInfo.dischargeTons}}/{{indexInfo.totalDischargeTons}}</view>
-    </view>
-    <view>
-      <view>已完成卸货吨位</view>
-      <view>{{indexInfo.finshDischargeTons}}</view>
-    </view>
-  </view>
-</view>
-<input class="p10 m30a" style="border: 1rpx solid grey;width: 80%;background: #fff;" type="text" placeholder="搜索船舶信息" />
-<view class="df aic jcsa">
-  <view>运输中</view>
-  <view>卸货中</view>
+  <Voyages class="voyages"></Voyages>
 </view>

+ 16 - 1
miniprogram/pages/index/index.wxss

@@ -26,5 +26,20 @@
   margin-bottom: 30rpx;
 }
 
+.search {
+  border: 1rpx solid grey;
+  width: 80%;
+  background: #fff;
+}
+
+.tabs {
+  width: 100%;
+  height: 100rpx;
+  background: #fff;
+  box-shadow: rgb(209, 206, 206) 5rpx 5rpx 10rpx
+}
 
-.block-line>view>view:last-child {}
+.tabs>view {
+  width: 100rpx;
+  height: 60rpx;
+}

+ 6 - 11
project.config.json

@@ -40,8 +40,8 @@
     "useCompilerPlugins": false,
     "ignoreUploadUnusedFiles": true
   },
-  "appid": "wxf22759845920b6f3",
-  "projectname": "%E6%B1%9F%E8%BF%90%E9%9A%8F%E6%89%8B%E6%8B%8D2.0",
+  "appid": "wxd8fe7909b3471a51",
+  "projectname": "货主小程序",
   "libVersion": "2.19.6",
   "cloudfunctionTemplateRoot": "cloudfunctionTemplate/",
   "condition": {
@@ -68,18 +68,13 @@
     }
   },
   "compileType": "miniprogram",
-  "scripts": {},
   "packOptions": {
     "ignore": [],
     "include": []
   },
-  "watchOptions": {
-    "ignore": []
-  },
-  "debugOptions": {
-    "hidedInDevtools": []
-  },
-  "staticServerOptions": {
-    "servePath": ""
+  "srcMiniprogramRoot": "miniprogram/",
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
   }
 }

+ 3 - 33
project.private.config.json

@@ -1,17 +1,5 @@
 {
   "condition": {
-    "plugin": {
-      "current": -1,
-      "list": []
-    },
-    "game": {
-      "current": -1,
-      "list": []
-    },
-    "gamePlugin": {
-      "current": -1,
-      "list": []
-    },
     "miniprogram": {
       "list": [
         {
@@ -25,8 +13,8 @@
           "name": "",
           "pathName": "pages/login/login",
           "query": "",
-          "scene": null,
-          "launchMode": "default"
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }
@@ -34,33 +22,15 @@
   "setting": {
     "urlCheck": true,
     "coverView": true,
-    "es6": true,
-    "postcss": true,
     "compileHotReLoad": false,
     "lazyloadPlaceholderEnable": false,
     "preloadBackgroundData": false,
-    "minified": true,
     "autoAudits": false,
-    "uglifyFileName": false,
-    "uploadWithSourceMap": true,
-    "enhance": true,
     "useMultiFrameRuntime": false,
     "showShadowRootInWxmlPanel": true,
-    "packNpmManually": false,
-    "packNpmRelationList": [],
-    "minifyWXSS": true,
-    "minifyWXML": true,
     "useStaticServer": true,
     "showES6CompileOption": false,
-    "checkInvalidKey": true,
-    "babelSetting": {
-      "ignore": [],
-      "disablePlugins": [],
-      "outputPath": ""
-    },
-    "disableUseStrict": false,
-    "useCompilerPlugins": false,
-    "ignoreUploadUnusedFiles": true
+    "checkInvalidKey": true
   },
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
 }