index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  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" @click="goHotSell">
  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. goHotSell() {
  191. uni.navigateTo({
  192. url: '/pages-sell/pages/hot-sell'
  193. });
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. .sell-container {
  200. position: relative;
  201. min-height: 100vh;
  202. background-color: #F6F6F6;
  203. overflow-x: hidden;
  204. }
  205. /* 顶部大背景图 */
  206. .top-bg-image {
  207. position: absolute;
  208. top: 0;
  209. left: 0;
  210. width: 100%;
  211. z-index: 0;
  212. display: block;
  213. }
  214. /* 导航栏 */
  215. .custom-navbar {
  216. position: fixed;
  217. top: 0;
  218. left: 0;
  219. width: 100%;
  220. z-index: 100;
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. .navbar-content {
  225. height: 44px;
  226. width: 100%;
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. position: relative;
  231. .navbar-title {
  232. color: #fff;
  233. font-size: 36rpx;
  234. font-weight: 600;
  235. }
  236. }
  237. }
  238. .main-content {
  239. position: relative;
  240. z-index: 1;
  241. padding: 0 24rpx;
  242. }
  243. /* 搜索框 */
  244. .search-wrapper {
  245. margin-top: 10rpx;
  246. margin-bottom: 20rpx;
  247. .search-box-uview {
  248. height: 80rpx;
  249. background-color: #fff;
  250. border-radius: 40rpx;
  251. display: flex;
  252. align-items: center;
  253. padding: 0 10rpx 0 16rpx;
  254. position: relative;
  255. /* 覆盖 u-search 的 padding 以适配 */
  256. ::v-deep .u-search {
  257. flex: 1;
  258. /* 让输入框不遮挡右侧按钮 */
  259. padding-right: 140rpx !important;
  260. }
  261. .search-btn-overlay {
  262. position: absolute;
  263. right: 8rpx;
  264. top: 50%;
  265. transform: translateY(-50%);
  266. width: 140rpx;
  267. height: 64rpx;
  268. background: linear-gradient(0deg, #37C148 0%, #6ADD83 100%);
  269. border-radius: 32rpx;
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. z-index: 2;
  274. text {
  275. color: #fff;
  276. font-size: 28rpx;
  277. font-weight: 500;
  278. }
  279. }
  280. }
  281. }
  282. /* 顶部横幅 */
  283. .top-banner-wrapper {
  284. width: 100%;
  285. margin-bottom: 30rpx;
  286. position: relative;
  287. .top-banner-img {
  288. width: 100%;
  289. border-radius: 40rpx;
  290. display: block;
  291. }
  292. }
  293. /* 分类图标 */
  294. .category-grid {
  295. display: flex;
  296. flex-wrap: wrap;
  297. margin-bottom: 10rpx;
  298. .grid-item {
  299. width: 20%;
  300. display: flex;
  301. flex-direction: column;
  302. align-items: center;
  303. margin-bottom: 30rpx;
  304. .icon-circle {
  305. width: 96rpx;
  306. height: 96rpx;
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. margin-bottom: 12rpx;
  311. .cat-icon {
  312. width: 100%;
  313. height: 100%;
  314. }
  315. }
  316. .cat-name {
  317. font-size: 24rpx;
  318. color: #333;
  319. font-weight: 500;
  320. }
  321. }
  322. }
  323. /* 推广双卡片 */
  324. .promo-dual-card {
  325. display: flex;
  326. justify-content: space-between;
  327. margin-bottom: 24rpx;
  328. .card-left {
  329. width: 48%;
  330. height: 252rpx;
  331. background: linear-gradient(135deg, #FFECC8, #FFE0B2);
  332. border-radius: 20rpx;
  333. position: relative;
  334. overflow: hidden;
  335. .card-content {
  336. padding: 30rpx 24rpx;
  337. /* Increased top/bottom padding as requested */
  338. .card-title-lg {
  339. font-size: 26rpx;
  340. color: #E68A00;
  341. font-weight: bold;
  342. display: block;
  343. margin-bottom: 8rpx;
  344. }
  345. .card-subtitle-lg {
  346. font-size: 24rpx;
  347. color: #FFA000;
  348. font-weight: 500;
  349. }
  350. .promo-decoration {
  351. position: absolute;
  352. bottom: 0;
  353. left: 0;
  354. width: 100%;
  355. display: block;
  356. }
  357. }
  358. }
  359. .card-right {
  360. width: 48%;
  361. height: 252rpx;
  362. /* Updated background per request */
  363. background: linear-gradient(to bottom, #FFD7C3 0%, #FFFFFF 32%);
  364. border-radius: 20rpx;
  365. padding: 20rpx;
  366. box-sizing: border-box;
  367. .right-header {
  368. display: flex;
  369. align-items: center;
  370. justify-content: center;
  371. margin-bottom: 20rpx;
  372. .right-title {
  373. font-size: 30rpx;
  374. font-weight: bold;
  375. color: #333;
  376. margin: 0 10rpx;
  377. }
  378. .fire-icon {
  379. width: 30rpx;
  380. height: 30rpx;
  381. }
  382. .flip {
  383. transform: scaleX(-1);
  384. }
  385. }
  386. .products-container {
  387. display: flex;
  388. justify-content: space-between;
  389. gap: 20rpx;
  390. .product-cover {
  391. flex: 1;
  392. height: 160rpx;
  393. border-radius: 12rpx;
  394. background-color: #f0f0f0;
  395. }
  396. }
  397. }
  398. }
  399. /* 信息双卡片 */
  400. .info-dual-card {
  401. display: flex;
  402. justify-content: space-between;
  403. margin-bottom: 24rpx;
  404. .info-card {
  405. width: 48%;
  406. padding: 24rpx;
  407. border-radius: 12px;
  408. /* Updated radius */
  409. display: flex;
  410. justify-content: space-between;
  411. align-items: center;
  412. height: 140rpx;
  413. box-sizing: border-box;
  414. position: relative;
  415. /* For absolute icon */
  416. overflow: hidden;
  417. &.bg-orange {
  418. background: #FFF3E0;
  419. border: 1px solid #FFB72A;
  420. }
  421. &.bg-green {
  422. background: #D4F1D8;
  423. border: 1px solid #54A94E;
  424. }
  425. .info-text-group {
  426. flex: 1;
  427. z-index: 1;
  428. /* Ensure text is above */
  429. .info-title {
  430. font-size: 28rpx;
  431. font-weight: bold;
  432. display: block;
  433. margin-bottom: 6rpx;
  434. }
  435. .info-desc {
  436. font-size: 22rpx;
  437. line-height: 1.2;
  438. }
  439. .text-orange {
  440. color: #DB832D;
  441. }
  442. .text-orange-light {
  443. color: #DB832D;
  444. }
  445. .text-green {
  446. color: #1F8049;
  447. }
  448. .text-green-light {
  449. color: #1F8049;
  450. }
  451. }
  452. .info-icon {
  453. width: 100rpx;
  454. /* Slightly larger maybe */
  455. height: 100rpx;
  456. position: absolute;
  457. right: 0;
  458. bottom: 0;
  459. z-index: 0;
  460. opacity: 0.8;
  461. }
  462. }
  463. }
  464. /* 公众号 */
  465. .gzh-section {
  466. margin-bottom: 30rpx;
  467. height: 180rpx;
  468. /* Fixed height for consistency */
  469. border-radius: 20rpx;
  470. overflow: hidden;
  471. .gzh-bg-wrapper {
  472. width: 100%;
  473. height: 100%;
  474. position: relative;
  475. .gzh-img-bg {
  476. width: 100%;
  477. height: 100%;
  478. position: absolute;
  479. top: 0;
  480. left: 0;
  481. }
  482. .gzh-content-overlay {
  483. position: absolute;
  484. top: 0;
  485. left: 0;
  486. width: 60%;
  487. /* Only cover left side */
  488. height: 100%;
  489. padding: 30rpx;
  490. display: flex;
  491. flex-direction: column;
  492. justify-content: center;
  493. .gzh-title {
  494. font-size: 32rpx;
  495. font-weight: bold;
  496. color: #134E13;
  497. /* Dark green */
  498. margin-bottom: 16rpx;
  499. }
  500. .gzh-subtitle-pill {
  501. background: #FFF;
  502. border-radius: 24rpx;
  503. padding: 0 14rpx;
  504. line-height: 1.4;
  505. align-self: flex-start;
  506. .gzh-subtitle {
  507. font-size: 22rpx;
  508. color: #134E13;
  509. font-weight: 500;
  510. }
  511. }
  512. }
  513. }
  514. }
  515. /* 书嗨推荐 */
  516. .recommend-section {
  517. background-color: #fff;
  518. border-radius: 20rpx;
  519. padding: 30rpx;
  520. .section-header {
  521. display: flex;
  522. justify-content: space-between;
  523. align-items: center;
  524. margin-bottom: 24rpx;
  525. .section-title {
  526. font-size: 32rpx;
  527. font-weight: bold;
  528. color: #333;
  529. }
  530. .view-more {
  531. display: flex;
  532. align-items: center;
  533. font-size: 24rpx;
  534. color: #8D8D8D;
  535. .arrow-icon {
  536. width: 12rpx;
  537. margin-left: 6rpx;
  538. }
  539. }
  540. }
  541. .book-scroll {
  542. width: 100%;
  543. white-space: nowrap;
  544. .book-list {
  545. display: flex;
  546. padding-bottom: 10rpx;
  547. }
  548. .book-item {
  549. width: 200rpx;
  550. margin-right: 24rpx;
  551. display: flex;
  552. flex-direction: column;
  553. .book-image {
  554. width: 200rpx;
  555. height: 255rpx;
  556. border-radius: 2rpx;
  557. margin-bottom: 16rpx;
  558. background-color: #f9f9f9;
  559. }
  560. .book-name {
  561. font-family: 'Source Han Sans SC';
  562. font-weight: bold;
  563. font-size: 28rpx;
  564. color: #303030;
  565. margin-bottom: 10rpx;
  566. overflow: hidden;
  567. text-overflow: ellipsis;
  568. white-space: nowrap;
  569. }
  570. .price-row {
  571. display: flex;
  572. align-items: baseline;
  573. margin-bottom: 12rpx;
  574. .currency {
  575. font-family: 'Source Han Sans SC';
  576. font-weight: 500;
  577. font-size: 22rpx;
  578. color: #D81A00;
  579. }
  580. .price-val {
  581. font-family: 'Source Han Sans SC';
  582. font-weight: 500;
  583. font-size: 28rpx;
  584. color: #D81A00;
  585. margin-right: 12rpx;
  586. }
  587. .price-old {
  588. font-family: 'Source Han Sans SC';
  589. font-weight: 500;
  590. font-size: 22rpx;
  591. color: #999999;
  592. text-decoration: line-through;
  593. }
  594. }
  595. .add-btn {
  596. width: fit-content;
  597. height: 36rpx;
  598. line-height: 36rpx;
  599. background: linear-gradient(0deg, #4ED964 0%, #4ED964 100%);
  600. border-radius: 18rpx;
  601. padding: 0 20rpx;
  602. display: flex;
  603. align-items: center;
  604. justify-content: center;
  605. text {
  606. font-size: 22rpx;
  607. color: #fff;
  608. }
  609. .cart-symbol {
  610. width: 24rpx;
  611. height: 24rpx;
  612. margin-left: 6rpx;
  613. }
  614. }
  615. }
  616. }
  617. }
  618. .bottom-safe-area {
  619. height: 30rpx
  620. }
  621. </style>