details.vue 10 KB

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