details.vue 11 KB

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