|
@@ -0,0 +1,74 @@
|
|
|
+// pages/luckDraw/components/tabbar.js
|
|
|
+Component({
|
|
|
+ /**
|
|
|
+ * 组件的属性列表
|
|
|
+ */
|
|
|
+ properties: {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组件的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ list: [
|
|
|
+ {
|
|
|
+ text: "首页",
|
|
|
+ pagePath: "/pages/welfareMall/index",
|
|
|
+ selectedIconPath: "../../../images/welfareMall/home-active.png",
|
|
|
+ iconPath: "../../../images/welfareMall/home.png",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "我的",
|
|
|
+ pagePath: "/pages/welfareMall/personal/personal",
|
|
|
+ selectedIconPath: "../../../images/welfareMall/user-active.png",
|
|
|
+ iconPath: "../../../images/welfareMall/user.png",
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+
|
|
|
+ attached: function() {
|
|
|
+ var url =getCurrentPages()[getCurrentPages().length-1].route
|
|
|
+ this.data.list.forEach(v => {
|
|
|
+ if (this.getPathName(v.pagePath) == this.getPathName(url)) {
|
|
|
+ v.active = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ list: this.data.list
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组件的方法列表
|
|
|
+ */
|
|
|
+ methods: {
|
|
|
+ toPage: function(e) {
|
|
|
+ const index = e.currentTarget.dataset.index;
|
|
|
+ this.data.list.forEach((v, i) => {
|
|
|
+ if (i == index) {
|
|
|
+ v.active = true
|
|
|
+ } else {
|
|
|
+ v.active = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ list: this.data.list
|
|
|
+ })
|
|
|
+ if (index == 0) {
|
|
|
+ wx.reLaunch({
|
|
|
+ url: this.data.list[index].pagePath,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ wx.redirectTo({
|
|
|
+ url: this.data.list[index].pagePath,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getPathName(path) {
|
|
|
+ let pos = path.indexOf("luckDraw/");
|
|
|
+ pos += "luckDraw/".length;
|
|
|
+ return path.substr(pos)
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|