// pages/subscription/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { warrantFlag:false, wxList: [], pages: 1, page: 1, keyword: '', total: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getList(); }, getList(e) { e&&(this.setData({ page: 1, wxList: [] })) wx.showLoading({ title: '加载中', }) app.func.req('/api/historyLink/list', 'get', { 'keyword': this.data.keyword, 'page': this.data.page, 'page_size': 20, }, (res) => { wx.hideLoading() if(res && res.errno == 0){ //成功 this.setData({ wxList: this.data.wxList.concat(res.rst.data), page: res.rst.pageInfo.page, pages: res.rst.pageInfo.pages, total: res.rst.pageInfo.total }) }else { wx.showToast({ title: res.err, icon: 'none', duration: 2000 }) } },()=>{ wx.hideLoading() }) }, toDel(e) { wx.showLoading({ title: '加载中', }) app.func.req('/api/historyLink/delete', 'get', { 'link_id': e.currentTarget.dataset.link }, (res) => { wx.hideLoading() if(res && res.errno == 0){ //成功 wx.showToast({ title: '删除成功', }) this.setData({ page: 1, wxList: [] }) this.getList(); }else { wx.showToast({ title: res.err?res.err:'服务器错误', icon: 'none', duration: 2000 }) } },()=>{ console.log(res) wx.hideLoading() }) }, getKeyword(e) { this.setData({ keyword: e.detail.value }) }, copyEvent(e){//点击复制 var that = this; if(!e.currentTarget.dataset.link) { wx.showToast({ title: '无效链接', icon: 'none' }) return; } wx.setClipboardData({ data: e.currentTarget.dataset.link, success: function (res) { wx.getClipboardData({ success: function (res) { wx.showToast({ title: '复制成功' }) that.setData({ isShow: false }) } }) } }) }, deleteEvent(){//删除 wx.showModal({ title: '提示', content: '确定要删除此商品?', success (res) { if (res.confirm) { console.log('用户点击确定') } else if (res.cancel) { console.log('用户点击取消') } } }) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.setData({ page:Number(this.data.page)+1 }) if(this.data.pages>=this.data.page) { this.getList(); } }, onShareAppMessage() { } })