index.vue 16 KB

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