index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <u-swiper :radius="0" :list="config.file" height="240px" indicator indicatorMode="dot" circular></u-swiper>
  5. </view>
  6. <view class="two" v-if="config.notice">
  7. <up-notice-bar :text="config.notice" duration="3000"></up-notice-bar>
  8. </view>
  9. <view class="thr">
  10. <view class="list" v-for="(item, index) in typeList" :key="index">
  11. <text class="t-icon" :class="[item.icon]"></text>
  12. <view class="text">{{item.name}}</view>
  13. </view>
  14. </view>
  15. <view class="four">
  16. <up-tabs :list="subjectList" keyName="label" @click="toTab"></up-tabs>
  17. </view>
  18. <view class="five">
  19. <up-list @scrolltolower="scrolltolower">
  20. <up-list-item v-for="(item, index) in list" :key="index">
  21. <up-cell :title="`列表长度-${index + 1}`">
  22. <template #icon>
  23. <up-avatar shape="square" size="35" :src="item.url"
  24. customStyle="margin: -3px 5px -3px 0"></up-avatar>
  25. </template>
  26. </up-cell>
  27. </up-list-item>
  28. </up-list>
  29. </view>
  30. <up-overlay :show="show">
  31. <login @showChange='showChange'></login>
  32. </up-overlay>
  33. </view>
  34. </template>
  35. <script setup lang="ts">
  36. import login from "@/components/login.vue"
  37. import { inject, computed, ref } from 'vue';
  38. //该依赖已内置不需要单独安装
  39. import { onShow, onPullDownRefresh } from "@dcloudio/uni-app";
  40. // 请求接口
  41. const $api = inject('$api');
  42. const $apifile = inject('$apifile');
  43. // 基本信息
  44. const typeList = ref([
  45. { name: '兴趣', icon: 't-icon-xingqu', type: '0' },
  46. { name: '小学', icon: 't-icon-xiaoxue', type: '1' },
  47. { name: '中学', icon: 't-icon-zhongxue', type: '2' },
  48. { name: '高中', icon: 't-icon-gaozhong', type: '3' },
  49. ]);
  50. const config = ref({ icon: [], logo: [], file: [] });
  51. const list = ref([]);
  52. const total = ref(0);
  53. // 字典表
  54. const subjectList = ref([]);
  55. // 遮罩层
  56. const show = ref(false);
  57. // user
  58. const user = computed(() => {
  59. return uni.getStorageSync('user');
  60. })
  61. onShow(async () => {
  62. await searchConfig();
  63. await searchOther();
  64. await search();
  65. if (!user.value) show.value = true
  66. loadmore();
  67. })
  68. const urls = [
  69. 'https://cdn.uviewui.com/uview/album/1.jpg',
  70. 'https://cdn.uviewui.com/uview/album/2.jpg',
  71. 'https://cdn.uviewui.com/uview/album/3.jpg',
  72. 'https://cdn.uviewui.com/uview/album/4.jpg',
  73. 'https://cdn.uviewui.com/uview/album/5.jpg',
  74. 'https://cdn.uviewui.com/uview/album/6.jpg',
  75. 'https://cdn.uviewui.com/uview/album/7.jpg',
  76. 'https://cdn.uviewui.com/uview/album/8.jpg',
  77. 'https://cdn.uviewui.com/uview/album/9.jpg',
  78. 'https://cdn.uviewui.com/uview/album/10.jpg',
  79. ];
  80. const scrolltolower = () => {
  81. loadmore();
  82. };
  83. const loadmore = () => {
  84. for (let i = 0; i < 30; i++) {
  85. list.value.push({
  86. url: urls[uni.$u.random(0, urls.length - 1)],
  87. });
  88. }
  89. };
  90. // config信息
  91. const searchConfig = async () => {
  92. config.value = uni.getStorageSync('config');
  93. };
  94. // 其他查询信息
  95. const searchOther = async () => {
  96. let res;
  97. // 学科
  98. res = await $api(`dictData`, 'GET', { code: 'subject', is_use: '0' });
  99. if (res.errcode === 0) subjectList.value = res.data;
  100. };
  101. // 查询
  102. const search = async () => { };
  103. // 改变标签
  104. const toTab = async (data) => {
  105. console.log(data);
  106. };
  107. const showChange = () => {
  108. show.value = false
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .content {
  113. display: flex;
  114. flex-direction: column;
  115. background-color: var(--f1Color);
  116. .two {
  117. margin: 2vw 2vw 0 2vw;
  118. border-radius: 5px;
  119. }
  120. .thr {
  121. display: flex;
  122. justify-content: space-between;
  123. align-items: center;
  124. background-color: var(--mainColor);
  125. margin: 2vw;
  126. border-radius: 5px;
  127. padding: 4vw;
  128. .list {
  129. display: flex;
  130. flex-direction: column;
  131. align-items: center;
  132. .text {
  133. margin: 1vw 0 0 0;
  134. font-size: var(--font14Size);
  135. }
  136. }
  137. }
  138. .four {
  139. margin: 2vw;
  140. border-radius: 5px;
  141. background-color: var(--mainColor);
  142. }
  143. .five {
  144. margin: 2vw;
  145. border-radius: 5px;
  146. background-color: var(--mainColor);
  147. }
  148. }
  149. </style>