|
@@ -0,0 +1,99 @@
|
|
|
|
|
+import {
|
|
|
|
|
+ uploadFile
|
|
|
|
|
+} from "../../utils/upload"
|
|
|
|
|
+Page({
|
|
|
|
|
+ data: {
|
|
|
|
|
+ avatar: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/avatar-icon.jpg?sign=f5c66c94d189436f82353eb48cb01f08&t=1634538864",
|
|
|
|
|
+ cameraIcon: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/camera-icon.png?sign=11a65871a2800cd04ecaa8991687fccd&t=1634607415",
|
|
|
|
|
+ newCameraIcon: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/camera.png?sign=ad0fe8bead6a46cb20f45f792d4bed67&t=1645502416",
|
|
|
|
|
+ userName: "",
|
|
|
|
|
+ phone: "",
|
|
|
|
|
+ shipName: "",
|
|
|
|
|
+ shipMmsi: "",
|
|
|
|
|
+ authModal: false,
|
|
|
|
|
+ modalText: "位置"
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ takePhotoAction: function () {
|
|
|
|
|
+ const ctx = wx.createCameraContext()
|
|
|
|
|
+ ctx.takePhoto({
|
|
|
|
|
+ quality: 'high',
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ let src = res.tempImagePath
|
|
|
|
|
+ wx.compressImage({
|
|
|
|
|
+ src,
|
|
|
|
|
+ quality: 80, // 压缩质量
|
|
|
|
|
+ success: async e => {
|
|
|
|
|
+ console.log("图片压缩成功!", e)
|
|
|
|
|
+ wx.hideLoading({
|
|
|
|
|
+ success: (res) => {},
|
|
|
|
|
+ })
|
|
|
|
|
+ if (wx.getStorageSync('userName')) {
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
|
+ title: '正在上传...',
|
|
|
|
|
+ })
|
|
|
|
|
+ let postData = {
|
|
|
|
|
+ type: 0,
|
|
|
|
|
+ userId: wx.getStorageSync('userId'),
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ postData.location = ''
|
|
|
|
|
+ let res = await uploadFile(e.tempFilePath, postData)
|
|
|
|
|
+ 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.redirectTo({
|
|
|
|
|
+ url: '/pages/takeBill/success/success',
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: e => {
|
|
|
|
|
+ console.log("失败3", e)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: res.msg
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 新用户图片
|
|
|
|
|
+ console.log("新用户图片", e)
|
|
|
|
|
+ wx.setStorageSync('type', 1)
|
|
|
|
|
+ wx.setStorageSync('file', e.tempFilePath)
|
|
|
|
|
+ wx.redirectTo({
|
|
|
|
|
+ url: `/pages/newCachePage/newCachePage`,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: e => {
|
|
|
|
|
+ console.log("失败2", e)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ onLoad() {
|
|
|
|
|
+ let userName = wx.getStorageSync('userName')
|
|
|
|
|
+ let userId = wx.getStorageSync('userId')
|
|
|
|
|
+ let phone = wx.getStorageSync('phone')
|
|
|
|
|
+ let shipId = wx.getStorageSync('shipId')
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ userName,
|
|
|
|
|
+ phone,
|
|
|
|
|
+ userId,
|
|
|
|
|
+ shipId
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+})
|