123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import {
- getSelfRead
- } from '~/api/user'
- import {
- getModelTexts,
- getReadRanking,
- getSelfReadRanking
- } from '~/api/global'
- import {
- store
- } from '~/store/index'
- import {
- createStoreBindings
- } from 'mobx-miniprogram-bindings'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [],
- // true是人气榜,false是参赛作品
- currentType: true,
- activityUserList: [],
- bannerList: [],
- myActivityUser: {},
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // 手工绑定
- this.storeBindings = createStoreBindings(this, {
- store,
- fields: {
- userInfo: 'userInfo'
- },
- actions: {
- setUser: 'setUser'
- }
- })
- // 立刻更新
- this.storeBindings.updateStoreBindings()
- this.getModelTexts()
- this.getReadRanking()
- },
- // 获取范文
- async getModelTexts() {
- let bannerList = await getModelTexts({
- grade: 'PRIMARY_FIRST_GRADE' || this.data.userInfo.grade
- })
- this.setData({
- bannerList
- })
- },
- async getReadRanking() {
- let {
- activityUserList,
- myActivityUser
- } = await getReadRanking()
- this.setData({
- activityUserList,
- myActivityUser
- })
- },
- async getSelfReadRanking() {
- let list = await getSelfReadRanking()
- this.setData({
- list
- })
- },
- bannelEvent({
- target
- }) {
- wx.navigateTo({
- url: `/pages/reading/index?videoId=${target.dataset.id}&readingType=readMatch`
- })
- },
- jumpUserInfo({
- currentTarget
- }) {
- wx.navigateTo({
- url: `/pages/personal/index?uid=${currentTarget.dataset.uid}`,
- })
- },
- jumpIntro() {
- wx.navigateTo({
- url: `/pages/rankIntro/index?title=活动规则&img=${this.data.explain}`,
- })
- },
- selectType({
- target
- }) {
- if (target.dataset.type) {
- let currentType = JSON.parse(target.dataset.type)
- if (!currentType) {
- this.getSelfReadRanking()
- }
- this.setData({
- currentType
- })
- }
- },
- })
|