var i18n = require('../../i18n/index') Page({ data: { statusBarHeight: 44, deviceId: '', trialDays: 7, isFreeMode: false, tipTitle: '' }, onShow: function () { i18n.bind(this) }, updateTip: function () { this.setData({ tipTitle: this.data.isFreeMode ? i18n.t('bindSuccess.freeModeOpen') : i18n.t('bindSuccess.trialGranted', { days: this.data.trialDays }) }) }, onBack: function () { wx.navigateBack({ fail: function () { wx.reLaunch({ url: '/pages/index/index' }) } }) }, onLoad: function (options) { var app = getApp() this.setData({ statusBarHeight: app.globalData.statusBarHeight }) this.setData({ deviceId: options.device_id || '' }) this.updateTip() var self = this var http = require('../../utils/request') http.get('/api/v1/subscription').then(function (sub) { if (sub && sub.plan === 'free') { self.setData({ isFreeMode: true }) self.updateTip() } }).catch(function () {}) }, onStart: function () { wx.redirectTo({ url: '/pages/wear-check/wear-check' }) }, onGoHome: function () { wx.reLaunch({ url: '/pages/index/index' }) } })