coop.js 1.75 KB
import {
  getBindtapData,
  getObjByListKeyValue
} from '../../utils/util';

import {
  productMap
} from '../../const/custom-data';

let app = getApp();
Page({
  data: {
    groupMemberCoopVisible: true,
    options: null,
    wishInfo: {},
    wishList: []
  },
  onShareAppMessage() {},
  onLoad(options) {
    this.setData({
      options
    })
    this.initData();
  },
  initData() {
    app.queryIndex().then((result) => {
      this.queryWishbillDetail();
    })
  },
  // 我也要玩
  onPlayTooHandler() {
    app.router.push({
      openType: "reLaunch",
      path: "index"
    })
  },
  // 获取心愿单详情
  queryWishbillDetail() {
    return new Promise((resolve, reject) => {
      app.post({
        url: app.api.wishbillDetail,
        data: {
          billCode: app.globalData.indexInfo.wishBillCode
        }
      }).then((result) => {
        let wishList = result.wishGifts;
        wishList.forEach(element => {
          let product = productMap[element.prizeDefineCode + ""];
          element = Object.assign(element, product);
          let progress = element.elasticValue / element.conditionElasticValue * 100;
          if (progress > 100) progress = 100;
          // 直接计算坐标
          let progressLeft = progress * 3.22 - 51;
          element.progress = progress;
          element.progressLeft = progressLeft;
        });
        this.setData({
          wishInfo: result,
          wishList: wishList
        })
        console.log("wishInfo:", this.data.wishInfo);
        console.log("wishList:", this.data.wishList);
      })
    });
  },
  // 子组件事件
  evtcomp(evt) {
    let {
      name,
      data
    } = evt.detail;
    switch (name) {

      case "_evt_hide":
        break;

      default:
        break;
    }
  },
})