index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#F5F5F5"
  5. indicator-active-color="#ffffff" :autoplay="false" :interval="3000" :duration="1000">
  6. <swiper-item class="list" v-for="(item,index) in advertList" :key="index">
  7. <image class="image" :src="item.image&&item.image.length>0?item.image[0].url:''" mode=""></image>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <view class="two">
  12. <uni-collapse>
  13. <uni-collapse-item title="群组" thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png">
  14. <view class="content">
  15. <view class="list" v-for="(item, index) in groupList" :key="index" @tap="toInfo(item)">
  16. 1111
  17. </view>
  18. <view class="is_bottom" v-if="is_bottom">
  19. <text>{{config.bottom_title||'到底了!'}}</text>
  20. </view>
  21. </view>
  22. </uni-collapse-item>
  23. <uni-collapse-item title="好友" thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png">
  24. <view class="content">
  25. <view class="list" v-for="(item, index) in friendList" :key="index" @tap="toInfo(item)">
  26. 1111
  27. </view>
  28. <view class="is_bottom" v-if="is_bottom">
  29. <text>{{config.bottom_title||'到底了!'}}</text>
  30. </view>
  31. </view>
  32. </uni-collapse-item>
  33. </uni-collapse>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. user: {},
  42. config: {},
  43. // 广告
  44. advertList: [],
  45. // 群组
  46. groupList: [],
  47. // 好友
  48. friendList: []
  49. }
  50. },
  51. onShow: async function() {
  52. const that = this;
  53. await that.searchToken();
  54. await that.searchConfig();
  55. await that.search();
  56. },
  57. onPullDownRefresh: async function() {
  58. const that = this;
  59. await that.search();
  60. uni.stopPullDownRefresh();
  61. },
  62. methods: {
  63. // 用户信息
  64. searchToken() {
  65. const that = this;
  66. try {
  67. const res = uni.getStorageSync('token');
  68. if (res) that.$set(that, `user`, res);
  69. } catch (e) {
  70. uni.showToast({
  71. title: err.errmsg,
  72. icon: 'error',
  73. duration: 2000
  74. });
  75. }
  76. },
  77. searchConfig() {
  78. const that = this;
  79. try {
  80. const res = uni.getStorageSync('config');
  81. if (res) that.$set(that, `config`, res);
  82. } catch (e) {
  83. uni.showToast({
  84. title: err.errmsg,
  85. icon: 'error',
  86. duration: 2000
  87. });
  88. }
  89. },
  90. // 查询
  91. async search() {
  92. const that = this;
  93. // 广告
  94. const res = await that.$api(`/adv`, 'GET', {
  95. is_use: '0'
  96. })
  97. if (res.errcode == '0') {
  98. that.$set(that, `advertList`, res.data)
  99. } else {
  100. uni.showToast({
  101. title: res.errmsg,
  102. });
  103. }
  104. },
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .main {
  110. .one {
  111. padding: 0 0 2vw 0;
  112. .swiper {
  113. height: 60vw;
  114. .list {
  115. .image {
  116. width: 100%;
  117. height: 100%;
  118. }
  119. }
  120. }
  121. }
  122. }
  123. </style>