details.vue 7.8 KB

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