123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- import {
- getMyInfo,
- getVipInfo,
- } from '~/api/user'
- import {
- createStoreBindings
- } from 'mobx-miniprogram-bindings'
- import {
- store
- } from '~/store/index'
- const app = getApp()
- Page({
- data: {
- userInfo: {},
- vipTime: '',
- tasks: [],
- isIos: app.globalData.isIOS,
- activationModal: false
- },
- onLoad() {
- // 手工绑定
- this.storeBindings = createStoreBindings(this, {
- store,
- actions: {
- setUser: 'setUser'
- }
- })
- },
- 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.setData({
- userInfo,
- vipTime,
- })
- },
- activationCode() {
- wx.showModal({
- title: '请输入激活码',
- editable: true,
- success: () => {
- if (typeof this.getTabBar === 'function') {
- this.getTabBar().setData({
- mask: true
- })
- }
- this.setData({
- activationModal: true
- })
- }
- })
- },
- jump({
- currentTarget
- }) {
- let url = currentTarget.dataset.url
- wx.navigateTo({
- url: url
- });
- },
- clipboar() {
- wx.setClipboardData({
- data: this.data.userInfo.user.eid,
- success: function (res) { //成功回调函数
- wx.showToast({
- title: '已复制',
- icon: "none"
- })
- }
- })
- },
- closeModal() {
- this.setData({
- activationModal: false
- })
- if (typeof this.getTabBar === 'function') {
- this.getTabBar().setData({
- mask: false
- })
- }
- },
- // 分享配置
- onShareAppMessage: function (res) {
- return {
- title: '自从用了它,家里朗朗书声,美妙极了!你家孩子也快来试试!',
- path: '/pages/index/index',
- imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/375-300-1.jpg'
- }
- },
- onShareTimeline: function () {
- return {
- title: '终于找到适合孩子的朗读神器了!动画配音,边玩边学!',
- query: `uid=${wx.getStorageSync('uid')}`,
- imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/yuwen.jpg'
- }
- },
- })
|