Commit 72d0956c by 高淑倩

add: tab_跳转

parent 223d18fd
......@@ -9,13 +9,13 @@ Component({
* 组件的属性列表
*/
properties: {
categoryType:{
type: Object,
value: null
}
categoryType: {
type: Object,
value: null
}
},
attached() {
},
/**
* 组件的初始数据
......@@ -23,13 +23,14 @@ Component({
data: {
// currentTab: 0,
currentTab: 99,
isAuthorization: false, // false 不显示 true 显示
},
/**
* 组件的方法列表
*/
methods: {
handelToVipCode() {
wxService.router(`/pages/memberOfOwn/memberOfOwn`)
wxService.router(`/pages/memberOfOwn/memberOfOwn`)
},
handelToCart() {
wxService.router(`/pages/cart/cart`)
......@@ -37,9 +38,12 @@ Component({
// 设置tab active
switchNav(event) {
const ev = event.currentTarget.dataset;
console.log('ev', ev)
let cur = ev.current
let redirectid = ev.redirectid
console.log('redirectid', redirectid)
let curItemType = ev.item
const userInfo = wx.getStorageSync('_baseUserInfo')
// 切换 active
if (this.data.currentTab == cur) {
return false
} else {
......@@ -47,11 +51,78 @@ Component({
currentTab: cur,
})
}
// link row
if (curItemType.link) {
let currentClickType = app.globalData.commonFunc.getLink(curItemType.link.type, curItemType)
if (curItemType.link.type == 1) {
// 触发父组件更新页面 外部小程序
this.setData({
isAuthorization: false
})
return false
} else if (!userInfo) {
this.setData({
isAuthorization: true
})
return false
} else if (userInfo && userInfo.member && !userInfo.member.mobile) {
wxService.openCard()
return false
}
if (curItemType.link.type == 2) {
// 触发父组件更新页面
wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url })
})
} else if (curItemType.link.type == 3) {
// 预览
wx.previewImage({
current: `${app.globalData.imageUrl}/${currentClickType.imageUrl}`, // 当前显示图片的http链接
urls: [`${app.globalData.imageUrl}/${currentClickType.link.url}`] // 需要预览的图片http链接列表
})
} else if (curItemType.link.type == 4) {
wxService.router(`/${currentClickType}`)
} else if (curItemType.link.type == 5) {
if (currentClickType == 1) {
wxService.openCard()
} else if (currentClickType == 2) {
wxService.openCard()
}
} else if (curItemType.link.type == 6) {
wxService.router(`/${currentClickType}`)
} else if (curItemType.link.type == 7) {
// 集点详情
}
} else if (curItemType.row) {
let rowObj = JSON.parse(curItemType.row)
let currentClickRow = app.globalData.commonFunc.getLinkRow(rowObj.type, rowObj)
console.log('bacccccccccc', currentClickRow)
if (rowObj.type == 1) { }
else if (rowObj.type == 2) { }
else if (rowObj.type == 3) { }
else if (rowObj.type == 4) { }
else if (rowObj.type == 5) { }
else if (rowObj.type == 6) { }
else if (rowObj.type == 7) { }
else if (rowObj.type == 8) {
// 商品
wxService.router(`/pages/productDetail/productDetail?productId=${currentClickRow}`)
}
else if (rowObj.type == 9) {
// 分类
wxService.router(`/subPackage/page/pages/categoryPro/categoryPro?${currentClickRow}`)
}
}
},
switchTab(event) {
var cur = event.detail.current
this.setData({
currentTab: cur
currentTab: cur
})
}
}
......
......@@ -12,6 +12,7 @@
style="width:{{navItemWidth}}%"
data-current="{{idx}}"
data-redirectId="{{navItem.redirectId}}"
data-item ="{{navItem}}"
bindtap="switchNav"
>
<view>{{navItem.title}}</view>
......
......@@ -28,7 +28,7 @@ HandlerLink.prototype = {
let res = this.currentLinkType(type, item)
return res
},
currentLinkType(type, item={}) {
currentLinkType(type, item = {}) {
// 1. 外部小程序_url 2. 内部动态页面_pageId 3.预览 4. 内部页面 5. 卡券__1_卡包 2_激活领卡
if (type == 1) {
wx.navigateToMiniProgram({
......@@ -36,10 +36,10 @@ HandlerLink.prototype = {
appId: item.link.appid,
path: `${item.link.url}`,
success: e => {
console.log('type=1',e)
console.log('type=1', e)
},
fail: e => {
console.log('type=1',e)
console.log('type=1', e)
},
complete: e => {
console.log(e)
......@@ -54,18 +54,18 @@ HandlerLink.prototype = {
return `${item.link.url}`
} else if (type == 5) {
let currentOpen = ''
if(item.link.url == 1){
if (item.link.url == 1) {
// 卡包
currentOpen = 1
return currentOpen
// wxService.openCardList()
} else if(item.link.url == 2){
// wxService.openCardList()
} else if (item.link.url == 2) {
// 激活领卡--开卡
currentOpen= 2
currentOpen = 2
return currentOpen
// wxService.openCard()
// wxService.openCard()
}
} else if(type == 6){
} else if (type == 6) {
// 跳转路径中包括http的跳转到h5页面中,用web-view去加载h5页面
if (/http/gi.test(item.link.url)) {
const enCodeUrl = encodeURIComponent(item.link.url)
......@@ -81,6 +81,79 @@ const getLink = function (type, id, name) {
return handlerLink.init.apply(handlerLink, arguments)
}
const getLinkRow = function (type, item) {
const handlerLinkRow = new HandlerLinkRow()
return handlerLinkRow.init.apply(handlerLinkRow, arguments)
}
const HandlerLinkRow = function () { }
HandlerLinkRow.prototype = {
init(type, item = {}) {
let res = this.currentLinkRowType(type, item)
return res
},
currentLinkRowType(type, item = {}) {
// 1 外部小程序链接 2 配置页面 3 弹出图片 4 小程序内部功能列表 5 微信卡券 6 H5链接 7 小程序内部页面 8 商品 9 分类
console.log('commonType', type)
if (type == 1) {
wx.navigateToMiniProgram({
// 跳转外部小程序
appId: item.link.appid,
path: `${item.link.url}`,
success: e => {
console.log('type=1', e)
},
fail: e => {
console.log('type=1', e)
},
complete: e => {
console.log(e)
},
})
return ''
} else if (type == 2) {
return item.link
} else if (type == 3) {
return item
} else if (type == 4) {
return `${item.link.url}`
} else if (type == 5) {
let currentOpen = ''
if (item.link.url == 1) {
// 卡包
currentOpen = 1
return currentOpen
// wxService.openCardList()
} else if (item.link.url == 2) {
// 激活领卡--开卡
currentOpen = 2
return currentOpen
// wxService.openCard()
}
} else if (type == 6) {
// 跳转路径中包括http的跳转到h5页面中,用web-view去加载h5页面
if (/http/gi.test(item.link.url)) {
const enCodeUrl = encodeURIComponent(item.link.url)
return `/subPackage/page/pages/h5/h5page?url=${enCodeUrl}`
}
return `/${item.link.url}`
} else if (type == 7) {
return `${item.link.url}`
} else if (type == 8) {
console.log('----', item)
return `${item.url}`
} else if (type == 9) {
console.log('----', item.name)
return `id=${item.url}&name=${item.name}`
}
}
}
const getUrlParam = function (name, url) {
if (!url) {
return null
......@@ -124,6 +197,7 @@ class Parmas {
module.exports = {
getLink: getLink,
getLinkRow: getLinkRow,
parmas: new Parmas(),
getUrlParam: getUrlParam,
handlerLink: new HandlerLink(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment