|
@@ -20,13 +20,105 @@ Page({
|
|
|
shipName: "",
|
|
shipName: "",
|
|
|
shipMmsi: "",
|
|
shipMmsi: "",
|
|
|
agreeModal: false,
|
|
agreeModal: false,
|
|
|
- agreeText: false
|
|
|
|
|
|
|
+ agreeText: false,
|
|
|
|
|
+ isWxRegister: false
|
|
|
},
|
|
},
|
|
|
goBack() {
|
|
goBack() {
|
|
|
wx.redirectTo({
|
|
wx.redirectTo({
|
|
|
url: '/pages/index/index',
|
|
url: '/pages/index/index',
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ async register() {
|
|
|
|
|
+ if (!this.checkout()) return
|
|
|
|
|
+ let res = await postApi('/user/wx/register', {
|
|
|
|
|
+ userId: wx.getStorageSync('userId'),
|
|
|
|
|
+ shipName: this.data.shipName,
|
|
|
|
|
+ shipMmsi: this.data.shipMmsi,
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ 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.compressImage({
|
|
|
|
|
+ src: wx.getStorageSync('file'),
|
|
|
|
|
+ quality: 80, // 压缩质量
|
|
|
|
|
+ success: async e => {
|
|
|
|
|
+ console.log("图片压缩成功!", e)
|
|
|
|
|
+ wx.hideLoading({
|
|
|
|
|
+ success: (res) => {},
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
|
+ title: '正在上传...',
|
|
|
|
|
+ })
|
|
|
|
|
+ let res = await uploadFile(e.tempFilePath, {
|
|
|
|
|
+ type: 3,
|
|
|
|
|
+ userId: wx.getStorageSync('userId'),
|
|
|
|
|
+ location: `${this.data.longitude},${this.data.latitude}`
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log("上传结束", res)
|
|
|
|
|
+ if (res.status == 0) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: res.msg
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.setStorageSync('shareImageUrl', res.result.viewUrl)
|
|
|
|
|
+ console.log(wx.getStorageSync('shareImageUrl'))
|
|
|
|
|
+ wx.downloadFile({
|
|
|
|
|
+ url: res.result.viewUrl,
|
|
|
|
|
+ success: e => {
|
|
|
|
|
+ console.log("下载调用!", e)
|
|
|
|
|
+ wx.setStorageSync('cacheImage', e.tempFilePath)
|
|
|
|
|
+ wx.saveImageToPhotosAlbum({
|
|
|
|
|
+ filePath: e.tempFilePath,
|
|
|
|
|
+ success: e => {
|
|
|
|
|
+ if (e.errMsg == "saveImageToPhotosAlbum:ok") {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '保存成功!',
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.removeStorageSync('cacheImage')
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: e => {
|
|
|
|
|
+ console.log("失败44", e)
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ authModal: true,
|
|
|
|
|
+ modalText: "文件存储"
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.navigateTo({
|
|
|
|
|
+ url: '/pages/takePhoto/success/success',
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: e => {
|
|
|
|
|
+ console.log("失败3", e)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: res.msg
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: e => {
|
|
|
|
|
+ console.log("失败22", e)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
checkout() {
|
|
checkout() {
|
|
|
if (!this.data.shipName) {
|
|
if (!this.data.shipName) {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
@@ -91,25 +183,17 @@ Page({
|
|
|
} = result
|
|
} = result
|
|
|
if (phone) {
|
|
if (phone) {
|
|
|
wx.setStorageSync('phone', phone)
|
|
wx.setStorageSync('phone', phone)
|
|
|
- let {
|
|
|
|
|
- shipName,
|
|
|
|
|
- shipMmsi
|
|
|
|
|
- } = this.data
|
|
|
|
|
try {
|
|
try {
|
|
|
- let res = await uploadFile(wx.getStorageSync('file'), {
|
|
|
|
|
|
|
+ let res = await postApi('/user/wx/login', {
|
|
|
openId: wx.getStorageSync('openId'),
|
|
openId: wx.getStorageSync('openId'),
|
|
|
- phone,
|
|
|
|
|
- shipName,
|
|
|
|
|
- shipMmsi,
|
|
|
|
|
- type: wx.getStorageSync('type'),
|
|
|
|
|
- location: `${this.data.longitude},${this.data.latitude}`
|
|
|
|
|
- }, 1)
|
|
|
|
|
- if (res.status == 0) {
|
|
|
|
|
- wx.setStorageSync('shareImageUrl', res.result.mediaInfo.viewUrl)
|
|
|
|
|
|
|
+ phone
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ if (res.data.status == 0) {
|
|
|
let {
|
|
let {
|
|
|
shipInfo,
|
|
shipInfo,
|
|
|
userInfo
|
|
userInfo
|
|
|
- } = res.result
|
|
|
|
|
|
|
+ } = res.data.result
|
|
|
|
|
|
|
|
let data = {
|
|
let data = {
|
|
|
...shipInfo,
|
|
...shipInfo,
|
|
@@ -118,78 +202,96 @@ Page({
|
|
|
Object.keys(data).forEach(function (key) {
|
|
Object.keys(data).forEach(function (key) {
|
|
|
wx.setStorageSync(key, data[key])
|
|
wx.setStorageSync(key, data[key])
|
|
|
})
|
|
})
|
|
|
- wx.showToast({
|
|
|
|
|
- title: res.msg,
|
|
|
|
|
- })
|
|
|
|
|
- wx.downloadFile({
|
|
|
|
|
- url: res.result.mediaInfo.viewUrl,
|
|
|
|
|
- success: e => {
|
|
|
|
|
- console.log("下载调用!", e)
|
|
|
|
|
- wx.setStorageSync('cacheImage', e.tempFilePath)
|
|
|
|
|
- wx.saveImageToPhotosAlbum({
|
|
|
|
|
- filePath: e.tempFilePath,
|
|
|
|
|
- success: e => {
|
|
|
|
|
- console.log(5, e)
|
|
|
|
|
-
|
|
|
|
|
- if (e.errMsg == "saveImageToPhotosAlbum:ok") {
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- title: '保存成功!',
|
|
|
|
|
- })
|
|
|
|
|
- wx.removeStorageSync('cacheImage')
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- fail: async e => {
|
|
|
|
|
- console.log("6", e)
|
|
|
|
|
- wx.hideLoading({})
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- title: '保存失败!',
|
|
|
|
|
- duration: 5000
|
|
|
|
|
- })
|
|
|
|
|
- await cloudApi('sendError', {
|
|
|
|
|
- e,
|
|
|
|
|
- flag: 4,
|
|
|
|
|
- msg: "保存失败"
|
|
|
|
|
- })
|
|
|
|
|
- this.setData({
|
|
|
|
|
- authModal: true,
|
|
|
|
|
- modalText: "文件存储"
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- wx.navigateTo({
|
|
|
|
|
- url: '/pages/takePhoto/success/success',
|
|
|
|
|
|
|
+ wx.compressImage({
|
|
|
|
|
+ src: wx.getStorageSync('file'),
|
|
|
|
|
+ quality: 80, // 压缩质量
|
|
|
|
|
+ success: async e => {
|
|
|
|
|
+ console.log("图片压缩成功!", e)
|
|
|
|
|
+ wx.hideLoading({
|
|
|
|
|
+ success: (res) => {},
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
- fail: async e => {
|
|
|
|
|
- wx.hideLoading({})
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- title: '下载失败!',
|
|
|
|
|
- duration: 5000
|
|
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
|
+ title: '正在上传...',
|
|
|
})
|
|
})
|
|
|
- await cloudApi('sendError', {
|
|
|
|
|
- e,
|
|
|
|
|
- msg: "下载失败",
|
|
|
|
|
- flag: 3
|
|
|
|
|
|
|
+ let res = await uploadFile(e.tempFilePath, {
|
|
|
|
|
+ type: 3,
|
|
|
|
|
+ userId: wx.getStorageSync('userId'),
|
|
|
|
|
+ location: `${this.data.longitude},${this.data.latitude}`
|
|
|
})
|
|
})
|
|
|
|
|
+ console.log("上传结束", res)
|
|
|
|
|
+ if (res.status == 0) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: res.msg
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.setStorageSync('shareImageUrl', res.result.viewUrl)
|
|
|
|
|
+ console.log(wx.getStorageSync('shareImageUrl'))
|
|
|
|
|
+ wx.downloadFile({
|
|
|
|
|
+ url: res.result.viewUrl,
|
|
|
|
|
+ success: e => {
|
|
|
|
|
+ console.log("下载调用!", e)
|
|
|
|
|
+ wx.setStorageSync('cacheImage', e.tempFilePath)
|
|
|
|
|
+ wx.saveImageToPhotosAlbum({
|
|
|
|
|
+ filePath: e.tempFilePath,
|
|
|
|
|
+ success: e => {
|
|
|
|
|
+ if (e.errMsg == "saveImageToPhotosAlbum:ok") {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '保存成功!',
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.removeStorageSync('cacheImage')
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: e => {
|
|
|
|
|
+ console.log("失败4", e)
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ authModal: true,
|
|
|
|
|
+ modalText: "文件存储"
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.navigateTo({
|
|
|
|
|
+ url: '/pages/takePhoto/success/success',
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: e => {
|
|
|
|
|
+ console.log("失败33", e)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: res.msg
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: e => {
|
|
|
|
|
+ console.log("失败2", e)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
- wx.hideLoading({})
|
|
|
|
|
- await cloudApi('sendError', {
|
|
|
|
|
- res,
|
|
|
|
|
- flag: 2
|
|
|
|
|
|
|
+ let {
|
|
|
|
|
+ userInfo
|
|
|
|
|
+ } = res.data.result
|
|
|
|
|
+
|
|
|
|
|
+ let data = {
|
|
|
|
|
+ ...userInfo
|
|
|
|
|
+ }
|
|
|
|
|
+ Object.keys(data).forEach(function (key) {
|
|
|
|
|
+ wx.setStorageSync(key, data[key])
|
|
|
})
|
|
})
|
|
|
- wx.showToast({
|
|
|
|
|
- title: res.msg,
|
|
|
|
|
- icon: "error"
|
|
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ isWxRegister: true,
|
|
|
|
|
+ agreeModal: false
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- await cloudApi('sendError', {
|
|
|
|
|
- error,
|
|
|
|
|
- flag: 1
|
|
|
|
|
|
|
+ console.log(error)
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ wx.hideLoading({
|
|
|
|
|
+ success: (res) => {},
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
wx.hideLoading({})
|
|
wx.hideLoading({})
|
|
|
wx.showToast({
|
|
wx.showToast({
|