activity.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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="other">
  10. <view class="other_1">
  11. <view class="drop" v-for="(item, index) in list" :key="index">
  12. .
  13. <view class="line"></view>
  14. </view>
  15. </view>
  16. <view class="other_2">
  17. <view class="list" v-for="(item, index) in list" :key="index" @tap="toInfo(item)">
  18. <view class="list_1">
  19. <view class="date">{{item.date||'暂无日期'}}</view>
  20. <view class="status"
  21. :class="[item.status=='0'?'status0':item.status=='1'?'status1':'status2']">
  22. {{item.status_name||'暂无状态'}}
  23. </view>
  24. </view>
  25. <view class="list_2">
  26. <view class="name">{{item.name||'暂无活动名称'}}</view>
  27. <view class="score">
  28. <view class="red">
  29. <view class="red_name">{{item.red_name||'暂无红方名称'}}</view>
  30. <view class="red_image">
  31. <image class="image" mode="aspectFill"
  32. :src="item.red_logo||config.logoUrl"></image>
  33. </view>
  34. <view class="red_score">{{item.red_score||0}}</view>
  35. </view>
  36. <view class="center">:</view>
  37. <view class="blue">
  38. <view class="blue_score">{{item.blue_score||0}}</view>
  39. <view class="blue_image">
  40. <image class="image" mode="aspectFill"
  41. :src="item.blue_logo||config.logoUrl"></image>
  42. </view>
  43. <view class="blue_name">{{item.blue_name||'暂无蓝方名称'}}</view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="is_bottom" v-if="is_bottom">
  51. <text>{{config.bottomTitle||'到底了!'}}</text>
  52. </view>
  53. </view>
  54. </scroll-view>
  55. </view>
  56. </view>
  57. </template>
  58. <script setup lang="ts">
  59. import { ref } from 'vue';
  60. //该依赖已内置不需要单独安装
  61. import { onShow } from "@dcloudio/uni-app";
  62. interface PropsItem {
  63. id ?: number,
  64. name ?: string,
  65. date ?: string,
  66. red_name ?: string,
  67. red_score ?: number,
  68. red_logo ?: string,
  69. blue_name ?: string,
  70. blue_score ?: number,
  71. blue_logo ?: string,
  72. status ?: string,
  73. status_name ?: string,
  74. };
  75. // 基本信息
  76. const config = ref({ bottomTitle: '', logoUrl: '' });
  77. // 查询
  78. const searchInfo = ref({ name: '' });
  79. // 列表
  80. const list = ref<PropsItem[]>([{ id: 1, name: '测试球队' }, { id: 1, name: '肝帝集团队' }]);
  81. // 分页
  82. const skip = ref(0);
  83. const limit = ref(6);
  84. const page = ref(0);
  85. const total = ref(0);
  86. // 数据是否触底
  87. const scrollTop = ref(0);
  88. const is_bottom = ref(false);
  89. onShow(() => {
  90. searchConfig();
  91. search();
  92. })
  93. // config信息
  94. const searchConfig = async () => {
  95. config.value = uni.getStorageSync('config');
  96. };
  97. // 查询列表
  98. const search = async () => {
  99. console.log('查询');
  100. };
  101. //查询
  102. const toInput = (e : any) => {
  103. if (searchInfo.value.name) searchInfo.value.name = e.detail.value
  104. searchInfo.value = { name: '' }
  105. clearPage();
  106. search();
  107. };
  108. // 活动详情
  109. const toInfo = (item : any) => {
  110. uni.navigateTo({
  111. url: `/pagesHome/activity/info?id=${item._id || item.id}&name=${item.name}`,
  112. })
  113. };
  114. // 分页
  115. const toPage = () => {
  116. if (total.value > list.value.length) {
  117. uni.showLoading({
  118. title: '加载中',
  119. mask: true
  120. })
  121. page.value = page.value + 1
  122. skip.value = page.value * limit.value;
  123. search();
  124. uni.hideLoading();
  125. } else is_bottom.value = true
  126. };
  127. const toScroll = (e : any) => {
  128. let up = scrollTop.value;
  129. scrollTop.value = e.detail.scrollTop
  130. let num = Math.sign(up - e.detail.scrollTop);
  131. if (num == 1) is_bottom.value = false
  132. };
  133. // 清空数据
  134. const clearPage = () => {
  135. list.value = []
  136. skip.value = 0
  137. limit.value = 6
  138. page.value = 0
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .main {
  143. display: flex;
  144. flex-direction: column;
  145. width: 100vw;
  146. height: 66vh;
  147. .first {
  148. display: flex;
  149. justify-content: center;
  150. align-items: center;
  151. padding: 2vw;
  152. border-bottom: 1px solid var(--f5Color);
  153. input {
  154. width: 100%;
  155. padding: 2vw;
  156. background-color: var(--f1Color);
  157. font-size: var(--font14Size);
  158. border-radius: 5px;
  159. }
  160. }
  161. .second {
  162. position: relative;
  163. flex-grow: 1;
  164. .other {
  165. display: flex;
  166. .other_1 {
  167. padding: 2vw 2vw 2vw 5vw;
  168. font-size: 20px;
  169. font-weight: bold;
  170. .line {
  171. height: 18vh;
  172. margin: 0 0 0 2px;
  173. border-left: 1px dashed var(--f99Color);
  174. }
  175. }
  176. .other_2 {
  177. width: 90%;
  178. .list {
  179. .list_1 {
  180. display: flex;
  181. align-items: center;
  182. padding: 4vw 2vw 2vw 2vw;
  183. .date {
  184. font-size: var(--font16Size);
  185. font-weight: bold;
  186. }
  187. .status {
  188. font-size: var(--font12Size);
  189. margin: 0 1vw;
  190. padding: 1px 5px;
  191. }
  192. .status0 {
  193. color: var(--mainColor);
  194. background-color: var(--fF0Color);
  195. }
  196. .status1 {
  197. color: var(--mainColor);
  198. background-color: var(--fFFColor);
  199. }
  200. .status2 {
  201. color: var(--f99Color);
  202. background-color: var(--f9Color);
  203. }
  204. }
  205. .list_2 {
  206. border: 1px solid var(--f5Color);
  207. padding: 2vw;
  208. border-radius: 2px;
  209. .name {
  210. font-size: var(--font16Size);
  211. font-weight: bold;
  212. margin: 2vw;
  213. }
  214. .score {
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. font-size: var(--font14Size);
  219. background-color: var(--f9Color);
  220. border-radius: 5vw;
  221. padding: 1vw 0;
  222. .red {
  223. display: flex;
  224. align-items: center;
  225. margin: 0 1vw 0 0;
  226. .red_image {
  227. margin: 0 1vw;
  228. .image {
  229. width: 8vw;
  230. height: 8vw;
  231. border-radius: 8vw;
  232. }
  233. }
  234. .red_score {
  235. font-size: var(--font16Size);
  236. color: var(--fF0Color);
  237. }
  238. }
  239. .center {
  240. font-size: var(--font16Size);
  241. color: var(--fF0Color);
  242. }
  243. .blue {
  244. display: flex;
  245. align-items: center;
  246. margin: 0 0 0 1vw;
  247. .blue_image {
  248. margin: 0 1vw;
  249. .image {
  250. width: 8vw;
  251. height: 8vw;
  252. border-radius: 8vw;
  253. }
  254. }
  255. .blue_score {
  256. font-size: var(--font16Size);
  257. color: var(--fF0Color);
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. .scroll-view {
  268. position: absolute;
  269. top: 0;
  270. left: 0;
  271. right: 0;
  272. bottom: 0;
  273. .list-scroll-view {
  274. display: flex;
  275. flex-direction: column;
  276. }
  277. }
  278. .is_bottom {
  279. width: 100%;
  280. text-align: center;
  281. text {
  282. padding: 2vw 0;
  283. display: inline-block;
  284. color: var(--f85Color);
  285. font-size: var(--font14Size);
  286. }
  287. }
  288. </style>