// index.ts // 获取应用实例 const app = getApp() Component({ data: { current: 0, autoplay: false, interval: 5000, duration: 500, popupShow: false }, methods: { // 事件处理函数 changeSwiper(e: any) { const detail = e.detail; if(detail.source === 'touch' || detail.source == 'autoplay') { this.setData({ current: detail.current }) } }, isLogin() { // 判断是否登录 if(!app.globalData.isLogin) { wx.navigateTo({ url: '../login/login', }) return false } return true }, /** 我的订单 */ onOrder() { // 判断是否登录 if(!this.isLogin()) { return } wx.navigateTo({ url: '../orders/orders', }) }, onBuyShop() { // 判断是否登录 if(!this.isLogin()) { return } this.setData({ popupShow: true }) }, onClose() { this.setData({ popupShow: false }) }, onSubmit() { // 判断是否登录 if(!this.isLogin()) { return } wx.navigateTo({ url: '../orders/order-detail', }) this.setData({ popupShow: false }) } // getUserProfile() { // // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 // wx.getUserProfile({ // desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 // success: (res) => { // console.log(res) // this.setData({ // userInfo: res.userInfo, // hasUserInfo: true // }) // } // }) // }, }, })