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; var first_leader=t.first_leader; if(first_leader){ //-- user_id代过来免登录 -- getApp().globalData.first_leader=first_leader; //调用接口判断是不是会员 getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{ if(res.data.code==0){ getApp().globalData.guide_id=res.data.data.id; getApp().globalData.guide_pick_id= res.data.data.pickup_id } }) } getApp().getConfig2(function (conf) { if (conf.couponset) conf.couponset = conf.couponset.replace(/\ 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 }; if (item.useobjecttype == 20 && item.type == 1) { getApp().request.get('/api/weshop/goods/list', { data: { store_id: os.stoid, erpwareid: item.useobjectid, }, success(res) { if (ut.ajax_ok2(res)) { good = res.data.data; } } }) } //-- 导购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; th.setData(obj); if (good.length > 0) { wx.showToast({ title: '领取成功', success() { let item = good[0]; let url = `/pages/goods/goodsInfo/goodsInfo?goods_id=${item.goods_id}&prom_type=${item.prom_type}&prom_id=${item.prom_id}` setTimeout(()=>{ getApp().goto(url) },500) } }) } else { th.setData({ show_success: 1, }) } } 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("/packageD/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); }, //发送给好友 onShareAppMessage:async function(e) { getApp().globalData.no_clear=1; var url= `packageA/pages/quan_list/quan_list`; var userInfo = getApp().globalData.userInfo; //是分销商才带 if (userInfo) { url += "?first_leader=" + userInfo.user_id; } var ob = { title:"优惠券列表", path: url, //imageUrl:this.data.url+this.data.store_config.store_logo, }; return ob; }, //发送给朋友圈 onShareTimeline() { getApp().globalData.no_clear=1; var user_id= getApp().globalData.user_id return { title:"优惠券列表", query: 'first_leader='+user_id } }, });