index.vue 16 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" @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.imgUrl" class="cat-icon" mode="aspectFit"></image>
  42. </view>
  43. <text class="cat-name">{{ item.showCateName || '-' }}</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" :autoplay="true" :interval="3000" name="imgUrl"></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 v-for="(item, index) in bookList" :key="index" :src="item.imgUrl" class="product-cover" mode="aspectFill" @click="navigateTo(item.jumpUrl)"></image>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 健康与成长双卡片 -->
  68. <view class="info-dual-card">
  69. <view class="info-card bg-orange">
  70. <view class="info-text-group">
  71. <text class="info-title text-orange">健康与身材</text>
  72. <text class="info-desc text-orange-light">和身体和解科学管理状态</text>
  73. </view>
  74. <image src="/pages-sell/static/shape-19.png" class="info-icon" mode="aspectFit"
  75. style="width: 125rpx;height: 111rpx;"></image>
  76. </view>
  77. <view class="info-card bg-green">
  78. <view class="info-text-group">
  79. <text class="info-title text-green">成长与心态</text>
  80. <text class="info-desc text-green-light">拥有持续进步的动力和抗挫力</text>
  81. </view>
  82. <image src="/pages-sell/static/shape-20.png" class="info-icon" mode="aspectFit"></image>
  83. </view>
  84. </view>
  85. <!-- 公众号横幅 -->
  86. <view class="gzh-section">
  87. <view class="gzh-bg-wrapper">
  88. <image src="/pages-sell/static/gzh-banner.png" class="gzh-img-bg" mode="aspectFill"></image>
  89. <view class="gzh-content-overlay">
  90. <text class="gzh-title">关注公众号 ,定期领红包</text>
  91. <view class="gzh-subtitle-pill">
  92. <text class="gzh-subtitle">别让好书蒙尘 ,书嗨陪你逐页品读</text>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <!-- 书嗨推荐 -->
  98. <view class="recommend-section" @click="navigateTo(item.jumpUrl)" v-for="(item, index) in topicList" :key="index">
  99. <view class="section-header">
  100. <text class="section-title">书嗨推荐</text>
  101. <view class="view-more">
  102. <text>查看全部</text>
  103. <image src="/pages-sell/static/right-arrow.png" class="arrow-icon" mode="widthFix"></image>
  104. </view>
  105. </view>
  106. <view class="book-list">
  107. <view class="book-item" v-for="(book, index) in getDisplayBooks(item)" :key="index" @click="navigateTo('/pages-sell/pages/detail?isbn=' + book.bookIsbn)">
  108. <image :src="book.bookImg" class="book-image" mode="aspectFill"></image>
  109. <text class="book-name">{{ book.bookName }}</text>
  110. <view class="price-row">
  111. <text class="currency">¥</text>
  112. <text class="price-val">{{ book.bookPrice }}</text>
  113. <text class="price-old">¥{{ book.bookOriginalPrice }}</text>
  114. </view>
  115. <view class="add-btn">
  116. <text>加入购物车</text>
  117. <image src="/pages-sell/static/shape-10.png" class="cart-symbol"></image>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- 底部留白,防止遮挡 -->
  123. <view class="bottom-safe-area"></view>
  124. </view>
  125. </view>
  126. </template>
  127. <script>
  128. export default {
  129. name: 'SellContainer',
  130. data() {
  131. return {
  132. barStyle: {
  133. backgroundColor: 'transparent',
  134. background: "url('/pages-sell/static/tab-selected.png') no-repeat center",
  135. backgroundSize: '100% 100%',
  136. position: 'relative',
  137. top: '-6rpx',
  138. },
  139. swiperList: [],
  140. statusBarHeight: 20,
  141. keyword: '',
  142. // u-tabs 需要对象数组 [{name: 'xxx'}]
  143. hotTagList: [
  144. { name: '热搜' },
  145. { name: '励志' },
  146. { name: '绘本' },
  147. { name: '诺贝尔文学奖' },
  148. { name: '茅盾奖' },
  149. { name: '童书' }
  150. ],
  151. currentHotTag: 0,
  152. // 临时的网络书封面图片
  153. bookCoverUrl: 'https://img.yzcdn.cn/vant/cat.jpeg',
  154. categoryList: [], //金刚区
  155. bookList: [], // 右侧推荐书籍
  156. recommendBooks: [
  157. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  158. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  159. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' }
  160. ],
  161. topicList:[], //专题推荐
  162. }
  163. },
  164. created() {
  165. const systemInfo = uni.getSystemInfoSync();
  166. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  167. this.getIndexCateInfo()
  168. },
  169. methods: {
  170. handleCategory(item) {
  171. if(!item.jumpUrl) return
  172. this.navigateTo(item.jumpUrl)
  173. },
  174. changeHotTag(index) {
  175. this.currentHotTag = index;
  176. console.log('切换标签:', index);
  177. },
  178. //跳转 URL
  179. navigateTo(url) {
  180. if(!url) return
  181. console.log(url)
  182. uni.navigateTo({
  183. url: url
  184. });
  185. },
  186. goRecommend() {
  187. uni.navigateTo({
  188. url: '/pages-sell/pages/recommend'
  189. });
  190. },
  191. goHotSell() {
  192. uni.navigateTo({
  193. url: '/pages-sell/pages/hot-sell'
  194. });
  195. },
  196. //获取首页装修信息
  197. getIndexCateInfo() {
  198. uni.$u.http.get('/token/shop/showIndex/getIndexCateInfo').then(res => {
  199. console.log(res)
  200. if (res.code == 200) {
  201. console.log(res.data)
  202. this.categoryList = res.data.find(item => item.position == 'diamond_area')?.shopIndexCateVo || []
  203. this.swiperList = res.data.find(item => item.position == 'left_banner')?.shopIndexCateVo || []
  204. this.bookList = res.data.find(item => item.position == 'right_banner')?.shopIndexCateVo || []
  205. //获取专题推荐
  206. this.topicList = res.data.find(item => item.position == 'topic')?.shopIndexCateVo || []
  207. }
  208. })
  209. },
  210. getDisplayBooks(item) {
  211. if (!item.bookInfoList) return []
  212. let limit = 3
  213. if (item.positionType === 'double_row_topic') {
  214. limit = 6
  215. }
  216. return item.bookInfoList.slice(0, limit)
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss" scoped>
  222. .sell-container {
  223. position: relative;
  224. min-height: 100vh;
  225. background-color: #F6F6F6;
  226. overflow-x: hidden;
  227. }
  228. /* 顶部大背景图 */
  229. .top-bg-image {
  230. position: absolute;
  231. top: 0;
  232. left: 0;
  233. width: 100%;
  234. z-index: 0;
  235. display: block;
  236. }
  237. /* 导航栏 */
  238. .custom-navbar {
  239. position: fixed;
  240. top: 0;
  241. left: 0;
  242. width: 100%;
  243. z-index: 100;
  244. display: flex;
  245. align-items: center;
  246. justify-content: center;
  247. .navbar-content {
  248. height: 44px;
  249. width: 100%;
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. position: relative;
  254. .navbar-title {
  255. color: #fff;
  256. font-size: 36rpx;
  257. font-weight: 600;
  258. }
  259. }
  260. }
  261. .main-content {
  262. position: relative;
  263. z-index: 1;
  264. padding: 0 24rpx;
  265. }
  266. /* 搜索框 */
  267. .search-wrapper {
  268. margin-top: 10rpx;
  269. margin-bottom: 20rpx;
  270. .search-box-uview {
  271. height: 80rpx;
  272. background-color: #fff;
  273. border-radius: 40rpx;
  274. display: flex;
  275. align-items: center;
  276. padding: 0 10rpx 0 16rpx;
  277. position: relative;
  278. /* 覆盖 u-search 的 padding 以适配 */
  279. ::v-deep .u-search {
  280. flex: 1;
  281. /* 让输入框不遮挡右侧按钮 */
  282. padding-right: 140rpx !important;
  283. }
  284. .search-btn-overlay {
  285. position: absolute;
  286. right: 8rpx;
  287. top: 50%;
  288. transform: translateY(-50%);
  289. width: 140rpx;
  290. height: 64rpx;
  291. background: linear-gradient(0deg, #37C148 0%, #6ADD83 100%);
  292. border-radius: 32rpx;
  293. display: flex;
  294. align-items: center;
  295. justify-content: center;
  296. z-index: 2;
  297. text {
  298. color: #fff;
  299. font-size: 28rpx;
  300. font-weight: 500;
  301. }
  302. }
  303. }
  304. }
  305. /* 顶部横幅 */
  306. .top-banner-wrapper {
  307. width: 100%;
  308. margin-bottom: 30rpx;
  309. position: relative;
  310. .top-banner-img {
  311. width: 100%;
  312. border-radius: 40rpx;
  313. display: block;
  314. }
  315. }
  316. /* 分类图标 */
  317. .category-grid {
  318. display: flex;
  319. flex-wrap: wrap;
  320. margin-bottom: 10rpx;
  321. .grid-item {
  322. width: 20%;
  323. display: flex;
  324. flex-direction: column;
  325. align-items: center;
  326. margin-bottom: 30rpx;
  327. .icon-circle {
  328. width: 96rpx;
  329. height: 96rpx;
  330. display: flex;
  331. align-items: center;
  332. justify-content: center;
  333. margin-bottom: 12rpx;
  334. .cat-icon {
  335. width: 100%;
  336. height: 100%;
  337. }
  338. }
  339. .cat-name {
  340. font-size: 24rpx;
  341. color: #333;
  342. font-weight: 500;
  343. }
  344. }
  345. }
  346. /* 推广双卡片 */
  347. .promo-dual-card {
  348. display: flex;
  349. justify-content: space-between;
  350. margin-bottom: 24rpx;
  351. .card-left {
  352. width: 48%;
  353. height: 252rpx;
  354. border-radius: 20rpx;
  355. position: relative;
  356. overflow: hidden;
  357. }
  358. .card-right {
  359. width: 48%;
  360. height: 252rpx;
  361. /* Updated background per request */
  362. background: linear-gradient(to bottom, #FFD7C3 0%, #FFFFFF 32%);
  363. border-radius: 20rpx;
  364. padding: 20rpx;
  365. box-sizing: border-box;
  366. .right-header {
  367. display: flex;
  368. align-items: center;
  369. justify-content: center;
  370. margin-bottom: 20rpx;
  371. .right-title {
  372. font-size: 30rpx;
  373. font-weight: bold;
  374. color: #333;
  375. margin: 0 10rpx;
  376. }
  377. .fire-icon {
  378. width: 30rpx;
  379. height: 30rpx;
  380. }
  381. .flip {
  382. transform: scaleX(-1);
  383. }
  384. }
  385. .products-container {
  386. display: flex;
  387. justify-content: space-between;
  388. gap: 20rpx;
  389. .product-cover {
  390. flex: 1;
  391. height: 160rpx;
  392. border-radius: 12rpx;
  393. background-color: #f0f0f0;
  394. }
  395. }
  396. }
  397. }
  398. /* 信息双卡片 */
  399. .info-dual-card {
  400. display: flex;
  401. justify-content: space-between;
  402. margin-bottom: 24rpx;
  403. .info-card {
  404. width: 48%;
  405. padding: 24rpx;
  406. border-radius: 12px;
  407. /* Updated radius */
  408. display: flex;
  409. justify-content: space-between;
  410. align-items: center;
  411. height: 140rpx;
  412. box-sizing: border-box;
  413. position: relative;
  414. /* For absolute icon */
  415. overflow: hidden;
  416. &.bg-orange {
  417. background: #FFF3E0;
  418. border: 1px solid #FFB72A;
  419. }
  420. &.bg-green {
  421. background: #D4F1D8;
  422. border: 1px solid #54A94E;
  423. }
  424. .info-text-group {
  425. flex: 1;
  426. z-index: 1;
  427. /* Ensure text is above */
  428. .info-title {
  429. font-size: 28rpx;
  430. font-weight: bold;
  431. display: block;
  432. margin-bottom: 6rpx;
  433. }
  434. .info-desc {
  435. font-size: 22rpx;
  436. line-height: 1.2;
  437. }
  438. .text-orange {
  439. color: #DB832D;
  440. }
  441. .text-orange-light {
  442. color: #DB832D;
  443. }
  444. .text-green {
  445. color: #1F8049;
  446. }
  447. .text-green-light {
  448. color: #1F8049;
  449. }
  450. }
  451. .info-icon {
  452. width: 100rpx;
  453. /* Slightly larger maybe */
  454. height: 100rpx;
  455. position: absolute;
  456. right: 0;
  457. bottom: 0;
  458. z-index: 0;
  459. opacity: 0.8;
  460. }
  461. }
  462. }
  463. /* 公众号 */
  464. .gzh-section {
  465. margin-bottom: 30rpx;
  466. height: 180rpx;
  467. /* Fixed height for consistency */
  468. border-radius: 20rpx;
  469. overflow: hidden;
  470. .gzh-bg-wrapper {
  471. width: 100%;
  472. height: 100%;
  473. position: relative;
  474. .gzh-img-bg {
  475. width: 100%;
  476. height: 100%;
  477. position: absolute;
  478. top: 0;
  479. left: 0;
  480. }
  481. .gzh-content-overlay {
  482. position: absolute;
  483. top: 0;
  484. left: 0;
  485. width: 60%;
  486. /* Only cover left side */
  487. height: 100%;
  488. padding: 30rpx;
  489. display: flex;
  490. flex-direction: column;
  491. justify-content: center;
  492. .gzh-title {
  493. font-size: 32rpx;
  494. font-weight: bold;
  495. color: #134E13;
  496. /* Dark green */
  497. margin-bottom: 16rpx;
  498. }
  499. .gzh-subtitle-pill {
  500. background: #FFF;
  501. border-radius: 24rpx;
  502. padding: 0 14rpx;
  503. line-height: 1.4;
  504. align-self: flex-start;
  505. .gzh-subtitle {
  506. font-size: 22rpx;
  507. color: #134E13;
  508. font-weight: 500;
  509. }
  510. }
  511. }
  512. }
  513. }
  514. /* 书嗨推荐 */
  515. .recommend-section {
  516. background-color: #fff;
  517. border-radius: 20rpx;
  518. padding: 30rpx;
  519. margin-bottom: 24rpx;
  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-list {
  542. display: flex;
  543. flex-wrap: wrap;
  544. justify-content: space-between;
  545. }
  546. .book-item {
  547. width: 200rpx;
  548. margin-bottom: 24rpx;
  549. display: flex;
  550. flex-direction: column;
  551. .book-image {
  552. width: 200rpx;
  553. height: 255rpx;
  554. border-radius: 2rpx;
  555. margin-bottom: 16rpx;
  556. background-color: #f9f9f9;
  557. }
  558. .book-name {
  559. font-family: 'Source Han Sans SC';
  560. font-weight: bold;
  561. font-size: 28rpx;
  562. color: #303030;
  563. margin-bottom: 10rpx;
  564. overflow: hidden;
  565. text-overflow: ellipsis;
  566. white-space: nowrap;
  567. }
  568. .price-row {
  569. display: flex;
  570. align-items: baseline;
  571. margin-bottom: 12rpx;
  572. .currency {
  573. font-family: 'Source Han Sans SC';
  574. font-weight: 500;
  575. font-size: 22rpx;
  576. color: #D81A00;
  577. }
  578. .price-val {
  579. font-family: 'Source Han Sans SC';
  580. font-weight: 500;
  581. font-size: 28rpx;
  582. color: #D81A00;
  583. margin-right: 12rpx;
  584. }
  585. .price-old {
  586. font-family: 'Source Han Sans SC';
  587. font-weight: 500;
  588. font-size: 22rpx;
  589. color: #999999;
  590. text-decoration: line-through;
  591. }
  592. }
  593. .add-btn {
  594. width: fit-content;
  595. height: 36rpx;
  596. line-height: 36rpx;
  597. background: linear-gradient(0deg, #4ED964 0%, #4ED964 100%);
  598. border-radius: 18rpx;
  599. padding: 0 20rpx;
  600. display: flex;
  601. align-items: center;
  602. justify-content: center;
  603. text {
  604. font-size: 22rpx;
  605. color: #fff;
  606. }
  607. .cart-symbol {
  608. width: 24rpx;
  609. height: 24rpx;
  610. margin-left: 6rpx;
  611. }
  612. }
  613. }
  614. }
  615. .bottom-safe-area {
  616. height: 30rpx
  617. }
  618. </style>