| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- // pages/shipOwnerManage/shipOwnerList/shipOwnerList.js
- import {
- postApi
- } from "../../../apis/api"
- import {
- uploadImage
- } from "../../../utils/uploadImage"
- Page({
- data: {
- step: 2,
- 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', {
- userPhone: this.data.userPhone
- })
- console.log(res)
- if (res.data.status == 0) {
- this.setData({
- ...res.data.result,
- 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("/cos/upload", {
- type: 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("/cos/upload", {
- type: 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)
- wx.setStorageSync('apiStatus', 'success')
- if (res.data.status == 0) {
- wx.switchTab({
- url: '/pages/shipOwnerManage/shipOwnerList/shipOwnerList',
- })
- }
- }
- })
|