var t = require("../../../utils/util.js"), ut = t, e = require("../../../utils/common.js"), oo = getApp().globalData, os = getApp().globalData.setting; var utils = require('../../../utils/util.js'),ut=utils; Page({ data: { stoid: os.stoid, url: os.url, resourceUrl: os.resourceUrl, iurl: os.imghost, defaultAvatar: os.resourceUrl + "/static/images/user68.jpg", dataList: null, config2:null, curpage:1, loading:0, get_item:null, show_success:0, getcurday:null, }, //------初始化加载---------- onLoad: function(t) { var th=this; getApp().getConfig2(function (conf) { conf.couponset=conf.couponset.replace(/\ { th.data.loading=0; if(res.data.code==0){ if(!th.data.dataList) th.data.dataList=new Array(); th.data.dataList=th.data.dataList.concat(res.data.data.pageData); th.data.curpage++; th.setData({dataList:th.data.dataList}); } }); }, //---加载更多是靠这个函数---- onReachBottom: function() { this.get_quan_list(); }, //--滚动到顶部-- doScrollTop: function() { wx.pageScrollTo({ scrollTop: 0 }); }, //-----领取券----- get_quan: function(e) { var cid = e.currentTarget.dataset.cid; var index = e.currentTarget.dataset.ind; var item = this.data.dataList[index]; //--先判断会员状态-- var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { wx.navigateTo({ url: '/pages/togoin/togoin', }) return false; } //如果券还在领取中,不能再点 if (item.linging == 1) { getApp().my_warnning('领取中..', 0, this); return false; } //如果领取的次数到了 if (item.everyone_num > 0 && item.lqnum >= item.everyone_num) { getApp().my_warnning('领取失败,您已领完该券', 0, this); return false; } var lq_num = item.lqnum; var pdata = { 'uid': oo.user_id, 'cid': cid, 'store_id': os.stoid, 'type': 5 }; //-- 导购ID -- if(getApp().globalData.guide_id){ pdata.guide_id=getApp().globalData.guide_id; } var app = getApp(), th = this; app.request.post("/api/weshop/couponList/saveCouponList", { data: pdata, success: function(res) { if (res.data.code == 0) { var text = "dataList[" + index + "].is_get"; var text2 = "dataList[" + index + "].linging"; var text3 = "get_item"; var obj = {};obj[text] = 1; obj[text2] = 0;obj[text3] = item;obj['show_success']=1; th.setData(obj); } else { app.confirmBox(res.data.msg); var text2 = "dataList[" + index + "].linging"; th.setData({[text2]:0}); } } }) }, close_show:function () { this.setData({show_success:0,get_item:null}) }, go_quan:function () { getApp().goto("/pages/user/coupons/coupons"); }, go_detail:function (e) { var index=e.currentTarget.dataset.ind; var item=this.data.dataList[index]; getApp().goto("/packageA/pages/quan_pro/quan_pro?id="+item.id); } });