activity.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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, toRefs, getCurrentInstance } from 'vue';
  60. //该依赖已内置不需要单独安装
  61. import { onShow } from "@dcloudio/uni-app";
  62. // 请求接口
  63. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  64. interface PropsItem {
  65. id ?: number,
  66. name ?: string,
  67. date ?: string,
  68. red_name ?: string,
  69. red_score ?: number,
  70. red_logo ?: string,
  71. blue_name ?: string,
  72. blue_score ?: number,
  73. blue_logo ?: string,
  74. status ?: string,
  75. status_name ?: string,
  76. };
  77. // 用户信息
  78. const user = ref({});
  79. // 查询
  80. const searchInfo = ref({ });
  81. // 列表
  82. const list = ref<PropsItem[]>([{ id: 1, name: '测试球队' }, { id: 1, name: '肝帝集团队' }]);
  83. // 分页
  84. const pageNum = ref(1);
  85. const pageSize = ref(10);
  86. const total = ref(0);
  87. // 数据是否触底
  88. const scrollTop = ref(0);
  89. const is_bottom = ref(false);
  90. const props = defineProps({
  91. config: { type: Object, default: () => { } },
  92. });
  93. const { config } = toRefs(props);
  94. onShow(async () => {
  95. await searchUser();
  96. await search();
  97. })
  98. // 用户信息
  99. const searchUser = async () => {
  100. user.value = uni.getStorageSync('user');
  101. };
  102. // 查询列表
  103. const search = async () => {
  104. // const info = {
  105. // pageNum: pageNum.value,
  106. // pageSize: pageSize.value,
  107. // userId: user.value.id
  108. // }
  109. // const res = await $api('activity/list', 'GET', {
  110. // ...info,
  111. // ...searchInfo.value
  112. // });
  113. // if (res.code === 200) {
  114. // list.value = res.rows
  115. // total.value = res.total
  116. // } else {
  117. // uni.showToast({
  118. // title: res.msg || '',
  119. // icon: 'error',
  120. // });
  121. // }
  122. };
  123. //查询
  124. const toInput = (e : any) => {
  125. if (searchInfo.value.name) searchInfo.value.name = e.detail.value
  126. searchInfo.value = { }
  127. clearPage();
  128. search();
  129. };
  130. // 活动详情
  131. const toInfo = (item : any) => {
  132. uni.navigateTo({
  133. url: `/pagesHome/activity/info?id=${item._id || item.id}&name=${item.name}`,
  134. })
  135. };
  136. // 分页
  137. const toPage = () => {
  138. if (total.value > list.value.length) {
  139. uni.showLoading({
  140. title: '加载中',
  141. mask: true
  142. })
  143. pageNum.value = pageNum.value + 1
  144. pageSize.value = pageNum.value * 10;
  145. search();
  146. uni.hideLoading();
  147. } else is_bottom.value = true
  148. };
  149. const toScroll = (e : any) => {
  150. let up = scrollTop.value;
  151. scrollTop.value = e.detail.scrollTop
  152. let num = Math.sign(up - e.detail.scrollTop);
  153. if (num == 1) is_bottom.value = false
  154. };
  155. // 清空数据
  156. const clearPage = () => {
  157. list.value = []
  158. pageNum.value = 1
  159. pageSize.value = 10
  160. };
  161. </script>
  162. <style lang="scss" scoped>
  163. .main {
  164. display: flex;
  165. flex-direction: column;
  166. width: 100vw;
  167. height: 66vh;
  168. .first {
  169. display: flex;
  170. justify-content: center;
  171. align-items: center;
  172. padding: 2vw;
  173. border-bottom: 1px solid var(--f5Color);
  174. input {
  175. width: 100%;
  176. padding: 2vw;
  177. background-color: var(--f1Color);
  178. font-size: var(--font14Size);
  179. border-radius: 5px;
  180. }
  181. }
  182. .second {
  183. position: relative;
  184. flex-grow: 1;
  185. .other {
  186. display: flex;
  187. .other_1 {
  188. padding: 2vw 2vw 2vw 5vw;
  189. font-size: 20px;
  190. font-weight: bold;
  191. .line {
  192. height: 18vh;
  193. margin: 0 0 0 2px;
  194. border-left: 1px dashed var(--f99Color);
  195. }
  196. }
  197. .other_2 {
  198. width: 90%;
  199. .list {
  200. .list_1 {
  201. display: flex;
  202. align-items: center;
  203. padding: 4vw 2vw 2vw 2vw;
  204. .date {
  205. font-size: var(--font16Size);
  206. font-weight: bold;
  207. }
  208. .status {
  209. font-size: var(--font12Size);
  210. margin: 0 1vw;
  211. padding: 1px 5px;
  212. }
  213. .status0 {
  214. color: var(--mainColor);
  215. background-color: var(--fF0Color);
  216. }
  217. .status1 {
  218. color: var(--mainColor);
  219. background-color: var(--fFFColor);
  220. }
  221. .status2 {
  222. color: var(--f99Color);
  223. background-color: var(--f9Color);
  224. }
  225. }
  226. .list_2 {
  227. border: 1px solid var(--f5Color);
  228. padding: 2vw;
  229. border-radius: 2px;
  230. .name {
  231. font-size: var(--font16Size);
  232. font-weight: bold;
  233. margin: 2vw;
  234. }
  235. .score {
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. font-size: var(--font14Size);
  240. background-color: var(--f9Color);
  241. border-radius: 5vw;
  242. padding: 1vw 0;
  243. .red {
  244. display: flex;
  245. align-items: center;
  246. margin: 0 1vw 0 0;
  247. .red_image {
  248. margin: 0 1vw;
  249. .image {
  250. width: 8vw;
  251. height: 8vw;
  252. border-radius: 8vw;
  253. }
  254. }
  255. .red_score {
  256. font-size: var(--font16Size);
  257. color: var(--fF0Color);
  258. }
  259. }
  260. .center {
  261. font-size: var(--font16Size);
  262. color: var(--fF0Color);
  263. }
  264. .blue {
  265. display: flex;
  266. align-items: center;
  267. margin: 0 0 0 1vw;
  268. .blue_image {
  269. margin: 0 1vw;
  270. .image {
  271. width: 8vw;
  272. height: 8vw;
  273. border-radius: 8vw;
  274. }
  275. }
  276. .blue_score {
  277. font-size: var(--font16Size);
  278. color: var(--fF0Color);
  279. }
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. .scroll-view {
  289. position: absolute;
  290. top: 0;
  291. left: 0;
  292. right: 0;
  293. bottom: 0;
  294. .list-scroll-view {
  295. display: flex;
  296. flex-direction: column;
  297. }
  298. }
  299. .is_bottom {
  300. width: 100%;
  301. text-align: center;
  302. text {
  303. padding: 2vw 0;
  304. display: inline-block;
  305. color: var(--f85Color);
  306. font-size: var(--font14Size);
  307. }
  308. }
  309. </style>