// packageD/getCoupon/getCoupon.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { language: "", isMid: "", // isOrderid:'', page: "1", }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ isOrderid: options.id, }); this.getshare(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { let language = wx.getStorageSync("langIndex"); this.setData({ language: language.en }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.current_page >= this.data.last_page) { wx.showToast({ title: "没有更多", icon: "none", duration: 1000, }); } else { let pahe = this.data.page + 1; this.setData({ page: pahe, }); this.nextGetRecord(); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, goHome() { wx.reLaunch({ url: "/packageG/index/index", }); }, getshare() { let that = this; var urlStr = app.getNetAddresss("coupon.share-coupon.receive"); urlStr += "&order_ids=" + that.data.isOrderid; app._getNetWork({ url: urlStr, success: (resdata) => { var res = resdata.data; if (res.result == 1) { console.log(res); that.setData({ banner: res.data.set.banner, status: res.data.code, coupon: res.data.coupon, name: res.data.member_name, msg: res.data.msg, }); //获取记录 this.getRecord(); } else { wx.showToast({ icon: "none", title: res.msg, duration: 1000, }); } }, fail: function (res) { console.log(res); }, }); }, getRecord() { let that = this; var urlStr = app.getNetAddresss("coupon.share-coupon.log-list"); urlStr += "&order_ids=" + that.data.isOrderid + "&page=" + that.data.page; app._getNetWork({ url: urlStr, success: (resdata) => { var res = resdata.data; if (res.result == 1) { console.log(res); that.setData({ record_arr: res.data.data, max_num: res.data.remainder, current_page: res.data.current_page, last_page: res.data.last_page, }); } else { wx.showToast({ icon: "none", title: res.msg, duration: 1000, }); } }, fail: function (res) { console.log(res); }, }); }, nextGetRecord() { let that = this; var urlStr = app.getNetAddresss("coupon.share-coupon.log-list"); urlStr += "&order_ids=" + that.data.isOrderid + "&page=" + that.data.page; app._getNetWork({ url: urlStr, success: (resdata) => { var res = resdata.data; if (res.result == 1) { console.log(res); that.setData({ max_num: res.data.remainder, record_arr: that.data.record_arr.concat(res.data.data), current_page: res.data.current_page, last_page: res.data.last_page, }); } else { wx.showToast({ icon: "none", title: res.msg, duration: 1000, }); } }, fail: function (res) { console.log(res); }, }); }, });