123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import Api from "../../model/api";
- import {
- getEventParam
- } from "../../utils/utils";
- import Route from "../../model/route";
- import {
- videoTypes,
- htmlTypes
- } from "../../model/enum";
- const app = getApp();
- app.Base({
- dict: {
- "兑换课程": {
- method: Api.getNoScoreList,
- isComplete: false
- },
- "已兑换课程": {
- method: Api.getScoreList,
- isComplete: true
- },
- },
- title: '兑换课程',
- data: {
- scoreInfos: [],
- active: 0,
- isComplete: false,
- show: false,
- item: {},
- },
- async onLoad(options) {
- await this.init();
- },
- async init() {
- const data = await Api.getScoreInfo(true);
- this.setData({
- scoreInfos: data.data
- })
- },
- async onPullDownRefresh() {
- await this.init();
- },
- async pay(e) {
- await this.onPullDownRefresh();
- },
- async onChange(e) {
- this.title = getEventParam(e, "title");
- this.setData({
- isComplete: this.dict[this.title].isComplete
- }, async () => {
- await this.changeResetData(this);
- })
- },
- toDetail(e) {
- Route.toScoreDetail();
- },
- toRule() {
- Route.toIntegralRule(htmlTypes.INTEGRAL_RULE, "积分规则");
- },
- toNewsDetail(e) {
- let item = getEventParam(e, "item");
- this.setData({
- item: item,
- show: true
- })
- },
- async requestData() {
- let res = await this.dict[this.title].method({
- pageNum: this.pageNum,
- pageSize: this.pageSize
- });
- res.data.rows = res.data.rows.map(item => {
- let flag = this.data.scoreInfos.some(info => {
- return info.surplusValue >= item.score;
- })
- return {
- ...item,
- hasScore: flag,
- }
- });
- return res;
- },
- toVideo(e) {
- const item = getEventParam(e, "item");
- Route.toVideo(item.id, videoTypes.SCORE, "积分课")
- }
- })
|