小程序链接助手

index.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. isIPhoneX: false,
  7. follow: false,
  8. text: ''
  9. },
  10. // 事件处理函数
  11. bindViewTap() {
  12. wx.navigateTo({
  13. url: '../logs/logs'
  14. })
  15. },
  16. onLoad() {
  17. this.getText();
  18. },
  19. toOther(e) {
  20. var type = Number(e.currentTarget.dataset.type);
  21. switch (type) {
  22. case 1:
  23. wx.showToast({
  24. title: '敬请期待',
  25. icon: 'none'
  26. })
  27. break;
  28. case 2:
  29. wx.navigateTo({
  30. url: '/pages/floow/floow'
  31. })
  32. break;
  33. case 3:
  34. wx.navigateTo({
  35. url: '/pages/about/about'
  36. })
  37. break;
  38. default:
  39. wx.navigateTo({
  40. url: '/pages/historyLink/index'
  41. })
  42. break;
  43. }
  44. },
  45. getText() {
  46. wx.showLoading({
  47. title: '加载中',
  48. })
  49. app.func.req('/api/app/config', 'get', {
  50. 'version': '1.0.1'
  51. }, (res) => {
  52. wx.hideLoading()
  53. wx.setStorageSync('version',res.v)
  54. if(res && res.errno == 0){
  55. this.setData({
  56. text: res.rst.platform
  57. })
  58. }else {
  59. wx.showToast({
  60. title: res.err,
  61. icon: 'none',
  62. duration: 2000
  63. })
  64. }
  65. },()=>{
  66. wx.hideLoading()
  67. })
  68. },
  69. toLink(e) {
  70. if(wx.getStorageSync('isLogin')){
  71. wx.navigateTo({
  72. url: e.currentTarget.dataset.page,
  73. })
  74. }else{
  75. wx.setStorageSync('encryptedData',e.detail.encryptedData)
  76. wx.setStorageSync('iv',e.detail.iv)
  77. app.login((res)=>{
  78. wx.navigateTo({
  79. url: e.currentTarget.dataset.page,
  80. })
  81. },(err)=>{
  82. wx.showToast({
  83. title: '服务繁忙,请稍后重试!',
  84. icon: 'none',
  85. duration: 2000
  86. })
  87. })
  88. }
  89. },
  90. toApplet() {
  91. wx.navigateToMiniProgram({
  92. appId: 'wx5bcf8975e677d8d4',
  93. path: '/pages/index/index'
  94. })
  95. },
  96. closeToast() {
  97. this.setData({
  98. follow: false
  99. })
  100. },
  101. onShareAppMessage(res) {
  102. return app.shareEvent(res,'/pages/index/index')
  103. }
  104. })