tips-prize-comp.js 2.17 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) => {

          // 再查看奖品
          app.post({
            url: app.api.wishbillGiftQuery,
            data: {
              instanceCode: wishInfo.instanceCode
            }
          }).then((result) => {
            let curData = app.globalData.giftData
            curData = Object.assign(curData, result);
            app.globalData.giftData = curData;
            console.log("app.globalData.giftData 333:", app.globalData.giftData);
            console.log(JSON.stringify(app.globalData.giftData));
            resolve(result)
          })

        })
      });
    },

    // 自提
    toSelfLiftHandler() {
      this.queryWishbillAcceptTypeSubmit(2).then((result) => {
        let wishInfo = this.properties.wishInfo;
        this.hideMask();
        app.router.push({
          path: "prizeDetail",
        })
      })
    },
    // 邮寄
    toUserTableHandler() {
      this.queryWishbillAcceptTypeSubmit(1).then((result) => {
        let wishInfo = this.properties.wishInfo;
        this.hideMask();
        app.router.push({
          path: "userTable",
        })
      })
    },

  }
})