details.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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. if (options.title) {
  143. uni.setNavigationBarTitle({ title: decodeURIComponent(options.title) });
  144. }
  145. })
  146. // 分页
  147. const pages = ref({
  148. current: 1,
  149. pageSize: 10,
  150. total: 0
  151. })
  152. const loadmoreInfo = ref({
  153. status: 'loadmore',
  154. loadingText: '努力加载中...',
  155. loadmoreText: '点击加载更多~',
  156. nomoreText: '已经到底啦~'
  157. })
  158. // 加载更多
  159. async function handleLoadmore(e) {
  160. if (pages.value.current < Math.ceil(pages.value.total / pages.value.pageSize)) {
  161. pages.value.current += 1;
  162. loadmoreInfo.value.status = 'loading';
  163. await getList();
  164. } else {
  165. loadmoreInfo.value.status = 'nomore';
  166. }
  167. }
  168. // const getListAdderss = async () => {
  169. // const res = await volunteerDataList()
  170. // console.log(res, 'volunteerDataList>>>>>>>>>>')
  171. // }
  172. const getList = async () => {
  173. try {
  174. loadmoreInfo.value.status = 'loading';
  175. // 检查 businessManagementId 是否存在
  176. if (!businessManagementId.value) {
  177. console.log('No businessManagementId selected');
  178. return;
  179. }
  180. // 请求时传递分页参数
  181. const res = await volunteerinfolist({
  182. pageNum: pages.value.current, // 当前页码
  183. pageSize: pages.value.pageSize, // 每页大小
  184. businessManagementId: businessManagementId.value
  185. });
  186. if (!res || !res.rows) {
  187. return;
  188. }
  189. // 如果是第一页,先清空
  190. if (pages.value.current === 1) {
  191. leftList.value = [];
  192. rightList.value = [];
  193. }
  194. // 将数据分成左右两列
  195. res.rows.forEach((item, index) => {
  196. index % 2 !== 0 ? rightList.value.push(item) : leftList.value.push(item);
  197. });
  198. pages.value.total = res.total;
  199. // 判断是否已经到了最后一页
  200. if (pages.value.current >= Math.ceil(res.total / pages.value.pageSize)) {
  201. loadmoreInfo.value.status = 'nomore';
  202. } else {
  203. loadmoreInfo.value.status = 'loadmore';
  204. }
  205. } catch (error) {
  206. clearList();
  207. console.error('Error fetching data:', error);
  208. }
  209. };
  210. const clearList = () => {
  211. leftList.value = [];
  212. rightList.value = [];
  213. loadmoreInfo.value.status = 'loadmore';
  214. pages.value.total = 0;
  215. }
  216. onReachBottom(() => {
  217. if (pages.value.current < Math.ceil(pages.value.total / pages.value.pageSize)) {
  218. pages.value.current += 1;
  219. loadmoreInfo.value.status = 'loading';
  220. getList();
  221. }
  222. })
  223. onMounted(() => {
  224. // 如果有默认选中的 tab,则初始化数据
  225. if (list1.value.length > 0) {
  226. const defaultTab = list1.value[0];
  227. businessManagementId.value = defaultTab.id;
  228. getList();
  229. }
  230. })
  231. </script>
  232. <style scoped>
  233. .main-content {
  234. width: 100%;
  235. height: 100vh;
  236. background: #fff;
  237. }
  238. .content-box {
  239. width: 100%;
  240. height: 100%;
  241. padding-bottom: 40rpx;
  242. }
  243. .Wrapper {
  244. display: flex;
  245. align-items: center;
  246. gap: 10rpx;
  247. }
  248. .Wrapper-img {
  249. width: 50rpx;
  250. height: 50rpx;
  251. margin-left: 10rpx;
  252. }
  253. .Wrapper-content {
  254. color: rgba(16, 16, 16, 1);
  255. font-size: 25rpx;
  256. font-family: PingFangSC-regular;
  257. line-height: 20rpx;
  258. }
  259. /* 外层容器 */
  260. .tabs-container {
  261. width: 100%;
  262. background: #fff;
  263. padding: 10px 0;
  264. }
  265. /* Flex 布局容器 */
  266. .tabs-wrapper {
  267. display: flex;
  268. align-items: center;
  269. position: relative;
  270. }
  271. /* 可横向滚动的 scroll-view */
  272. .tabs-scroll {
  273. flex: 1;
  274. /* 占据剩余空间 */
  275. overflow-x: auto;
  276. /* 允许横向滚动 */
  277. white-space: nowrap;
  278. /* 禁止换行 */
  279. -webkit-overflow-scrolling: touch;
  280. /* iOS 平滑滚动 */
  281. }
  282. /* 隐藏滚动条(可选) */
  283. .tabs-scroll::-webkit-scrollbar {
  284. display: none;
  285. }
  286. /* 固定图标(始终显示在右侧) */
  287. .fixed-icon {
  288. width: 30px;
  289. height: 30px;
  290. margin-left: 10px;
  291. /* 与 tabs 的间距 */
  292. flex-shrink: 0;
  293. /* 禁止压缩 */
  294. }
  295. .demo-warter {
  296. border-radius: 16rpx;
  297. margin: 10rpx;
  298. background-color: #ffffff;
  299. padding: 10rpx;
  300. }
  301. .u-close {
  302. position: absolute;
  303. top: 32rpx;
  304. right: 32rpx;
  305. }
  306. .demo-image {
  307. width: 100%;
  308. border-radius: 8rpx;
  309. }
  310. .demo-title {
  311. font-size: 25rpx;
  312. margin-top: 8rpx;
  313. color: #999;
  314. display: -webkit-box;
  315. -webkit-box-orient: vertical;
  316. -webkit-line-clamp: 2;
  317. overflow: hidden;
  318. text-overflow: ellipsis;
  319. word-break: break-word;
  320. }
  321. .demo-skillDescribe {
  322. font-size: 30rpx;
  323. margin-top: 8rpx;
  324. color: #333;
  325. display: -webkit-box;
  326. -webkit-box-orient: vertical;
  327. -webkit-line-clamp: 2;
  328. overflow: hidden;
  329. text-overflow: ellipsis;
  330. word-break: break-word;
  331. }
  332. .demo-img {
  333. width: 60rpx;
  334. height: 60rpx;
  335. border-radius: 50%;
  336. }
  337. .demo-PriceDome {
  338. display: flex;
  339. justify-content: space-between;
  340. align-items: center;
  341. width: 100%;
  342. margin-top: 20rpx;
  343. }
  344. .demo-price {
  345. display: flex;
  346. align-items: center;
  347. flex: 1;
  348. overflow: hidden;
  349. }
  350. .name-image {
  351. width: 50rpx;
  352. height: 50rpx;
  353. margin-right: 12rpx;
  354. border-radius: 50%;
  355. }
  356. .name-text {
  357. white-space: nowrap;
  358. overflow: hidden;
  359. text-overflow: ellipsis;
  360. max-width: 150rpx;
  361. color: #444;
  362. }
  363. .demo-warter {
  364. border-radius: 16rpx;
  365. margin: 10rpx;
  366. background-color: #ffffff;
  367. padding: 10rpx;
  368. }
  369. .u-close {
  370. position: absolute;
  371. top: 32rpx;
  372. right: 32rpx;
  373. }
  374. .demo-image {
  375. width: 100%;
  376. border-radius: 8rpx;
  377. }
  378. .demo-title {
  379. font-size: 25rpx;
  380. margin-top: 8rpx;
  381. color: #999;
  382. display: -webkit-box;
  383. -webkit-box-orient: vertical;
  384. -webkit-line-clamp: 2;
  385. overflow: hidden;
  386. text-overflow: ellipsis;
  387. word-break: break-word;
  388. }
  389. .demo-skillDescribe {
  390. font-size: 30rpx;
  391. margin-top: 8rpx;
  392. color: #333;
  393. display: -webkit-box;
  394. -webkit-box-orient: vertical;
  395. -webkit-line-clamp: 2;
  396. overflow: hidden;
  397. text-overflow: ellipsis;
  398. word-break: break-word;
  399. }
  400. .demo-img {
  401. width: 60rpx;
  402. height: 60rpx;
  403. border-radius: 50%;
  404. }
  405. .demo-PriceDome {
  406. display: flex;
  407. justify-content: space-between;
  408. align-items: center;
  409. width: 100%;
  410. margin-top: 20rpx;
  411. }
  412. .demo-price {
  413. display: flex;
  414. align-items: center;
  415. flex: 1;
  416. overflow: hidden;
  417. }
  418. .name-image {
  419. width: 50rpx;
  420. height: 50rpx;
  421. margin-right: 12rpx;
  422. border-radius: 50%;
  423. }
  424. .name-text {
  425. white-space: nowrap;
  426. overflow: hidden;
  427. text-overflow: ellipsis;
  428. max-width: 150rpx;
  429. color: #444;
  430. }
  431. </style>