提交 b37146e0 编写于 作者: X xiaoyucoding

feat(mp): 小程序平台 previewImage 参数 current 支持传入索引值

上级 5ac4c785
...@@ -215,9 +215,14 @@ const protocols = { // 需要做转换的 API 列表 ...@@ -215,9 +215,14 @@ const protocols = { // 需要做转换的 API 列表
previewImage: { previewImage: {
args (fromArgs) { args (fromArgs) {
// 支付宝小程序的 current 是索引值,而非图片地址。 // 支付宝小程序的 current 是索引值,而非图片地址。
if (fromArgs.current && Array.isArray(fromArgs.urls)) { const currentIndex = Number(fromArgs.current)
const index = fromArgs.urls.indexOf(fromArgs.current) if (isNaN(currentIndex)) {
fromArgs.current = ~index ? index : 0 if (fromArgs.current && Array.isArray(fromArgs.urls)) {
const index = fromArgs.urls.indexOf(fromArgs.current)
fromArgs.current = ~index ? index : 0
}
} else {
fromArgs.current = currentIndex
} }
return { return {
indicator: false, indicator: false,
......
...@@ -59,9 +59,19 @@ const protocols = { ...@@ -59,9 +59,19 @@ const protocols = {
} }
}, },
previewImage: { previewImage: {
args: { args (fromArgs) {
indicator: false, // 处理传入索引值的情况
loop: false const currentIndex = Number(fromArgs.current)
if (!isNaN(currentIndex)) {
const urls = fromArgs.urls && Array.isArray(fromArgs.urls) ? fromArgs.urls.concat() : []
fromArgs.urls = urls.filter((item, index) => {
return index < currentIndex ? item !== urls[currentIndex] : true
})
}
return {
indicator: false,
loop: false
}
} }
}, },
getRecorderManager: { getRecorderManager: {
......
...@@ -92,9 +92,19 @@ const protocols = { ...@@ -92,9 +92,19 @@ const protocols = {
} }
}, },
previewImage: { previewImage: {
args: { args (fromArgs) {
indicator: false, // 处理传入索引值的情况
loop: false const currentIndex = Number(fromArgs.current)
if (!isNaN(currentIndex)) {
const urls = fromArgs.urls && Array.isArray(fromArgs.urls) ? fromArgs.urls.concat() : []
fromArgs.urls = urls.filter((item, index) => {
return index < currentIndex ? item !== urls[currentIndex] : true
})
}
return {
indicator: false,
loop: false
}
} }
}, },
connectSocket: { connectSocket: {
......
export const protocols = {} export const protocols = {
previewImage: {
args (fromArgs) {
// 处理传入索引值的情况
const currentIndex = Number(fromArgs.current)
if (!isNaN(currentIndex)) {
const urls = fromArgs.urls && Array.isArray(fromArgs.urls) ? fromArgs.urls.concat() : []
fromArgs.urls = urls.filter((item, index) => {
return index < currentIndex ? item !== urls[currentIndex] : true
})
}
}
}
}
export const todos = [] export const todos = []
export const canIUses = [] export const canIUses = []
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册