import { getMyInfo, getVipInfo, getWxQrcode, getLearnCard } from '~/api/user' import event from '~/mixins/event' import { getProducts, userEvent } from '~/api/global' import { createStoreBindings } from 'mobx-miniprogram-bindings' import { store } from '~/store/index' const app = getApp() Page({ behaviors: [event], data: { userInfo: {}, products: [], }, async onLoad() { // 手工绑定 this.storeBindings = createStoreBindings(this, { store, actions: { setUser: 'setUser' } }) if (this.data.isIos) { let qrCode = await getWxQrcode() this.setData({ qrCode: qrCode.ticketUrl }) } }, async onShow() { if (typeof this.getTabBar === 'function') { this.getTabBar().setData({ selected: 4 }) } let uid = wx.getStorageSync('uid') || '' if (!uid) { getApp().callBack = (res) => { this.setUserInfo() } } else { this.setUserInfo() } }, // 设置用户信息及vip状态 async setUserInfo() { let userInfo = await getMyInfo() let vipTime = await getVipInfo() this.setUser(userInfo.user) this.getProducts() this.setData({ userInfo, vipTime, }) }, paySuccess() { this.setUserInfo() this.selectComponent('#vipModal').open() }, async getProducts() { let { productList: products, } = await getProducts() this.setData({ products, }) }, openDonutBuy({ currentTarget }) { let product = currentTarget.dataset.product this.selectComponent('#donutBuy').open(product) }, jump({ currentTarget }) { let url = currentTarget.dataset.url console.log(url); wx.navigateTo({ url: url }); }, clipboar() { wx.setClipboardData({ data: this.data.userInfo.user.eid, success: function (res) { //成功回调函数 wx.showToast({ title: '已复制', icon: "none" }) } }) }, })