index.vue 17 KB

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