扩展链接高佣版

index.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // pages/mine/index.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. wxLength: 0
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. // if(wx.getStorageSync('isLogin')) {
  15. // this.getList();
  16. // }
  17. },
  18. onShow() {
  19. if(this.data.wxLength==0&&wx.getStorageSync('isLogin')) {
  20. this.getList();
  21. }
  22. },
  23. // 获取授权公众号的数量
  24. getList(e) {
  25. e&&(this.setData({
  26. wxList: []
  27. }))
  28. app.func.req('/api/account/index', 'get',{
  29. page: 1,
  30. page_size:20
  31. }, (res) => {
  32. wx.hideLoading()
  33. if(res && res.errno == 0){
  34. //成功
  35. this.setData({
  36. wxLength: res.rst.pageInfo.total
  37. })
  38. }else if(res.errno != '4001'){
  39. wx.showToast({
  40. title: res.err,
  41. icon: 'none',
  42. duration: 2000
  43. })
  44. }
  45. },()=>{
  46. wx.hideLoading()
  47. })
  48. },
  49. getUserInfo(e) {
  50. if(wx.getStorageSync('isLogin')){
  51. wx.navigateTo({
  52. url: e.currentTarget.dataset.page,
  53. })
  54. }else{
  55. wx.setStorageSync('encryptedData',e.detail.encryptedData)
  56. wx.setStorageSync('iv',e.detail.iv)
  57. app.login(()=>{
  58. wx.navigateTo({
  59. url: e.currentTarget.dataset.page,
  60. })
  61. },(err)=>{
  62. wx.showToast({
  63. title: '服务繁忙,请稍后重试!',
  64. icon: 'none',
  65. duration: 2000
  66. })
  67. })
  68. }
  69. },
  70. goPage(e){//去其他页面
  71. wx.navigateTo({
  72. url: e.currentTarget.dataset.page,
  73. })
  74. },
  75. /**
  76. * 用户点击右上角分享
  77. */
  78. onShareAppMessage: function (res) {
  79. return app.shareEvent(res,'/pages/index/index')
  80. },
  81. })