index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Component({
  2. properties: {
  3. pos: {
  4. type: String,
  5. value: 0
  6. }
  7. },
  8. data: {
  9. info: '',
  10. ishow: false
  11. },
  12. attached: function(){
  13. this.getData();
  14. },
  15. pageLifetimes: {
  16. show: function() {
  17. console.log('pageLifetimes')
  18. this.getData();
  19. }
  20. },
  21. methods: {
  22. getData: function() {
  23. let that = this;
  24. getApp().util.request({
  25. url: 'entry/wxapp/index',
  26. data: {
  27. controller: 'index.get_advimg'
  28. },
  29. dataType: 'json',
  30. success: function (res) {
  31. if(res.data.code==0) {
  32. let info = res.data.data;
  33. let pos = info.pos || [];
  34. let ishow = pos.includes(that.data.pos);
  35. that.setData({ info, ishow })
  36. } else {
  37. that.setData({ ishow: false })
  38. }
  39. }
  40. })
  41. },
  42. goNav: function(){
  43. let info = this.data.info;
  44. let type = info.linktype;
  45. let url = info.link;
  46. if (type == 0) {
  47. // 跳转webview
  48. wx.navigateTo({
  49. url: '/lionfish_comshop/pages/web-view?url=' + encodeURIComponent(url),
  50. })
  51. } else if (type == 1) {
  52. if (url.indexOf('lionfish_comshop/pages/index/index') != -1 || url.indexOf('lionfish_comshop/pages/order/shopCart') != -1 || url.indexOf('lionfish_comshop/pages/user/me') != -1 || url.indexOf('lionfish_comshop/pages/type/index') != -1) {
  53. url && wx.switchTab({ url })
  54. } else {
  55. url && wx.navigateTo({ url })
  56. }
  57. } else if (type == 2) {
  58. // 跳转小程序
  59. let appId = info.appid;
  60. appId && wx.navigateToMiniProgram({
  61. appId,
  62. path: url,
  63. extraData: {},
  64. envVersion: 'release',
  65. success(res) {
  66. // 打开成功
  67. },
  68. fail(error) {
  69. console.log(error)
  70. }
  71. })
  72. } else if (type == 3) {
  73. if(this.data.pos==0) {
  74. this.triggerEvent("switchType", url);
  75. } else {
  76. getApp().globalData.indexCateId = url;
  77. wx.switchTab({
  78. url: '/lionfish_comshop/pages/index/index'
  79. })
  80. }
  81. } else if (type == 4) {
  82. //独立分类
  83. getApp().globalData.typeCateId = url;
  84. wx.switchTab({
  85. url: '/lionfish_comshop/pages/type/index'
  86. })
  87. }else if (type==5){
  88. // 跳转小程序
  89. let appId = info.appid;
  90. appId && wx.navigateToMiniProgram({
  91. appId,
  92. path: url,
  93. extraData: {},
  94. envVersion: 'release',
  95. success(res) {
  96. // 打开成功
  97. },
  98. fail(error) {
  99. console.log(error)
  100. }
  101. })
  102. }
  103. }
  104. }
  105. })