扩展链接高佣版

applet.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // pages/applet/applet.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. title: '',
  9. app_id: '',
  10. wxList: [],
  11. path: '',
  12. page: 1,
  13. pages: 1,
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. this.getList();
  20. },
  21. getList(e) {
  22. wx.showLoading({
  23. title: '加载中',
  24. })
  25. e&&(this.setData({
  26. page: 1,
  27. wxList: []
  28. }))
  29. app.func.req('/api/weapp/list', 'get',{
  30. page: this.data.page,
  31. page_size: 20,
  32. }, (res) => {
  33. wx.hideLoading()
  34. if(res && res.errno == 0){
  35. //成功
  36. this.setData({
  37. wxList: this.data.wxList.concat(res.rst.data),
  38. page: Number(res.rst.pageInfo.page),
  39. pages: res.rst.pageInfo.pages,
  40. })
  41. }else {
  42. wx.showToast({
  43. title: res.err,
  44. icon: 'none',
  45. duration: 2000
  46. })
  47. }
  48. },()=>{
  49. wx.hideLoading()
  50. })
  51. },
  52. getApp(e) {
  53. this.setData({
  54. app_id: e.detail.value
  55. })
  56. },
  57. // 添加小程序
  58. addPro(e) {
  59. if(!this.data.app_id) {
  60. wx.showToast({
  61. title: '请填写APPID',
  62. icon: 'none'
  63. })
  64. return;
  65. }
  66. wx.showLoading({
  67. title: '加载中',
  68. })
  69. app.func.req('/api/weapp/add', 'post',{
  70. app_id: this.data.app_id,
  71. }, (res) => {
  72. wx.hideLoading()
  73. if(res && res.errno == 0){
  74. //成功
  75. wx.showToast({
  76. title: '添加成功',
  77. })
  78. this.setData({
  79. page: 1,
  80. wxList: [],
  81. warrantFlag: false,
  82. app_id: ''
  83. })
  84. this.getList()
  85. }else {
  86. wx.showToast({
  87. title: res.err,
  88. icon: 'none',
  89. duration: 2000
  90. })
  91. }
  92. },()=>{
  93. wx.hideLoading()
  94. })
  95. },
  96. // 选择小程序
  97. checkPro(e) {
  98. this.setData({
  99. itemObj: e.currentTarget.dataset.item
  100. })
  101. wx.setStorageSync('itemObj',this.data.itemObj)
  102. wx.redirectTo({
  103. url: '/pages/appletEdit/appletEdit'
  104. })
  105. },
  106. goWarrant() {
  107. this.setData({
  108. warrantFlag: true
  109. })
  110. },
  111. closeToast(e) {
  112. this.setData({
  113. warrantFlag: false,
  114. app_id: ''
  115. })
  116. },
  117. /**
  118. * 页面上拉触底事件的处理函数
  119. */
  120. onReachBottom: function () {
  121. this.setData({
  122. page: this.data.page+1
  123. })
  124. if(this.data.pages>=this.data.page) {
  125. this.getList();
  126. }
  127. },
  128. onShareAppMessage() {
  129. }
  130. })