扩展链接高佣版

index.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // pages/subscription/index.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. warrantFlag:false,
  9. wxList: [],
  10. pages: 1,
  11. page: 1
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function () {
  17. this.getList();
  18. },
  19. goWarrant(){//去授权
  20. this.setData({
  21. warrantFlag:true
  22. })
  23. },
  24. closeToast(){
  25. this.setData({
  26. warrantFlag:false
  27. })
  28. },
  29. getList(e) {
  30. wx.showLoading({
  31. title: '加载中',
  32. })
  33. e&&(this.setData({
  34. page: 1,
  35. wxList: []
  36. }))
  37. app.func.req('/api/account/index', 'get',{
  38. page: this.data.page,
  39. page_size: 20,
  40. }, (res) => {
  41. wx.hideLoading()
  42. if(res && res.errno == 0){
  43. //成功
  44. this.setData({
  45. wxList: this.data.wxList.concat(res.rst.data),
  46. page: res.rst.pageInfo.page,
  47. pages: res.rst.pageInfo.pages,
  48. })
  49. }else {
  50. wx.showToast({
  51. title: res.err,
  52. icon: 'none',
  53. duration: 2000
  54. })
  55. }
  56. },()=>{
  57. wx.hideLoading()
  58. })
  59. },
  60. /**
  61. * 页面上拉触底事件的处理函数
  62. */
  63. onReachBottom: function () {
  64. this.setData({
  65. page:Number(this.data.page)+1
  66. })
  67. if(this.data.pages>=this.data.page) {
  68. this.getList();
  69. }
  70. },
  71. // 选择公众号
  72. toCheck(e) {
  73. if(e.currentTarget.dataset.item.is_checked==1) {
  74. return;
  75. }
  76. app.func.req('/api/account/checked', 'post', {
  77. 'app_id': e.currentTarget.dataset.item.app_id
  78. }, (res) => {
  79. wx.hideLoading()
  80. if(res && res.errno == 0){
  81. //成功
  82. wx.showToast({
  83. title: '切换公众号成功',
  84. })
  85. this.setData({
  86. wxList: [],
  87. page: 1
  88. })
  89. this.getList();
  90. }else {
  91. wx.showToast({
  92. title: res.err,
  93. icon: 'none',
  94. duration: 2000
  95. })
  96. }
  97. },()=>{
  98. wx.hideLoading()
  99. })
  100. },
  101. toCustom() {
  102. this.setData({
  103. warrantFlag: false
  104. })
  105. },
  106. onShareAppMessage() {
  107. }
  108. })