sales.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <view class="sales-container">
  3. <!-- 顶部Tab标签页 -->
  4. <view class="tab-header">
  5. <view class="tab-list">
  6. <view
  7. class="tab-item"
  8. :class="{ active: activeTab === 'all' }"
  9. @click="switchTab('all')"
  10. >
  11. <text class="tab-text">全部</text>
  12. </view>
  13. <view
  14. class="tab-item"
  15. :class="{ active: activeTab === 'sale' }"
  16. @click="switchTab('sale')"
  17. >
  18. <text class="tab-text">出售信息</text>
  19. </view>
  20. <view
  21. class="tab-item"
  22. :class="{ active: activeTab === 'purchase' }"
  23. @click="switchTab('purchase')"
  24. >
  25. <text class="tab-text">收购信息</text>
  26. </view>
  27. </view>
  28. <view class="tab-indicator" :style="{ left: getIndicatorPosition() }"></view>
  29. </view>
  30. <!-- 搜索筛选 -->
  31. <view class="search-section">
  32. <view class="search-box">
  33. <image class="search-icon" src="/static/icons/search.png" mode="aspectFit"></image>
  34. <input
  35. class="search-input"
  36. placeholder="搜索农产品信息"
  37. placeholder-style="color: #999;"
  38. v-model="searchKeyword"
  39. @confirm="handleSearch"
  40. />
  41. </view>
  42. </view>
  43. <!-- 全部农产品信息列表 -->
  44. <view class="content-container">
  45. <view class="info-list">
  46. <view
  47. class="info-card"
  48. v-for="item in filteredAllInfo"
  49. :key="`${item.type}_${item.id}`"
  50. @click="navigateToDetail(item)"
  51. >
  52. <view class="card-content">
  53. <!-- 封面图片 -->
  54. <view class="info-image">
  55. <image :src="item.image" mode="aspectFill"></image>
  56. </view>
  57. <!-- 信息内容 -->
  58. <view class="info-content">
  59. <!-- 类型标签和标题 -->
  60. <view class="info-header">
  61. <view class="type-tag" :class="item.type">
  62. {{ item.type === 'sale' ? '出售' : '收购' }}
  63. </view>
  64. <view class="info-title">{{ item.title }}</view>
  65. </view>
  66. <!-- 简要说明 -->
  67. <view class="info-desc">{{ item.description }}</view>
  68. <!-- 底部信息 -->
  69. <view class="info-footer">
  70. <view class="publish-info">
  71. <text class="publisher">{{ item.publisher }}</text>
  72. <text class="publish-time">{{ item.publishTime }}</text>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 浮动发布按钮 -->
  81. <view class="floating-btn" @click="navigateToMyPublish">
  82. <view class="btn-icon">+</view>
  83. <text class="btn-text">我的发布</text>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. export default {
  89. data() {
  90. return {
  91. activeTab: 'all', // 当前活跃的标签页
  92. searchKeyword: '',
  93. // 全部农产品信息列表(出售+收购)
  94. allInfoList: [
  95. // 出售信息
  96. {
  97. id: 1,
  98. type: 'sale',
  99. title: '优质红薯 ¥2.5/斤',
  100. description: '自家种植,香甜可口,现挖现卖',
  101. image: '/static/images/products/corn-seeds-new.jpg',
  102. publisher: '李**',
  103. publishTime: '今天',
  104. price: '2.5',
  105. unit: '斤'
  106. },
  107. {
  108. id: 2,
  109. type: 'sale',
  110. title: '有机苹果 ¥8.5/斤',
  111. description: '新鲜采摘,无农药残留,口感清脆',
  112. image: '/static/images/products/rice-seeds.jpg',
  113. publisher: '张**',
  114. publishTime: '2小时前',
  115. price: '8.5',
  116. unit: '斤'
  117. },
  118. {
  119. id: 3,
  120. type: 'sale',
  121. title: '土鸡蛋 ¥2.0/个',
  122. description: '散养土鸡,营养丰富,蛋黄金黄',
  123. image: '/static/images/products/seeds-packets.jpg',
  124. publisher: '王**',
  125. publishTime: '昨天',
  126. price: '2.0',
  127. unit: '个'
  128. },
  129. {
  130. id: 4,
  131. type: 'sale',
  132. title: '新鲜玉米 ¥3.0/斤',
  133. description: '当季玉米,粒粒饱满,甜度高',
  134. image: '/static/images/products/greenhouse-film.jpg',
  135. publisher: '陈**',
  136. publishTime: '2天前',
  137. price: '3.0',
  138. unit: '斤'
  139. },
  140. // 收购信息
  141. {
  142. id: 5,
  143. type: 'purchase',
  144. title: '高价收购优质土豆 ¥3.5/斤',
  145. description: '大量收购,要求新鲜无病害,长期合作',
  146. image: '/static/images/products/agriculture-tools.jpg',
  147. publisher: '刘**',
  148. publishTime: '今天',
  149. quantity: '1000斤',
  150. budgetPrice: '3.5',
  151. unit: '斤'
  152. },
  153. {
  154. id: 6,
  155. type: 'purchase',
  156. title: '收购新鲜玉米 ¥2.8/斤',
  157. description: '需求量大,价格优惠,现金结算',
  158. image: '/static/images/products/organic-fertilizer-new.jpg',
  159. publisher: '周**',
  160. publishTime: '5小时前',
  161. quantity: '5000斤',
  162. budgetPrice: '2.8',
  163. unit: '斤'
  164. },
  165. {
  166. id: 7,
  167. type: 'purchase',
  168. title: '收购有机蔬菜 ¥8.0/斤',
  169. description: '要求有机认证,品质优良,长期收购',
  170. image: '/static/images/products/plastic-film.jpg',
  171. publisher: '赵**',
  172. publishTime: '昨天',
  173. quantity: '500斤',
  174. budgetPrice: '8.0',
  175. unit: '斤'
  176. },
  177. {
  178. id: 8,
  179. type: 'sale',
  180. title: '优质大米 ¥6.8/斤',
  181. description: '当季新米,粒粒饱满,口感香甜',
  182. image: '/static/images/products/fertilizer.jpg',
  183. publisher: '孙**',
  184. publishTime: '3天前',
  185. price: '6.8',
  186. unit: '斤'
  187. }
  188. ]
  189. }
  190. },
  191. computed: {
  192. filteredAllInfo() {
  193. let list = this.allInfoList;
  194. // 按类型筛选
  195. if (this.activeTab === 'sale') {
  196. list = list.filter(item => item.type === 'sale');
  197. } else if (this.activeTab === 'purchase') {
  198. list = list.filter(item => item.type === 'purchase');
  199. }
  200. // 按搜索关键词筛选
  201. if (this.searchKeyword.trim()) {
  202. const keyword = this.searchKeyword.trim().toLowerCase();
  203. list = list.filter(item =>
  204. item.title.toLowerCase().includes(keyword) ||
  205. item.description.toLowerCase().includes(keyword) ||
  206. item.publisher.toLowerCase().includes(keyword)
  207. );
  208. }
  209. return list;
  210. }
  211. },
  212. methods: {
  213. // 切换Tab标签页
  214. switchTab(tab) {
  215. this.activeTab = tab;
  216. },
  217. // 获取指示器位置
  218. getIndicatorPosition() {
  219. const positions = {
  220. 'all': '0%',
  221. 'sale': '33.33%',
  222. 'purchase': '66.66%'
  223. };
  224. return positions[this.activeTab] || '0%';
  225. },
  226. // 搜索处理
  227. handleSearch() {
  228. // 搜索逻辑已在computed中处理
  229. },
  230. // 导航到详情页
  231. navigateToDetail(item) {
  232. uni.navigateTo({
  233. url: `/pages/service/sales-detail?id=${item.id}&type=${item.type}&title=${encodeURIComponent(item.title)}`
  234. });
  235. },
  236. // 导航到我的发布页面
  237. navigateToMyPublish() {
  238. uni.navigateTo({
  239. url: '/pages/service/my-publish'
  240. });
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss">
  246. .sales-container {
  247. min-height: 100vh;
  248. background-color: #f5f5f5;
  249. padding-bottom: 120rpx;
  250. }
  251. .tab-header {
  252. background-color: #fff;
  253. position: relative;
  254. border-bottom: 1rpx solid #f0f0f0;
  255. }
  256. .tab-list {
  257. display: flex;
  258. align-items: center;
  259. }
  260. .tab-item {
  261. flex: 1;
  262. text-align: center;
  263. padding: 32rpx 0;
  264. position: relative;
  265. .tab-text {
  266. font-size: 30rpx;
  267. color: #666;
  268. font-weight: 500;
  269. transition: color 0.3s ease;
  270. }
  271. &.active .tab-text {
  272. color: #4CAF50;
  273. font-weight: bold;
  274. }
  275. }
  276. .tab-indicator {
  277. position: absolute;
  278. bottom: 0;
  279. left: 0;
  280. width: 33.33%;
  281. height: 4rpx;
  282. background-color: #4CAF50;
  283. transition: left 0.3s ease;
  284. }
  285. .search-section {
  286. background-color: #fff;
  287. padding: 20rpx;
  288. border-bottom: 1rpx solid #f0f0f0;
  289. }
  290. .search-box {
  291. flex: 1;
  292. display: flex;
  293. align-items: center;
  294. background-color: #f8f8f8;
  295. border-radius: 32rpx;
  296. padding: 16rpx 24rpx;
  297. }
  298. .search-icon {
  299. width: 32rpx;
  300. height: 32rpx;
  301. margin-right: 16rpx;
  302. }
  303. .search-input {
  304. flex: 1;
  305. font-size: 28rpx;
  306. line-height: 1.5;
  307. }
  308. .filter-btn {
  309. display: flex;
  310. align-items: center;
  311. padding: 16rpx 24rpx;
  312. background-color: #f8f8f8;
  313. border-radius: 24rpx;
  314. font-size: 28rpx;
  315. color: #666;
  316. .filter-icon {
  317. margin-left: 8rpx;
  318. font-size: 20rpx;
  319. }
  320. }
  321. .category-tags {
  322. background-color: #fff;
  323. border-bottom: 1rpx solid #f0f0f0;
  324. }
  325. .tags-scroll {
  326. white-space: nowrap;
  327. }
  328. .tags-list {
  329. display: inline-flex;
  330. padding: 0 20rpx;
  331. }
  332. .tag-item {
  333. flex-shrink: 0;
  334. padding: 20rpx 32rpx;
  335. margin-right: 8rpx;
  336. font-size: 28rpx;
  337. color: #666;
  338. border-radius: 32rpx;
  339. transition: all 0.2s ease;
  340. &.active {
  341. color: #4CAF50;
  342. background-color: #f0fdf4;
  343. font-weight: bold;
  344. }
  345. }
  346. // 内容容器
  347. .content-container {
  348. padding: 20rpx;
  349. }
  350. .info-list {
  351. display: flex;
  352. flex-direction: column;
  353. gap: 16rpx;
  354. }
  355. // 统一信息卡片样式
  356. .info-card {
  357. background-color: #fff;
  358. border-radius: 12rpx;
  359. overflow: hidden;
  360. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  361. transition: transform 0.2s ease;
  362. &:active {
  363. transform: scale(0.98);
  364. }
  365. }
  366. .card-content {
  367. display: flex;
  368. padding: 20rpx;
  369. gap: 20rpx;
  370. }
  371. // 封面图片
  372. .info-image {
  373. width: 160rpx;
  374. height: 160rpx;
  375. border-radius: 8rpx;
  376. overflow: hidden;
  377. flex-shrink: 0;
  378. image {
  379. width: 100%;
  380. height: 100%;
  381. }
  382. }
  383. // 信息内容
  384. .info-content {
  385. flex: 1;
  386. display: flex;
  387. flex-direction: column;
  388. justify-content: space-between;
  389. }
  390. // 信息头部
  391. .info-header {
  392. display: flex;
  393. align-items: flex-start;
  394. margin-bottom: 12rpx;
  395. gap: 12rpx;
  396. }
  397. .type-tag {
  398. padding: 6rpx 12rpx;
  399. border-radius: 12rpx;
  400. font-size: 20rpx;
  401. font-weight: bold;
  402. flex-shrink: 0;
  403. &.sale {
  404. background-color: #e8f5e8;
  405. color: #4CAF50;
  406. }
  407. &.purchase {
  408. background-color: #e6f7ff;
  409. color: #1890ff;
  410. }
  411. }
  412. .info-title {
  413. font-size: 28rpx;
  414. font-weight: bold;
  415. color: #333;
  416. flex: 1;
  417. line-height: 1.4;
  418. }
  419. // 简要说明
  420. .info-desc {
  421. font-size: 26rpx;
  422. color: #666;
  423. margin-bottom: 16rpx;
  424. overflow: hidden;
  425. text-overflow: ellipsis;
  426. white-space: nowrap;
  427. line-height: 1.4;
  428. }
  429. // 底部信息
  430. .info-footer {
  431. display: flex;
  432. justify-content: space-between;
  433. align-items: center;
  434. }
  435. .publish-info {
  436. display: flex;
  437. align-items: center;
  438. gap: 16rpx;
  439. }
  440. .publisher {
  441. font-size: 24rpx;
  442. color: #4CAF50;
  443. font-weight: bold;
  444. }
  445. .publish-time {
  446. font-size: 24rpx;
  447. color: #999;
  448. }
  449. // 浮动发布按钮
  450. .floating-btn {
  451. position: fixed;
  452. bottom: 120rpx;
  453. right: 30rpx;
  454. width: 140rpx;
  455. height: 140rpx;
  456. background-color: #4CAF50;
  457. border-radius: 70rpx;
  458. display: flex;
  459. flex-direction: column;
  460. align-items: center;
  461. justify-content: center;
  462. box-shadow: 0 8rpx 24rpx rgba(76, 175, 80, 0.3);
  463. z-index: 1000;
  464. transition: transform 0.2s ease;
  465. &:active {
  466. transform: scale(0.95);
  467. }
  468. .btn-icon {
  469. font-size: 56rpx;
  470. color: #fff;
  471. font-weight: 300;
  472. line-height: 1;
  473. margin-bottom: 2rpx;
  474. }
  475. .btn-text {
  476. font-size: 22rpx;
  477. color: #fff;
  478. font-weight: bold;
  479. }
  480. }
  481. </style>