98 lines
2.2 KiB
JavaScript
98 lines
2.2 KiB
JavaScript
import _ from '../../commons/js/commons'
|
|
const app = getApp()
|
|
Component({
|
|
//组件的属性列表
|
|
properties: {
|
|
currentIndex: {
|
|
type: String,
|
|
value: '0'
|
|
},
|
|
},
|
|
|
|
//组件的初始数据
|
|
data: {
|
|
|
|
list: [
|
|
{
|
|
"url": "/pages/index/index",
|
|
"icon": "tab-home",
|
|
"activeIcon": "tab-home-ac",
|
|
"title": "首页",
|
|
},
|
|
{
|
|
"url": "/pages/customer/index",
|
|
"icon": "tab-customer",
|
|
"activeIcon": "tab-customer-ac",
|
|
"title": "客户",
|
|
},
|
|
{
|
|
"url": "/pages/order/index",
|
|
"icon": "tab-order",
|
|
"activeIcon": "tab-order-ac",
|
|
"title": "订单",
|
|
},
|
|
{
|
|
"url": "/pages/mine/index?source=shop",
|
|
"icon": "tab-mine",
|
|
"activeIcon": "tab-mine-ac",
|
|
"title": "我的",
|
|
},
|
|
],
|
|
},
|
|
|
|
//生命周期方法
|
|
lifetimes: {
|
|
//在组件实例进入页面节点树时执行
|
|
attached: function () {
|
|
|
|
},
|
|
//在组件实例被从页面节点树移除时执行
|
|
detached: function () {
|
|
|
|
},
|
|
},
|
|
|
|
//组件所在页面的生命周期
|
|
pageLifetimes: {
|
|
//组件所在的页面被展示时执行
|
|
show: function () {
|
|
|
|
},
|
|
//组件所在的页面被隐藏时执行
|
|
hide: function () {
|
|
|
|
},
|
|
//组件所在的页面尺寸变化时执行
|
|
resize: function () {
|
|
|
|
},
|
|
},
|
|
|
|
//组件的方法列表
|
|
methods: {
|
|
//页面跳转
|
|
pushNavTab(e) {
|
|
let pages = getCurrentPages() //获取加载的页面
|
|
let currentPage = pages[pages.length - 1] //获取当前页面的对象
|
|
let url = currentPage.route //当前页面url
|
|
let isBack = false
|
|
let backIndex = 0
|
|
if (e.currentTarget.dataset.url && e.currentTarget.dataset.url != '/' + url) {
|
|
pages.forEach((item,index) => {
|
|
if(e.currentTarget.dataset.url=='/'+item.route){
|
|
isBack = true
|
|
backIndex = index
|
|
}
|
|
});
|
|
if(isBack){//后退
|
|
_.$router.back(Number(pages.length-backIndex-1))
|
|
}else{//前进打开
|
|
_.$router.openUrlScheme(e.currentTarget.dataset.url)
|
|
}
|
|
|
|
} else {
|
|
_.utils.scrollPageToDomForTop('.container')
|
|
}
|
|
},
|
|
}
|
|
}) |