index.vue 16 KB

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