index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. <!-- 底部留白,防止遮挡 -->
  126. <view class="bottom-safe-area"></view>
  127. </view>
  128. </view>
  129. </template>
  130. <script>
  131. export default {
  132. name: 'SellContainer',
  133. data() {
  134. return {
  135. barStyle: {
  136. backgroundColor: 'transparent',
  137. background: "url('/pages-sell/static/tab-selected.png') no-repeat center",
  138. backgroundSize: '100% 100%',
  139. position: 'relative',
  140. top: '-6rpx',
  141. },
  142. swiperList: [
  143. {
  144. image: '/pages-sell/static/banner-3.png'
  145. },
  146. {
  147. image: '/pages-sell/static/banner-1.png'
  148. },
  149. {
  150. image: '/pages-sell/static/banner-2.png'
  151. }
  152. ],
  153. statusBarHeight: 20,
  154. keyword: '',
  155. // u-tabs 需要对象数组 [{name: 'xxx'}]
  156. hotTagList: [
  157. { name: '热搜' },
  158. { name: '励志' },
  159. { name: '绘本' },
  160. { name: '诺贝尔文学奖' },
  161. { name: '茅盾奖' },
  162. { name: '童书' }
  163. ],
  164. currentHotTag: 0,
  165. // 临时的网络书封面图片
  166. bookCoverUrl: 'https://img.yzcdn.cn/vant/cat.jpeg',
  167. categoryList: [
  168. { name: '热销榜单', icon: '/pages-sell/static/icon-hot-sales.png' },
  169. { name: '心灵 / 成长', icon: '/pages-sell/static/icon-heart-growth.png' },
  170. { name: '诺贝尔文学奖', icon: '/pages-sell/static/icon-nobel.png' },
  171. { name: '茅盾文学奖', icon: '/pages-sell/static/icon-maodun.png' },
  172. { name: '樊登书单', icon: '/pages-sell/static/icon-fandeng.png' },
  173. { name: '东野圭吾', icon: '/pages-sell/static/icon-dongye.png' },
  174. { name: '余华', icon: '/pages-sell/static/icon-yuhua.png' },
  175. { name: '村上春树', icon: '/pages-sell/static/icon-haruki.png' },
  176. { name: '童书', icon: '/pages-sell/static/icon-children.png' },
  177. { name: '书嗨推荐', icon: '/pages-sell/static/icon-recommend.png' }
  178. ],
  179. recommendBooks: [
  180. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  181. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  182. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' }
  183. ]
  184. }
  185. },
  186. created() {
  187. const systemInfo = uni.getSystemInfoSync();
  188. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  189. },
  190. methods: {
  191. handleCategory(item) {
  192. console.log('点击分类:', item.name);
  193. },
  194. changeHotTag(index) {
  195. this.currentHotTag = index;
  196. console.log('切换标签:', index);
  197. },
  198. //跳转 URL
  199. navigateTo(url) {
  200. uni.navigateTo({
  201. url: url
  202. });
  203. },
  204. goRecommend() {
  205. uni.navigateTo({
  206. url: '/pages-sell/pages/recommend'
  207. });
  208. },
  209. goHotSell() {
  210. uni.navigateTo({
  211. url: '/pages-sell/pages/hot-sell'
  212. });
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .sell-container {
  219. position: relative;
  220. min-height: 100vh;
  221. background-color: #F6F6F6;
  222. overflow-x: hidden;
  223. }
  224. /* 顶部大背景图 */
  225. .top-bg-image {
  226. position: absolute;
  227. top: 0;
  228. left: 0;
  229. width: 100%;
  230. z-index: 0;
  231. display: block;
  232. }
  233. /* 导航栏 */
  234. .custom-navbar {
  235. position: fixed;
  236. top: 0;
  237. left: 0;
  238. width: 100%;
  239. z-index: 100;
  240. display: flex;
  241. align-items: center;
  242. justify-content: center;
  243. .navbar-content {
  244. height: 44px;
  245. width: 100%;
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. position: relative;
  250. .navbar-title {
  251. color: #fff;
  252. font-size: 36rpx;
  253. font-weight: 600;
  254. }
  255. }
  256. }
  257. .main-content {
  258. position: relative;
  259. z-index: 1;
  260. padding: 0 24rpx;
  261. }
  262. /* 搜索框 */
  263. .search-wrapper {
  264. margin-top: 10rpx;
  265. margin-bottom: 20rpx;
  266. .search-box-uview {
  267. height: 80rpx;
  268. background-color: #fff;
  269. border-radius: 40rpx;
  270. display: flex;
  271. align-items: center;
  272. padding: 0 10rpx 0 16rpx;
  273. position: relative;
  274. /* 覆盖 u-search 的 padding 以适配 */
  275. ::v-deep .u-search {
  276. flex: 1;
  277. /* 让输入框不遮挡右侧按钮 */
  278. padding-right: 140rpx !important;
  279. }
  280. .search-btn-overlay {
  281. position: absolute;
  282. right: 8rpx;
  283. top: 50%;
  284. transform: translateY(-50%);
  285. width: 140rpx;
  286. height: 64rpx;
  287. background: linear-gradient(0deg, #37C148 0%, #6ADD83 100%);
  288. border-radius: 32rpx;
  289. display: flex;
  290. align-items: center;
  291. justify-content: center;
  292. z-index: 2;
  293. text {
  294. color: #fff;
  295. font-size: 28rpx;
  296. font-weight: 500;
  297. }
  298. }
  299. }
  300. }
  301. /* 顶部横幅 */
  302. .top-banner-wrapper {
  303. width: 100%;
  304. margin-bottom: 30rpx;
  305. position: relative;
  306. .top-banner-img {
  307. width: 100%;
  308. border-radius: 40rpx;
  309. display: block;
  310. }
  311. }
  312. /* 分类图标 */
  313. .category-grid {
  314. display: flex;
  315. flex-wrap: wrap;
  316. margin-bottom: 10rpx;
  317. .grid-item {
  318. width: 20%;
  319. display: flex;
  320. flex-direction: column;
  321. align-items: center;
  322. margin-bottom: 30rpx;
  323. .icon-circle {
  324. width: 96rpx;
  325. height: 96rpx;
  326. display: flex;
  327. align-items: center;
  328. justify-content: center;
  329. margin-bottom: 12rpx;
  330. .cat-icon {
  331. width: 100%;
  332. height: 100%;
  333. }
  334. }
  335. .cat-name {
  336. font-size: 24rpx;
  337. color: #333;
  338. font-weight: 500;
  339. }
  340. }
  341. }
  342. /* 推广双卡片 */
  343. .promo-dual-card {
  344. display: flex;
  345. justify-content: space-between;
  346. margin-bottom: 24rpx;
  347. .card-left {
  348. width: 48%;
  349. height: 252rpx;
  350. border-radius: 20rpx;
  351. position: relative;
  352. overflow: hidden;
  353. }
  354. .card-right {
  355. width: 48%;
  356. height: 252rpx;
  357. /* Updated background per request */
  358. background: linear-gradient(to bottom, #FFD7C3 0%, #FFFFFF 32%);
  359. border-radius: 20rpx;
  360. padding: 20rpx;
  361. box-sizing: border-box;
  362. .right-header {
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. margin-bottom: 20rpx;
  367. .right-title {
  368. font-size: 30rpx;
  369. font-weight: bold;
  370. color: #333;
  371. margin: 0 10rpx;
  372. }
  373. .fire-icon {
  374. width: 30rpx;
  375. height: 30rpx;
  376. }
  377. .flip {
  378. transform: scaleX(-1);
  379. }
  380. }
  381. .products-container {
  382. display: flex;
  383. justify-content: space-between;
  384. gap: 20rpx;
  385. .product-cover {
  386. flex: 1;
  387. height: 160rpx;
  388. border-radius: 12rpx;
  389. background-color: #f0f0f0;
  390. }
  391. }
  392. }
  393. }
  394. /* 信息双卡片 */
  395. .info-dual-card {
  396. display: flex;
  397. justify-content: space-between;
  398. margin-bottom: 24rpx;
  399. .info-card {
  400. width: 48%;
  401. padding: 24rpx;
  402. border-radius: 12px;
  403. /* Updated radius */
  404. display: flex;
  405. justify-content: space-between;
  406. align-items: center;
  407. height: 140rpx;
  408. box-sizing: border-box;
  409. position: relative;
  410. /* For absolute icon */
  411. overflow: hidden;
  412. &.bg-orange {
  413. background: #FFF3E0;
  414. border: 1px solid #FFB72A;
  415. }
  416. &.bg-green {
  417. background: #D4F1D8;
  418. border: 1px solid #54A94E;
  419. }
  420. .info-text-group {
  421. flex: 1;
  422. z-index: 1;
  423. /* Ensure text is above */
  424. .info-title {
  425. font-size: 28rpx;
  426. font-weight: bold;
  427. display: block;
  428. margin-bottom: 6rpx;
  429. }
  430. .info-desc {
  431. font-size: 22rpx;
  432. line-height: 1.2;
  433. }
  434. .text-orange {
  435. color: #DB832D;
  436. }
  437. .text-orange-light {
  438. color: #DB832D;
  439. }
  440. .text-green {
  441. color: #1F8049;
  442. }
  443. .text-green-light {
  444. color: #1F8049;
  445. }
  446. }
  447. .info-icon {
  448. width: 100rpx;
  449. /* Slightly larger maybe */
  450. height: 100rpx;
  451. position: absolute;
  452. right: 0;
  453. bottom: 0;
  454. z-index: 0;
  455. opacity: 0.8;
  456. }
  457. }
  458. }
  459. /* 公众号 */
  460. .gzh-section {
  461. margin-bottom: 30rpx;
  462. height: 180rpx;
  463. /* Fixed height for consistency */
  464. border-radius: 20rpx;
  465. overflow: hidden;
  466. .gzh-bg-wrapper {
  467. width: 100%;
  468. height: 100%;
  469. position: relative;
  470. .gzh-img-bg {
  471. width: 100%;
  472. height: 100%;
  473. position: absolute;
  474. top: 0;
  475. left: 0;
  476. }
  477. .gzh-content-overlay {
  478. position: absolute;
  479. top: 0;
  480. left: 0;
  481. width: 60%;
  482. /* Only cover left side */
  483. height: 100%;
  484. padding: 30rpx;
  485. display: flex;
  486. flex-direction: column;
  487. justify-content: center;
  488. .gzh-title {
  489. font-size: 32rpx;
  490. font-weight: bold;
  491. color: #134E13;
  492. /* Dark green */
  493. margin-bottom: 16rpx;
  494. }
  495. .gzh-subtitle-pill {
  496. background: #FFF;
  497. border-radius: 24rpx;
  498. padding: 0 14rpx;
  499. line-height: 1.4;
  500. align-self: flex-start;
  501. .gzh-subtitle {
  502. font-size: 22rpx;
  503. color: #134E13;
  504. font-weight: 500;
  505. }
  506. }
  507. }
  508. }
  509. }
  510. /* 书嗨推荐 */
  511. .recommend-section {
  512. background-color: #fff;
  513. border-radius: 20rpx;
  514. padding: 30rpx;
  515. .section-header {
  516. display: flex;
  517. justify-content: space-between;
  518. align-items: center;
  519. margin-bottom: 24rpx;
  520. .section-title {
  521. font-size: 32rpx;
  522. font-weight: bold;
  523. color: #333;
  524. }
  525. .view-more {
  526. display: flex;
  527. align-items: center;
  528. font-size: 24rpx;
  529. color: #8D8D8D;
  530. .arrow-icon {
  531. width: 12rpx;
  532. margin-left: 6rpx;
  533. }
  534. }
  535. }
  536. .book-scroll {
  537. width: 100%;
  538. white-space: nowrap;
  539. .book-list {
  540. display: flex;
  541. padding-bottom: 10rpx;
  542. }
  543. .book-item {
  544. width: 200rpx;
  545. margin-right: 24rpx;
  546. display: flex;
  547. flex-direction: column;
  548. .book-image {
  549. width: 200rpx;
  550. height: 255rpx;
  551. border-radius: 2rpx;
  552. margin-bottom: 16rpx;
  553. background-color: #f9f9f9;
  554. }
  555. .book-name {
  556. font-family: 'Source Han Sans SC';
  557. font-weight: bold;
  558. font-size: 28rpx;
  559. color: #303030;
  560. margin-bottom: 10rpx;
  561. overflow: hidden;
  562. text-overflow: ellipsis;
  563. white-space: nowrap;
  564. }
  565. .price-row {
  566. display: flex;
  567. align-items: baseline;
  568. margin-bottom: 12rpx;
  569. .currency {
  570. font-family: 'Source Han Sans SC';
  571. font-weight: 500;
  572. font-size: 22rpx;
  573. color: #D81A00;
  574. }
  575. .price-val {
  576. font-family: 'Source Han Sans SC';
  577. font-weight: 500;
  578. font-size: 28rpx;
  579. color: #D81A00;
  580. margin-right: 12rpx;
  581. }
  582. .price-old {
  583. font-family: 'Source Han Sans SC';
  584. font-weight: 500;
  585. font-size: 22rpx;
  586. color: #999999;
  587. text-decoration: line-through;
  588. }
  589. }
  590. .add-btn {
  591. width: fit-content;
  592. height: 36rpx;
  593. line-height: 36rpx;
  594. background: linear-gradient(0deg, #4ED964 0%, #4ED964 100%);
  595. border-radius: 18rpx;
  596. padding: 0 20rpx;
  597. display: flex;
  598. align-items: center;
  599. justify-content: center;
  600. text {
  601. font-size: 22rpx;
  602. color: #fff;
  603. }
  604. .cart-symbol {
  605. width: 24rpx;
  606. height: 24rpx;
  607. margin-left: 6rpx;
  608. }
  609. }
  610. }
  611. }
  612. }
  613. .bottom-safe-area {
  614. height: 30rpx
  615. }
  616. </style>