var e = getApp(), a = e.globalData.setting, os = a, t = e.request, d = e.globalData; Page({ data: { url: a.url, //接口网址 iurl: a.imghost, //图片前缀网址 getStorageID: '', getUserID: '', wareCard: [], page: 0, pageSize: 10, isEmpty: true, loadingType: 0, //定义加载方式 0---contentdown 1---contentrefresh 2---contentnomore contentText: { contentdown: '加载更多', contentrefresh: '加载中...', contentnomore: '已加载全部' } }, onLoad: function(options) { var th = this; th.setData({ getStorageID: a.stoid, getUserID: 5682130 }) }, onShow: function() { var th = this; th.setData({ pages: 1, pageSize: 10, loadingType: 0 }) th.getList(); }, GetBuyPrice: function(e) { var that = this.data; var th = this; var lbId = e.currentTarget.dataset.lbId;//活动id var my_confirm = th.selectComponent("#my_confirm"); //组件的id my_confirm.open( "是否确定购买该礼包", "取消", "确定", function() { my_confirm.open_cancel(0); }, function() { var json = { "actId": '', //活动Id "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销 "buyType": '2', //1=积分兑换 2=余额购买 "lbId": lbId, //礼包Id "storeId": that.getStorageID, //商家Id "userId": that.getUserID, //用户ID "buyFrom": 2 }; var data = JSON.stringify(json); var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; wx.request({ url: url, data: data, method: 'post', header: { 'content-type': 'application/json' }, // 设置请求的 header success: function (res) { if (res.data.code == 0) { window.location.href = th.data.url + '/Mobile/Payment/getPay.html?stoid=' + that.getStorageID + '&order_sn=' + res.data.data.orderSn + '&recharge_type=6'; } else { getApp().my_warnning(res.data.msg, 0, th); } } }) } ) }, GetBuyIntegral: function(e) { var that = this.data; var th = this; var lbId = e.currentTarget.dataset.lbId;//活动id var my_confirm = th.selectComponent("#my_confirm"); //组件的id my_confirm.open( "是否确定兑换该礼包", "取消", "确定", function() { my_confirm.open_cancel(0); }, function() { getApp().request.post('/api/weshop/marketing/buy/receive/gift/record/insert', { data: { "actId": '', //活动Id "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销 "buyType": '1', //1=积分兑换 2=余额购买 "lbId": 26, //礼包Id "storeId": that.getStorageID, //商家Id "userId": that.getUserID //用户ID }, success: function success(res) { if (res.data.code == 0) { getApp().my_warnning("兑换成功!", 1, th); } else { getApp().my_warnning(res.data.msg, 0, th); } } }) }) }, getList: function(e) { var _this = this; //上拉加载 var that = this.data; if (that.loadingType != 0) { return false; } // that.loadingType = 1; _this.setData({ loadingType: 1 }) getApp().request.get('/api/weshop/marketing/my/giftbag/page', { data: { "storeId": that.getStorageID, //商家ID "userId": that.getUserID, //用户ID "page": that.pages, "pageSize": that.pageSize }, success: function success(res) { if (res.data.code == 0) { if (res.data.data.total > 0) { _this.setData({ isEmpty: false }) } else { _this.setData({ isEmpty: true }) } if (res.data.data.pageData.length == 0) { _this.setData({ loadingType: 2 }) } else { var wareCard = that.wareCard; if (wareCard.length < res.data.data.total) { for (var i = 0; i < res.data.data.pageData.length; i++) { wareCard.push(res.data.data.pageData[i]); } } _this.setData({ wareCard: wareCard }) _this.setData({ loadingType: 0 }) } } else { getApp().my_warnning(res.data.msg, 0, th); } } }) }, //界面跳转 goto: function(e) { var th = this; var url = e.currentTarget.dataset.url; getApp().goto(url); } })