Bläddra i källkod

新增 新建船东;首页数据

wzh 3 år sedan
förälder
incheckning
e96deee998

+ 1 - 6
miniprogram/app.wxss

@@ -1,9 +1,4 @@
-page {
-  width: 100%;
-  height: 100%;
-  background: #fff;
-}
-
+page,
 view,
 scroll-view,
 cover-view {

+ 29 - 25
miniprogram/pages/index/index.js

@@ -9,10 +9,8 @@ Page({
     indexInfo: {},
   },
   async getIndexInfo() {
-    if (wx.getStorageSync('isClient')) return
-    let res = await postApi('/voyage/index', {
-      cargoOwnerId: wx.getStorageSync('cargoOwnerId'),
-      isClient: wx.getStorageSync('isClient'),
+    let res = await postApi('/index', {
+      loginAccountId: wx.getStorageSync('loginAccountId'),
     })
     this.setData({
       indexInfo: res.data.result
@@ -22,29 +20,35 @@ Page({
 
   },
   onLoad() {
-    wx.removeStorageSync('voyageDetailId')
+    this.getIndexInfo()
   },
   onShow() {
-    if (wx.getStorageSync('isClient')) return
-    if (wx.getStorageSync('voyageDetailId')) return
-    wx.removeStorageSync('voyageDetailId')
-    let cargoOwnerId = wx.getStorageSync('cargoOwnerId')
-    if (cargoOwnerId) {
-      this.getIndexInfo()
-      this.setData({
-        cargoOwnerId
-      })
-    }
-    let rolePermission = wx.getStorageSync('rolePermission')
 
-    if (rolePermission.indexOf('VOYAGELIST') == -1) {
-      wx.showToast({
-        icon: "none",
-        title: '暂无权限,请联系管理员',
-      })
-      return
-    }
-    const child = this.selectComponent('.voyages');
-    child.getVoyageList()
+    let data = [{
+        letter: 'A',
+        data: [{
+            name: 'azh',
+            phone: 13303849723
+          },
+          {
+            name: 'azz',
+            phone: 13303849723
+          },
+        ]
+      },
+      {
+        letter: 'B',
+        data: [{
+            name: 'bzh',
+            phone: 13303849723
+          },
+          {
+            name: 'bzz',
+            phone: 13303849723
+          },
+        ]
+      }
+    ]
+
   }
 })

+ 6 - 6
miniprogram/pages/index/index.wxml

@@ -3,17 +3,17 @@
     <view class="block-line df aic">
       <view style="width: 100%;">
         <view>活跃船舶数量</view>
-        <view>{{cargoOwnerId?indexInfo.transShipCount:'*****'}}</view>
+        <view>{{indexInfo.activeShipNum}}</view>
       </view>
     </view>
     <view class="block-line df aic">
       <view>
         <view>装载吨位</view>
-        <view>{{cargoOwnerId?indexInfo.dischargeTons:'*****'}}</view>
+        <view>{{indexInfo.loadTons}}</view>
       </view>
       <view>
         <view>卸载吨位</view>
-        <view>{{cargoOwnerId?indexInfo.finshDischargeTons:'*****'}}</view>
+        <view>{{indexInfo.discTons}}</view>
       </view>
     </view>
   </view>
@@ -21,17 +21,17 @@
     <view class="df">
       <view>
         <image src="../../images/camera.png"></image>
-        <view>日报</view>
+        <view>日报{{indexInfo.dayReportNum}}</view>
       </view>
       <view>
         <image src="../../images/ship.png"></image>
-        <view>卸货</view>
+        <view>卸货{{indexInfo.discVoyageNum}}</view>
       </view>
     </view>
     <view class="df">
       <view>
         <image src="../../images/bills.png"></image>
-        <view>单据</view>
+        <view>单据{{indexInfo.billNum}}</view>
       </view>
       <view>
         <image src="../../images/rudder.png"></image>

+ 155 - 2
miniprogram/pages/shipOwnerManage/addShipOnwer/addShipOnwer.js

@@ -2,14 +2,167 @@
 import {
   postApi
 } from "../../../apis/api"
+
+import {
+  uploadImage
+} from "../../../utils/uploadImage"
+
 Page({
   data: {
-    phone: ''
+    step: 1,
+    userId: 0,
+    userName: "",
+    userPhone: "",
+    idCardNo: '',
+    idcardFrontFileKey: '',
+    idcardFrontViewUrl: '',
+    idcardFrontDownloadUrl: '',
+    idcardBackFileKey: '',
+    idcardBackViewUrl: '',
+    idcardBackDownloadUrl: '',
+    shipId: 0,
+    shipName: "",
+    shipMmsi: "",
+    shipCerts: []
   },
   async checkShipOwner() {
+    if (!this.data.userPhone) {
+      wx.showToast({
+        title: '请填写手机号',
+        icon: "error"
+      })
+      return
+    }
     let res = await postApi('/ship/search/shipOwner', {
-      phone: this.data.phone
+      userPhone: this.data.userPhone
+    })
+    console.log(res)
+    if (res.data.status == 0) {
+      let {
+        userName,
+        userId,
+      } = res.data.result
+
+      this.setData({
+        userName,
+        userId,
+        step: 2
+      })
+    } else {
+      this.setData({
+        step: 2
+      })
+    }
+  },
+  step2next() {
+    if (!this.data.userName) {
+      wx.showToast({
+        title: '请填写船东姓名',
+        icon: "error"
+      })
+      return
+    }
+
+    if (!this.data.userPhone) {
+      wx.showToast({
+        title: '请填写手机号',
+        icon: "error"
+      })
+      return
+    }
+    this.setData({
+      step: 3
     })
+  },
+  async uploadId(e) {
+    let res = await uploadImage(1)
+    if (res.status == 0) {
+      if (e.currentTarget.dataset.type == 'head') {
+        let {
+          idcardFrontFileKey,
+          idcardFrontViewUrl,
+          idcardFrontDownloadUrl,
+        } = this
+        idcardFrontFileKey = res.result.key
+        idcardFrontViewUrl = res.result.viewUrl
+        idcardFrontDownloadUrl = res.result.downloadUrl
+        this.setData({
+          idcardFrontFileKey,
+          idcardFrontViewUrl,
+          idcardFrontDownloadUrl,
+        })
+      } else {
+        let {
+          idcardBackFileKey,
+          idcardBackViewUrl,
+          idcardBackDownloadUrl,
+        } = this
+        idcardBackFileKey = res.result.key
+        idcardBackViewUrl = res.result.viewUrl
+        idcardBackDownloadUrl = res.result.downloadUrl
+        this.setData({
+          idcardBackFileKey,
+          idcardBackViewUrl,
+          idcardBackDownloadUrl,
+        })
+      }
+    }
+  },
+  async uploadShipCerts(e) {
+    let res = await uploadImage(2)
+    if (res.status == 0) {
+      let {
+        downloadUrl,
+        key: fileKey,
+        viewUrl
+      } = res.result
+      if (e.currentTarget.dataset.type == 'push') {
+        this.data.shipCerts.push({
+          downloadUrl,
+          fileKey,
+          viewUrl
+        })
+      } else {
+        this.data.shipCerts[e.currentTarget.dataset.index] = {
+          downloadUrl,
+          fileKey,
+          viewUrl
+        }
+      }
+      this.setData({
+        shipCerts: this.data.shipCerts
+      })
+    }
+  },
+  async submit() {
+    if (!this.data.shipName) {
+      wx.showToast({
+        title: '请填写船舶名称',
+        icon: "error"
+      })
+      return
+    }
+    if (!this.data.shipMmsi) {
+      wx.showToast({
+        title: '请填写MMSI',
+        icon: "error"
+      })
+      return
+    }
+    let postData = {
+      ...this.data,
+      loginAccountId: wx.getStorageSync('loginAccountId')
+    }
+    console.log(postData)
+    delete postData.__webviewId__
+    delete postData.step
+    let res = await postApi('/ship/add', postData)
     console.log(res)
+    return
+    if (res.data.status == 0) {
+      wx.switchTab({
+        url: '/pages/shipOwnerManage/shipOwnerList/shipOwnerList',
+      })
+    }
   }
 })

+ 51 - 4
miniprogram/pages/shipOwnerManage/addShipOnwer/addShipOnwer.wxml

@@ -1,5 +1,52 @@
-<view style="width: 80vw;height: 50vw;border: 2rpx solid grey;border-radius: 10rpx;text-align: center;margin:10vh auto">
-  <view style="margin: 5vw;">请输入船东手机号</view>
-  <input model:value="{{phone}}" style="width: 400rpx;height: 60rpx;border: 1rpx solid grey;margin:0 auto;border-radius: 6rpx;padding-left: 20rpx;" type="number" placeholder-style="text-align:left" placeholder="必填" />
-  <view bindtap="checkShipOwner" style="width: 300rpx;height: 80rpx;line-height:80rpx;color: #fff;background:#0094FE;border-radius: 10rpx;margin: 8vw auto;">新建</view>
+<view class="box">
+  <block wx:if="{{step==1}}">
+    <view style="margin-bottom: 5vw;">请输入船东手机号</view>
+    <input model:value="{{userPhone}}" class="ship-owner-phone" type="number" placeholder-style="text-align:left" placeholder="必填" />
+    <view bindtap="checkShipOwner" class="next">新建</view>
+  </block>
+  <block wx:if="{{step==2}}">
+    <view>船东信息</view>
+    <view class="df jcsb line">
+      <view>姓名</view>
+      <view><input disabled="{{userId}}" model:value="{{userName}}" type="text" placeholder="必填" /></view>
+    </view>
+    <view class="df jcsb line">
+      <view>手机号</view>
+      <view><input disabled="{{userId}}" model:value="{{userPhone}}" type="text" placeholder="必填" /></view>
+    </view>
+    <view class="df jcsb line">
+      <view>身份证号</view>
+      <view><input model:value="{{idCardNo}}" type="text" /></view>
+    </view>
+    <view>
+      <view>身份证人像面</view>
+      <image wx:if="{{idcardFrontViewUrl}}" class="upload-image" src="{{idcardFrontViewUrl}}"></image>
+      <view wx:else="" class="upload" bindtap="uploadId" data-type="head">上传</view>
+    </view>
+    <view>
+      <view>身份证国徽面</view>
+      <image wx:if="{{idcardBackViewUrl}}" class="upload-image" src="{{idcardBackViewUrl}}"></image>
+      <view wx:else="" class="upload" bindtap="uploadId" data-type="emblem">上传</view>
+    </view>
+    <view bindtap="step2next" class="next">下一步</view>
+  </block>
+  <block wx:if="{{step==3}}">
+    <view>船舶信息</view>
+    <view class="df jcsb line">
+      <view>船舶名称</view>
+      <view><input disabled="{{shipId}}" model:value="{{shipName}}" type="text" placeholder="必填" /></view>
+    </view>
+    <view class="df jcsb line">
+      <view>MMSI</view>
+      <view><input disabled="{{shipId}}" model:value="{{shipMmsi}}" type="number" placeholder="必填" /></view>
+    </view>
+    <view>
+      <view>船舶证书</view>
+      <block wx:if="{{shipCerts.length}}">
+        <image bindtap="uploadShipCerts" wx:for="{{shipCerts}}" data-index="{{index}}" class="upload-image" src="{{item.viewUrl}}"></image>
+      </block>
+      <view data-type="push" class="upload" bindtap="uploadShipCerts">上传</view>
+    </view>
+    <view bindtap="submit" class="next">确定</view>
+  </block>
 </view>

+ 63 - 1
miniprogram/pages/shipOwnerManage/addShipOnwer/addShipOnwer.wxss

@@ -1 +1,63 @@
-/* pages/shipOwnerManage/addShipOnwer/addShipOnwer.wxss */
+/* pages/shipOwnerManage/addShipOnwer/addShipOnwer.wxss */
+.box {
+  width: 80vw;
+  border: 2rpx solid grey;
+  border-radius: 10rpx;
+  text-align: center;
+  margin: 0 auto;
+  padding: 5vw 0;
+}
+
+.ship-owner-phone {
+  width: 400rpx;
+  height: 60rpx;
+  border: 1rpx solid grey;
+  margin: 0 auto;
+  border-radius: 6rpx;
+  padding-left: 20rpx;
+}
+
+.line {
+  width: 80%;
+  margin: 30rpx auto;
+  font-size: 28rpx;
+}
+
+.line view {
+  line-height: 48rpx;
+
+}
+
+.line input {
+  border: 1px solid grey;
+  height: 48rpx;
+}
+
+.upload {
+  width: 68vw;
+  height: 32vw;
+  border: 1px solid grey;
+  margin: 3vw auto;
+}
+
+page {
+  padding-top: 5vw;
+}
+
+.upload-image {
+  width: 68vw;
+  height: 32vw;
+  border: 1px solid grey;
+  margin: 3vw auto;
+}
+
+.next {
+  width: 300rpx;
+  height: 80rpx;
+  line-height: 80rpx;
+  color: #fff;
+  background: #0094FE;
+  border-radius: 10rpx;
+  margin: 0 auto;
+  margin-top: 8vw;
+}

+ 1 - 1
project.config.json

@@ -38,7 +38,7 @@
     "minifyWXML": true,
     "showES6CompileOption": false,
     "useCompilerPlugins": false,
-    "ignoreUploadUnusedFiles": false
+    "ignoreUploadUnusedFiles": true
   },
   "appid": "wxd2dff8f427e787d7",
   "projectname": "汇很多代理",