标签:special MinIP ora text app dex ppi 小程序 theme
const nav = function (skipType, bannerJson, channelType = ‘CHANNEL_ACTIVITY_LABEL_SHOW‘ ) {
bannerJson = JSON.parse(bannerJson);
let { actSn, actType = ‘‘, url = ‘‘, shopSn = ‘‘, id = ‘‘} = bannerJson
let qrCode = getUrlParam(‘qrCode‘, url) || ‘‘
if (skipType == ‘BANNER_NO_SKIP‘) return
// 跳转大礼包
let jumpGift = () => {
actNav.navToGift(actSn, channelType, qrCode)
}
// 跳转特卖
let jumpSpecial = () => {
actNav.navToSpecial(actSn, channelType, qrCode)
}
// 跳转会员小程序
let jumpVip = () => {
let { url } = bannerJson
// 只跳tab页面
wx.switchTab({
url
});
}
// 跳转外部小程序
let jumpApp = () => {
let { appId, url } = bannerJson
wx.navigateToMiniProgram({
appId,
path: url ? url : ‘‘
})
}
// 跳转H5
let jumpH5 = () => {
let { url } = bannerJson
wx.navigateTo({
url: `/pages/index/webview/webview?url=${encodeURIComponent(url)}`
})
}
// 跳转图文
let jumpImg = () => {
let { title, context} = bannerJson
wx.setStorageSync(‘bannerJsonContext‘, context)
wx.navigateTo({
url: `/pages/index/bannerImg/bannerImg?title=${title}&context=${context}&ctime=${item.ctime}`
})
}
// 跳转合辑
let compilation = ()=> {
let { id } = bannerJson
wx.navigateTo({
url: `/pages/index/collection/collection?compId=${id}&channelType=CHANNEL_ACTIVITY_LABEL_SHOW&qrCode=${qrCode}`
})
}
// 中秋主题
let BANNER_THEME = () => {
let { themeId } = bannerJson
wx.navigateTo({
url: `/pages/midautumn/midautumn?id=${themeId}`
})
}
// 跳转集卡
let BANNER_CARD_COLLECT = ()=> {
let { id } = bannerJson
wx.navigateTo({
url: `/national/pages/collect_cards/collect_cards?actSn=${actSn}&type=1&qrCode=${qrCode}&channelType=MARKET_TRACK`
})
}
// 跳转抽奖
let BANNER_LUCKY_DRAW = ()=> {
wx.navigateTo({
url: `/national/pages/lucky_draw/lucky_draw?actSn=${actSn}&qrCode=${qrCode}&channelType=MARKET_TRACK`
})
}
// 集卡主题
let BANNER_THEME_CARD_COLLECT = ()=> {
let { id } = bannerJson
wx.navigateTo({
url: `/national/pages/index/index?actSn=${actSn}&qrCode=${qrCode}&channelType=MARKET_TRACK`
})
}
const actions = new Map([
[‘BANNER_OUTSIDE_BIG_GIFT_PAGE_ACT_GIFT_PACKAGE‘, jumpGift],
[‘BANNER_SPECIAL_SELL_PAGE_ACT_SPECIAL_OFFER‘, jumpSpecial],
[‘BANNER_IMAGE_TEXT_‘, jumpImg],
[‘BANNER_VIP_APPLIE_PAGE_‘, jumpVip],
[‘BANNER_OUTSIDE_APPLE_‘, jumpApp],
[‘BANNER_OUTSIDE_H5_‘, jumpH5],
[‘BANNER_COMPILATION_‘, compilation],
[‘BANNER_CARD_COLLECT_ACT_CARD_COLLECT‘, BANNER_CARD_COLLECT],
[‘BANNER_LUCKY_DRAW_ACT_LUCKY_DRAW‘, BANNER_LUCKY_DRAW],
[‘BANNER_THEME_CARD_COLLECT_ACT_THEME_CARD_COLLECT‘, BANNER_THEME_CARD_COLLECT],
[‘BANNER_THEME_‘, BANNER_THEME]
])
actions.get(`${skipType}_${actType}`).call(this)
}
export default nav
使用Map避免多层if嵌套
标签:special MinIP ora text app dex ppi 小程序 theme
原文地址:https://www.cnblogs.com/fengqi0505/p/11572077.html