details.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. <!-- 可滑动的 tabs 区域 -->
  15. <scroll-view scroll-x class="tabs-scroll">
  16. <up-tabs :list="list1" @change="handlTabs" keyName="businessName"
  17. class="tabs-content"></up-tabs>
  18. </scroll-view>
  19. <!-- 固定不动的图标 -->
  20. <image ref="iconRef" src="/static/img/分类or广场or其他.png" class="fixed-icon" @click="toggleDropdown" />
  21. </view>
  22. <view v-if="showDropdown" class="custom-dropdown">
  23. <up-tabs :list="list2" @change="clickList2" class="tabs-content" :current="currentTabs2"
  24. keyName="businessName" />
  25. <!-- <up-tabs :list="list3" @click="click" class="tabs-content" keyName="businessName" /> -->
  26. </view>
  27. </view>
  28. <!-- 瀑布流 -->
  29. <view v-if="userType == '1'">
  30. <up-waterfall v-model="flowList">
  31. <template #left :listData="listData">
  32. <view class="demo-warter" v-for="(item, index) in listData" :key="index"
  33. @click="goToDetail(item)">
  34. <up-lazy-load threshold="-450" border-radius="10" :image="item.volunteerPicture"
  35. :index="index"></up-lazy-load>
  36. <view class="demo-title">
  37. {{item.businessTierName}}
  38. </view>
  39. <view class="demo-skillDescribe">
  40. {{item.skillDescribe}}
  41. </view>
  42. <view class="demo-PriceDome">
  43. <view class="demo-price">
  44. <image :src="item.volunteerPicture" class="name-image"></image>
  45. {{item.name}}
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <template #right :rightList="rightList">
  51. <view class="demo-warter" v-for="(item, index) in rightList" :key="index"
  52. @click="goToDetail(item)">
  53. <up-lazy-load threshold="-450" border-radius="10" :image="item.volunteerPicture"
  54. :index="index"></up-lazy-load>
  55. <view class="demo-title">
  56. {{item.businessTierName}}
  57. </view>
  58. <view class="demo-skillDescribe">
  59. {{item.skillDescribe}}
  60. </view>
  61. <view class="demo-PriceDome">
  62. <view class="demo-price">
  63. <image :src="item.volunteerPicture" class="name-image"></image>
  64. {{item.name}}
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. </up-waterfall>
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <script setup>
  75. import {
  76. ref,
  77. onMounted,
  78. reactive,
  79. nextTick
  80. } from 'vue';
  81. import {
  82. onLoad
  83. } from '@dcloudio/uni-app';
  84. import {
  85. typeOptionSelect,
  86. volunteerInfoList,
  87. getDetailsvolunteerId,
  88. dictListlrRstudy,
  89. dictListlrData,
  90. volunteerSeachgetTreeList,
  91. volunteerinfolist
  92. } from "@/api/volunteerDetailsApi/details.js"
  93. import {
  94. useRoute
  95. } from 'vue-router';
  96. const value1 = ref(1)
  97. const value2 = ref(2)
  98. const list1 = ref([])
  99. const list2 = ref([])
  100. const flowList = ref([]); //list数据
  101. const listData = ref([])
  102. const rightList = ref([])
  103. const defaultTab = ref({
  104. dictValue: 1
  105. });
  106. const currentTabs2 = ref(0)
  107. const total = ref(0)
  108. const userType = uni.getStorageSync('userType') //读取本地存储
  109. // 用户/志愿者 识别标识
  110. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  111. // 获取当前路由对象
  112. const route = useRoute();
  113. // 存储服务名称
  114. const serviceName = ref('');
  115. const showDropdown = ref(false)
  116. function handlTabs(item, index) {
  117. console.log(index, typeof index, '>>>>index');
  118. console.log(item, '>>>>item');
  119. currentTabs2.value = 0
  120. list2.value = item.children
  121. }
  122. function clickList2(item, index) {
  123. console.log(index, typeof index, '>>>>index99999');
  124. console.log(item, '>>>>item9999');
  125. // list2.value = item.children
  126. currentTabs2.value = index
  127. }
  128. function toggleDropdown() {
  129. console.log("点击了")
  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. // businessName
  152. console.log(dataList, '>>>>>option');
  153. // data.value = option;
  154. list1.value = dataList
  155. list2.value = dataList[0].children
  156. })
  157. const getList = async () => {
  158. try {
  159. const res = await volunteerinfolist();
  160. if (!res || !res.rows) {
  161. console.error('No data returned from API');
  162. return;
  163. }
  164. let leftArr = [];
  165. let rightArr = [];
  166. (res.rows || []).forEach((item, index) => {
  167. index % 2 !== 0 ? leftArr.push(item) : rightArr.push(item);
  168. });
  169. listData.value = leftArr;
  170. rightList.value = rightArr;
  171. total.value = res.rows;
  172. } catch (error) {
  173. console.error('Error fetching data:', error);
  174. }
  175. };
  176. onMounted(() => {
  177. getList()
  178. })
  179. </script>
  180. <style scoped>
  181. .Wrapper {
  182. display: flex;
  183. align-items: center;
  184. gap: 10rpx;
  185. }
  186. .Wrapper-img {
  187. width: 50rpx;
  188. height: 50rpx;
  189. margin-left: 10rpx;
  190. }
  191. .Wrapper-content {
  192. color: rgba(16, 16, 16, 1);
  193. font-size: 25rpx;
  194. font-family: PingFangSC-regular;
  195. line-height: 20rpx;
  196. }
  197. /* 外层容器 */
  198. .tabs-container {
  199. width: 100%;
  200. background: #fff;
  201. padding: 10px 0;
  202. }
  203. /* Flex 布局容器 */
  204. .tabs-wrapper {
  205. display: flex;
  206. align-items: center;
  207. position: relative;
  208. }
  209. /* 可横向滚动的 scroll-view */
  210. .tabs-scroll {
  211. flex: 1;
  212. /* 占据剩余空间 */
  213. overflow-x: auto;
  214. /* 允许横向滚动 */
  215. white-space: nowrap;
  216. /* 禁止换行 */
  217. -webkit-overflow-scrolling: touch;
  218. /* iOS 平滑滚动 */
  219. }
  220. /* 隐藏滚动条(可选) */
  221. .tabs-scroll::-webkit-scrollbar {
  222. display: none;
  223. }
  224. /* 固定图标(始终显示在右侧) */
  225. .fixed-icon {
  226. width: 30px;
  227. height: 30px;
  228. margin-left: 10px;
  229. /* 与 tabs 的间距 */
  230. flex-shrink: 0;
  231. /* 禁止压缩 */
  232. }
  233. .demo-warter {
  234. border-radius: 8px;
  235. margin: 5px;
  236. background-color: #ffffff;
  237. padding: 5px;
  238. }
  239. .u-close {
  240. position: absolute;
  241. top: 32rpx;
  242. right: 32rpx;
  243. }
  244. .demo-image {
  245. width: 100%;
  246. border-radius: 4px;
  247. }
  248. .demo-title {
  249. font-size: 25rpx;
  250. margin-top: 5px;
  251. color: #ccc;
  252. /* margin-left: 15rpx; */
  253. display: -webkit-box;
  254. -webkit-box-orient: vertical;
  255. -webkit-line-clamp: 3;
  256. overflow: hidden;
  257. text-overflow: ellipsis;
  258. word-break: break-all;
  259. }
  260. .demo-skillDescribe {
  261. font-size: 30rpx;
  262. margin-top: 5px;
  263. color: black;
  264. /* margin-left: 15rpx; */
  265. display: -webkit-box;
  266. -webkit-box-orient: vertical;
  267. -webkit-line-clamp: 3;
  268. overflow: hidden;
  269. text-overflow: ellipsis;
  270. word-break: break-all;
  271. }
  272. .demo-img {
  273. width: 40rpx;
  274. height: 40rpx;
  275. border-radius: 50%;
  276. }
  277. .demo-PriceDome {
  278. display: flex;
  279. justify-content: space-between;
  280. align-items: center;
  281. width: 100%;
  282. margin-top: 15rpx;
  283. }
  284. .demo-price {
  285. display: flex;
  286. align-items: center;
  287. flex: 1;
  288. overflow: hidden;
  289. /* 防止内容溢出 */
  290. }
  291. .name-image {
  292. width: 40rpx;
  293. height: 40rpx;
  294. margin-right: 10rpx;
  295. border-radius: 50%;
  296. }
  297. .name-text {
  298. white-space: nowrap;
  299. /* 禁止换行 */
  300. overflow: hidden;
  301. /* 超出部分隐藏 */
  302. text-overflow: ellipsis;
  303. /* 显示省略号 */
  304. max-width: 120rpx;
  305. /* 6个中文字符大约占120rpx */
  306. }
  307. </style>