|
|
@@ -1,5 +1,14 @@ |
|
|
|
<template> |
|
|
|
<div class="page"> |
|
|
|
<!-- 性别tab --> |
|
|
|
<view class="sexTab"> |
|
|
|
<view @click="sex = 1" class="sex" :class="sex == 1 ? 'sexActive' : ''" |
|
|
|
>男</view |
|
|
|
> |
|
|
|
<view @click="sex = 2" class="sex" :class="sex == 2 ? 'sexActive' : ''" |
|
|
|
>女</view |
|
|
|
> |
|
|
|
</view> |
|
|
|
<u-list |
|
|
|
class="styleListBox" |
|
|
|
@scrolltolower="scrolltolower" |
|
|
@@ -25,7 +34,7 @@ |
|
|
|
<script setup> |
|
|
|
//#region 导入 |
|
|
|
import { onPullDownRefresh } from "@dcloudio/uni-app"; |
|
|
|
import { ref, reactive } from "vue"; |
|
|
|
import { ref, reactive, watch } from "vue"; |
|
|
|
import { getListApi } from "../../api/closeStyle"; |
|
|
|
//#endregion |
|
|
|
|
|
|
@@ -47,19 +56,35 @@ import { getListApi } from "../../api/closeStyle"; |
|
|
|
//#region 列表加载 |
|
|
|
const pageNum = ref(1); |
|
|
|
const pageSize = ref(20); |
|
|
|
const sex = ref(1); //1男2女 |
|
|
|
const styleList = ref([]); |
|
|
|
// 得到列表 |
|
|
|
async function getList() { |
|
|
|
try { |
|
|
|
const res = await getListApi(pageNum.value, pageSize.value); |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中...", |
|
|
|
mask: true, |
|
|
|
}); |
|
|
|
const res = await getListApi(pageNum.value, pageSize.value, sex.value); |
|
|
|
styleList.value = res.data.list; |
|
|
|
uni.hideLoading(); |
|
|
|
} catch (error) { |
|
|
|
uni.hideLoading(); |
|
|
|
uni.showToast({ |
|
|
|
title: "获取列表失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
// 监听性别tab变化 |
|
|
|
watch( |
|
|
|
() => sex.value, |
|
|
|
(sex) => { |
|
|
|
pageNum.value = 1; |
|
|
|
pageSize.value = 20; |
|
|
|
getList(); |
|
|
|
} |
|
|
|
); |
|
|
|
getList(); |
|
|
|
// 触底加载更多 |
|
|
|
const scrolltolower = async () => { |
|
|
@@ -67,10 +92,9 @@ const scrolltolower = async () => { |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中...", |
|
|
|
mask: true, |
|
|
|
duration: 2000, |
|
|
|
}); |
|
|
|
pageNum.value += 1; |
|
|
|
const res = await getListApi(pageNum.value, pageSize.value); |
|
|
|
const res = await getListApi(pageNum.value, pageSize.value, sex.value); |
|
|
|
styleList.value.push(...res.data.list); |
|
|
|
setTimeout(function () { |
|
|
|
uni.hideLoading(); |
|
|
@@ -125,7 +149,29 @@ function createPhoto(item) { |
|
|
|
.page { |
|
|
|
background-color: #222527; |
|
|
|
} |
|
|
|
.sexTab { |
|
|
|
margin: 20rpx 0; |
|
|
|
width: 100%; |
|
|
|
height: 60rpx; |
|
|
|
display: flex; |
|
|
|
justify-content: space-evenly; |
|
|
|
line-height: 54rpx; |
|
|
|
text-align: center; |
|
|
|
.sex { |
|
|
|
border-radius: 20rpx; |
|
|
|
border: 2rpx solid #ccc; |
|
|
|
width: 40%; |
|
|
|
} |
|
|
|
.sexActive { |
|
|
|
color: #ff4f00; |
|
|
|
border: 2rpx solid #ff4f00; |
|
|
|
transition: all 0.3s; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.u-list { |
|
|
|
overflow: hidden; |
|
|
|
height: calc(100vh - 200rpx) !important; |
|
|
|
width: 650rpx; |
|
|
|
.glodYBox { |
|
|
|
display: flex !important; |
|
|
|