浏览代码

新增 已注册用户绑定船舶

wzh 3 年之前
父节点
当前提交
20308fbe27

+ 62 - 1
miniprogram/pages/takePhoto/takePhoto.js

@@ -1,6 +1,9 @@
 import {
   uploadFile
 } from "../../utils/upload"
+import {
+  postApi
+} from "../../apis/api"
 Page({
   data: {
     avatar: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/avatar-icon.jpg?sign=f5c66c94d189436f82353eb48cb01f08&t=1634538864",
@@ -11,7 +14,8 @@ Page({
     shipName: "",
     shipMmsi: "",
     authModal: false,
-    modalText: "位置"
+    modalText: "位置",
+    shipId: ''
   },
   openSetting() {
     this.setData({
@@ -45,6 +49,62 @@ Page({
       url: '/pages/takeBill/takeBill',
     })
   },
+  async registerShip() {
+    if (!this.checkout()) return
+    let res = await postApi('/user/wx/register', {
+      userId: wx.getStorageSync('userId'),
+      shipName: this.data.shipName,
+      shipMmsi: this.data.shipMmsi,
+    })
+
+
+    if (res.data.status == 0) {
+      let {
+        shipInfo,
+        userInfo
+      } = res.data.result
+
+      let data = {
+        ...shipInfo,
+        ...userInfo
+      }
+      Object.keys(data).forEach(function (key) {
+        wx.setStorageSync(key, data[key])
+      })
+      wx.showToast({
+        title: res.data.msg,
+      })
+      this.setData({
+        ...data
+      })
+    } else {
+      wx.showToast({
+        title: res.data.msg,
+      })
+    }
+
+
+  },
+
+  checkout() {
+    if (!this.data.shipName) {
+      wx.showToast({
+        title: '请输入船名!',
+        icon: "error"
+      })
+      return
+    }
+
+    if (!this.data.shipMmsi) {
+      wx.showToast({
+        title: '请输入MMSI!',
+        icon: "error"
+      })
+      return
+    }
+
+    return true
+  },
   takePhoto(e) {
     let {
       mediatype
@@ -226,6 +286,7 @@ Page({
     let userId = wx.getStorageSync('userId')
     let phone = wx.getStorageSync('phone')
     let shipId = wx.getStorageSync('shipId')
+
     this.setData({
       userName,
       phone,

+ 21 - 7
miniprogram/pages/takePhoto/takePhoto.wxml

@@ -2,17 +2,31 @@
   <image class="avatar-icon" src="{{avatar}}"></image>
   <view class="text" style="text-align: center;">{{userName?"":"体验用户"}}<text wx:if="{{userName}}" class="user-name">{{userName}}</text><text wx:if="{{phone}}" class="phone">{{phone}}</text></view>
 </view>
-<view wx:if="{{userId&&shipId}}" class="new-camera camera-cargo">
-  <image class="icon" bindtap="takePhoto" data-mediatype="{{3}}" src="{{newCameraIcon}}"></image>
-  <view bindtap="takePhoto" data-mediatype="{{3}}">拍货物</view>
+<view wx:if="{{userId&&shipId}}">
+  <view class="new-camera camera-cargo">
+    <image class="icon" bindtap="takePhoto" data-mediatype="{{3}}" src="{{newCameraIcon}}"></image>
+    <view bindtap="takePhoto" data-mediatype="{{3}}">拍货物</view>
 
+  </view>
+  <view class="new-camera camera-bill">
+    <image class="icon" data-mediatype="{{0}}" bindtap="takeBill" src="{{newCameraIcon}}"></image>
+    <view data-mediatype="{{0}}" bindtap="takeBill"> 拍单据
+    </view>
+  </view>
 </view>
-<view wx:if="{{userId&&shipId}}" class="new-camera camera-bill">
-  <image class="icon" data-mediatype="{{0}}" bindtap="takeBill" src="{{newCameraIcon}}"></image>
-  <view data-mediatype="{{0}}" bindtap="takeBill"> 拍单据
+<view wx:else>
+  <image wx:if="{{!userId&&!shipId||!userId}}" class="camera-icon" bindtap="takePhoto" data-mediatype="{{3}}" src="{{cameraIcon}}"></image>
+  <view wx:else style="margin-top: 20%;">
+    <view class="line mb30">
+      <view class="ship-name">船舶名称 : </view><input class="ship-name-ipt" model:value="{{shipName}}" type="text" placeholder="请输入船舶名称" />
+    </view>
+    <view class="line">
+      <view class="ship-mmsi">MMSI : </view><input class="ship-mmsi-ipt" model:value="{{shipMmsi}}" type="text" placeholder="请输入MMSI" />
+    </view>
+    <view bindtap="registerShip" class="submit">绑定船舶</view>
   </view>
+
 </view>
-<image wx:else class="camera-icon" bindtap="takePhoto" data-mediatype="{{3}}" src="{{cameraIcon}}"></image>
 <view class="auth-modal" wx:if="{{authModal}}">
   <view class="modal">
     <view class="service">为了更好的提供服务</view>

+ 41 - 0
miniprogram/pages/takePhoto/takePhoto.wxss

@@ -110,4 +110,45 @@
   padding-top: 6vh;
   color: #fff;
   font-size: 42rpx;
+}
+
+
+.ship-name,
+.ship-mmsi {
+  width: 153rpx;
+  height: 36rpx;
+  font-size: 30rpx;
+  font-family: PingFangSC-Regular,
+    PingFang SC;
+  font-weight: 400;
+  color: #333333;
+  line-height: 36rpx;
+  text-align: right;
+  margin-right: 6rpx;
+}
+
+.ship-name-ipt,
+.ship-mmsi-ipt {
+  width: 420rpx;
+  height: 67rpx;
+  border: 1px solid #979797;
+  font-size: 30rpx;
+  padding-left: 20rpx;
+}
+
+
+.submit {
+  margin: 130rpx auto;
+  width: 80%;
+  height: 80rpx;
+  background: #0094FE;
+  border-radius: 4rpx;
+  font-size: 34rpx;
+  font-family: PingFangSC-Regular,
+    PingFang SC;
+  font-weight: 400;
+  color: #FFFFFF;
+  text-align: center;
+  line-height: 80rpx;
+  border-radius: 40rpx;
 }

+ 4 - 9
project.config.json

@@ -68,18 +68,13 @@
     }
   },
   "compileType": "miniprogram",
-  "scripts": {},
   "packOptions": {
     "ignore": [],
     "include": []
   },
-  "watchOptions": {
-    "ignore": []
-  },
-  "debugOptions": {
-    "hidedInDevtools": []
-  },
-  "staticServerOptions": {
-    "servePath": ""
+  "srcMiniprogramRoot": "miniprogram/",
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
   }
 }

+ 1 - 31
project.private.config.json

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