game.vue 4.6 KB

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