|
@@ -40,94 +40,95 @@
|
|
|
return {
|
|
|
tabActive: 0,
|
|
|
counts: 0,
|
|
|
- tabList: [
|
|
|
- {
|
|
|
- label: '首页',
|
|
|
- icon: 'home',
|
|
|
- url: '/jylab/mainSearch',
|
|
|
- index: 0
|
|
|
- },
|
|
|
- {
|
|
|
- label: '订阅',
|
|
|
- icon: 'book',
|
|
|
- url: '/swordfish/newhistorypush',
|
|
|
- index: 1
|
|
|
- },
|
|
|
- {
|
|
|
- label: '消息',
|
|
|
- icon: 'mesg',
|
|
|
- url: '/weixin/frontPage/messageCenter/sess/index',
|
|
|
- index: 2
|
|
|
- },
|
|
|
- {
|
|
|
- label: '百宝箱',
|
|
|
- icon: 'box',
|
|
|
- url: '/page_treasurebox/index.html',
|
|
|
- index: 3
|
|
|
- },
|
|
|
- {
|
|
|
- label: '我的',
|
|
|
- icon: 'mine',
|
|
|
- url: '/front/wxMyOrder/myMenu',
|
|
|
- index: 4
|
|
|
- },
|
|
|
- ]
|
|
|
+ tabList: [
|
|
|
+ {
|
|
|
+ label: '首页',
|
|
|
+ icon: 'home',
|
|
|
+ url: '/jylab/mainSearch',
|
|
|
+ index: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '订阅',
|
|
|
+ icon: 'book',
|
|
|
+ url: '/swordfish/newhistorypush',
|
|
|
+ index: 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '消息',
|
|
|
+ icon: 'mesg',
|
|
|
+ url: '/weixin/frontPage/messageCenter/sess/index',
|
|
|
+ index: 2
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '百宝箱',
|
|
|
+ icon: 'box',
|
|
|
+ url: '/page_treasurebox/index.html',
|
|
|
+ index: 3
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '我的',
|
|
|
+ icon: 'mine',
|
|
|
+ url: '/front/wxMyOrder/myMenu',
|
|
|
+ index: 4
|
|
|
+ },
|
|
|
+ ]
|
|
|
}
|
|
|
},
|
|
|
- created() {
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ Object.assign(this.$data, this.$options.data())
|
|
|
+ var uMsg = Number(getQueryString('msg') || this.getURLIndex())
|
|
|
+ this.tabActive = uMsg
|
|
|
this.tabsCount()
|
|
|
- var uMsg = Number(getQueryString('msg') || this.getURLIndex())
|
|
|
- this.tabActive = uMsg
|
|
|
},
|
|
|
- computed: {
|
|
|
- getMsgCount: function () {
|
|
|
- return this.counts ? (this.counts > 99 ? '99+' : this.counts) : ''
|
|
|
+ computed: {
|
|
|
+ getMsgCount: function () {
|
|
|
+ return this.counts ? (this.counts > 99 ? '99+' : this.counts) : ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getURLIndex: function () {
|
|
|
+ try {
|
|
|
+ var tempUrl = this.findMapsForUrl(this.tabList, location.pathname)
|
|
|
+ if (tempUrl.length) {
|
|
|
+ return tempUrl[0].index
|
|
|
+ } else {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ return ''
|
|
|
}
|
|
|
},
|
|
|
- methods: {
|
|
|
- getURLIndex: function () {
|
|
|
- try {
|
|
|
- var tempUrl = this.findMapsForUrl(this.tabList, location.pathname)
|
|
|
- if (tempUrl.length) {
|
|
|
- return tempUrl[0].index
|
|
|
- } else {
|
|
|
- return ''
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- return ''
|
|
|
- }
|
|
|
- },
|
|
|
- findMapsForUrl: function (arr, url) {
|
|
|
- var tempReuslt = []
|
|
|
- arr.forEach(function (v) {
|
|
|
- if (url.indexOf(v.url) !== -1) {
|
|
|
- tempReuslt.push(v)
|
|
|
- }
|
|
|
- })
|
|
|
- return tempReuslt.sort(function(a,b) {
|
|
|
- return b.url.length - a.url.length
|
|
|
- })
|
|
|
- },
|
|
|
+ findMapsForUrl: function (arr, url) {
|
|
|
+ var tempReuslt = []
|
|
|
+ arr.forEach(function (v) {
|
|
|
+ if (url.indexOf(v.url) !== -1) {
|
|
|
+ tempReuslt.push(v)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return tempReuslt.sort(function(a,b) {
|
|
|
+ return b.url.length - a.url.length
|
|
|
+ })
|
|
|
+ },
|
|
|
tabsCount() {
|
|
|
- const _this = this
|
|
|
- $.ajax({
|
|
|
- type:'GET',
|
|
|
- url:'/jymessageCenter/isMsgOpen',
|
|
|
- data: {},
|
|
|
- success:function (res) {
|
|
|
- if (res && res.status == 1 && res.data && res.data.count) {
|
|
|
- _this.counts = res.data.count
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- routeHref(index) {
|
|
|
- var goHref = this.tabList[index].url + '?msg=' + index
|
|
|
- if (index === this.tabActive) {
|
|
|
- location.replace(goHref)
|
|
|
- } else {
|
|
|
- location.href = goHref
|
|
|
+ const _this = this
|
|
|
+ $.ajax({
|
|
|
+ type:'GET',
|
|
|
+ url:'/jymessageCenter/getCount?t=' + Date.now(),
|
|
|
+ success:function (res) {
|
|
|
+ if (res && res.status == 1 && res.data && res.data.count) {
|
|
|
+ _this.counts = res.data.count
|
|
|
}
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ routeHref(index) {
|
|
|
+ var goHref = this.tabList[index].url + '?msg=' + index
|
|
|
+ if (index === this.tabActive) {
|
|
|
+ location.replace(goHref)
|
|
|
+ } else {
|
|
|
+ location.href = goHref
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|