details.vue 9.3 KB

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