var util = require('../../utils/util.js'); 
 | 
var api = require('../../utils/service-api.js'); 
 | 
const app=getApp(); 
 | 
Page({ 
 | 
  
 | 
  /** 
 | 
   * 页面的初始数据 
 | 
   */ 
 | 
  data: { 
 | 
    couponList:[], 
 | 
  }, 
 | 
  onLoad: function (options) { 
 | 
    this.getCouponList(); 
 | 
    this.getArrondiCouponList(); 
 | 
  }, 
 | 
  //获取专区优惠券 
 | 
  getArrondiCouponList() { 
 | 
    var _this = this; 
 | 
    util.request({ 
 | 
      method: "GET",  
 | 
      api: "/wxapi/shopCoupon/getCouponListByTag/" + app.shopInfo.id + "/zqyhq",  
 | 
      callback: function (data) { 
 | 
      console.log(data.rows) 
 | 
      _this.setData({ 
 | 
        arrondiList: data.rows 
 | 
      }); 
 | 
    }}); 
 | 
  }, 
 | 
  //获取优惠券 
 | 
  getCouponList() { 
 | 
    var _this = this; 
 | 
    util.request({ 
 | 
      method: "GET",  
 | 
      api: "/wxapi/shopCoupon/getCouponListByTag/" + app.shopInfo.id + "/gmyhq",  
 | 
      callback: function (data) { 
 | 
      _this.setData({ 
 | 
        couponList: data.rows 
 | 
      }); 
 | 
    }}); 
 | 
  }, 
 | 
  
 | 
  
 | 
  checkUserInfoIsBuding() { 
 | 
    if (util.isBlank(getApp().userInfo.nickName)) { 
 | 
      wx.navigateTo({ 
 | 
        url: '/pages/welcome/welcome?url=/pages/yuyue/khyuyue', 
 | 
      }) 
 | 
    } else if (util.isBlank(getApp().userInfo.phoneNumber)) { 
 | 
      wx.navigateTo({ 
 | 
        url: '/pages/phone/phone?url=/pages/yuyue/khyuyue', 
 | 
      }) 
 | 
    } 
 | 
  }, 
 | 
  
 | 
   
 | 
  getCoupon(e) { 
 | 
    var _this = this; 
 | 
    var index = e.currentTarget.dataset.index; 
 | 
    var value = e.currentTarget.dataset.value; 
 | 
    var couponList = _this.data.couponList; 
 | 
  
 | 
    this.checkUserInfoIsBuding(); 
 | 
  
 | 
    util.request({ 
 | 
      method: "GET", 
 | 
      api: "/wxapi/shopCoupon/receiveCoupon/" + value.id, 
 | 
      callback: function (data) { 
 | 
        console.log(value.id) 
 | 
        if (data.status == '200') { 
 | 
          wx.showToast({ 
 | 
            title: data.info, 
 | 
            icon: 'success', 
 | 
            duration: 2000 
 | 
          }) 
 | 
        } 
 | 
      } 
 | 
    }); 
 | 
  
 | 
  } 
 | 
}) 
 |