team.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="main">
  3. <view class="first">
  4. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索球队名称">
  5. </view>
  6. <view class="second">
  7. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  8. <view class="list-scroll-view">
  9. <view class="list" v-for="(item, index) in list" :key="index" @tap="toInfo(item)">
  10. <view class="list_1">
  11. <view class="left">
  12. <image class="image" mode="aspectFill" :src="item.logo||config.logoUrl"></image>
  13. </view>
  14. <view class="right">
  15. <view class="name">
  16. {{item.name||'暂无名称'}}
  17. <text class="label"
  18. :class="[item.user_type=='0'?'label_1':'label_2']">{{item.label||'队长'}}</text>
  19. </view>
  20. <view class="other">
  21. {{item.activity||'暂无活动'}}
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="is_bottom" v-if="is_bottom">
  27. <text>{{config.bottomTitle||'到底了!'}}</text>
  28. </view>
  29. </view>
  30. </scroll-view>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup lang="ts">
  35. import { ref } from 'vue';
  36. //该依赖已内置不需要单独安装
  37. import { onShow } from "@dcloudio/uni-app";
  38. interface PropsItem {
  39. id ?: number,
  40. name ?: string,
  41. activity ?: string,
  42. logo ?: string,
  43. label ?: string,
  44. user_type ?: string,
  45. };
  46. // 基本信息
  47. const config = ref({ bottomTitle: '', logoUrl: '' });
  48. // 查询
  49. const searchInfo = ref({ name: '' });
  50. // 列表
  51. const list = ref<PropsItem[]>([{ id: 1, name: '测试球队' }, { id: 2, name: '肝帝集团队' }]);
  52. // 分页
  53. const skip = ref(0);
  54. const limit = ref(6);
  55. const page = ref(0);
  56. const total = ref(0);
  57. // 数据是否触底
  58. const scrollTop = ref(0);
  59. const is_bottom = ref(false);
  60. onShow(() => {
  61. searchConfig();
  62. search();
  63. })
  64. // config信息
  65. const searchConfig = async () => {
  66. config.value = uni.getStorageSync('config');
  67. };
  68. // 查询列表
  69. const search = async () => {
  70. console.log('查询');
  71. };
  72. //查询
  73. const toInput = (e : any) => {
  74. if (searchInfo.value.name) searchInfo.value.name = e.detail.value
  75. searchInfo.value = { name: '' }
  76. clearPage();
  77. search();
  78. };
  79. // 球队详情
  80. const toInfo = (item : any) => {
  81. uni.navigateTo({
  82. url: `/pagesHome/team/info?id=${item._id || item.id}`,
  83. })
  84. };
  85. // 分页
  86. const toPage = () => {
  87. if (total.value > list.value.length) {
  88. uni.showLoading({
  89. title: '加载中',
  90. mask: true
  91. })
  92. page.value = page.value + 1
  93. skip.value = page.value * limit.value;
  94. search();
  95. uni.hideLoading();
  96. } else is_bottom.value = true
  97. };
  98. const toScroll = (e : any) => {
  99. let up = scrollTop.value;
  100. scrollTop.value = e.detail.scrollTop
  101. let num = Math.sign(up - e.detail.scrollTop);
  102. if (num == 1) is_bottom.value = false
  103. };
  104. // 清空数据
  105. const clearPage = () => {
  106. list.value = []
  107. skip.value = 0
  108. limit.value = 6
  109. page.value = 0
  110. };
  111. </script>
  112. <style lang="scss" scoped>
  113. .main {
  114. display: flex;
  115. flex-direction: column;
  116. width: 100vw;
  117. height: 66vh;
  118. .first {
  119. display: flex;
  120. justify-content: center;
  121. align-items: center;
  122. padding: 2vw;
  123. border-bottom: 1px solid var(--f5Color);
  124. input {
  125. width: 100%;
  126. padding: 2vw;
  127. background-color: var(--f1Color);
  128. font-size: var(--font14Size);
  129. border-radius: 5px;
  130. }
  131. }
  132. .second {
  133. position: relative;
  134. flex-grow: 1;
  135. .list {
  136. border-bottom: 1px solid var(--f5Color);
  137. padding: 3vw;
  138. .list_1 {
  139. display: flex;
  140. align-items: center;
  141. .left {
  142. width: 15vw;
  143. .image {
  144. width: 15vw;
  145. height: 15vw;
  146. border-radius: 20vw;
  147. }
  148. }
  149. .right {
  150. width: 75vw;
  151. margin: 0 0 0 2vw;
  152. .name {
  153. font-size: var(--font16Size);
  154. .label {
  155. padding: 3px 6px;
  156. font-size: 10px;
  157. color: var(--mainColor);
  158. border-radius: 2px;
  159. }
  160. .label_1 {
  161. background-color: var(--fFFColor);
  162. }
  163. .label_2 {
  164. background-color: var(--fF0Color);
  165. }
  166. }
  167. .other {
  168. margin: 1vw 0 0 0;
  169. font-size: var(--font14Size);
  170. color: var(--f85Color);
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. .scroll-view {
  178. position: absolute;
  179. top: 0;
  180. left: 0;
  181. right: 0;
  182. bottom: 0;
  183. .list-scroll-view {
  184. display: flex;
  185. flex-direction: column;
  186. }
  187. }
  188. .is_bottom {
  189. width: 100%;
  190. text-align: center;
  191. text {
  192. padding: 2vw 0;
  193. display: inline-block;
  194. color: var(--f85Color);
  195. font-size: var(--font14Size);
  196. }
  197. }
  198. </style>