details.vue 9.5 KB

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