123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import {
- getSelfRead
- } from '~/api/user'
- import {
- isActivityWork
- } from '~/api/works'
- import {
- getModelTexts,
- getReadRanking,
- getActivityInfo,
- getSelfReadRanking
- } from '~/api/global'
- import {
- store
- } from '~/store/index'
- import {
- createStoreBindings
- } from 'mobx-miniprogram-bindings'
- import event from '~/mixins/share'
- import share from '~/mixins/share'
- Page({
- behaviors: [share,event],
- /**
- * 页面的初始数据
- */
- data: {
- list: [],
- // true是人气榜,false是参赛作品
- currentType: true,
- activityUserList: [],
- modelList: [],
- myActivityUser: {},
- activityId: '',
- bannerList: [],
- //1是收费0是免费
- free: 1
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.setData({
- activityId: options.activityId
- })
- getActivityInfo(options.activityId).then(res => {
- let {
- free
- } = res
- this.setData({
- free
- })
- })
- this.getLocUserInfo()
- if (Object.keys(this.data.userInfo).length > 0) {
- this.reload()
- } else {
- getApp().callBack = (res) => {
- this.getLocUserInfo()
- this.reload()
- }
- }
- },
- getLocUserInfo() {
- this.storeBindings = createStoreBindings(this, {
- store,
- fields: {
- userInfo: 'userInfo'
- },
- actions: {
- setUser: 'setUser'
- }
- })
- this.storeBindings.updateStoreBindings()
- },
- reload() {
- this.getModelTexts()
- this.getReadRanking()
- },
- // 获取范文
- async getModelTexts() {
- let modelList = await getModelTexts({
- grade: this.data.userInfo.grade,
- activityId: this.data.activityId
- })
- this.setData({
- modelList
- })
- },
- async getReadRanking() {
- let {
- activityUserList,
- myActivityUser,
- activity
- } = await getReadRanking({
- activityId: this.data.activityId
- })
- console.log(activity);
- this.setData({
- activityUserList,
- myActivityUser,
- bannerList: activity.bannerList
- })
- },
- async getSelfReadRanking() {
- let list = await getSelfReadRanking({
- activityId: this.data.activityId
- })
- this.setData({
- list
- })
- },
- bannelEvent({
- target
- }) {
- wx.navigateTo({
- url: `/pages/reading/index?videoId=${target.dataset.id}&activityId=${this.data.activityId}&readingType=readMatch&autoPlay=true&free=${this.data.free}`
- })
- },
- jumpUserInfo({
- currentTarget
- }) {
- wx.navigateTo({
- url: `/pages/personal/index?uid=${currentTarget.dataset.uid}`,
- })
- },
- selectType({
- target
- }) {
- if (target.dataset.type) {
- let currentType = JSON.parse(target.dataset.type)
- if (!currentType) {
- this.getSelfReadRanking()
- }
- this.setData({
- currentType
- })
- }
- },
- jumpIntro({
- currentTarget
- }) {
- let iconDetail = currentTarget.dataset.icondetail
- if (iconDetail) {
- wx.navigateTo({
- url: `/pages/rankIntro/index?img=${iconDetail}`,
- })
- }
- },
- })
|