提交 9d64c997 编写于 作者: D DCloud_LXH

feat: closePreviewImage

上级 d59687bc
...@@ -53,6 +53,7 @@ const media = [ ...@@ -53,6 +53,7 @@ const media = [
'chooseImage', 'chooseImage',
'chooseFile', 'chooseFile',
'previewImage', 'previewImage',
'closePreviewImage',
'getImageInfo', 'getImageInfo',
'getVideoInfo', 'getVideoInfo',
'saveImageToPhotosAlbum', 'saveImageToPhotosAlbum',
......
...@@ -25,3 +25,7 @@ export function previewImage (args = {}) { ...@@ -25,3 +25,7 @@ export function previewImage (args = {}) {
return invokeMethod('previewImagePlus', args) return invokeMethod('previewImagePlus', args)
} }
export function closePreviewImage (args = {}) {
return invokeMethod('closePreviewImagePlus', args)
}
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
t t
} from 'uni-core/helpers/i18n' } from 'uni-core/helpers/i18n'
export function previewImagePlus ({ export function previewImagePlus({
current = 0, current = 0,
background = '#000000', background = '#000000',
indicator = 'number', indicator = 'number',
...@@ -85,3 +85,16 @@ export function previewImagePlus ({ ...@@ -85,3 +85,16 @@ export function previewImagePlus ({
errMsg: 'previewImage:ok' errMsg: 'previewImage:ok'
} }
} }
export function closePreviewImagePlus() {
try {
plus.nativeUI.closePreviewImage()
return {
errMsg: 'closePreviewImagePlus:ok'
}
} catch (error) {
return {
errMsg: 'closePreviewImagePlus:fail'
}
}
}
const {
invokeCallbackHandler: invoke
} = UniServiceJSBridge
export function previewImage ({ export function previewImage ({
urls, urls,
current current
}, callbackId) { }, callbackId) {
const {
invokeCallbackHandler: invoke
} = UniServiceJSBridge
getApp().$router.push({ getApp().$router.push({
type: 'navigateTo', type: 'navigateTo',
path: '/preview-image', path: '/preview-image',
...@@ -22,4 +22,18 @@ export function previewImage ({ ...@@ -22,4 +22,18 @@ export function previewImage ({
errMsg: 'previewImage:fail' errMsg: 'previewImage:fail'
}) })
}) })
} }
export function closePreviewImage (_, callbackId) {
const $router = getApp().$router
if ($router.history.current.path === '/preview-image') {
$router.back()
invoke(callbackId, {
errMsg: 'closePreviewImage:ok'
})
} else {
invoke(callbackId, {
errMsg: 'closePreviewImage:fail'
})
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册