wzy
2021-04-01 d388e2788b7ef088d7cd40f901b0acdcec460bc3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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
          })
        }
      }
    });
 
  }
})