|
|
@@ -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',
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|