game.vue 4.3 KB

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