123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- // 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() {
-
- }
- })
|