details.vue 11 KB

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