index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <home-frame @toPath="toPath">
  3. <view class="main">
  4. <view class="one">
  5. <view class="list" v-for="(item,index) in list" :key="index" @tap="toWeb(item)">
  6. <image class="image" :src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''" mode="">
  7. </image>
  8. <view class="name textOver">
  9. {{item.title}}
  10. </view>
  11. </view>
  12. </view>
  13. </view>
  14. </home-frame>
  15. </template>
  16. <script>
  17. import homeFrame from "../components/home-frame.vue";
  18. export default {
  19. components: {
  20. homeFrame
  21. },
  22. data() {
  23. return {
  24. list: []
  25. };
  26. },
  27. onLoad() {
  28. const that = this;
  29. that.search()
  30. },
  31. onShow() {
  32. },
  33. methods: {
  34. async search() {
  35. const that = this;
  36. // 轮播图
  37. let res;
  38. res = await that.$api('appapk', 'GET', {
  39. is_use: '0',
  40. limit: 100
  41. });
  42. if (res.errcode == '0') {
  43. that.$set(that, `list`, res.data)
  44. }
  45. },
  46. toWeb(e) {
  47. const that = this;
  48. let system = that.$config.system
  49. if (system.uniPlatform == 'app') {
  50. plus.runtime.openURL(e.web_url)
  51. } else if (system.uniPlatform == 'mp-weixin') {
  52. uni.showToast({
  53. title: '小程序无法打开链接,请打开app进行跳转',
  54. icon: "none"
  55. })
  56. }
  57. },
  58. // 跳转页面
  59. toPath(e) {
  60. let url = `/${e.route}`;
  61. if (e.type == '0') uni.navigateTo({
  62. url
  63. })
  64. else if (e.type == '1') uni.redirectTo({
  65. url
  66. })
  67. else if (e.type == '2') uni.reLaunch({
  68. url
  69. })
  70. else if (e.type == '3') uni.switchTab({
  71. url
  72. })
  73. }
  74. },
  75. };
  76. </script>
  77. <style lang="scss">
  78. .main {
  79. background-color: var(--rgb000);
  80. display: flex;
  81. flex-direction: column;
  82. width: 100vw;
  83. height: 92vh;
  84. .one {
  85. padding: 8px;
  86. display: flex;
  87. flex-wrap: wrap;
  88. justify-content: space-between;
  89. background-color: var(--rgb000);
  90. .list {
  91. width: 18%;
  92. margin: 0 0 10px 0;
  93. .image {
  94. width: 100%;
  95. height: 62px;
  96. overflow: hidden;
  97. border-radius: 5px;
  98. }
  99. .name {
  100. font-size: 12px;
  101. color: var(--rgbfff);
  102. text-align: center;
  103. }
  104. }
  105. }
  106. }
  107. </style>