// pages/Components/tabbar/tabbar.js const app = getApp(); const util = require('../../../utils/util.js') let url = null Component({ lifetimes: { attached() { this.isApple() if (!wx.getStorageSync('isShow')) { this.data.titleList.splice(2, 1) this.setData({ titleList: this.data.titleList }) } } }, /** * 组件的属性列表 */ properties: { curIndex: { type: Number, value: 0 }, curHtml: { type: String, value: '' }, phone:{ type: String, value: '' } }, /** * 组件的初始数据 */ data: { titleList: [{ title: '首页', icon: '/images/index.png', curIcon: '/images/cur-index.png', val: '首页', path: '/pages/index/index' }, { title: '练琴', icon: '/images/piano.png', curIcon: '/images/cur-piano.png', val: '练琴', path: '/pages/piano/piano' }, { title: '活动', icon: '/images/active.png', curIcon: '/images/active-red.png', val: '活动', path: '/pages/tabBar/active/active' }, { title: '我的', icon: '/images/my.png', curIcon: '/images/cur-my.png', val: '我的', path: '/pages/myself/myself' }, ], phoneList: [ 'iPhone X', 'iPhone XR', 'iPhone XS Max', 'iPhone 11', 'iPhone 11 Pro', 'iPhone 11 Pro Max', 'iPhone 12', 'iPhone 12 Mini', 'iPhone 12 Pro', 'iPhone 12 Pro Max' ], }, /** * 组件的方法列表 */ methods: { isApple: function () { wx.getSystemInfo({ //当小程序初始化完成时 获取用户的手机机型 并写出适配ipnone手机安全区域的的适配方案 success: (res) => { const phone = res.model.split(" ") this.data.phoneList.forEach(item => { if (item == phone[0] + ' ' + phone[1]) { this.setData({ bottomStyle: true }) return false; } }); } }) }, changeTitle: function (e) { const name = e.currentTarget.dataset.value if(name == '活动'){ wx.navigateToMiniProgram({ appId: 'wx4efd688fa52ba3f7', path: 'pages/welcome/welcome?isPage=active', // extraData: { // foo: 'bar' // }, envVersion: 'release', success(res) { // 打开成功 wx.redirectTo({ url: '/pages/index/index', }) } }) return } const phone = wx.getStorageSync('phone') if (e.currentTarget.dataset.index == this.data.curIndex) { return } const index = e.currentTarget.dataset.index wx.redirectTo({ url: this.data.titleList[index].path }) }, //授权手机号 getPhoneNumber: function (e) { url = e.currentTarget.dataset.url let that = this; if (e.detail.errMsg == "getPhoneNumber:ok") { util.doPost( 'getPhoneNumber', { encryptedData: e.detail.encryptedData, iv: e.detail.iv, openId: app.globalData.openId, } ).then(rs => { if (rs.success > 0) { wx.setStorageSync('phone', rs.data.phoneNumber) this.setData({ phone: rs.data.phoneNumber }) wx.redirectTo({ url: e.currentTarget.dataset.url, }) } }) } that.setData({ model: false, localtion: true }) }, } })