import TabMenu from './data'; import R from '../utils/request'; import C from '../utils/constant'; Component({ data: { active: 0, list: [], is_share: false, cdnHost: C.cdnHost, }, ready() { R.get('/index.php/api/v1/my').then(({ model }) => { this.setData({ is_share: !!model.is_share, list: TabMenu.filter((_, idx) => { if (model.is_share) { return true } else { return idx !== 1 } }) }); }); }, methods: { goTakePhoto() { wx.navigateTo({ url: '/pages/takephoto/takephoto', }) }, onChange(event) { this.setData({ active: event.detail.value }); wx.switchTab({ url: this.data.list[event.detail.value].url.startsWith('/') ? this.data.list[event.detail.value].url : `/${this.data.list[event.detail.value].url}`, }); }, init() { const page = getCurrentPages().pop(); const route = page ? page.route.split('?')[0] : ''; const active = this.data.list.findIndex( (item) => (item.url.startsWith('/') ? item.url.substr(1) : item.url) === `${route}`, ); this.setData({ active }); }, getPhoneNumber(e) { console.log(e.detail.code) // 动态令牌 console.log(e.detail.errMsg) // 回调信息(成功失败都会返回) console.log(e.detail.errno) // 错误码(失败时返回) if (!e.detail.errno) { R.post('/index.php/api/v1/bind_auth_phone', { code: e.detail.code }).then(() => { this.setData({ hasPhone: true }) this.goTakePhoto(); }) } else { // e.detail.errMsg } }, }, });