|
|
@@ -9,13 +9,35 @@ Page({
|
|
|
phone: "",
|
|
|
shipName: "",
|
|
|
shipMmsi: "",
|
|
|
- locationModal: false
|
|
|
+ authModal: false,
|
|
|
+ modalText: "位置"
|
|
|
},
|
|
|
openSetting() {
|
|
|
this.setData({
|
|
|
- locationModal: false
|
|
|
+ authModal: false,
|
|
|
+ })
|
|
|
+ wx.openSetting({
|
|
|
+ complete: e => {
|
|
|
+ console.log(e)
|
|
|
+ if (e.authSetting["scope.writePhotosAlbum"]) {
|
|
|
+ if (wx.getStorageSync('cacheImage')) {
|
|
|
+ wx.saveImageToPhotosAlbum({
|
|
|
+ filePath: wx.getStorageSync('cacheImage'),
|
|
|
+ success: e => {
|
|
|
+ wx.showToast({
|
|
|
+ title: '保存成功!',
|
|
|
+ })
|
|
|
+ wx.removeStorageSync('cacheImage')
|
|
|
+ },
|
|
|
+ complete: e => {
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
- wx.openSetting({})
|
|
|
},
|
|
|
takePhoto() {
|
|
|
wx.getLocation({
|
|
|
@@ -29,7 +51,7 @@ Page({
|
|
|
wx.setStorageSync('latitude', latitude)
|
|
|
wx.setStorageSync('longitude', longitude)
|
|
|
wx.chooseMedia({
|
|
|
- // sourceType: ["camera", "album"],
|
|
|
+ mediaType: ["image"],
|
|
|
sourceType: ["camera"],
|
|
|
success: e => {
|
|
|
let src = e.tempFiles[0].tempFilePath
|
|
|
@@ -104,9 +126,34 @@ Page({
|
|
|
wx.showToast({
|
|
|
title: res.msg
|
|
|
})
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/takePhoto/success/success',
|
|
|
+ wx.downloadFile({
|
|
|
+ url: res.result.viewUrl,
|
|
|
+ success: 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 => {
|
|
|
+ this.setData({
|
|
|
+ authModal: true,
|
|
|
+ modalText: "文件存储"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/takePhoto/success/success',
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
+
|
|
|
+
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: res.msg
|
|
|
@@ -132,7 +179,8 @@ Page({
|
|
|
},
|
|
|
fail: e => {
|
|
|
this.setData({
|
|
|
- locationModal: true
|
|
|
+ authModal: true,
|
|
|
+ modalText: "位置信息"
|
|
|
})
|
|
|
}
|
|
|
})
|