tips-prize-comp.js 2 KB
let app = getApp();
Component({
  properties: {
    // 这里定义了innerText属性,属性值可以在组件使用时指定
    innerText: {
      type: String,
      value: 'default value',
    },
    wishInfo: {
      type: Object,
      value: {},
    },
    // 1正常(有库存) 2无库存
    status: {
      type: Number,
      status: 2
    }
  },
  data: {
    // 这里是一些组件内部数据
    someData: {}
  },
  methods: {
    // 这里是一个自定义方法
    customMethod() {
      this.triggerEvent('evtcomp', {
        name: "_evt_custom"
      })
    },
    // 隐藏蒙层
    hideMask() {
      this.triggerEvent('evtcomp', {
        name: "_evt_hide_mask"
      });
    },
    /**
     * 提交礼品领取方式

     */
    queryWishbillAcceptTypeSubmit(acceptType) {
      return new Promise((resolve, reject) => {
        let wishInfo = this.properties.wishInfo;
        app.post({
          url: app.api.wishbillAcceptTypeSubmit,
          data: {
            instanceCode: wishInfo.instanceCode,
            acceptType: acceptType
          }
        }).then((result) => {
          resolve(result)
        })
      });
    },

    // 自提
    toSelfLiftHandler() {
      this.queryWishbillAcceptTypeSubmit(2).then((result) => {
        console.log("prize-self-result:", result);
        let wishInfo = this.properties.wishInfo;
        let query = Object.assign(wishInfo, result);
        console.log("prize-self-query:", query);
        this.hideMask();
        app.router.push({
          path: "prizeDetail",
          query: query
        })
      })
    },
    // 邮寄
    toUserTableHandler() {
      this.queryWishbillAcceptTypeSubmit(1).then((result) => {
        console.log("prize-table-result:", result);
        let wishInfo = this.properties.wishInfo;
        let query = Object.assign(wishInfo, result);
        console.log("prize-table-query:", query);
        this.hideMask();
        app.router.push({
          path: "userTable",
          query: query
        })
      })
    },

  }
})