1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- const app = getApp()
- Component({
- data: {
- selected: '',
- color: "#7A7E83",
- selectedColor: "#409eff",
- list: [{
- "pagePath": "/pages/home/index",
- "iconPath": "/image/home1.png",
- "selectedIconPath": "/image/home2.png",
- "text": "首页"
- },
- {
- "pagePath": "/pages/reserve/index",
- "iconPath": "/image/reserve1.png",
- "selectedIconPath": "/image/reserve2.png",
- "text": "报餐"
- },
- {
- "pagePath": "/pages/news/index",
- "iconPath": "/image/news1.png",
- "selectedIconPath": "/image/news2.png",
- "text": "新闻"
- },
- {
- "pagePath": "/pages/my/index",
- "iconPath": "/image/my1.png",
- "selectedIconPath": "/image/my2.png",
- "text": "我的"
- }]
- },
- attached() {
- },
- methods: {
- switchTab(e) {
- const { index, path } = e.currentTarget.dataset;
- if (index == 3) {
- wx.getStorage({
- key: 'userInfo',
- success: function (res) {
- app.globalData.userInfo = res.data;
- wx.switchTab({ url: path })
- },
- fail: function (res) {
- wx.getUserProfile({
- desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: (res) => {
- wx.setStorage({ key: "userInfo", data: res.userInfo })
- app.globalData.userInfo = res.userInfo;
- wx.switchTab({ url: path })
- }
- })
- }
- })
- } else {
- wx.switchTab({ url: path })
- }
- // wx.switchTab({ url })
- // wx.reLaunch({ url })
- // this.setData({
- // selected: data.index
- // })
- }
- }
- })
|