giftpacklist.js 6.67 KB
var t = require("../../utils/common.js"); var os = getApp().globalData.setting;
Page({
  data: function data() {
    return {
      isBuy: 0,
      getGiftID: '',
      giftImage: '',
      giftTitle: '',
      giftDate: '',
      giftPrice: '',
      giftIntegral: '',
      giftPosPrice: '',
      giftQty: '',
      giftRemark: '',
      giftType: '',
      actTitle: '',
      getUrl: '',
      wareCard: []
    };

  },
  onLoad: function onLoad(options) {
    this.isBuy = options.isBuy;
    this.getStorageID = options.stoid;
    this.getUserID = options.userid;
    this.getGiftID = options.id;

    console.log(this.isBuy + '||' + this.getStorageID + '||' + this.getUserID + '||' + this.getGiftID);
  },
  onShow: function onShow() {
    if (this.isBuy == 0) {
      this.GetMyGiftList();
    } else {
      this.GetBuyGiftList();
    }

    this.giftRemark = this.giftRemark.replace(/<p><img/gi, "<p class='img'><img");
  },
  methods: {
    GetBuyPrice: function GetBuyPrice() {
      var that = this;
      uni.showModal({
        title: '',
        content: '是否确定购买该礼包',
        success: function success(res) {
          if (res.confirm) {
            getApp().request.promisepost('/api/weshop/marketing/buy/receive/gift/record/insert',{
              data: {
                "actId": '', //活动Id
                "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销
                "buyType": '2', //1=积分兑换 2=余额购买
                "lbId": that.getGiftID, //礼包Id
                "storeId": that.getStorageID, //商家Id
                "userId": that.getUserID //用户ID
              },
              success: function success(res) {
                console.log(res.data);
                if (res.data.code == 0) {
                  console.log(res.data.msg);
                  uni.showToast({
                    icon: 'none',
                    title: '购买成功!'
                  });

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

                }
              }
            });


          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        }
      });


    },
    GetBuyIntegral: function GetBuyIntegral() {
      var that = this;
      uni.showModal({
        title: '',
        content: '是否确定兑换该礼包',
        success: function success(res) {
          if (res.confirm) {
            getApp().request.promisepost('/api/weshop/marketing/buy/receive/gift/record/insert',{
              data: {
                "actId": '', //活动Id
                "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销
                "buyType": '1', //1=积分兑换 2=余额购买
                "lbId": that.getGiftID, //礼包Id
                "storeId": that.getStorageID, //商家Id
                "userId": that.getUserID //用户ID
              },
              success: function success(res) {
                console.log(res.data);
                if (res.data.code == 0) {
                  console.log(res.data.msg);
                  uni.showToast({
                    icon: 'none',
                    title: '兑换成功!'
                  });

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

                }
              }
            });


          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        }
      });




    },
    GetMyGiftList: function GetMyGiftList() {
      var _this = this;
      getApp().request.promiseget('/api/weshop/marketing/my/giftbag/detail/get',{
        data: {
          "storeId": this.getStorageID, //商家ID
          "userId": this.getUserID, //用户ID
          "orderSn": this.getGiftID
        },
        success: function success(res) {
          console.log(res.data);
          _this.giftImage = _this.$GetInfo.imgHttp + res.data.data.lbUrl;
          _this.giftTitle = res.data.data.giftTitle;
          if (res.data.data.giftRemark == '') {
            _this.giftRemark = '暂无详情......';
          } else {
            _this.giftRemark = res.data.data.giftRemark;
          }
          _this.giftDate = res.data.data.endTime;
          _this.giftPosPrice = res.data.data.giftPosPrice;
          _this.giftQty = res.data.data.giftQty;
          _this.giftIntegral = res.data.data.payIntegral;
          _this.giftPrice = res.data.data.payMoney;
          _this.giftType = res.data.data.actType;
          _this.actTitle = res.data.data.actTitle;
          _this.wareCard = res.data.data.wareCard;
          console.log(res.data.actImg);
        }
      });

    },
    GetBuyGiftList: function GetBuyGiftList() {
      var _this2 = this;
      getApp().request.promiseget('/api/weshop/marketing/giftbag/detail/get',{
        data: {
          "storeId": this.getStorageID, //商家ID
          "userId": this.getUserID, //用户ID
          "giftBagId": this.getGiftID
        },
        success: function success(res) {
          console.log(res.data);
          _this2.giftImage = _this2.$GetInfo.imgHttp + res.data.data.lbUrl;
          _this2.giftTitle = res.data.data.giftTitle;
          if (res.data.data.giftRemark == '') {
            _this2.giftRemark = '暂无详情......';
          } else {
            _this2.giftRemark = res.data.data.giftRemark;
          }
          _this2.giftDate = res.data.data.endTime;
          _this2.giftPosPrice = res.data.data.giftPosPrice;
          _this2.giftQty = res.data.data.giftQty;
          _this2.giftIntegral = res.data.data.payIntegral;
          _this2.giftPrice = res.data.data.payMoney;
          _this2.giftType = res.data.data.actType;
          _this2.actTitle = res.data.data.actTitle;
          _this2.wareCard = res.data.data.wareCard;
          console.log(res.data.actImg);
        }
      });

    },
    GetQrCode: function GetQrCode() {
      //不销毁调整
      uni.navigateTo({
        url: '/pages/mygiftpack/QrCode?number=' + this.getGiftID
      });

    },
    GetWebHttp: function GetWebHttp(type) {

      if (type == 0) {
        this.getUrl = this.$GetInfo.HtmlHttp + '/index.php/Mobile/User/coupon/stoid/' + this.getStorageID + '/user_id/' + this.getUserID + '.html';
      }
      if (type == 1) {
        this.getUrl = this.$GetInfo.HtmlHttp + '/index.php/Mobile/Yyservice/service_items_list/stoid/' + this.getStorageID + '/user_id/' + this.getUserID + '.html';
      }
      window.location.href = this.getUrl;
    }
  }
});