index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. <text class="text">群组</text>
  16. </view>
  17. </uni-collapse-item>
  18. <uni-collapse-item title="好友" thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png">
  19. <view class="content">
  20. <text class="text">群组</text>
  21. </view>
  22. </uni-collapse-item>
  23. </uni-collapse>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. user: {},
  32. // 广告
  33. advertList: []
  34. }
  35. },
  36. onShow: async function() {
  37. const that = this;
  38. await that.searchToken();
  39. await that.search();
  40. },
  41. onPullDownRefresh: async function() {
  42. const that = this;
  43. await that.search();
  44. uni.stopPullDownRefresh();
  45. },
  46. methods: {
  47. // 用户信息
  48. searchToken() {
  49. const that = this;
  50. try {
  51. const res = uni.getStorageSync('token');
  52. if (res) that.$set(that, `user`, res);
  53. } catch (e) {
  54. uni.showToast({
  55. title: err.errmsg,
  56. icon: 'error',
  57. duration: 2000
  58. });
  59. }
  60. },
  61. // 查询
  62. async search() {
  63. const that = this;
  64. // 广告
  65. const res = await that.$api(`/adv`, 'GET', {
  66. is_use: '0'
  67. })
  68. if (res.errcode == '0') {
  69. that.$set(that, `advertList`, res.data)
  70. } else {
  71. uni.showToast({
  72. title: res.errmsg,
  73. });
  74. }
  75. },
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .main {
  81. .one {
  82. padding: 0 0 2vw 0;
  83. .swiper {
  84. height: 60vw;
  85. .list {
  86. .image {
  87. width: 100%;
  88. height: 100%;
  89. }
  90. }
  91. }
  92. }
  93. }
  94. </style>