index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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">
  17. <view class="search-box-uview">
  18. <u-search placeholder="搜索关键字" :show-action="false" bg-color="transparent" height="40"
  19. :clearabled="true" v-model="keyword"
  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. <text class="card-title-lg">推广卖书买书都有提成啦</text>
  52. <text class="card-subtitle-lg">10% 收益等你拿</text>
  53. <!-- 装饰图 -->
  54. <image src="/pages-sell/static/tgtc.png" class="promo-decoration" mode="widthFix"></image>
  55. </view>
  56. </view>
  57. <!-- 右侧:热销商品 -->
  58. <view class="card-right">
  59. <view class="right-header">
  60. <image src="/pages-sell/static/icon-fire.png" class="fire-icon" mode="widthFix"></image>
  61. <text class="right-title">热销商品</text>
  62. <image src="/pages-sell/static/icon-fire.png" class="fire-icon flip" mode="widthFix"></image>
  63. </view>
  64. <view class="products-container">
  65. <!-- 使用网络图片作为书的封面占位 -->
  66. <image :src="bookCoverUrl" class="product-cover" mode="aspectFill"></image>
  67. <image :src="bookCoverUrl" class="product-cover" mode="aspectFill"></image>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 健康与成长双卡片 -->
  72. <view class="info-dual-card">
  73. <view class="info-card bg-orange">
  74. <view class="info-text-group">
  75. <text class="info-title text-orange">健康与身材</text>
  76. <text class="info-desc text-orange-light">和身体和解科学管理状态</text>
  77. </view>
  78. <image src="/pages-sell/static/shape-19.png" class="info-icon" mode="aspectFit"
  79. style="width: 125rpx;height: 111rpx;"></image>
  80. </view>
  81. <view class="info-card bg-green">
  82. <view class="info-text-group">
  83. <text class="info-title text-green">成长与心态</text>
  84. <text class="info-desc text-green-light">拥有持续进步的动力和抗挫力</text>
  85. </view>
  86. <image src="/pages-sell/static/shape-20.png" class="info-icon" mode="aspectFit"></image>
  87. </view>
  88. </view>
  89. <!-- 公众号横幅 -->
  90. <view class="gzh-section">
  91. <view class="gzh-bg-wrapper">
  92. <image src="/pages-sell/static/gzh-banner.png" class="gzh-img-bg" mode="aspectFill"></image>
  93. <view class="gzh-content-overlay">
  94. <text class="gzh-title">关注公众号 ,定期领红包</text>
  95. <view class="gzh-subtitle-pill">
  96. <text class="gzh-subtitle">别让好书蒙尘 ,书嗨陪你逐页品读</text>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <!-- 书嗨推荐 -->
  102. <view class="recommend-section">
  103. <view class="section-header">
  104. <text class="section-title">书嗨推荐</text>
  105. <view class="view-more">
  106. <text>查看全部</text>
  107. <image src="/pages-sell/static/right-arrow.png" class="arrow-icon" mode="widthFix"></image>
  108. </view>
  109. </view>
  110. <scroll-view scroll-x class="book-scroll" :show-scrollbar="false">
  111. <view class="book-list">
  112. <view class="book-item" v-for="(book, index) in recommendBooks" :key="index">
  113. <image :src="book.cover" class="book-image" mode="aspectFill"></image>
  114. <text class="book-name">{{ book.title }}</text>
  115. <view class="price-row">
  116. <text class="currency">¥</text>
  117. <text class="price-val">{{ book.price }}</text>
  118. <text class="price-old">¥{{ book.original }}</text>
  119. </view>
  120. <view class="add-btn">
  121. <text>加入购物车</text>
  122. <image src="/pages-sell/static/shape-10.png" class="cart-symbol"></image>
  123. </view>
  124. </view>
  125. </view>
  126. </scroll-view>
  127. </view>
  128. <!-- 底部留白,防止遮挡 -->
  129. <view class="bottom-safe-area"></view>
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. export default {
  135. name: 'SellContainer',
  136. data() {
  137. return {
  138. barStyle: {
  139. backgroundColor: 'transparent',
  140. background: "url('/pages-sell/static/tab-selected.png') no-repeat center",
  141. backgroundSize: '100% 100%',
  142. position: 'relative',
  143. top: '-6rpx',
  144. },
  145. statusBarHeight: 20,
  146. keyword: '',
  147. // u-tabs 需要对象数组 [{name: 'xxx'}]
  148. hotTagList: [
  149. { name: '热搜' },
  150. { name: '励志' },
  151. { name: '绘本' },
  152. { name: '诺贝尔文学奖' },
  153. { name: '茅盾奖' },
  154. { name: '童书' }
  155. ],
  156. currentHotTag: 0,
  157. // 临时的网络书封面图片
  158. bookCoverUrl: 'https://img.yzcdn.cn/vant/cat.jpeg',
  159. categoryList: [
  160. { name: '热销榜单', icon: '/pages-sell/static/icon-hot-sales.png' },
  161. { name: '心灵 / 成长', icon: '/pages-sell/static/icon-heart-growth.png' },
  162. { name: '诺贝尔文学奖', icon: '/pages-sell/static/icon-nobel.png' },
  163. { name: '茅盾文学奖', icon: '/pages-sell/static/icon-maodun.png' },
  164. { name: '樊登书单', icon: '/pages-sell/static/icon-fandeng.png' },
  165. { name: '东野圭吾', icon: '/pages-sell/static/icon-dongye.png' },
  166. { name: '余华', icon: '/pages-sell/static/icon-yuhua.png' },
  167. { name: '村上春树', icon: '/pages-sell/static/icon-haruki.png' },
  168. { name: '童书', icon: '/pages-sell/static/icon-children.png' },
  169. { name: '书嗨推荐', icon: '/pages-sell/static/icon-recommend.png' }
  170. ],
  171. recommendBooks: [
  172. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  173. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  174. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' }
  175. ]
  176. }
  177. },
  178. created() {
  179. const systemInfo = uni.getSystemInfoSync();
  180. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  181. },
  182. methods: {
  183. handleCategory(item) {
  184. console.log('点击分类:', item.name);
  185. },
  186. changeHotTag(index) {
  187. this.currentHotTag = index;
  188. console.log('切换标签:', index);
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. .sell-container {
  195. position: relative;
  196. min-height: 100vh;
  197. background-color: #F6F6F6;
  198. overflow-x: hidden;
  199. }
  200. /* 顶部大背景图 */
  201. .top-bg-image {
  202. position: absolute;
  203. top: 0;
  204. left: 0;
  205. width: 100%;
  206. z-index: 0;
  207. display: block;
  208. }
  209. /* 导航栏 */
  210. .custom-navbar {
  211. position: fixed;
  212. top: 0;
  213. left: 0;
  214. width: 100%;
  215. z-index: 100;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. .navbar-content {
  220. height: 44px;
  221. width: 100%;
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. position: relative;
  226. .navbar-title {
  227. color: #fff;
  228. font-size: 36rpx;
  229. font-weight: 600;
  230. }
  231. }
  232. }
  233. .main-content {
  234. position: relative;
  235. z-index: 1;
  236. padding: 0 24rpx;
  237. }
  238. /* 搜索框 */
  239. .search-wrapper {
  240. margin-top: 10rpx;
  241. margin-bottom: 20rpx;
  242. .search-box-uview {
  243. height: 80rpx;
  244. background-color: #fff;
  245. border-radius: 40rpx;
  246. display: flex;
  247. align-items: center;
  248. padding: 0 10rpx 0 16rpx;
  249. position: relative;
  250. /* 覆盖 u-search 的 padding 以适配 */
  251. ::v-deep .u-search {
  252. flex: 1;
  253. /* 让输入框不遮挡右侧按钮 */
  254. padding-right: 140rpx !important;
  255. }
  256. .search-btn-overlay {
  257. position: absolute;
  258. right: 8rpx;
  259. top: 50%;
  260. transform: translateY(-50%);
  261. width: 140rpx;
  262. height: 64rpx;
  263. background: linear-gradient(0deg, #37C148 0%, #6ADD83 100%);
  264. border-radius: 32rpx;
  265. display: flex;
  266. align-items: center;
  267. justify-content: center;
  268. z-index: 2;
  269. text {
  270. color: #fff;
  271. font-size: 28rpx;
  272. font-weight: 500;
  273. }
  274. }
  275. }
  276. }
  277. /* 顶部横幅 */
  278. .top-banner-wrapper {
  279. width: 100%;
  280. margin-bottom: 30rpx;
  281. position: relative;
  282. .top-banner-img {
  283. width: 100%;
  284. border-radius: 40rpx;
  285. display: block;
  286. }
  287. }
  288. /* 分类图标 */
  289. .category-grid {
  290. display: flex;
  291. flex-wrap: wrap;
  292. margin-bottom: 10rpx;
  293. .grid-item {
  294. width: 20%;
  295. display: flex;
  296. flex-direction: column;
  297. align-items: center;
  298. margin-bottom: 30rpx;
  299. .icon-circle {
  300. width: 96rpx;
  301. height: 96rpx;
  302. display: flex;
  303. align-items: center;
  304. justify-content: center;
  305. margin-bottom: 12rpx;
  306. .cat-icon {
  307. width: 100%;
  308. height: 100%;
  309. }
  310. }
  311. .cat-name {
  312. font-size: 24rpx;
  313. color: #333;
  314. font-weight: 500;
  315. }
  316. }
  317. }
  318. /* 推广双卡片 */
  319. .promo-dual-card {
  320. display: flex;
  321. justify-content: space-between;
  322. margin-bottom: 24rpx;
  323. .card-left {
  324. width: 48%;
  325. height: 252rpx;
  326. background: linear-gradient(135deg, #FFECC8, #FFE0B2);
  327. border-radius: 20rpx;
  328. position: relative;
  329. overflow: hidden;
  330. .card-content {
  331. padding: 30rpx 24rpx;
  332. /* Increased top/bottom padding as requested */
  333. .card-title-lg {
  334. font-size: 26rpx;
  335. color: #E68A00;
  336. font-weight: bold;
  337. display: block;
  338. margin-bottom: 8rpx;
  339. }
  340. .card-subtitle-lg {
  341. font-size: 24rpx;
  342. color: #FFA000;
  343. font-weight: 500;
  344. }
  345. .promo-decoration {
  346. position: absolute;
  347. bottom: 0;
  348. left: 0;
  349. width: 100%;
  350. display: block;
  351. }
  352. }
  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>