details.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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 volunteerSide from "@/pages/Volunteerside/Side_index.vue"
  85. import {
  86. typeOptionSelect,
  87. volunteerInfoList,
  88. getDetailsvolunteerId,
  89. dictListlrRstudy,
  90. dictListlrData,
  91. volunteerSeachgetTreeList,
  92. volunteerinfolist
  93. } from "@/api/volunteerDetailsApi/details.js"
  94. import {
  95. useRoute
  96. } from 'vue-router';
  97. import {
  98. func
  99. } from 'uview-plus/libs/function/test';
  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 defaultTab = ref({
  108. dictValue: 1
  109. });
  110. const currentTabs2 = ref(0)
  111. const total = ref(0)
  112. const userType = uni.getStorageSync('userType') //读取本地存储
  113. // 用户/志愿者 识别标识
  114. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  115. // 获取当前路由对象
  116. const route = useRoute();
  117. // 存储服务名称
  118. const serviceName = ref('');
  119. const showDropdown = ref(false)
  120. function handlTabs(item, index) {
  121. console.log(index, typeof index, '>>>>index');
  122. console.log(item, '>>>>item');
  123. currentTabs2.value = 0
  124. list2.value = item.children
  125. }
  126. function clickList2(item, index) {
  127. console.log(index, typeof index, '>>>>index99999');
  128. console.log(item, '>>>>item9999');
  129. // list2.value = item.children
  130. currentTabs2.value = index
  131. }
  132. function toggleDropdown() {
  133. console.log("点击了")
  134. showDropdown.value = !showDropdown.value
  135. }
  136. const goToDetail = async (item) => {
  137. const params = {
  138. volunteerId: item.volunteerId, // 获取 volunteerId
  139. serviceCategory: item.serviceCategory, // 获取 serviceCategory
  140. businessManagementId: item.businessManagementId, //获取 businessManagementId
  141. };
  142. uni.navigateTo({
  143. url: `/pages_home/pages/Volunteerside/goodsDetails?params=${JSON.stringify(params)}`
  144. });
  145. }
  146. const inputStyle = { //input輸入框樣式設置
  147. borderRadius: '140rpx',
  148. border: '1rpx solid #ccc',
  149. height: '70rpx',
  150. paddingLeft: '30rpx',
  151. width: '600rpx',
  152. }
  153. onLoad((options) => {
  154. const dataList = JSON.parse(decodeURIComponent(options.dataList));
  155. // businessName
  156. // console.log(option, '>>>>>option');
  157. // data.value = option;
  158. list1.value = dataList
  159. list2.value = dataList[0].children
  160. })
  161. const getList = async () => {
  162. try {
  163. const res = await volunteerinfolist();
  164. if (!res || !res.rows) {
  165. console.error('No data returned from API');
  166. return;
  167. }
  168. let leftArr = [];
  169. let rightArr = [];
  170. (res.rows || []).forEach((item, index) => {
  171. index % 2 !== 0 ? leftArr.push(item) : rightArr.push(item);
  172. });
  173. listData.value = leftArr;
  174. rightList.value = rightArr;
  175. total.value = res.rows;
  176. } catch (error) {
  177. console.error('Error fetching data:', error);
  178. }
  179. };
  180. onMounted(() => {
  181. getList()
  182. })
  183. </script>
  184. <style scoped>
  185. .Wrapper {
  186. display: flex;
  187. align-items: center;
  188. gap: 10rpx;
  189. }
  190. .Wrapper-img {
  191. width: 50rpx;
  192. height: 50rpx;
  193. margin-left: 10rpx;
  194. }
  195. .Wrapper-content {
  196. color: rgba(16, 16, 16, 1);
  197. font-size: 25rpx;
  198. font-family: PingFangSC-regular;
  199. line-height: 20rpx;
  200. }
  201. /* 外层容器 */
  202. .tabs-container {
  203. width: 100%;
  204. background: #fff;
  205. padding: 10px 0;
  206. }
  207. /* Flex 布局容器 */
  208. .tabs-wrapper {
  209. display: flex;
  210. align-items: center;
  211. position: relative;
  212. }
  213. /* 可横向滚动的 scroll-view */
  214. .tabs-scroll {
  215. flex: 1;
  216. /* 占据剩余空间 */
  217. overflow-x: auto;
  218. /* 允许横向滚动 */
  219. white-space: nowrap;
  220. /* 禁止换行 */
  221. -webkit-overflow-scrolling: touch;
  222. /* iOS 平滑滚动 */
  223. }
  224. /* 隐藏滚动条(可选) */
  225. .tabs-scroll::-webkit-scrollbar {
  226. display: none;
  227. }
  228. /* 固定图标(始终显示在右侧) */
  229. .fixed-icon {
  230. width: 30px;
  231. height: 30px;
  232. margin-left: 10px;
  233. /* 与 tabs 的间距 */
  234. flex-shrink: 0;
  235. /* 禁止压缩 */
  236. }
  237. .demo-warter {
  238. border-radius: 8px;
  239. margin: 5px;
  240. background-color: #ffffff;
  241. padding: 5px;
  242. }
  243. .u-close {
  244. position: absolute;
  245. top: 32rpx;
  246. right: 32rpx;
  247. }
  248. .demo-image {
  249. width: 100%;
  250. border-radius: 4px;
  251. }
  252. .demo-title {
  253. font-size: 25rpx;
  254. margin-top: 5px;
  255. color: #ccc;
  256. /* margin-left: 15rpx; */
  257. display: -webkit-box;
  258. -webkit-box-orient: vertical;
  259. -webkit-line-clamp: 3;
  260. overflow: hidden;
  261. text-overflow: ellipsis;
  262. word-break: break-all;
  263. }
  264. .demo-skillDescribe {
  265. font-size: 30rpx;
  266. margin-top: 5px;
  267. color: black;
  268. /* margin-left: 15rpx; */
  269. display: -webkit-box;
  270. -webkit-box-orient: vertical;
  271. -webkit-line-clamp: 3;
  272. overflow: hidden;
  273. text-overflow: ellipsis;
  274. word-break: break-all;
  275. }
  276. .demo-img {
  277. width: 40rpx;
  278. height: 40rpx;
  279. border-radius: 50%;
  280. }
  281. .demo-PriceDome {
  282. display: flex;
  283. justify-content: space-between;
  284. align-items: center;
  285. width: 100%;
  286. margin-top: 15rpx;
  287. }
  288. .demo-price {
  289. display: flex;
  290. align-items: center;
  291. flex: 1;
  292. overflow: hidden;
  293. /* 防止内容溢出 */
  294. }
  295. .name-image {
  296. width: 40rpx;
  297. height: 40rpx;
  298. margin-right: 10rpx;
  299. border-radius: 50%;
  300. }
  301. .name-text {
  302. white-space: nowrap;
  303. /* 禁止换行 */
  304. overflow: hidden;
  305. /* 超出部分隐藏 */
  306. text-overflow: ellipsis;
  307. /* 显示省略号 */
  308. max-width: 120rpx;
  309. /* 6个中文字符大约占120rpx */
  310. }
  311. </style>