evaluategift.js 6.17 KB
var _default =
{
  data: function data() {
    return {
      itemShow: false, //项目栏目是否显示
      cardShow: false, //代金券栏目是否显示
      packShow: false, //福利栏目是否显示
      textShow: false, //规则是否显示
      integralShow: true, //积分领取是否显示
      growUpShow: true, //成长值领取是否显示
      itemButton: '',
      cardButton: '',
      getActId: '',
      getActType: '',
      giftID: '',
      getUserID: '',
      getStorageID: '',
      receiveState: '已领取',
      integralTitle: '已领取',
      growUpTitle: '已领取',
      textTitle: '',
      getUrl: '',
      noShow: false,
      //判断中间的连接线是否显示
      itemShows: function itemShows() {
        if (this.itemShow) {
          if (this.cardShow) {
            return true;
          } else {
            return false;
          }
        } else {
          if (this.cardShow) {
            return false;
          } else {
            return false;
          }

        }
      },
      //判断中间的连接线是否显示
      cardShows: function cardShows() {
        if (this.cardShow) {
          if (this.packShow) {
            return true;
          } else {
            return false;
          }
        } else {
          if (this.packShow) {
            return false;
          } else {
            return false;
          }

        }
      },
      cards: [],
      itemWare: []
    };



  },
  onLoad: function onLoad(options) {

    // 获取url对应的参数
    // this.getActId = this.GetQueryString('actId'); //活动id
    // this.getActType = this.GetQueryString('actType'); //活动类型 1新人礼 2评价有礼 3节日营销 4生日营销
    // this.giftID = this.GetQueryString('giftID'); //礼包ID
    // this.getStorageID = this.GetQueryString('storageID'); //商家ID
    // this.getUserID = this.GetQueryString('userID'); //用户ID

    this.getActId = options.actId; //活动id
    this.getActType = options.actType; //活动类型 1新人礼 2评价有礼 3节日营销 4生日营销
    this.giftID = options.giftBagId; //礼包ID
    this.getStorageID = options.storeId; //商家ID
    this.getUserID = options.userId; //用户ID      

    this.GetList();

  },
  onShow: function onShow() {
    this.textTitle = this.textTitle.replace(/<p><img/gi, "<p class='img'><img");
  },
  methods: {

    getQueryString: function getQueryString(name) {
      var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
      var r = window.location.search.substr(1).match(reg);
      if (r != null) {
        return unescape(r[2]);
      }
      return null;
    },

    GetList: function GetList() {
      var _this = this;
      uni.request({
        url: this.$GetInfo.ApiHttp + '/api/weshop/marketing/giftbag/bound/get',
        data: {
          "actId": this.getActId, //活动id
          "actType": this.getActType, //活动类型 1新人礼 2评价有礼 3节日营销 4生日营销
          "giftBagId": this.giftID, //礼包ID
          "storeId": this.getStorageID, //商家ID
          "userId": this.getUserID //用户ID
        },
        method: 'GET',
        header: {
          'Content-Type': 'application/x-www-form-urlencoded' //自定义请求头信息
        },
        success: function success(res) {
          console.log(res.data);
          if (res.data.code == 0) {
            if (res.data.data.lbCoupons != null) {
              _this.cardShow = true;
              _this.cards = res.data.data.lbCoupons;
            }
            if (res.data.data.lbSM != null) {
              _this.itemShow = true;
              _this.itemWare = res.data.data.lbSM;
            }
            if (res.data.data.lbIntegral <= 0) {
              if (res.data.data.lbGrowthValue <= 0) {
                _this.packShow = false;
              } else {
                _this.packShow = true;
                _this.integralShow = false;
                _this.growUpShow = true;
              }

            } else {
              if (res.data.data.lbGrowthValue > 0) {
                _this.packShow = true;
              } else {
                _this.packShow = true;
                _this.integralShow = true;
                _this.growUpShow = false;
              }
            }

            _this.integralTitle = '领取' + res.data.data.lbIntegral + '积分';
            _this.growUpTitle = '领取' + res.data.data.lbGrowthValue + '积分';
            if (res.data.data.receiveState == 0) {
              _this.receiveState = '一键全部领取';
            } else {
              _this.receiveState = '已领取';
            }


            if (res.data.data.actIntro != '') {
              _this.textShow = true;
              _this.textTitle = res.data.data.actIntro;
            }

          } else {
            console.log(res.data.msg);
          }
        }
      });

    },
    GetWebHttp: function GetWebHttp() {
      this.getUrl = this.$GetInfo.HtmlHttp + '/mobile/index/index/stoid/' + this.getStorageID + '.html';
      window.location.href = this.getUrl;
    },
    GetReceive: function GetReceive() {
      var that = this;
      if (that.receiveState == '已领取') {
        return false;
      }
      uni.request({
        url: that.$GetInfo.ApiHttp + '/api/weshop/marketing/free/receive/gift/record/insert',
        data: {
          "actId": that.getActId, //活动Id
          "actType": '2', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销
          "lbId": that.giftID, //礼包Id
          "storeId": that.getStorageID, //商家Id
          "userId": that.getUserID //用户ID
        },
        method: 'POST',
        header: {
          'Content-Type': 'application/json' //自定义请求头信息
        },
        success: function success(res) {
          console.log(res.data);
          if (res.data.code == 0) {
            console.log(res.data.msg);
            that.receiveState = '已领取';
            uni.showToast({
              icon: 'none',
              title: '领取成功!'
            });

          } else {
            console.log(res.data.msg);
            uni.showToast({
              icon: 'none',
              title: res.data.msg
            });

          }
        }
      });

    }
  }
};