details.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view style="padding-top: 20rpx; width: 100vw; height: 100vh; overflow: hidden">
  3. <view style="width: 100%; height: 100%; overflow:scroll">
  4. <view class="Wrapper">
  5. <image src="/static/img/Location.png" class="Wrapper-img" />
  6. <span class="Wrapper-content">重庆</span>
  7. <vie class="input-container">
  8. <up-input v-model="value" @click.native="goToDetail" placeholder="请输入内容" prefixIcon="search"
  9. :customStyle="inputStyle"></up-input>
  10. </vie>
  11. </view>
  12. <view class="tabs-container">
  13. <view class="tabs-wrapper">
  14. <!-- 可滑动的 tabs 区域 -->
  15. <scroll-view scroll-x class="tabs-scroll">
  16. <up-tabs :list="list1" @change="handlTabs" keyName="businessName"
  17. class="tabs-content"></up-tabs>
  18. </scroll-view>
  19. <!-- 固定不动的图标 -->
  20. <image ref="iconRef" src="/static/img/分类or广场or其他.png" class="fixed-icon" @click="toggleDropdown" />
  21. </view>
  22. <view v-if="showDropdown" class="custom-dropdown">
  23. <up-tabs :list="list2" @change="clickList2" class="tabs-content" :current="currentTabs2"
  24. keyName="businessName" />
  25. <!-- <up-tabs :list="list3" @click="click" class="tabs-content" keyName="businessName" /> -->
  26. </view>
  27. </view>
  28. <!-- 瀑布流 -->
  29. <view v-if="userType == '1'">
  30. <up-waterfall v-model="flowList">
  31. <template #left>
  32. <view class="demo-warter" v-for="(item, index) in leftList" :key="index"
  33. @click="goToDetail(item)">
  34. <up-lazy-load threshold="-450" border-radius="10" :image="item.volunteerPicture"
  35. :index="index"></up-lazy-load>
  36. <view class="demo-title">
  37. {{item.businessTierName}}
  38. </view>
  39. <view class="demo-skillDescribe">
  40. {{item.skillDescribe}}
  41. </view>
  42. <view class="demo-PriceDome">
  43. <view class="demo-price">
  44. <image :src="item.volunteerPicture" class="name-image"></image>
  45. {{item.name}}
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <template #right>
  51. <view class="demo-warter" v-for="(item, index) in rightList" :key="index"
  52. @click="goToDetail(item)">
  53. <up-lazy-load threshold="-450" border-radius="10" :image="item.volunteerPicture"
  54. :index="index"></up-lazy-load>
  55. <view class="demo-title">
  56. {{item.businessTierName}}
  57. </view>
  58. <view class="demo-skillDescribe">
  59. {{item.skillDescribe}}
  60. </view>
  61. <view class="demo-PriceDome">
  62. <view class="demo-price">
  63. <image :src="item.volunteerPicture" class="name-image"></image>
  64. {{item.name}}
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. </up-waterfall>
  70. </view>
  71. <up-loadmore style="margin-top: 40rpx;" :status="loadmoreInfo.status"
  72. :loadmoreText="loadmoreInfo.loadingText" :loadingText="loadmoreInfo.loadmoreText"
  73. :nomoreText="loadmoreInfo.nomoreText" @loadmore="handleLoadmore" v-if="userType == 1" />
  74. </view>
  75. </view>
  76. </template>
  77. <script setup>
  78. import {
  79. ref,
  80. onMounted,
  81. reactive,
  82. nextTick
  83. } from 'vue';
  84. import {
  85. onLoad,
  86. onShow,
  87. onReachBottom
  88. } from "@dcloudio/uni-app";
  89. import {
  90. typeOptionSelect,
  91. volunteerInfoList,
  92. getDetailsvolunteerId,
  93. dictListlrRstudy,
  94. dictListlrData,
  95. volunteerSeachgetTreeList,
  96. volunteerinfolist
  97. } from "@/api/volunteerDetailsApi/details.js"
  98. const value1 = ref(1)
  99. const value2 = ref(2)
  100. const list1 = ref([])
  101. const list2 = ref([])
  102. const flowList = ref([]); //list数据
  103. const listData = ref([])
  104. const rightList = ref([])
  105. const currentTabs2 = ref(0)
  106. const total = ref(0)
  107. const serviceCategory = ref('')
  108. const leftList = ref([])
  109. const showDropdown = ref(false)
  110. const defaultTab = ref({
  111. dictValue: 1
  112. });
  113. const userType = uni.getStorageSync('userType') //读取本地存储
  114. // 用户/志愿者 识别标识
  115. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  116. function handlTabs(item, index) {
  117. currentTabs2.value = 0
  118. list2.value = item.children
  119. }
  120. function clickList2(item, index) {
  121. currentTabs2.value = index
  122. }
  123. function toggleDropdown() {
  124. showDropdown.value = !showDropdown.value
  125. }
  126. const goToDetail = async (item) => {
  127. const params = {
  128. volunteerId: item.volunteerId, // 获取 volunteerId
  129. serviceCategory: item.serviceCategory, // 获取 serviceCategory
  130. businessManagementId: item.businessManagementId, //获取 businessManagementId
  131. };
  132. uni.navigateTo({
  133. url: `/pages_home/pages/Volunteerside/goodsDetails?params=${JSON.stringify(params)}`
  134. });
  135. }
  136. const inputStyle = { //input輸入框樣式設置
  137. borderRadius: '140rpx',
  138. border: '1rpx solid #ccc',
  139. height: '70rpx',
  140. paddingLeft: '30rpx',
  141. width: '600rpx',
  142. }
  143. onLoad((options) => {
  144. const dataList = JSON.parse(decodeURIComponent(options.dataList));
  145. serviceCategory.value = options.serviceCategory
  146. list1.value = dataList
  147. list2.value = dataList[0].children
  148. })
  149. // 分页
  150. const pages = ref({
  151. current: 1,
  152. pageSize: 10,
  153. total: 0
  154. })
  155. const loadmoreInfo = ref({
  156. status: 'loadmore',
  157. loadingText: '努力加载中...',
  158. loadmoreText: '点击加载更多~',
  159. nomoreText: '已经到底啦~'
  160. })
  161. // 加载更多
  162. async function handleLoadmore(e) {
  163. if (pages.value.current < Math.ceil(pages.value.total / pages.value.pageSize)) {
  164. pages.value.current += 1;
  165. loadmoreInfo.value.status = 'loading';
  166. await getList();
  167. } else {
  168. loadmoreInfo.value.status = 'nomore';
  169. }
  170. }
  171. // const getListAdderss = async () => {
  172. // const res = await volunteerDataList()
  173. // console.log(res, 'volunteerDataList>>>>>>>>>>')
  174. // }
  175. const getList = async () => {
  176. try {
  177. loadmoreInfo.value.status = 'loading';
  178. // 请求时传递分页参数
  179. const res = await volunteerinfolist({
  180. pageNum: pages.value.current, // 当前页码
  181. pageSize: pages.value.pageSize, // 每页大小
  182. serviceCategory: serviceCategory.value
  183. });
  184. console.log(res, '>>>>>>>res');
  185. if (!res || !res.rows) {
  186. return;
  187. }
  188. // 判断是否已经到了最后一页
  189. if (pages.value.current >= Math.ceil(res.total / pages.value.pageSize)) {
  190. loadmoreInfo.value.status = 'nomore';
  191. } else {
  192. loadmoreInfo.value.status = 'loadmore';
  193. }
  194. // 将数据分成左右两列
  195. res.rows.forEach((item, index) => {
  196. index % 2 !== 0 ? leftList.value.push(item) : rightList.value.push(item);
  197. });
  198. pages.value.total = res.total;
  199. } catch (error) {
  200. leftList.value = [];
  201. rightList.value = [];
  202. loadmoreInfo.value.status = 'loadmore';
  203. pages.value.total = 0;
  204. console.error('Error fetching data:', error);
  205. }
  206. };
  207. onReachBottom(() => {
  208. if (loadmoreInfo.value.status !== 'nomore') { // 更宽松的条件
  209. loadmoreInfo.value.status = 'loading';
  210. pages.value.current += 1;
  211. getList();
  212. }
  213. })
  214. onMounted(() => {
  215. getList()
  216. })
  217. </script>
  218. <style scoped>
  219. .Wrapper {
  220. display: flex;
  221. align-items: center;
  222. gap: 10rpx;
  223. }
  224. .Wrapper-img {
  225. width: 50rpx;
  226. height: 50rpx;
  227. margin-left: 10rpx;
  228. }
  229. .Wrapper-content {
  230. color: rgba(16, 16, 16, 1);
  231. font-size: 25rpx;
  232. font-family: PingFangSC-regular;
  233. line-height: 20rpx;
  234. }
  235. /* 外层容器 */
  236. .tabs-container {
  237. width: 100%;
  238. background: #fff;
  239. padding: 10px 0;
  240. }
  241. /* Flex 布局容器 */
  242. .tabs-wrapper {
  243. display: flex;
  244. align-items: center;
  245. position: relative;
  246. }
  247. /* 可横向滚动的 scroll-view */
  248. .tabs-scroll {
  249. flex: 1;
  250. /* 占据剩余空间 */
  251. overflow-x: auto;
  252. /* 允许横向滚动 */
  253. white-space: nowrap;
  254. /* 禁止换行 */
  255. -webkit-overflow-scrolling: touch;
  256. /* iOS 平滑滚动 */
  257. }
  258. /* 隐藏滚动条(可选) */
  259. .tabs-scroll::-webkit-scrollbar {
  260. display: none;
  261. }
  262. /* 固定图标(始终显示在右侧) */
  263. .fixed-icon {
  264. width: 30px;
  265. height: 30px;
  266. margin-left: 10px;
  267. /* 与 tabs 的间距 */
  268. flex-shrink: 0;
  269. /* 禁止压缩 */
  270. }
  271. .demo-warter {
  272. border-radius: 8px;
  273. margin: 5px;
  274. background-color: #ffffff;
  275. padding: 5px;
  276. }
  277. .u-close {
  278. position: absolute;
  279. top: 32rpx;
  280. right: 32rpx;
  281. }
  282. .demo-image {
  283. width: 100%;
  284. border-radius: 4px;
  285. }
  286. .demo-title {
  287. font-size: 25rpx;
  288. margin-top: 5px;
  289. color: #ccc;
  290. /* margin-left: 15rpx; */
  291. display: -webkit-box;
  292. -webkit-box-orient: vertical;
  293. -webkit-line-clamp: 3;
  294. overflow: hidden;
  295. text-overflow: ellipsis;
  296. word-break: break-all;
  297. }
  298. .demo-skillDescribe {
  299. font-size: 30rpx;
  300. margin-top: 5px;
  301. color: black;
  302. /* margin-left: 15rpx; */
  303. display: -webkit-box;
  304. -webkit-box-orient: vertical;
  305. -webkit-line-clamp: 3;
  306. overflow: hidden;
  307. text-overflow: ellipsis;
  308. word-break: break-all;
  309. }
  310. .demo-img {
  311. width: 40rpx;
  312. height: 40rpx;
  313. border-radius: 50%;
  314. }
  315. .demo-PriceDome {
  316. display: flex;
  317. justify-content: space-between;
  318. align-items: center;
  319. width: 100%;
  320. margin-top: 15rpx;
  321. }
  322. .demo-price {
  323. display: flex;
  324. align-items: center;
  325. flex: 1;
  326. overflow: hidden;
  327. /* 防止内容溢出 */
  328. }
  329. .name-image {
  330. width: 40rpx;
  331. height: 40rpx;
  332. margin-right: 10rpx;
  333. border-radius: 50%;
  334. }
  335. .name-text {
  336. white-space: nowrap;
  337. /* 禁止换行 */
  338. overflow: hidden;
  339. /* 超出部分隐藏 */
  340. text-overflow: ellipsis;
  341. /* 显示省略号 */
  342. max-width: 120rpx;
  343. /* 6个中文字符大约占120rpx */
  344. }
  345. </style>