activity.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. name ?: string,
  40. activity ?: string,
  41. logo ?: string,
  42. label ?: string,
  43. user_type ?: string,
  44. };
  45. // 基本信息
  46. const config = ref({ bottomTitle: '', logoUrl: '' });
  47. // 查询
  48. const searchInfo = ref({ name: '' });
  49. // 列表
  50. const list = ref<PropsItem[]>([{ name: '测试球队' }, { name: '肝帝集团队' }]);
  51. // 分页
  52. const skip = ref(0);
  53. const limit = ref(6);
  54. const page = ref(0);
  55. const total = ref(0);
  56. // 数据是否触底
  57. const scrollTop = ref(0);
  58. const is_bottom = ref(false);
  59. onShow(() => {
  60. searchConfig();
  61. search();
  62. })
  63. // config信息
  64. const searchConfig = async () => {
  65. config.value = uni.getStorageSync('config');
  66. };
  67. // 查询列表
  68. const search = async () => {
  69. console.log('查询');
  70. };
  71. //查询
  72. const toInput = (e : any) => {
  73. if (searchInfo.value.name) searchInfo.value.name = e.detail.value
  74. searchInfo.value = { name: '' }
  75. clearPage();
  76. search();
  77. };
  78. // 球队详情
  79. const toInfo = (item : any) => {
  80. console.log(item);
  81. };
  82. // 分页
  83. const toPage = () => {
  84. if (total.value > list.value.length) {
  85. uni.showLoading({
  86. title: '加载中',
  87. mask: true
  88. })
  89. page.value = page.value + 1
  90. skip.value = page.value * limit.value;
  91. search();
  92. uni.hideLoading();
  93. } else is_bottom.value = true
  94. };
  95. const toScroll = (e : any) => {
  96. let up = scrollTop.value;
  97. scrollTop.value = e.detail.scrollTop
  98. let num = Math.sign(up - e.detail.scrollTop);
  99. if (num == 1) is_bottom.value = false
  100. };
  101. // 清空数据
  102. const clearPage = () => {
  103. list.value = []
  104. skip.value = 0
  105. limit.value = 6
  106. page.value = 0
  107. };
  108. </script>
  109. <style lang="scss" scoped>
  110. .main {
  111. display: flex;
  112. flex-direction: column;
  113. width: 100vw;
  114. height: 66vh;
  115. .first {
  116. display: flex;
  117. justify-content: center;
  118. align-items: center;
  119. padding: 2vw;
  120. border-bottom: 1px solid var(--f5Color);
  121. input {
  122. width: 100%;
  123. padding: 2vw;
  124. background-color: var(--f1Color);
  125. font-size: var(--font14Size);
  126. border-radius: 5px;
  127. }
  128. }
  129. .second {
  130. position: relative;
  131. flex-grow: 1;
  132. .list {
  133. border-bottom: 1px solid var(--f5Color);
  134. padding: 3vw;
  135. .list_1 {
  136. display: flex;
  137. align-items: center;
  138. .left {
  139. width: 15vw;
  140. .image {
  141. width: 15vw;
  142. height: 15vw;
  143. border-radius: 20vw;
  144. }
  145. }
  146. .right {
  147. width: 75vw;
  148. margin: 0 0 0 2vw;
  149. .name {
  150. font-size: var(--font16Size);
  151. .label {
  152. padding: 3px 6px;
  153. font-size: 10px;
  154. color: var(--mainColor);
  155. border-radius: 2px;
  156. }
  157. .label_1 {
  158. background-color: var(--fF0Color);
  159. }
  160. .label_2 {
  161. background-color: var(--fFFColor);
  162. }
  163. }
  164. .other {
  165. margin: 1vw 0 0 0;
  166. font-size: var(--font14Size);
  167. color: var(--f85Color);
  168. }
  169. }
  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>