index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. <template>
  2. <view class="sell-container">
  3. <!-- 顶部背景图 -->
  4. <image class="top-bg-image" src="/pages-sell/static/top-bg.png" mode="widthFix"></image>
  5. <!-- 导航栏 -->
  6. <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
  7. <view class="navbar-content">
  8. <text class="navbar-title">书嗨</text>
  9. <!-- 右侧胶囊占位,保持布局平衡 -->
  10. <view class="nav-right-placeholder"></view>
  11. </view>
  12. </view>
  13. <!-- 主要内容区域 -->
  14. <view class="main-content" :style="{ marginTop: (statusBarHeight + 44) + 'px' }">
  15. <!-- 搜索框 -->
  16. <view class="search-wrapper" @click="navigateTo('/pages-sell/pages/search')">
  17. <view class="search-box-uview">
  18. <u-search placeholder="搜索关键字" :show-action="false" bg-color="transparent" height="40"
  19. :clearabled="true" v-model="keyword" :disabled="true"
  20. search-icon="/pages-sell/static/search-icon.png"></u-search>
  21. <view class="search-btn-overlay">
  22. <text>搜索</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- tab标签 -->
  27. <view class="tabs-wrapper">
  28. <u-tabs :list="hotTagList" :current="currentHotTag" @change="changeHotTag" bgColor="transparent"
  29. lineColor="transparent" :active-item-style="{ fontWeight: 'bold', color: '#333' }"
  30. inactive-color="#3C4F3E" :barStyle="barStyle" :bar-height="27" :bar-width="52"></u-tabs>
  31. </view>
  32. <!-- 顶部横幅 Banner -->
  33. <view class="top-banner-wrapper">
  34. <image src="/pages-sell/static/top-banner.png" class="top-banner-img" mode="widthFix"></image>
  35. </view>
  36. <!-- 金刚区分类图标 (2行5列) -->
  37. <view class="category-grid">
  38. <view class="grid-item" v-for="(item, index) in categoryList" :key="index"
  39. @click="handleCategory(item)">
  40. <view class="icon-circle">
  41. <image :src="item.icon" class="cat-icon" mode="aspectFit"></image>
  42. </view>
  43. <text class="cat-name">{{ item.name }}</text>
  44. </view>
  45. </view>
  46. <!-- 推广与热销双卡片 -->
  47. <view class="promo-dual-card">
  48. <!-- 左侧:推广卖书 -->
  49. <view class="card-left">
  50. <view class="card-content">
  51. <u-swiper :list="swiperList"></u-swiper>
  52. </view>
  53. </view>
  54. <!-- 右侧:热销商品 -->
  55. <view class="card-right">
  56. <view class="right-header" @click="navigateTo('/pages-sell/pages/hot-sell')">
  57. <image src="/pages-sell/static/icon-fire.png" class="fire-icon" mode="widthFix"></image>
  58. <text class="right-title">热销商品</text>
  59. <image src="/pages-sell/static/icon-fire.png" class="fire-icon flip" mode="widthFix"></image>
  60. </view>
  61. <view class="products-container">
  62. <!-- 使用网络图片作为书的封面占位 -->
  63. <image :src="bookCoverUrl" class="product-cover" mode="aspectFill"></image>
  64. <image :src="bookCoverUrl" class="product-cover" mode="aspectFill"></image>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 健康与成长双卡片 -->
  69. <view class="info-dual-card">
  70. <view class="info-card bg-orange">
  71. <view class="info-text-group">
  72. <text class="info-title text-orange">健康与身材</text>
  73. <text class="info-desc text-orange-light">和身体和解科学管理状态</text>
  74. </view>
  75. <image src="/pages-sell/static/shape-19.png" class="info-icon" mode="aspectFit"
  76. style="width: 125rpx;height: 111rpx;"></image>
  77. </view>
  78. <view class="info-card bg-green">
  79. <view class="info-text-group">
  80. <text class="info-title text-green">成长与心态</text>
  81. <text class="info-desc text-green-light">拥有持续进步的动力和抗挫力</text>
  82. </view>
  83. <image src="/pages-sell/static/shape-20.png" class="info-icon" mode="aspectFit"></image>
  84. </view>
  85. </view>
  86. <!-- 公众号横幅 -->
  87. <view class="gzh-section">
  88. <view class="gzh-bg-wrapper">
  89. <image src="/pages-sell/static/gzh-banner.png" class="gzh-img-bg" mode="aspectFill"></image>
  90. <view class="gzh-content-overlay">
  91. <text class="gzh-title">关注公众号 ,定期领红包</text>
  92. <view class="gzh-subtitle-pill">
  93. <text class="gzh-subtitle">别让好书蒙尘 ,书嗨陪你逐页品读</text>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 书嗨推荐 -->
  99. <view class="recommend-section" @click="navigateTo('/pages-sell/pages/recommend')">
  100. <view class="section-header">
  101. <text class="section-title">书嗨推荐</text>
  102. <view class="view-more">
  103. <text>查看全部</text>
  104. <image src="/pages-sell/static/right-arrow.png" class="arrow-icon" mode="widthFix"></image>
  105. </view>
  106. </view>
  107. <scroll-view scroll-x class="book-scroll" :show-scrollbar="false">
  108. <view class="book-list">
  109. <view class="book-item" v-for="(book, index) in recommendBooks" :key="index">
  110. <image :src="book.cover" class="book-image" mode="aspectFill"></image>
  111. <text class="book-name">{{ book.title }}</text>
  112. <view class="price-row">
  113. <text class="currency">¥</text>
  114. <text class="price-val">{{ book.price }}</text>
  115. <text class="price-old">¥{{ book.original }}</text>
  116. </view>
  117. <view class="add-btn">
  118. <text>加入购物车</text>
  119. <image src="/pages-sell/static/shape-10.png" class="cart-symbol"></image>
  120. </view>
  121. </view>
  122. </view>
  123. </scroll-view>
  124. </view>
  125. <view class="recommend-section" @click="navigateTo('/pages-sell/pages/topic')">
  126. <view class="section-header">
  127. <text class="section-title">大学四六级推荐</text>
  128. <view class="view-more">
  129. <text>查看全部</text>
  130. <image src="/pages-sell/static/right-arrow.png" class="arrow-icon" mode="widthFix"></image>
  131. </view>
  132. </view>
  133. <scroll-view scroll-x class="book-scroll" :show-scrollbar="false">
  134. <view class="book-list">
  135. <view class="book-item" v-for="(book, index) in recommendBooks" :key="index" @click="navigateTo('/pages-sell/pages/detail')">
  136. <image :src="book.cover" class="book-image" mode="aspectFill"></image>
  137. <text class="book-name">{{ book.title }}</text>
  138. <view class="price-row">
  139. <text class="currency">¥</text>
  140. <text class="price-val">{{ book.price }}</text>
  141. <text class="price-old">¥{{ book.original }}</text>
  142. </view>
  143. <view class="add-btn">
  144. <text>加入购物车</text>
  145. <image src="/pages-sell/static/shape-10.png" class="cart-symbol"></image>
  146. </view>
  147. </view>
  148. </view>
  149. </scroll-view>
  150. </view>
  151. <!-- 底部留白,防止遮挡 -->
  152. <view class="bottom-safe-area"></view>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. export default {
  158. name: 'SellContainer',
  159. data() {
  160. return {
  161. barStyle: {
  162. backgroundColor: 'transparent',
  163. background: "url('/pages-sell/static/tab-selected.png') no-repeat center",
  164. backgroundSize: '100% 100%',
  165. position: 'relative',
  166. top: '-6rpx',
  167. },
  168. swiperList: [
  169. {
  170. image: '/pages-sell/static/banner-3.png'
  171. },
  172. {
  173. image: '/pages-sell/static/banner-1.png'
  174. },
  175. {
  176. image: '/pages-sell/static/banner-2.png'
  177. }
  178. ],
  179. statusBarHeight: 20,
  180. keyword: '',
  181. // u-tabs 需要对象数组 [{name: 'xxx'}]
  182. hotTagList: [
  183. { name: '热搜' },
  184. { name: '励志' },
  185. { name: '绘本' },
  186. { name: '诺贝尔文学奖' },
  187. { name: '茅盾奖' },
  188. { name: '童书' }
  189. ],
  190. currentHotTag: 0,
  191. // 临时的网络书封面图片
  192. bookCoverUrl: 'https://img.yzcdn.cn/vant/cat.jpeg',
  193. categoryList: [
  194. { name: '热销榜单', icon: '/pages-sell/static/icon-hot-sales.png' },
  195. { name: '心灵 / 成长', icon: '/pages-sell/static/icon-heart-growth.png' },
  196. { name: '诺贝尔文学奖', icon: '/pages-sell/static/icon-nobel.png' },
  197. { name: '茅盾文学奖', icon: '/pages-sell/static/icon-maodun.png' },
  198. { name: '樊登书单', icon: '/pages-sell/static/icon-fandeng.png' },
  199. { name: '东野圭吾', icon: '/pages-sell/static/icon-dongye.png' },
  200. { name: '余华', icon: '/pages-sell/static/icon-yuhua.png' },
  201. { name: '村上春树', icon: '/pages-sell/static/icon-haruki.png' },
  202. { name: '童书', icon: '/pages-sell/static/icon-children.png' },
  203. { name: '书嗨推荐', icon: '/pages-sell/static/icon-recommend.png' }
  204. ],
  205. recommendBooks: [
  206. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  207. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  208. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' }
  209. ]
  210. }
  211. },
  212. created() {
  213. const systemInfo = uni.getSystemInfoSync();
  214. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  215. },
  216. methods: {
  217. handleCategory(item) {
  218. console.log('点击分类:', item.name);
  219. },
  220. changeHotTag(index) {
  221. this.currentHotTag = index;
  222. console.log('切换标签:', index);
  223. },
  224. //跳转 URL
  225. navigateTo(url) {
  226. uni.navigateTo({
  227. url: url
  228. });
  229. },
  230. goRecommend() {
  231. uni.navigateTo({
  232. url: '/pages-sell/pages/recommend'
  233. });
  234. },
  235. goHotSell() {
  236. uni.navigateTo({
  237. url: '/pages-sell/pages/hot-sell'
  238. });
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang="scss" scoped>
  244. .sell-container {
  245. position: relative;
  246. min-height: 100vh;
  247. background-color: #F6F6F6;
  248. overflow-x: hidden;
  249. }
  250. /* 顶部大背景图 */
  251. .top-bg-image {
  252. position: absolute;
  253. top: 0;
  254. left: 0;
  255. width: 100%;
  256. z-index: 0;
  257. display: block;
  258. }
  259. /* 导航栏 */
  260. .custom-navbar {
  261. position: fixed;
  262. top: 0;
  263. left: 0;
  264. width: 100%;
  265. z-index: 100;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. .navbar-content {
  270. height: 44px;
  271. width: 100%;
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. position: relative;
  276. .navbar-title {
  277. color: #fff;
  278. font-size: 36rpx;
  279. font-weight: 600;
  280. }
  281. }
  282. }
  283. .main-content {
  284. position: relative;
  285. z-index: 1;
  286. padding: 0 24rpx;
  287. }
  288. /* 搜索框 */
  289. .search-wrapper {
  290. margin-top: 10rpx;
  291. margin-bottom: 20rpx;
  292. .search-box-uview {
  293. height: 80rpx;
  294. background-color: #fff;
  295. border-radius: 40rpx;
  296. display: flex;
  297. align-items: center;
  298. padding: 0 10rpx 0 16rpx;
  299. position: relative;
  300. /* 覆盖 u-search 的 padding 以适配 */
  301. ::v-deep .u-search {
  302. flex: 1;
  303. /* 让输入框不遮挡右侧按钮 */
  304. padding-right: 140rpx !important;
  305. }
  306. .search-btn-overlay {
  307. position: absolute;
  308. right: 8rpx;
  309. top: 50%;
  310. transform: translateY(-50%);
  311. width: 140rpx;
  312. height: 64rpx;
  313. background: linear-gradient(0deg, #37C148 0%, #6ADD83 100%);
  314. border-radius: 32rpx;
  315. display: flex;
  316. align-items: center;
  317. justify-content: center;
  318. z-index: 2;
  319. text {
  320. color: #fff;
  321. font-size: 28rpx;
  322. font-weight: 500;
  323. }
  324. }
  325. }
  326. }
  327. /* 顶部横幅 */
  328. .top-banner-wrapper {
  329. width: 100%;
  330. margin-bottom: 30rpx;
  331. position: relative;
  332. .top-banner-img {
  333. width: 100%;
  334. border-radius: 40rpx;
  335. display: block;
  336. }
  337. }
  338. /* 分类图标 */
  339. .category-grid {
  340. display: flex;
  341. flex-wrap: wrap;
  342. margin-bottom: 10rpx;
  343. .grid-item {
  344. width: 20%;
  345. display: flex;
  346. flex-direction: column;
  347. align-items: center;
  348. margin-bottom: 30rpx;
  349. .icon-circle {
  350. width: 96rpx;
  351. height: 96rpx;
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. margin-bottom: 12rpx;
  356. .cat-icon {
  357. width: 100%;
  358. height: 100%;
  359. }
  360. }
  361. .cat-name {
  362. font-size: 24rpx;
  363. color: #333;
  364. font-weight: 500;
  365. }
  366. }
  367. }
  368. /* 推广双卡片 */
  369. .promo-dual-card {
  370. display: flex;
  371. justify-content: space-between;
  372. margin-bottom: 24rpx;
  373. .card-left {
  374. width: 48%;
  375. height: 252rpx;
  376. border-radius: 20rpx;
  377. position: relative;
  378. overflow: hidden;
  379. }
  380. .card-right {
  381. width: 48%;
  382. height: 252rpx;
  383. /* Updated background per request */
  384. background: linear-gradient(to bottom, #FFD7C3 0%, #FFFFFF 32%);
  385. border-radius: 20rpx;
  386. padding: 20rpx;
  387. box-sizing: border-box;
  388. .right-header {
  389. display: flex;
  390. align-items: center;
  391. justify-content: center;
  392. margin-bottom: 20rpx;
  393. .right-title {
  394. font-size: 30rpx;
  395. font-weight: bold;
  396. color: #333;
  397. margin: 0 10rpx;
  398. }
  399. .fire-icon {
  400. width: 30rpx;
  401. height: 30rpx;
  402. }
  403. .flip {
  404. transform: scaleX(-1);
  405. }
  406. }
  407. .products-container {
  408. display: flex;
  409. justify-content: space-between;
  410. gap: 20rpx;
  411. .product-cover {
  412. flex: 1;
  413. height: 160rpx;
  414. border-radius: 12rpx;
  415. background-color: #f0f0f0;
  416. }
  417. }
  418. }
  419. }
  420. /* 信息双卡片 */
  421. .info-dual-card {
  422. display: flex;
  423. justify-content: space-between;
  424. margin-bottom: 24rpx;
  425. .info-card {
  426. width: 48%;
  427. padding: 24rpx;
  428. border-radius: 12px;
  429. /* Updated radius */
  430. display: flex;
  431. justify-content: space-between;
  432. align-items: center;
  433. height: 140rpx;
  434. box-sizing: border-box;
  435. position: relative;
  436. /* For absolute icon */
  437. overflow: hidden;
  438. &.bg-orange {
  439. background: #FFF3E0;
  440. border: 1px solid #FFB72A;
  441. }
  442. &.bg-green {
  443. background: #D4F1D8;
  444. border: 1px solid #54A94E;
  445. }
  446. .info-text-group {
  447. flex: 1;
  448. z-index: 1;
  449. /* Ensure text is above */
  450. .info-title {
  451. font-size: 28rpx;
  452. font-weight: bold;
  453. display: block;
  454. margin-bottom: 6rpx;
  455. }
  456. .info-desc {
  457. font-size: 22rpx;
  458. line-height: 1.2;
  459. }
  460. .text-orange {
  461. color: #DB832D;
  462. }
  463. .text-orange-light {
  464. color: #DB832D;
  465. }
  466. .text-green {
  467. color: #1F8049;
  468. }
  469. .text-green-light {
  470. color: #1F8049;
  471. }
  472. }
  473. .info-icon {
  474. width: 100rpx;
  475. /* Slightly larger maybe */
  476. height: 100rpx;
  477. position: absolute;
  478. right: 0;
  479. bottom: 0;
  480. z-index: 0;
  481. opacity: 0.8;
  482. }
  483. }
  484. }
  485. /* 公众号 */
  486. .gzh-section {
  487. margin-bottom: 30rpx;
  488. height: 180rpx;
  489. /* Fixed height for consistency */
  490. border-radius: 20rpx;
  491. overflow: hidden;
  492. .gzh-bg-wrapper {
  493. width: 100%;
  494. height: 100%;
  495. position: relative;
  496. .gzh-img-bg {
  497. width: 100%;
  498. height: 100%;
  499. position: absolute;
  500. top: 0;
  501. left: 0;
  502. }
  503. .gzh-content-overlay {
  504. position: absolute;
  505. top: 0;
  506. left: 0;
  507. width: 60%;
  508. /* Only cover left side */
  509. height: 100%;
  510. padding: 30rpx;
  511. display: flex;
  512. flex-direction: column;
  513. justify-content: center;
  514. .gzh-title {
  515. font-size: 32rpx;
  516. font-weight: bold;
  517. color: #134E13;
  518. /* Dark green */
  519. margin-bottom: 16rpx;
  520. }
  521. .gzh-subtitle-pill {
  522. background: #FFF;
  523. border-radius: 24rpx;
  524. padding: 0 14rpx;
  525. line-height: 1.4;
  526. align-self: flex-start;
  527. .gzh-subtitle {
  528. font-size: 22rpx;
  529. color: #134E13;
  530. font-weight: 500;
  531. }
  532. }
  533. }
  534. }
  535. }
  536. /* 书嗨推荐 */
  537. .recommend-section {
  538. background-color: #fff;
  539. border-radius: 20rpx;
  540. padding: 30rpx;
  541. .section-header {
  542. display: flex;
  543. justify-content: space-between;
  544. align-items: center;
  545. margin-bottom: 24rpx;
  546. .section-title {
  547. font-size: 32rpx;
  548. font-weight: bold;
  549. color: #333;
  550. }
  551. .view-more {
  552. display: flex;
  553. align-items: center;
  554. font-size: 24rpx;
  555. color: #8D8D8D;
  556. .arrow-icon {
  557. width: 12rpx;
  558. margin-left: 6rpx;
  559. }
  560. }
  561. }
  562. .book-scroll {
  563. width: 100%;
  564. white-space: nowrap;
  565. .book-list {
  566. display: flex;
  567. padding-bottom: 10rpx;
  568. }
  569. .book-item {
  570. width: 200rpx;
  571. margin-right: 24rpx;
  572. display: flex;
  573. flex-direction: column;
  574. .book-image {
  575. width: 200rpx;
  576. height: 255rpx;
  577. border-radius: 2rpx;
  578. margin-bottom: 16rpx;
  579. background-color: #f9f9f9;
  580. }
  581. .book-name {
  582. font-family: 'Source Han Sans SC';
  583. font-weight: bold;
  584. font-size: 28rpx;
  585. color: #303030;
  586. margin-bottom: 10rpx;
  587. overflow: hidden;
  588. text-overflow: ellipsis;
  589. white-space: nowrap;
  590. }
  591. .price-row {
  592. display: flex;
  593. align-items: baseline;
  594. margin-bottom: 12rpx;
  595. .currency {
  596. font-family: 'Source Han Sans SC';
  597. font-weight: 500;
  598. font-size: 22rpx;
  599. color: #D81A00;
  600. }
  601. .price-val {
  602. font-family: 'Source Han Sans SC';
  603. font-weight: 500;
  604. font-size: 28rpx;
  605. color: #D81A00;
  606. margin-right: 12rpx;
  607. }
  608. .price-old {
  609. font-family: 'Source Han Sans SC';
  610. font-weight: 500;
  611. font-size: 22rpx;
  612. color: #999999;
  613. text-decoration: line-through;
  614. }
  615. }
  616. .add-btn {
  617. width: fit-content;
  618. height: 36rpx;
  619. line-height: 36rpx;
  620. background: linear-gradient(0deg, #4ED964 0%, #4ED964 100%);
  621. border-radius: 18rpx;
  622. padding: 0 20rpx;
  623. display: flex;
  624. align-items: center;
  625. justify-content: center;
  626. text {
  627. font-size: 22rpx;
  628. color: #fff;
  629. }
  630. .cart-symbol {
  631. width: 24rpx;
  632. height: 24rpx;
  633. margin-left: 6rpx;
  634. }
  635. }
  636. }
  637. }
  638. }
  639. .bottom-safe-area {
  640. height: 30rpx
  641. }
  642. </style>