create-wish.js 2.18 KB
let app = getApp();
Page({
  data: {
    tipsRegisterVisible: false,
    tipsGroupMemberVisible: false,
    tipsNewMemberVisible: false,
    curStatus: 1, // 当前场景
  },
  onShareAppMessage() {},
  onLoad(options) {
    this.initData();
  },
  initData() {
    app.queryIndex().then((result) => {});
  },
  /**
   * 点击提交心愿单按钮
   * 首先要根据自身状态判断
   */
  onSubmitHandler() {
    this.checkSubmit().then((result) => {

    }).catch((err) => {

    });;
  },
  /**
   * 提交前判断状态
   * 判断顺序
   * 1.crm登陆
   * 2.黑名单 (团购会员)
   * 3.新会员
   *
   */
  checkSubmit() {
    return new Promise((resolve, reject) => {
      let indexInfo = app.globalData.indexInfo;
      console.log("indexInfo:", indexInfo);
      let {
        isCrmLogin,
        isNewMember,
        isBlackList,
        hadAnswerQuestion,
        isSelfAssist,
        wishBillCode
      } = indexInfo;
      // 未登陆 出注册弹窗提示
      if (isCrmLogin == 0) {
        this.setData({
          tipsRegisterVisible: true
        })
        reject();
        return;
      }
      // 黑名单
      if (isBlackList == 1) {
        this.setData({
          tipsGroupMemberVisible: true
        })
        reject();
        return;
      }
      // 新老会员
      // isNewMember
      if (isNewMember == 1) {
        // 新会员
        if (hadAnswerQuestion) {
          // 已经答题,提示创建心愿单
        } else {
          // 未答题,提示答题
          this.setData({
            tipsNewMemberVisible: true
          })
        }
      } else {
        // 老会员

      }
      resolve();
    });

  },
  // 换一批
  onChangeStatusHandler() {
    let curStatus = this.data.curStatus;
    curStatus++;
    if (curStatus > 3) {
      curStatus = 1;
    }
    this.setData({
      curStatus
    })
  },
  // 子组件事件
  evtcomp(evt) {
    let {
      name,
      data
    } = evt.detail;
    switch (name) {

      case "_evt_hide_mask":
        this.setData({
          ruleTipsVisible: false,
          tipsGroupMemberVisible: false,
          tipsNewMemberVisible:false,
        })
        break;

      default:
        break;
    }
  },
})